JeVois  1.8
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
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  // Convert 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:56
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:279
unsigned int height
Image height in pixels.
Definition: RawImage.H:146
unsigned int fmt
Pixel format as a V4L2_PIX_FMT_XXX.
Definition: RawImage.H:147
Module(std::string const &instance)
Definition: Module.C:181
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:1240
virtual ~TutorialConvert()
Definition: tutorial2.C:14
Virtual base class for a vision processing module.
Definition: Module.H:279
Exception-safe wrapper around a raw image to be sent over USB.
Definition: Module.H:144
unsigned int width
Image width in pixels.
Definition: RawImage.H:145
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
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:68