JeVois
1.22
JeVois Smart Embedded Machine Vision Toolkit
|
|
#include <jevois/Image/RawImage.H>
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
The pixel data is allocated and memory mapped by the respective camera or gadget drivers. Because the pixel buffer is allocated and managed by the hardware driver, we cannot make deep copies of RawImage, and thus the copy constructor and assignment operators will yield images that share the same pixel data. To copy pixels from one RawImage to another (e.g., from camera image to USB image), see jevois::rawimage::paste() and other RawImage functions.
Definition at line 110 of file RawImage.H.
Public Member Functions | |
RawImage () | |
Default constructor, uninitialized. | |
RawImage (RawImage &&other)=default | |
Default move constructor. | |
RawImage (RawImage const &other)=default | |
Default copy constructor. | |
RawImage & | operator= (RawImage const &other)=default |
Default assignment. | |
RawImage (unsigned int w, unsigned int h, unsigned int f, float fs, std::shared_ptr< VideoBuf > b, size_t bindex) | |
Construct from an existing VideoBuf and associated params. | |
void | invalidate () |
Invalidate the image by zero'ing out the pointer to pixel buffer and the dims and format. | |
bool | valid () const |
Check whether the image has a valid pixel buffer. | |
void | clear () |
Clear the pixels to all black. | |
void | require (char const *info, unsigned int w, unsigned int h, unsigned int f) const |
Require a particular image size and format, issue a fatal error message and throw if no match. | |
unsigned int | bytesperpix () const |
Helper function to get the number of bytes/pixel given the RawImage pixel format. | |
unsigned int | bytesize () const |
Helper function to get the total number of bytes in the RawImage, i.e., width * height * bytesperpix() | |
bool | coordsOk (int x, int y) const |
Helper function to check that coords are within image bounds. | |
template<typename T > | |
T * | pixelsw () |
Shortcut access to pixels, read-write. | |
template<typename T > | |
T const * | pixels () const |
Shortcut access to pixels, read-only. | |
Public Attributes | |
unsigned int | width |
Image width in pixels. | |
unsigned int | height |
Image height in pixels. | |
unsigned int | fmt |
Pixel format as a V4L2_PIX_FMT_XXX. | |
float | fps |
Programmed frames/s as given by current video mapping, may not be actual. | |
std::shared_ptr< VideoBuf > | buf |
The pixel data buffer. | |
size_t | bufindex |
The index of the data buffer in the kernel driver. | |
jevois::RawImage::RawImage | ( | ) |
Default constructor, uninitialized.
Definition at line 24 of file RawImage.C.
|
default |
Default move constructor.
|
default |
Default copy constructor.
jevois::RawImage::RawImage | ( | unsigned int | w, |
unsigned int | h, | ||
unsigned int | f, | ||
float | fs, | ||
std::shared_ptr< VideoBuf > | b, | ||
size_t | bindex | ||
) |
Construct from an existing VideoBuf and associated params.
Definition at line 28 of file RawImage.C.
unsigned int jevois::RawImage::bytesize | ( | ) | const |
Helper function to get the total number of bytes in the RawImage, i.e., width * height * bytesperpix()
Definition at line 38 of file RawImage.C.
References jevois::v4l2BytesPerPix().
Referenced by jevois::rawimage::byteSwap().
unsigned int jevois::RawImage::bytesperpix | ( | ) | const |
Helper function to get the number of bytes/pixel given the RawImage pixel format.
Definition at line 34 of file RawImage.C.
References jevois::v4l2BytesPerPix().
Referenced by jevois::rawimage::byteSwap(), jevois::rawimage::convertCvBGRtoRawImage(), jevois::rawimage::convertCvGRAYtoRawImage(), jevois::rawimage::convertCvRGBtoRawImage(), jevois::rawimage::paste(), jevois::rawimage::pasteBGRtoYUYV(), jevois::rawimage::pasteGreyToYUYV(), jevois::rawimage::pasteRGBtoYUYV(), jevois::rawimage::roipaste(), and jevois::rawimage::writeText().
void jevois::RawImage::clear | ( | ) |
Clear the pixels to all black.
Black value depends on format. Does not work with MJPEG. Throws if the raw image is not valid() and silently does nothing if the raw image has MJPEG pixels (since the raw image buffer will be overwritten by the MJPEG compressor anyway).
Definition at line 50 of file RawImage.C.
References jevois::yuyv::Black, jevois::fccstr(), and LFATAL.
Referenced by jevois::drawErrorImage().
bool jevois::RawImage::coordsOk | ( | int | x, |
int | y | ||
) | const |
Helper function to check that coords are within image bounds.
Definition at line 88 of file RawImage.C.
Referenced by jevois::rawimage::drawDisk().
void jevois::RawImage::invalidate | ( | ) |
Invalidate the image by zero'ing out the pointer to pixel buffer and the dims and format.
Definition at line 42 of file RawImage.C.
Referenced by jevois::CameraDevice::get(), and jevois::OutputFrame::send().
T const * jevois::RawImage::pixels | ( | ) | const |
Shortcut access to pixels, read-only.
Referenced by jevois::rawimage::paste(), and jevois::rawimage::roipaste().
T * jevois::RawImage::pixelsw | ( | ) |
Shortcut access to pixels, read-write.
Referenced by jevois::rawimage::byteSwap(), jevois::compressBGRtoJpeg(), jevois::compressGRAYtoJpeg(), jevois::compressRGBAtoJpeg(), jevois::compressRGBtoJpeg(), jevois::rawimage::convertBayerToYUYV(), jevois::rawimage::convertCvBGRtoRawImage(), jevois::rawimage::convertCvGRAYtoRawImage(), jevois::rawimage::convertCvRGBtoRawImage(), jevois::rawimage::drawDisk(), jevois::rawimage::drawFilledRect(), jevois::rawimage::drawRect(), jevois::rawimage::hFlipYUYV(), jevois::rawimage::paste(), jevois::rawimage::pasteBGRtoYUYV(), jevois::rawimage::pasteGreyToYUYV(), jevois::rawimage::pasteRGBtoYUYV(), jevois::rawimage::roipaste(), jevois::rawimage::unpackCvRGBAtoGrayRawImage(), and jevois::rawimage::writeText().
void jevois::RawImage::require | ( | char const * | info, |
unsigned int | w, | ||
unsigned int | h, | ||
unsigned int | f | ||
) | const |
Require a particular image size and format, issue a fatal error message and throw if no match.
The info string is included in the fatal error message to help identifying which image failed the requirement. Typically, you would pass "input" or "output" as info.
Definition at line 80 of file RawImage.C.
References jevois::fccstr(), h, and LFATAL.
bool jevois::RawImage::valid | ( | ) | const |
Check whether the image has a valid pixel buffer.
Definition at line 46 of file RawImage.C.
Referenced by jevois::drawErrorImage().
std::shared_ptr<VideoBuf> jevois::RawImage::buf |
The pixel data buffer.
Definition at line 149 of file RawImage.H.
Referenced by jevois::compressBGRtoJpeg(), jevois::compressGRAYtoJpeg(), jevois::compressRGBAtoJpeg(), jevois::compressRGBtoJpeg(), jevois::rawimage::cvImage(), jevois::InputFrame::get(), jevois::MovieInput::get(), jevois::MovieOutput::get(), jevois::InputFrame::get2(), jevois::MovieInput::get2(), main(), jevois::GPUimage::set(), jevois::GPUimage::set(), jevois::GPUimage::set2(), jevois::VideoDisplayGL::setFormat(), jevois::VideoDisplayGUI::setFormat(), and jevois::Gadget::streamOn().
size_t jevois::RawImage::bufindex |
The index of the data buffer in the kernel driver.
Definition at line 150 of file RawImage.H.
Referenced by jevois::CameraDevice::done(), jevois::GUIhelper::drawImage(), jevois::GUIhelper::drawInputFrame(), jevois::GUIhelper::drawInputFrame2(), jevois::CameraDevice::get(), jevois::Gadget::get(), jevois::MovieInput::get(), jevois::MovieOutput::get(), jevois::VideoDisplayGL::get(), jevois::VideoDisplayGUI::get(), jevois::MovieInput::get2(), jevois::Gadget::send(), jevois::VideoDisplayGL::send(), jevois::VideoDisplayGUI::send(), jevois::VideoDisplayGL::setFormat(), jevois::VideoDisplayGUI::setFormat(), and jevois::Gadget::streamOn().
unsigned int jevois::RawImage::fmt |
Pixel format as a V4L2_PIX_FMT_XXX.
Definition at line 147 of file RawImage.H.
Referenced by jevois::rawimage::convertBayerToYUYV(), jevois::rawimage::convertCvBGRtoRawImage(), jevois::rawimage::convertCvGRAYtoRawImage(), jevois::rawimage::convertCvRGBAtoRawImage(), jevois::rawimage::convertCvRGBtoRawImage(), jevois::rawimage::convertGreyToYUYV(), jevois::rawimage::convertToCvBGR(), jevois::rawimage::convertToCvGray(), jevois::rawimage::convertToCvRGB(), jevois::rawimage::convertToCvRGBA(), jevois::rawimage::cvImage(), jevois::drawErrorImage(), jevois::MovieInput::get(), jevois::MovieOutput::get(), jevois::MovieInput::get2(), jevois::rawimage::hFlipYUYV(), jevois::GUIhelper::iinfo(), jevois::rawimage::paste(), jevois::rawimage::pasteBGRtoYUYV(), jevois::rawimage::pasteRGBtoYUYV(), jevois::dnn::PreProcessor::process(), jevois::rawimage::roipaste(), jevois::Gadget::send(), jevois::GPUimage::set(), jevois::GPUimage::set(), jevois::GPUimage::set2(), jevois::VideoDisplayGL::setFormat(), jevois::VideoDisplayGUI::setFormat(), jevois::GPUimage::setWithDmaBuf(), jevois::Gadget::streamOn(), and jevois::rawimage::unpackCvRGBAtoGrayRawImage().
float jevois::RawImage::fps |
Programmed frames/s as given by current video mapping, may not be actual.
Definition at line 148 of file RawImage.H.
Referenced by jevois::MovieInput::get(), jevois::MovieOutput::get(), jevois::MovieInput::get2(), jevois::VideoDisplayGL::setFormat(), jevois::VideoDisplayGUI::setFormat(), and jevois::Gadget::streamOn().
unsigned int jevois::RawImage::height |
Image height in pixels.
Definition at line 146 of file RawImage.H.
Referenced by jevois::rawimage::byteSwap(), jevois::rawimage::convertBayerToYUYV(), jevois::rawimage::convertCvBGRtoRawImage(), jevois::rawimage::convertCvGRAYtoRawImage(), jevois::rawimage::convertCvRGBAtoRawImage(), jevois::rawimage::convertCvRGBtoRawImage(), jevois::rawimage::convertGreyToYUYV(), jevois::rawimage::convertToCvBGR(), jevois::rawimage::convertToCvGray(), jevois::rawimage::convertToCvRGB(), jevois::rawimage::convertToCvRGBA(), jevois::rawimage::cvImage(), jevois::drawErrorImage(), jevois::rawimage::drawFilledRect(), jevois::GUIhelper::drawInputFrame(), jevois::rawimage::drawLine(), jevois::rawimage::drawRect(), jevois::MovieInput::get(), jevois::MovieOutput::get(), jevois::MovieInput::get2(), jevois::rawimage::hFlipYUYV(), jevois::GUIhelper::iinfo(), jevois::coords::imgToStd(), main(), jevois::rawimage::paste(), jevois::rawimage::pasteBGRtoYUYV(), jevois::rawimage::pasteGreyToYUYV(), jevois::rawimage::pasteRGBtoYUYV(), jevois::dnn::PreProcessor::process(), jevois::rawimage::roipaste(), jevois::Gadget::send(), jevois::OutputFrame::sendScaledCvBGR(), jevois::OutputFrame::sendScaledCvGRAY(), jevois::OutputFrame::sendScaledCvRGB(), jevois::OutputFrame::sendScaledCvRGBA(), jevois::GPUimage::set(), jevois::VideoDisplayGL::setFormat(), jevois::VideoDisplayGUI::setFormat(), jevois::GPUimage::setWithDmaBuf(), jevois::coords::stdToImg(), jevois::Gadget::streamOn(), jevois::rawimage::unpackCvRGBAtoGrayRawImage(), and jevois::rawimage::writeText().
unsigned int jevois::RawImage::width |
Image width in pixels.
Definition at line 145 of file RawImage.H.
Referenced by jevois::rawimage::byteSwap(), jevois::rawimage::convertBayerToYUYV(), jevois::rawimage::convertCvBGRtoRawImage(), jevois::rawimage::convertCvGRAYtoRawImage(), jevois::rawimage::convertCvRGBAtoRawImage(), jevois::rawimage::convertCvRGBtoRawImage(), jevois::rawimage::convertGreyToYUYV(), jevois::rawimage::convertToCvBGR(), jevois::rawimage::convertToCvGray(), jevois::rawimage::convertToCvRGB(), jevois::rawimage::convertToCvRGBA(), jevois::rawimage::cvImage(), jevois::rawimage::drawDisk(), jevois::drawErrorImage(), jevois::rawimage::drawFilledRect(), jevois::GUIhelper::drawInputFrame(), jevois::rawimage::drawLine(), jevois::rawimage::drawRect(), jevois::MovieInput::get(), jevois::MovieOutput::get(), jevois::MovieInput::get2(), jevois::rawimage::hFlipYUYV(), jevois::GUIhelper::iinfo(), jevois::coords::imgToStd(), main(), jevois::rawimage::paste(), jevois::rawimage::pasteBGRtoYUYV(), jevois::rawimage::pasteGreyToYUYV(), jevois::rawimage::pasteRGBtoYUYV(), jevois::dnn::PreProcessor::process(), jevois::dnn::PostProcessorYuNet::report(), jevois::rawimage::roipaste(), jevois::Gadget::send(), jevois::dnn::PreProcessor::sendreport(), jevois::OutputFrame::sendScaledCvBGR(), jevois::OutputFrame::sendScaledCvGRAY(), jevois::OutputFrame::sendScaledCvRGB(), jevois::OutputFrame::sendScaledCvRGBA(), jevois::GPUimage::set(), jevois::GPUimage::set(), jevois::GPUimage::set2(), jevois::VideoDisplayGL::setFormat(), jevois::VideoDisplayGUI::setFormat(), jevois::GPUimage::setWithDmaBuf(), jevois::coords::stdToImg(), jevois::Gadget::streamOn(), jevois::rawimage::unpackCvRGBAtoGrayRawImage(), and jevois::rawimage::writeText().