JeVois  1.22
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches

#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.

Collaboration diagram for jevois::RawImage:

Public Member Functions

 RawImage ()
 Default constructor, uninitialized.
 
 RawImage (RawImage &&other)=default
 Default move constructor.
 
 RawImage (RawImage const &other)=default
 Default copy constructor.
 
RawImageoperator= (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< VideoBufbuf
 The pixel data buffer.
 
size_t bufindex
 The index of the data buffer in the kernel driver.
 

Constructor & Destructor Documentation

◆ RawImage() [1/4]

jevois::RawImage::RawImage ( )

Default constructor, uninitialized.

Definition at line 24 of file RawImage.C.

◆ RawImage() [2/4]

jevois::RawImage::RawImage ( RawImage &&  other)
default

Default move constructor.

◆ RawImage() [3/4]

jevois::RawImage::RawImage ( RawImage const &  other)
default

Default copy constructor.

◆ RawImage() [4/4]

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.

Member Function Documentation

◆ bytesize()

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().

◆ bytesperpix()

◆ clear()

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().

◆ coordsOk()

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().

◆ invalidate()

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().

◆ operator=()

RawImage & jevois::RawImage::operator= ( RawImage const &  other)
default

Default assignment.

◆ pixels()

template<typename T >
T const * jevois::RawImage::pixels ( ) const

Shortcut access to pixels, read-only.

Referenced by jevois::rawimage::paste(), and jevois::rawimage::roipaste().

◆ pixelsw()

◆ require()

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.

◆ valid()

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().

Member Data Documentation

◆ buf

◆ bufindex

◆ fmt

◆ fps

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().

◆ height

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().

◆ width

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().


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