JeVois  1.20
JeVois Smart Embedded Machine Vision Toolkit
Share this page:

#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. More...
 
 RawImage (RawImage &&other)=default
 Default move constructor. More...
 
 RawImage (RawImage const &other)=default
 Default copy constructor. More...
 
RawImageoperator= (RawImage const &other)=default
 Default assignment. More...
 
 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. More...
 
void invalidate ()
 Invalidate the image by zero'ing out the pointer to pixel buffer and the dims and format. More...
 
bool valid () const
 Check whether the image has a valid pixel buffer. More...
 
void clear ()
 Clear the pixels to all black. More...
 
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. More...
 
unsigned int bytesperpix () const
 Helper function to get the number of bytes/pixel given the RawImage pixel format. More...
 
unsigned int bytesize () const
 Helper function to get the total number of bytes in the RawImage, i.e., width * height * bytesperpix() More...
 
bool coordsOk (int x, int y) const
 Helper function to check that coords are within image bounds. More...
 
template<typename T >
T * pixelsw ()
 Shortcut access to pixels, read-write. More...
 
template<typename T >
const T * pixels () const
 Shortcut access to pixels, read-only. More...
 

Public Attributes

unsigned int width
 Image width in pixels. More...
 
unsigned int height
 Image height in pixels. More...
 
unsigned int fmt
 Pixel format as a V4L2_PIX_FMT_XXX. More...
 
float fps
 Programmed frames/s as given by current video mapping, may not be actual. More...
 
std::shared_ptr< VideoBufbuf
 The pixel data buffer. More...
 
size_t bufindex
 The index of the data buffer in the kernel driver. More...
 

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(), and TutorialPassThrough::process().

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

◆ operator=()

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

Default assignment.

◆ pixels()

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

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

Referenced by TutorialPassThrough::process(), TutorialConvert::process(), TutorialEdgeDetection::process(), TutorialEdgeDetectionX4::process(), and __MODULE__::process().

◆ 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::MovieOutput::get(), jevois::MovieInput::get(), jevois::MovieInput::get2(), jevois::VideoDisplayGUI::setFormat(), jevois::VideoDisplayGL::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::MovieOutput::get(), jevois::MovieInput::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(), TutorialPassThrough::process(), TutorialConvert::process(), TutorialEdgeDetection::process(), TutorialEdgeDetectionX4::process(), __MODULE__::process(), 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::VideoDisplayGUI::setFormat(), jevois::VideoDisplayGL::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::MovieOutput::get(), jevois::MovieInput::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(), TutorialPassThrough::process(), TutorialConvert::process(), TutorialEdgeDetection::process(), TutorialEdgeDetectionX4::process(), __MODULE__::process(), 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::set2(), jevois::VideoDisplayGUI::setFormat(), jevois::VideoDisplayGL::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: