JeVois Tutorials  1.22
JeVois Smart Embedded Machine Vision Tutorials
 
Share this page:
Loading...
Searching...
No Matches
HelloJeVois.C
Go to the documentation of this file.
3
4// icon by Catalin Fertu in cinema at flaticon
5
6//! JeVois sample module
7/*! This module is provided as an example of how to create a new standalone module.
8
9 JeVois provides helper scripts and files to assist you in programming new modules, following two basic formats:
10
11 - if you wish to only create a single module that will execute a specific function, or a collection of such modules
12 where there is no shared code between the modules (i.e., each module does things that do not relate to the other
13 modules), use the skeleton provided by this sample module. Here, all the code for the sample module is compiled
14 into a single shared object (.so) file that is loaded by the JeVois engine when the corresponding video output
15 format is selected by the host computer.
16
17 - if you are planning to write a collection of modules with some shared algorithms among several of the modules, it
18 is better to first create machine vision Components that implement the algorithms that are shared among several of
19 your modules. You would then compile all your components into a first shared library (.so) file, and then compile
20 each module into its own shared object (.so) file that depends on and automatically loads your shared library file
21 when it is selected by the host computer. The jevoisbase library and collection of components and modules is an
22 example for how to achieve that, where libjevoisbase.so contains code for Saliency, ObjectRecognition, etc
23 components that are used in several modules, and each module's .so file contains only the code specific to that
24 module.
25
26 @author Sample Author
27
28 @videomapping YUYV 640 480 28.5 YUYV 640 480 28.5 SampleVendor HelloJeVois
29 @email sampleemail\@samplecompany.com
30 @address 123 First Street, Los Angeles, CA 90012
31 @copyright Copyright (C) 2017 by Sample Author
32 @mainurl http://samplecompany.com
33 @supporturl http://samplecompany.com/support
34 @otherurl http://samplecompany.com/about
35 @license GPL v3
36 @distribution Unrestricted
37 @restrictions None */
39{
40 public:
41 //! Default base class constructor ok
43
44 //! Virtual destructor for safe inheritance
45 virtual ~HelloJeVois() { }
46
47 //! Processing function
48 virtual void process(jevois::InputFrame && inframe, jevois::OutputFrame && outframe) override
49 {
50 // Wait for next available camera image:
51 jevois::RawImage const inimg = inframe.get(true);
52
53 // We only support YUYV pixels in this example, any resolution:
54 inimg.require("input", inimg.width, inimg.height, V4L2_PIX_FMT_YUYV);
55
56 // Wait for an image from our gadget driver into which we will put our results:
57 jevois::RawImage outimg = outframe.get();
58
59 // Enforce that the input and output formats and image sizes match:
60 outimg.require("output", inimg.width, inimg.height, inimg.fmt);
61
62 // Just copy the pixel data over:
63 memcpy(outimg.pixelsw<void>(), inimg.pixels<void>(), std::min(inimg.buf->length(), outimg.buf->length()));
64
65 // Print a text message:
67
68 // Let camera know we are done processing the input image:
69 inframe.done(); // NOTE: optional here, inframe destructor would call it anyway
70
71 // Send the output image with our processing results to the host over USB:
72 outframe.send(); // NOTE: optional here, outframe destructor would call it anyway
73 }
74};
75
76// Allow the module to be loaded as a shared object (.so) file:
JEVOIS_REGISTER_MODULE(ArUcoBlob)
JeVois sample module.
Definition HelloJeVois.C:39
virtual ~HelloJeVois()
Virtual destructor for safe inheritance.
Definition HelloJeVois.C:45
virtual void process(jevois::InputFrame &&inframe, jevois::OutputFrame &&outframe) override
Processing function.
Definition HelloJeVois.C:48
friend friend class Module
unsigned int fmt
T const * pixels() const
unsigned int width
unsigned int height
void require(char const *info, unsigned int w, unsigned int h, unsigned int f) const
std::shared_ptr< VideoBuf > buf
void writeText(RawImage &img, std::string const &txt, int x, int y, unsigned int col, Font font=Font6x10)
unsigned short constexpr White