29 std::shared_ptr<VideoBuf> b,
size_t bindex) :
30 width(w), height(
h), fmt(f), fps(fs), buf(b), bufindex(bindex)
43{ buf.reset(); width = 0; height = 0; fmt = 0; fps = 0.0F; }
47{
return (buf.get() !=
nullptr); }
52 if (valid() ==
false)
LFATAL(
"Cannot clear because not valid()");
56 case V4L2_PIX_FMT_YUYV:
57 std::fill(pixelsw<unsigned short>(), pixelsw<unsigned short>() + width * height,
jevois::yuyv::Black);
60 case V4L2_PIX_FMT_MJPEG:
63 case V4L2_PIX_FMT_GREY:
64 case V4L2_PIX_FMT_SRGGB8:
66 case V4L2_PIX_FMT_SBGGR16:
67 case V4L2_PIX_FMT_SGRBG16:
69 case V4L2_PIX_FMT_RGB565:
70 case V4L2_PIX_FMT_BGR24:
71 case V4L2_PIX_FMT_RGB24:
72 case V4L2_PIX_FMT_RGB32:
73 memset(pixelsw<void>(), 0, bytesize());
82 if (w != width ||
h != height || f != fmt)
83 LFATAL(
"Incorrect format for RawImage " << info <<
": want " << w <<
'x' <<
h <<
' ' <<
jevois::fccstr(f)
84 <<
" but image is " << width <<
'x' << height <<
' ' <<
jevois::fccstr(fmt));
90 if (x >= 0 && x <
int(width) && y >= 0 && y <
int(height))
return true;
bool coordsOk(int x, int y) const
Helper function to check that coords are within image bounds.
RawImage()
Default constructor, uninitialized.
unsigned int bytesize() const
Helper function to get the total number of bytes in the RawImage, i.e., width * height * bytesperpix(...
void invalidate()
Invalidate the image by zero'ing out the pointer to pixel buffer and the dims and format.
unsigned int bytesperpix() const
Helper function to get the number of bytes/pixel given the RawImage pixel format.
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.
void clear()
Clear the pixels to all black.
bool valid() const
Check whether the image has a valid pixel buffer.
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level.
unsigned int v4l2BytesPerPix(unsigned int fcc)
Return the number of bytes per pixel for a given V4L2_PIX_FMT_...
std::string fccstr(unsigned int fcc)
Convert a V4L2 four-cc code (V4L2_PIX_FMT_...) to a 4-char string.
unsigned short constexpr Black
YUYV color value.