SLProject
4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
|
Interface to access the camera in the browser. More...
#include <WebCamera.h>
Public Member Functions | |
void | open (WebCameraFacing facing) |
Acquires a video stream. More... | |
bool | isReady () |
Returns whether the video stream has been acquired. More... | |
CVMat | read () |
Reads the current frame. More... | |
CVSize2i | getSize () |
Gets the size of the video input. More... | |
void | setSize (CVSize2i size) |
Requests a video size from the browser. More... | |
void | close () |
Closes the video stream. More... | |
bool | isOpened () |
Private Attributes | |
bool | _isOpened = false |
CVMat | _image |
CVMat | _imageBGR |
bool | _waitingForResize = false |
Interface to access the camera in the browser.
Definition at line 25 of file WebCamera.h.
void WebCamera::close | ( | ) |
Closes the video stream.
After calling this function, the camera must be reopened before accessing any of the other member functions.
Definition at line 192 of file WebCamera.cpp.
CVSize2i WebCamera::getSize | ( | ) |
Gets the size of the video input.
The size is determined by getting the width and height of the HTML video element.
Definition at line 123 of file WebCamera.cpp.
|
inline |
Definition at line 36 of file WebCamera.h.
bool WebCamera::isReady | ( | ) |
Returns whether the video stream has been acquired.
The video stream is not immediately available when calling WebCamera::open. This function can be used to determine if the user has allowed camera access and if it is ready for reading.
Definition at line 57 of file WebCamera.cpp.
void WebCamera::open | ( | WebCameraFacing | facing | ) |
Acquires a video stream.
Requests a video stream from the browser and assigns it to the HTML video object as soon as it is ready. It must be called before accessing any of the other member functions. The function does not block, so the stream may not be ready yet after it returns.
facing | Preferred facing mode on mobile |
Definition at line 23 of file WebCamera.cpp.
CVMat WebCamera::read | ( | ) |
Reads the current frame.
If the video stream is ready, copies the current frame from the video HTML element into a CVMat in BGR format. Returns an empty image otherwise.
Definition at line 68 of file WebCamera.cpp.
Requests a video size from the browser.
The function tries to resize the video size. It is not guaranteed that this will have any effect or that the size after resizing will be equal to the size provided because the browser may not support it.
size | Preferred size of the video |
Definition at line 149 of file WebCamera.cpp.
|
private |
Definition at line 40 of file WebCamera.h.
|
private |
Definition at line 41 of file WebCamera.h.
|
private |
Definition at line 39 of file WebCamera.h.
|
private |
Definition at line 42 of file WebCamera.h.