JeVois  1.20
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
tutorial1.C
Go to the documentation of this file.
1 #include <jevois/Core/Module.H>
2 
3 // Simple module that just passes the captured camera frames through to USB host
5 {
6  public:
7  // Default base class constructor ok
9 
10  // Virtual destructor for safe inheritance
11  virtual ~TutorialPassThrough() { }
12 
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);
18 
19  // Wait for an image from our gadget driver into which we will put our results:
20  jevois::RawImage outimg = outframe.get();
21 
22  // Enforce that the input and output formats and image sizes match:
23  outimg.require("output", inimg.width, inimg.height, inimg.fmt);
24 
25  // Just copy the pixel data over:
26  memcpy(outimg.pixelsw<void>(), inimg.pixels<void>(), outimg.bytesize());
27 
28  // Let camera know we are done processing the input image:
29  inframe.done(); // NOTE: optional here, inframe destructor would call it anyway
30 
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 };
35 
36 // Allow the module to be loaded as a shared object (.so) file:
TutorialPassThrough::process
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
jevois::RawImage::pixels
const T * pixels() const
Shortcut access to pixels, read-only.
jevois::OutputFrame
Exception-safe wrapper around a raw image to be sent over USB.
Definition: OutputFrame.H:52
Module.H
jevois::RawImage::bytesize
unsigned int bytesize() const
Helper function to get the total number of bytes in the RawImage, i.e., width * height * bytesperpix(...
Definition: RawImage.C:38
jevois::RawImage
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
Definition: RawImage.H:110
jevois::RawImage::require
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:80
jevois::RawImage::width
unsigned int width
Image width in pixels.
Definition: RawImage.H:145
jevois::RawImage::pixelsw
T * pixelsw()
Shortcut access to pixels, read-write.
JEVOIS_REGISTER_MODULE
JEVOIS_REGISTER_MODULE(TutorialPassThrough)
TutorialPassThrough::~TutorialPassThrough
virtual ~TutorialPassThrough()
Definition: tutorial1.C:11
jevois::Module
Virtual base class for a vision processing module.
Definition: Module.H:104
jevois::RawImage::height
unsigned int height
Image height in pixels.
Definition: RawImage.H:146
jevois::InputFrame
Exception-safe wrapper around a raw camera input frame.
Definition: InputFrame.H:50
jevois::RawImage::fmt
unsigned int fmt
Pixel format as a V4L2_PIX_FMT_XXX.
Definition: RawImage.H:147
TutorialPassThrough
Definition: tutorial1.C:4
jevois::Component::Module
friend class Module
Definition: Component.H:519