JeVois camera driver class - grabs frames from a Video4Linux camera sensor.
On the platform hardware, the Camera class provides access to the camera sensor on the parallel camera bus (CSI). On other hardware, it can provide access to any Video4Linux2 camera (e.g., USB webcam), although with some limitations, such as:
- cannot read/write raw camera registers.
- usually cannot select any frames/s but instead limited to a few fixed values like 15fps, 30fps.
- usually limited to 3fps max (no 60fps or 120fps modes like on JeVois platform hardware)
- usually limited number of controls (exposure, gain, etc) available.
The camera runs a thread that handles capturing frames automatically. Users can access the next grabbed frame using get(), which may block until the frame is fully captured. Once they are finished with a frame obtained through get(), users should hand it back to the Camera by calling done(). When using the JeVois Engine and a Module, get() and done() are automatically called in an exception-safe manner through the use of the InputFrame class. Indeed, video grabbing uses a fixed set of image buffers that are allocated by the Linux kernel when a video format is configured, and the camera hardware then cycles through the buffers. On the platform, the camera image buffers are allocated in the ION carveout memory area, which is a reserved memory zone configured in the Linux kernel, and the USB output buffers are also allocated in that zone. To avoid reserving too much memory that will not be used, the ION carveout reservation is quite small by default, but is sufficient for 3 1280x1024 YUYV buffers.
Camera implements a zero-copy, zero-wait access to input video frames, that is:
- the pixel data of the image you obtain via get() is directly the memory-mapped pixel buffer that the silicon hardware on the JeVois chip uses via direct-memory-access (DMA) to stream the pixel data from the camera chip to processor memory;
- as soon as an image is captured by the camera hardware, get() unblocks and returns it (as opposed to having a fixed, regular interval at which images may be available). Camera has several image buffers, allowing one to be captured while another is being handed over for processing via get(). These buffers are recycled, i.e., once done() is called, the underlying buffer is sent back to the camera hardware for future capture.
Camera will drop frames if they are not processed by user code fast enough. That is, if all buffers have been grabbed already and not yet handed over through get() and then returned by done(), then the next camera sensor frame will be dropped.
Most programmers will never use Camera directly, instead using Engine and InputFrame.
Definition at line 64 of file Camera.H.
| ||Camera (std::string const &devname, unsigned int const nbufs=0)|
| ||Construct and open the device. More...|
| ||~Camera ()|
| ||Close the device and free all resources. More...|
|void ||streamOn () override|
| ||Start streaming. More...|
|void ||abortStream () override|
| ||Abort streaming. More...|
|void ||streamOff () override|
| ||Stop streaming. More...|
|void ||get (RawImage &img) override|
| ||Get the next captured buffer. More...|
|void ||done (RawImage &img) override|
| ||Indicate that user processing is done with an image previously obtained via get() More...|
|void ||queryControl (struct v4l2_queryctrl &qc) const override|
| ||Get information about a control, throw if unsupported by hardware. More...|
|void ||queryMenu (struct v4l2_querymenu &qm) const override|
| ||Get the available menu entry names for a menu-type control, throw if unsupported by hardware. More...|
|void ||getControl (struct v4l2_control &ctrl) const |
| ||Get a control's current value, throw if unsupported by hardware. More...|
|void ||setControl (struct v4l2_control const &ctrl) override|
| ||Set a control, throw if control not supported or the hardware rejects the value. More...|
|void ||setFormat (VideoMapping const &m) override|
| ||Set the video format and frame rate. More...|
|void ||writeRegister (unsigned char reg, unsigned char val) override|
| ||Write a value to one of the camera's registers. More...|
|unsigned char ||readRegister (unsigned char reg) override|
| ||Read a value from one of the camera's registers. More...|
| ||VideoInput (std::string const &devname, unsigned int const nbufs=0)|
| ||Constructor. More...|
|virtual ||~VideoInput ()|
| ||Virtual destructor for save inheritance. More...|