JeVois
1.22
JeVois Smart Embedded Machine Vision Toolkit
|
|
#include <jevois/Core/OutputFrame.H>
Exception-safe wrapper around a raw image to be sent over USB.
This wrapper operates much like std:future in standard C++11. Users can get the next memory-allocated but blank image to be sent over USB by calling get(), which may block if all buffers are still being sent over USB by Gadget and no blank one is available, or may throw if getting that buffer fails for some reason (e.g., usb disconnect, user just changed video mode in their webcam software or closed it). The allocated image size and pixel type is as defined by the current VideoMapping, USB section, i.e., it is the USB video mode currently selected by the user. To save time, image buffers are not zeroed out, so you should not assume that the image is filled with black pixels, it could contain random pixels, or previous output frames. In addition, a send() function is provided which users may use as soon as they are finished with writing the pixel data into the image obtained via get(), to allow the USB driver to send that image to the connected host computer. If send() has not been called by the time the OutputFrame is destroyed, it will be called automatically, if get() had been called.
OutputFrame implements a zero-copy, zero-wait access to output video frames, that is:
Definition at line 52 of file OutputFrame.H.
Public Member Functions | |
OutputFrame (OutputFrame &&other)=default | |
Move constructor. | |
RawImage const & | get () const |
Get a pre-allocated image so that we can fill the pixel data and later send out over USB using send() | |
void | send () const |
Send an image out over USB to the host computer. | |
void | sendCv (cv::Mat const &img, int quality=75) const |
Shorthand to send a cv::Mat after converting / scaling it to the current output format. | |
void | sendCvGRAY (cv::Mat const &img, int quality=75) const |
Shorthand to send a GRAY cv::Mat after converting it to the current output format. | |
void | sendCvBGR (cv::Mat const &img, int quality=75) const |
Shorthand to send a BGR cv::Mat after converting it to the current output format. | |
void | sendCvRGB (cv::Mat const &img, int quality=75) const |
Shorthand to send a RGB cv::Mat after converting it to the current output format. | |
void | sendCvRGBA (cv::Mat const &img, int quality=75) const |
Shorthand to send a RGBA cv::Mat after converting it to the current output format. | |
void | sendScaledCvGRAY (cv::Mat const &img, int quality=75) const |
Shorthand to send a GRAY cv::Mat after converting it to the current output format. | |
void | sendScaledCvBGR (cv::Mat const &img, int quality=75) const |
Shorthand to send a BGR cv::Mat after converting it to the current output format. | |
void | sendScaledCvRGB (cv::Mat const &img, int quality=75) const |
Shorthand to send a RGB cv::Mat after converting it to the current output format. | |
void | sendScaledCvRGBA (cv::Mat const &img, int quality=75) const |
Shorthand to send a RGBA cv::Mat after converting it to the current output format. | |
~OutputFrame () | |
Destructor, returns the buffers to the driver as needed. | |
Friends | |
class | Engine |
|
default |
Move constructor.
jevois::OutputFrame::~OutputFrame | ( | ) |
Destructor, returns the buffers to the driver as needed.
Definition at line 31 of file OutputFrame.C.
jevois::RawImage const & jevois::OutputFrame::get | ( | ) | const |
Get a pre-allocated image so that we can fill the pixel data and later send out over USB using send()
May throw if not buffer is available, i.e., all have been queued to send to the host but have not yet been sent. Application code must balance exactly one send() for each get().
Definition at line 55 of file OutputFrame.C.
void jevois::OutputFrame::send | ( | ) | const |
Send an image out over USB to the host computer.
May throw if the format is incorrect or std::overflow_error if we have not yet consumed the previous image.
Definition at line 63 of file OutputFrame.C.
References jevois::RawImage::invalidate().
void jevois::OutputFrame::sendCv | ( | cv::Mat const & | img, |
int | quality = 75 |
||
) | const |
Shorthand to send a cv::Mat after converting / scaling it to the current output format.
This is mostly intended for Python module writers, as they will likely use OpenCV for all their image processing. The cv::Mat will be rescaled to the same dims as the output frame.
The pixel format of the given cv::Mat is guessed as follows:
C++ module writers should stick to the get()/send() pair as this provides better fine-grained control. Note that the cv::Mat image will always be copied or converted to the destination RawImage and will then be sent out immediately by calling send(), so users should not call send() after using this function. This function is basically equivalent to calling get(), converting the given cv::Mat to the proper output format, and calling send(). quality is used only if the output format is MJPEG and should be between 1 and 100.
Definition at line 71 of file OutputFrame.C.
References jevois::cvtypestr(), and LFATAL.
void jevois::OutputFrame::sendCvBGR | ( | cv::Mat const & | img, |
int | quality = 75 |
||
) | const |
Shorthand to send a BGR cv::Mat after converting it to the current output format.
This is mostly intended for Python module writers, as they will likely use OpenCV for all their image processing. The cv::Mat must have same dims as the output frame. C++ module writers should stick to the get()/send() pair as this provides better fine-grained control. Note that the cv::Mat image will always be copied or converted to the destination RawImage and will then be sent out immediately by calling send(), so users should not call send() after using this function. This function is basically equivalent to calling get(), converting the given cv::Mat to the proper output format, and calling send(). quality is used only if the output format is MJPEG and should be between 1 and 100.
Definition at line 91 of file OutputFrame.C.
References jevois::rawimage::convertCvBGRtoRawImage().
void jevois::OutputFrame::sendCvGRAY | ( | cv::Mat const & | img, |
int | quality = 75 |
||
) | const |
Shorthand to send a GRAY cv::Mat after converting it to the current output format.
This is mostly intended for Python module writers, as they will likely use OpenCV for all their image processing. The cv::Mat must have same dims as the output frame. C++ module writers should stick to the get()/send() pair as this provides better fine-grained control. Note that the cv::Mat image will always be copied or converted to the destination RawImage and will then be sent out immediately by calling send(), so users should not call send() after using this function. This function is basically equivalent to calling get(), converting the given cv::Mat to the proper output format, and calling send(). quality is used only if the output format is MJPEG and should be between 1 and 100.
Definition at line 83 of file OutputFrame.C.
References jevois::rawimage::convertCvGRAYtoRawImage().
void jevois::OutputFrame::sendCvRGB | ( | cv::Mat const & | img, |
int | quality = 75 |
||
) | const |
Shorthand to send a RGB cv::Mat after converting it to the current output format.
This is mostly intended for Python module writers, as they will likely use OpenCV for all their image processing. The cv::Mat must have same dims as the output frame. C++ module writers should stick to the get()/send() pair as this provides better fine-grained control. Note that the cv::Mat image will always be copied or converted to the destination RawImage and will then be sent out immediately by calling send(), so users should not call send() after using this function. This function is basically equivalent to calling get(), converting the given cv::Mat to the proper output format, and calling send(). quality is used only if the output format is MJPEG and should be between 1 and 100.
Definition at line 98 of file OutputFrame.C.
References jevois::rawimage::convertCvRGBtoRawImage().
void jevois::OutputFrame::sendCvRGBA | ( | cv::Mat const & | img, |
int | quality = 75 |
||
) | const |
Shorthand to send a RGBA cv::Mat after converting it to the current output format.
This is mostly intended for Python module writers, as they will likely use OpenCV for all their image processing. The cv::Mat must have same dims as the output frame. C++ module writers should stick to the get()/send() pair as this provides better fine-grained control. Note that the cv::Mat image will always be copied or converted to the destination RawImage and will then be sent out immediately by calling send(), so users should not call send() after using this function. This function is basically equivalent to calling get(), converting the given cv::Mat to the proper output format, and calling send(). quality is used only if the output format is MJPEG and should be between 1 and 100.
Definition at line 106 of file OutputFrame.C.
References jevois::rawimage::convertCvRGBAtoRawImage().
void jevois::OutputFrame::sendScaledCvBGR | ( | cv::Mat const & | img, |
int | quality = 75 |
||
) | const |
Shorthand to send a BGR cv::Mat after converting it to the current output format.
This is mostly intended for Python module writers, as they will likely use OpenCV for all their image processing. The cv::Mat will be rescaled to the same dims as the output frame. C++ module writers should stick to the get()/send() pair as this provides better fine-grained control. Note that the cv::Mat image will always be copied or converted to the destination RawImage and will then be sent out immediately by calling send(), so users should not call send() after using this function. This function is basically equivalent to calling get(), converting the given cv::Mat to the proper output format, and calling send(). quality is used only if the output format is MJPEG and should be between 1 and 100.
Definition at line 123 of file OutputFrame.C.
References jevois::rawimage::convertCvBGRtoRawImage(), jevois::RawImage::height, jevois::rescaleCv(), and jevois::RawImage::width.
void jevois::OutputFrame::sendScaledCvGRAY | ( | cv::Mat const & | img, |
int | quality = 75 |
||
) | const |
Shorthand to send a GRAY cv::Mat after converting it to the current output format.
This is mostly intended for Python module writers, as they will likely use OpenCV for all their image processing. The cv::Mat will be rescaled to the same dims as the output frame. C++ module writers should stick to the get()/send() pair as this provides better fine-grained control. Note that the cv::Mat image will always be copied or converted to the destination RawImage and will then be sent out immediately by calling send(), so users should not call send() after using this function. This function is basically equivalent to calling get(), converting the given cv::Mat to the proper output format, and calling send(). quality is used only if the output format is MJPEG and should be between 1 and 100.
Definition at line 114 of file OutputFrame.C.
References jevois::rawimage::convertCvGRAYtoRawImage(), jevois::RawImage::height, jevois::rescaleCv(), and jevois::RawImage::width.
void jevois::OutputFrame::sendScaledCvRGB | ( | cv::Mat const & | img, |
int | quality = 75 |
||
) | const |
Shorthand to send a RGB cv::Mat after converting it to the current output format.
This is mostly intended for Python module writers, as they will likely use OpenCV for all their image processing. The cv::Mat will be rescaled to the same dims as the output frame. C++ module writers should stick to the get()/send() pair as this provides better fine-grained control. Note that the cv::Mat image will always be copied or converted to the destination RawImage and will then be sent out immediately by calling send(), so users should not call send() after using this function. This function is basically equivalent to calling get(), converting the given cv::Mat to the proper output format, and calling send(). quality is used only if the output format is MJPEG and should be between 1 and 100.
Definition at line 131 of file OutputFrame.C.
References jevois::rawimage::convertCvRGBtoRawImage(), jevois::RawImage::height, jevois::rescaleCv(), and jevois::RawImage::width.
void jevois::OutputFrame::sendScaledCvRGBA | ( | cv::Mat const & | img, |
int | quality = 75 |
||
) | const |
Shorthand to send a RGBA cv::Mat after converting it to the current output format.
This is mostly intended for Python module writers, as they will likely use OpenCV for all their image processing. The cv::Mat will be rescaled to the same dims as the output frame. C++ module writers should stick to the get()/send() pair as this provides better fine-grained control. Note that the cv::Mat image will always be copied or converted to the destination RawImage and will then be sent out immediately by calling send(), so users should not call send() after using this function. This function is basically equivalent to calling get(), converting the given cv::Mat to the proper output format, and calling send(). quality is used only if the output format is MJPEG and should be between 1 and 100.
Definition at line 140 of file OutputFrame.C.
References jevois::rawimage::convertCvRGBAtoRawImage(), jevois::RawImage::height, jevois::rescaleCv(), and jevois::RawImage::width.
|
friend |
Definition at line 172 of file OutputFrame.H.