JeVois  1.6
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.

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 >
T const * 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 fmt, height, jevois::v4l2BytesPerPix(), and width.

Referenced by BOOST_PYTHON_MODULE(), jevois::rawimage::byteSwap(), clear(), 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 bytesize(), jevois::fccstr(), fmt, height, LFATAL, valid(), and width.

Referenced by BOOST_PYTHON_MODULE(), and 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 76 of file RawImage.C.

References height, and width.

Referenced by BOOST_PYTHON_MODULE(), and 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.

References buf, fmt, fps, height, and width.

Referenced by BOOST_PYTHON_MODULE(), jevois::Camera::get(), jevois::Engine::mainLoop(), and jevois::Camera::streamOff().

◆ operator=()

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

Default assignment.

◆ pixels()

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

Shortcut access to pixels, read-only.

Definition at line 29 of file RawImageImpl.H.

References buf.

Referenced by jevois::rawimage::paste(), TutorialPassThrough::process(), 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 68 of file RawImage.C.

References jevois::fccstr(), fmt, height, LFATAL, and width.

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

◆ valid()

bool jevois::RawImage::valid ( ) const

Check whether the image has a valid pixel buffer.

Definition at line 46 of file RawImage.C.

References buf.

Referenced by BOOST_PYTHON_MODULE(), clear(), jevois::drawErrorImage(), jevois::Camera::get(), and jevois::Engine::mainLoop().

Member Data Documentation

◆ buf

◆ bufindex

◆ fmt

◆ fps

float jevois::RawImage::fps

◆ height

◆ width

unsigned int jevois::RawImage::width

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