JeVois  1.0
JeVois Smart Embedded Machine Vision Toolkit
Go to the documentation of this file.
1 #include <jevois/Core/Module.H>
3 #include <opencv2/core/core.hpp>
4 #include <opencv2/imgproc/imgproc.hpp>
6 // Simple module to convert between any supported camera grab formats and USB output formats
8 {
9  public:
10  // Default base class constructor ok
13  // Virtual destructor for safe inheritance
14  virtual ~TutorialConvert() { }
16  // Processing function
17  virtual void process(jevois::InputFrame && inframe, jevois::OutputFrame && outframe) override
18  {
19  // Wait for next available camera image:
20  jevois::RawImage inimg = inframe.get();
22  // TutorialConvert it to BGR24:
23  cv::Mat imgbgr = jevois::rawimage::convertToCvBGR(inimg);
25  // Let camera know we are done processing the input image:
26  inframe.done();
28  // Wait for an image from our gadget driver into which we will put our results:
29  jevois::RawImage outimg = outframe.get();
31  // Require that output has same dims as input, allow any output format:
32  outimg.require("output", inimg.width, inimg.height, outimg.fmt);
34  // TutorialConvert from BGR to desired output format:
37  // Send the output image with our processing results to the host over USB:
38  outframe.send();
39  }
40 };
42 // Allow the module to be loaded as a shared object (.so) file:
Exception-safe wrapper around a raw camera input frame.
Definition: Module.H:54
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...
Definition: RawImage.C:47
cv::Mat convertToCvBGR(RawImage const &src)
Convert RawImage to OpenCV doing color conversion from any RawImage source pixel to OpenCV BGR byte...
Definition: RawImageOps.C:226
unsigned int height
Image height in pixels.
Definition: RawImage.H:140
unsigned int fmt
Pixel format as a V4L2_PIX_FMT_XXX.
Definition: RawImage.H:141
Module(std::string const &instance)
Definition: Module.C:94
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
Definition: RawImage.H:110
void convertCvBGRtoRawImage(cv::Mat const &src, RawImage &dst, int quality)
Convert a BGR cv::Mat to RawImage with already-allocated pixels and pixel type.
Definition: RawImageOps.C:860
virtual ~TutorialConvert()
Definition: tutorial2.C:14
Virtual base class for a vision processing module.
Definition: Module.H:203
Exception-safe wrapper around a raw image to be sent over USB.
Definition: Module.H:110
unsigned int width
Image width in pixels.
Definition: RawImage.H:139
virtual void process(jevois::InputFrame &&inframe, jevois::OutputFrame &&outframe) override
Processing function, version that receives a frame from camera and sends a frame out over USB...
Definition: tutorial2.C:17