JeVois  1.0
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. 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, 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 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...
 
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

jevois::RawImage::RawImage ( )

Default constructor, uninitialized.

Definition at line 22 of file RawImage.C.

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

Default move constructor.

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

Default copy constructor.

jevois::RawImage::RawImage ( unsigned int  w,
unsigned int  h,
unsigned int  f,
std::shared_ptr< VideoBuf b,
size_t  bindex 
)

Construct from an existing VideoBuf and associated params.

Definition at line 26 of file RawImage.C.

Member Function Documentation

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 35 of file RawImage.C.

References jevois::v4l2BytesPerPix().

Referenced by jevois::rawimage::byteSwap(), and TutorialPassThrough::process().

unsigned int jevois::RawImage::bytesperpix ( ) const
bool jevois::RawImage::coordsOk ( int  x,
int  y 
) const

Helper function to check that coords are within image bounds.

Definition at line 55 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 39 of file RawImage.C.

Referenced by jevois::Camera::get().

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

Default assignment.

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

Shortcut access to pixels, read-only.

Definition at line 29 of file RawImageImpl.H.

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

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 47 of file RawImage.C.

References jevois::fccstr(), and LFATAL.

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

bool jevois::RawImage::valid ( ) const

Check whether the image has a valid pixel buffer.

Definition at line 43 of file RawImage.C.

Member Data Documentation


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