JeVois  1.0
JeVois Smart Embedded Machine Vision Toolkit
Go to the documentation of this file.
1 #include <jevois/Core/Module.H>
3 // Simple module that just passes the captured camera frames through to USB host
5 {
6  public:
7  // Default base class constructor ok
10  // Virtual destructor for safe inheritance
11  virtual ~TutorialPassThrough() { }
13  // Processing function
14  virtual void process(jevois::InputFrame && inframe, jevois::OutputFrame && outframe) override
15  {
16  // Wait for next available camera image:
17  jevois::RawImage const inimg = inframe.get(true);
19  // Wait for an image from our gadget driver into which we will put our results:
20  jevois::RawImage outimg = outframe.get();
22  // Enforce that the input and output formats and image sizes match:
23  outimg.require("output", inimg.width, inimg.height, inimg.fmt);
25  // Just copy the pixel data over:
26  memcpy(outimg.pixelsw<void>(), inimg.pixels<void>(), outimg.bytesize());
28  // Let camera know we are done processing the input image:
29  inframe.done(); // NOTE: optional here, inframe destructor would call it anyway
31  // Send the output image with our processing results to the host over USB:
32  outframe.send(); // NOTE: optional here, outframe destructor would call it anyway
33  }
34 };
36 // 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
unsigned int height
Image height in pixels.
Definition: RawImage.H:140
virtual ~TutorialPassThrough()
Definition: tutorial1.C:11
T * pixelsw()
Shortcut access to pixels, read-write.
Definition: RawImageImpl.H:24
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
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: tutorial1.C:14
unsigned int bytesize() const
Helper function to get the total number of bytes in the RawImage, i.e., width * height * bytesperpix(...
Definition: RawImage.C:35
T const * pixels() const
Shortcut access to pixels, read-only.
Definition: RawImageImpl.H:29
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