SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
WebCamera.h
Go to the documentation of this file.
1 /**
2  * \file WebCamera.h
3  * \brief Interface to access the camera through the browser.
4  * \date October 2022
5  * \authors Marino von Wattenwyl
6  * \copyright http://opensource.org/licenses/GPL-3.0
7  * \remarks Please use clangformat to format the code. See more code style on
8  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
9 */
10 
11 #ifndef SLPROJECT_WEBCAMERA_H
12 #define SLPROJECT_WEBCAMERA_H
13 
14 #include <CVTypedefs.h>
15 
16 //-----------------------------------------------------------------------------
17 //! Facing modes for the camera
18 enum class WebCameraFacing
19 {
20  FRONT = 0,
21  BACK = 1
22 };
23 //-----------------------------------------------------------------------------
24 //! Interface to access the camera in the browser
25 class WebCamera
26 {
27 public:
28  void open(WebCameraFacing facing);
29  bool isReady();
30  CVMat read();
31  CVSize2i getSize();
32  void setSize(CVSize2i size);
33  void close();
34 
35  // Getters
36  bool isOpened() { return _isOpened; }
37 
38 private:
39  bool _isOpened = false;
42  bool _waitingForResize = false;
43 };
44 //-----------------------------------------------------------------------------
45 #endif // SLPROJECT_WEBCAMERA_H
cv::Size2i CVSize2i
Definition: CVTypedefs.h:56
cv::Mat CVMat
Definition: CVTypedefs.h:38
WebCameraFacing
Facing modes for the camera.
Definition: WebCamera.h:19
Interface to access the camera in the browser.
Definition: WebCamera.h:26
CVMat _imageBGR
Definition: WebCamera.h:41
void close()
Closes the video stream.
Definition: WebCamera.cpp:192
bool isReady()
Returns whether the video stream has been acquired.
Definition: WebCamera.cpp:57
void open(WebCameraFacing facing)
Acquires a video stream.
Definition: WebCamera.cpp:23
CVMat read()
Reads the current frame.
Definition: WebCamera.cpp:68
bool isOpened()
Definition: WebCamera.h:36
bool _waitingForResize
Definition: WebCamera.h:42
CVMat _image
Definition: WebCamera.h:40
void setSize(CVSize2i size)
Requests a video size from the browser.
Definition: WebCamera.cpp:149
bool _isOpened
Definition: WebCamera.h:39
CVSize2i getSize()
Gets the size of the video input.
Definition: WebCamera.cpp:123