JeVois  1.5
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
jevois::InputFrame Class Reference

#include <jevois/Core/Module.H>

Exception-safe wrapper around a raw camera input frame.

This wrapper operates much like std:future in standard C++11. Users can get the next image captured by the camera by calling get(), which may block if the capture is not complete yet, or may throw if the capture fails for some reason (e.g., the camera is not streaming). The image size and pixel type are as defined by the current VideoMapping, camera section. In addition, a done() function is provided which users may use as soon as they are finished with the pixel data in the image obtained via get(), to allow the camera driver to setup the underlying memory buffer again for capture. If done() has not been called by the time the InputFrame is destroyed, it will be called automatically, if get() had been called. It may in some cases improve your frame rate to call done() manually as early as possible instead of letting the InputFrame destructor do it.

InputFrame implements a zero-copy, zero-wait access to input video frames, that is:

  1. 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;
  2. 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.

Definition at line 56 of file Module.H.

Public Member Functions

 InputFrame (InputFrame &&other)=default
 Move constructor. More...
 
RawImage const & get (bool casync=false) const
 Get the next captured camera image. More...
 
void done () const
 Indicate that user processing is done with the image previously obtained via get() More...
 
cv::Mat getCvGRAY (bool casync=false) const
 Shorthand to get the input image as a GRAY cv::Mat and release the raw buffer. More...
 
cv::Mat getCvBGR (bool casync=false) const
 Shorthand to get the input image as a BGR cv::Mat and release the raw buffer. More...
 
cv::Mat getCvRGB (bool casync=false) const
 Shorthand to get the input image as a RGB cv::Mat and release the raw buffer. More...
 
cv::Mat getCvRGBA (bool casync=false) const
 Shorthand to get the input image as a RGBA cv::Mat and release the raw buffer. More...
 
 ~InputFrame ()
 Destructor, returns the buffers to the driver as needed. More...
 

Friends

class Engine
 

Constructor & Destructor Documentation

◆ InputFrame()

jevois::InputFrame::InputFrame ( InputFrame &&  other)
default

Move constructor.

◆ ~InputFrame()

jevois::InputFrame::~InputFrame ( )

Destructor, returns the buffers to the driver as needed.

Definition at line 38 of file Module.C.

References jevois::VideoInput::done(), and jevois::VideoInput::get().

Member Function Documentation

◆ done()

void jevois::InputFrame::done ( ) const

Indicate that user processing is done with the image previously obtained via get()

You should call this as soon after get() as possible, once you are finished with the RawImage data so that it can be recycled and sent back to the camera driver for video capture.

Definition at line 60 of file Module.C.

References jevois::VideoInput::done().

Referenced by jevois::InputFramePython::done().

◆ get()

jevois::RawImage const & jevois::InputFrame::get ( bool  casync = false) const

Get the next captured camera image.

Throws if we the camera is not streaming or blocks until an image is available (has been captured).

Definition at line 51 of file Module.C.

References jevois::VideoInput::get().

Referenced by jevois::InputFramePython::get(), jevois::InputFramePython::get1(), and jevois::Engine::mainLoop().

◆ getCvBGR()

cv::Mat jevois::InputFrame::getCvBGR ( bool  casync = false) const

Shorthand to get the input image as a BGR cv::Mat and release the raw buffer.

This is mostly intended for Python module writers, as they will likely use OpenCV for all their image processing. C++ module writers should stick to the get()/done() pair as this provides better fine-grained control. Note that the raw image from the camera will always be copied or converted to cv::Mat and will then be released by calling done(), so users should not call done() after using this function. This function is basically equivalent to calling get(), converting to cv::Mat, and calling done().

Definition at line 76 of file Module.C.

References jevois::rawimage::convertToCvBGR().

Referenced by jevois::InputFramePython::getCvBGR(), and jevois::InputFramePython::getCvBGR1().

◆ getCvGRAY()

cv::Mat jevois::InputFrame::getCvGRAY ( bool  casync = false) const

Shorthand to get the input image as a GRAY cv::Mat and release the raw buffer.

This is mostly intended for Python module writers, as they will likely use OpenCV for all their image processing. C++ module writers should stick to the get()/done() pair as this provides better fine-grained control. Note that the raw image from the camera will always be copied or converted to cv::Mat and will then be released by calling done(), so users should not call done() after using this function. This function is basically equivalent to calling get(), converting to cv::Mat, and calling done().

Definition at line 67 of file Module.C.

References jevois::rawimage::convertToCvGray().

Referenced by jevois::InputFramePython::getCvGRAY(), and jevois::InputFramePython::getCvGRAY1().

◆ getCvRGB()

cv::Mat jevois::InputFrame::getCvRGB ( bool  casync = false) const

Shorthand to get the input image as a RGB cv::Mat and release the raw buffer.

This is mostly intended for Python module writers, as they will likely use OpenCV for all their image processing. C++ module writers should stick to the get()/done() pair as this provides better fine-grained control. Note that the raw image from the camera will always be copied or converted to cv::Mat and will then be released by calling done(), so users should not call done() after using this function. This function is basically equivalent to calling get(), converting to cv::Mat, and calling done().

Definition at line 85 of file Module.C.

References jevois::rawimage::convertToCvRGB().

Referenced by jevois::InputFramePython::getCvRGB(), and jevois::InputFramePython::getCvRGB1().

◆ getCvRGBA()

cv::Mat jevois::InputFrame::getCvRGBA ( bool  casync = false) const

Shorthand to get the input image as a RGBA cv::Mat and release the raw buffer.

This is mostly intended for Python module writers, as they will likely use OpenCV for all their image processing. C++ module writers should stick to the get()/done() pair as this provides better fine-grained control. Note that the raw image from the camera will always be copied or converted to cv::Mat and will then be released by calling done(), so users should not call done() after using this function. This function is basically equivalent to calling get(), converting to cv::Mat, and calling done().

Definition at line 94 of file Module.C.

References jevois::rawimage::convertToCvRGBA().

Referenced by jevois::InputFramePython::getCvRGBA(), and jevois::InputFramePython::getCvRGBA1().

Friends And Related Function Documentation

◆ Engine

friend class Engine
friend

Definition at line 111 of file Module.H.


The documentation for this class was generated from the following files: