JeVois  1.21
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
PythonModule.H
Go to the documentation of this file.
1// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2//
3// JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2016 by Laurent Itti, the University of Southern
4// California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5//
6// This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7// redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8// Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10// License for more details. You should have received a copy of the GNU General Public License along with this program;
11// if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12//
13// Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14// Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16/*! \file */
17
18#pragma once
19
20#include <jevois/Core/Module.H>
24
25namespace jevois
26{
27 class Engine;
28
29 /*! \defgroup python Support for JeVois modules written in Python
30
31 In addition to writing modules in C++, JeVois supports writing modules in Python. JeVois provides two-way
32 mappings:
33
34 - C++ functions and classes of JeVois become accessible in Python by importing Python package \p libjevois
35 - The JeVois engine can directly invoke class member functions of a Python class implementing a machine vision
36 processing module
37
38 \ingroup core */
39
40 //! Wrapper around InputFrame to be used by Python
41 /*! This wrapper is to work around the lack of move semantics in our Python support. This class is not intended for
42 general use, but only for use by PythonModule. Users of this class must ensure that the original InputFrame will
43 outlive any and all InputFramePython instances, since InputFramePython just references to the source InputFrame by
44 unprotected raw pointer. Although the C++ object is called InputFramePython, we will expose it to python under
45 the name InputFrame (see PythonSupport.C). \ingroup python */
47 {
48 public:
49 //! Default constructor to keep boost::python happy, object is not operational
50 InputFramePython() = default;
51
52 //! Construct from a regular (move-only) InputFrame that should be be coming from Engine
54
55 //! Get the next captured camera image, thin wrapper for default arg value
56 RawImage const & get1(bool casync) const;
57
58 //! Get the next captured camera image, thin wrapper for default arg value
59 RawImage const & get() const;
60
61 //! Check whether a second input image scaled by the JeVoisPro Platform ISP is available
62 bool hasScaledImage() const;
63
64 //! Indicate that user processing is done with the image previously obtained via get()
65 void done() const;
66
67 //! Indicate that user processing is done with the ISP-scaled image previously obtained via get2()
68 void done2() const;
69
70 //! Get the next captured camera image, ISP-scaled second frame
71 RawImage const & get21(bool casync) const;
72
73 //! Get the next captured camera image, ISP-scaled second frame
74 RawImage const & get2() const;
75
76 //! Get the next captured camera image that is intended for processing
77 RawImage const & getp1(bool casync) const;
78
79 //! Get the next captured camera image that is intended for processing
80 RawImage const & getp() const;
81
82 //! Shorthand to get the input image as a GRAY cv::Mat and release the raw buffer
83 cv::Mat getCvGRAY1(bool casync) const;
84
85 //! Shorthand to get the input image as a GRAY cv::Mat and release the raw buffer
86 cv::Mat getCvGRAY() const;
87
88 //! Shorthand to get the input image as a BGR cv::Mat and release the raw buffer
89 cv::Mat getCvBGR1(bool casync) const;
90
91 //! Shorthand to get the input image as a BGR cv::Mat and release the raw buffer
92 cv::Mat getCvBGR() const;
93
94 //! Shorthand to get the input image as a RGB cv::Mat and release the raw buffer
95 cv::Mat getCvRGB1(bool casync) const;
96
97 //! Shorthand to get the input image as a RGB cv::Mat and release the raw buffer
98 cv::Mat getCvRGB() const;
99
100 //! Shorthand to get the input image as a RGBA cv::Mat and release the raw buffer
101 cv::Mat getCvRGBA1(bool casync) const;
102
103 //! Shorthand to get the input image as a RGBA cv::Mat and release the raw buffer
104 cv::Mat getCvRGBA() const;
105
106 //! Shorthand to get the input image for processing as a GRAY cv::Mat and release the raw buffer
107 cv::Mat getCvGRAYp() const;
108
109 //! Shorthand to get the input image for processing as a BGR cv::Mat and release the raw buffer
110 cv::Mat getCvBGRp() const;
111
112 //! Shorthand to get the input image for processing as a RGB cv::Mat and release the raw buffer
113 cv::Mat getCvRGBp() const;
114
115 //! Shorthand to get the input image for processing as a RGBA cv::Mat and release the raw buffer
116 cv::Mat getCvRGBAp() const;
117
118 private:
119 friend class GUIhelperPython;
120 InputFrame * itsInputFrame;
121 };
122
123 //! Wrapper around OutputFrame to be used by Python
124 /*! This wrapper is to work around the lack of move semantics in our Python support. This class is not intended for
125 general use, but only for use by PythonModule. Users of this class must ensure that the original OutputFrame will
126 outlive any and all OutputFramePython instances, since OutputFramePython just references to the source OutputFrame
127 by unprotected raw pointer. Although the C++ object is called OutputFramePython, we will expose it to python
128 under the name OutputFrame (see PythonSupport.C). \ingroup python */
130 {
131 public:
132 //! Default constructor to keep boost::python happy, object is not operational
133 OutputFramePython() = default;
134
135 //! Construct from a regular (move-only) OutputFrame that should be be coming from Engine
137
138 //! Get the next captured camera image
139 RawImage const & get() const;
140
141 //! Indicate that user processing is done with the image previously obtained via get()
142 void send() const;
143
144 //! Shorthand to send a cv::Mat after scaling/converting it to the current output format
145 /* The pixel format of the given cv::Mat is guessed as follows:
146
147 - if img.type() == CV_8UC3, assume BGR pixels
148 - if img.type() == CV_8UC1, assume GRAY pixels
149 - if img.type() == CV_8UC4, assume RGBA pixels
150
151 If this is not what you want (e.g., you have CV_8UC3 but RGB pixels instead of BGR, then use the
152 other, more specialized sendScaledCv...() functions. */
153 void sendCv1(cv::Mat const & img, int quality) const;
154
155 //! Shorthand to send a cv::Mat after scaling/converting it to the current output format
156 /* The pixel format of the given cv::Mat is guessed as follows:
157
158 - if img.type() == CV_8UC3, assume BGR pixels
159 - if img.type() == CV_8UC1, assume GRAY pixels
160 - if img.type() == CV_8UC4, assume RGBA pixels
161
162 If this is not what you want (e.g., you have CV_8UC3 but RGB pixels instead of BGR, then use the
163 other, more specialized sendScaledCv...() functions. */
164 void sendCv(cv::Mat const & img) const;
165
166 //! Shorthand to send a GRAY cv::Mat after converting it to the current output format
167 void sendCvGRAY1(cv::Mat const & img, int quality) const;
168
169 //! Shorthand to send a GRAY cv::Mat after converting it to the current output format
170 void sendCvGRAY(cv::Mat const & img) const;
171
172 //! Shorthand to send a BGR cv::Mat after converting it to the current output format
173 void sendCvBGR1(cv::Mat const & img, int quality) const;
174
175 //! Shorthand to send a BGR cv::Mat after converting it to the current output format
176 void sendCvBGR(cv::Mat const & img) const;
177
178 //! Shorthand to send a RGB cv::Mat after converting it to the current output format
179 void sendCvRGB1(cv::Mat const & img, int quality) const;
180
181 //! Shorthand to send a RGB cv::Mat after converting it to the current output format
182 void sendCvRGB(cv::Mat const & img) const;
183
184 //! Shorthand to send a RGBA cv::Mat after converting it to the current output format
185 void sendCvRGBA1(cv::Mat const & img, int quality) const;
186
187 //! Shorthand to send a RGBA cv::Mat after converting it to the current output format
188 void sendCvRGBA(cv::Mat const & img) const;
189
190 //! Shorthand to send a GRAY cv::Mat after scaling/converting it to the current output format
191 void sendScaledCvGRAY1(cv::Mat const & img, int quality) const;
192
193 //! Shorthand to send a GRAY cv::Mat after scaling/converting it to the current output format
194 void sendScaledCvGRAY(cv::Mat const & img) const;
195
196 //! Shorthand to send a BGR cv::Mat after scaling/converting it to the current output format
197 void sendScaledCvBGR1(cv::Mat const & img, int quality) const;
198
199 //! Shorthand to send a BGR cv::Mat after scaling/converting it to the current output format
200 void sendScaledCvBGR(cv::Mat const & img) const;
201
202 //! Shorthand to send a RGB cv::Mat after scaling/converting it to the current output format
203 void sendScaledCvRGB1(cv::Mat const & img, int quality) const;
204
205 //! Shorthand to send a RGB cv::Mat after scaling/converting it to the current output format
206 void sendScaledCvRGB(cv::Mat const & img) const;
207
208 //! Shorthand to send a RGBA cv::Mat after scaling/converting it to the current output format
209 void sendScaledCvRGBA1(cv::Mat const & img, int quality) const;
210
211 //! Shorthand to send a RGBA cv::Mat after scaling/converting it to the current output format
212 void sendScaledCvRGBA(cv::Mat const & img) const;
213
214 private:
215 OutputFrame * itsOutputFrame;
216 };
217
218#ifdef JEVOIS_PRO
219 //! Wrapper around GUIhelper to be used by Python
220 /*! This class is not intended for general use, but only for use by PythonModule. Users of this class must ensure that
221 the original GUIhelper will outlive any and all GUIhelperPython instances, since GUIhelperPython just references
222 to the source GUIhelper by unprotected raw pointer. Although the C++ object is called GUIhelperPython, we will
223 expose it to python under the name GUIhelper (see PythonSupport.C). \ingroup python */
225 {
226 public:
227 //! Construct from a regular GUIhelper that should be be coming from Engine
229
230 //! Start a new rendering frame
231 boost::python::tuple startFrame();
232
233 //! Helper to indicate that startFrame() was called, and thus endFrame() should be called
234 bool frameStarted() const;
235
236 //! Draw a RawImage, copying pixel data to an OpenGL texture
237 boost::python::tuple drawImage(char const * name, RawImage const & img,
238 bool noalias = false, bool isoverlay = false);
239
240 //! Draw an OpenCV image, copying pixel data to an OpenGL texture
241 boost::python::tuple drawImage1(char const * name, cv::Mat const & img, bool rgb,
242 bool noalias = false, bool isoverlay = false);
243
244 //! Draw an OpenCV image, copying pixel data to an OpenGL texture
245 boost::python::tuple drawImage2(char const * name, RawImage const & img, int x, int y, int w, int h,
246 bool noalias = false, bool isoverlay = false);
247
248 //! Draw an OpenCV image, copying pixel data to an OpenGL texture
249 boost::python::tuple drawImage3(char const * name, cv::Mat const & img, bool rgb, int x, int y, int w, int h,
250 bool noalias = false, bool isoverlay = false);
251
252 //! Draw the input video frame from the camera using zero-copy
253 boost::python::tuple drawInputFrame(char const * name, InputFramePython const & frame,
254 bool noalias = false, bool casync = false);
255
256 //! Draw the second (scaled) input video frame from the camera using zero-copy
257 boost::python::tuple drawInputFrame2(char const * name, InputFramePython const & frame,
258 bool noalias = false, bool casync = false);
259
260 //! Convert coordinates of a point from within a rendered image to on-screen
261 ImVec2 i2d(ImVec2 p, char const * name = nullptr);
262
263 //! Convert coordinates of a point from within a rendered image to on-screen
264 ImVec2 i2d1(float x, float y, char const * name = nullptr);
265
266 //! Convert a 2D size from within a rendered image to on-screen
267 ImVec2 i2ds(ImVec2 p, char const * name = nullptr);
268
269 //! Convert a 2D size from within a rendered image to on-screen
270 ImVec2 i2ds1(float x, float y, char const * name = nullptr);
271
272 //! Draw line over an image
273 void drawLine(float x1, float y1, float x2, float y2, ImU32 col = IM_COL32(128,255,128,255));
274
275 //! Draw rectangular box over an image
276 void drawRect(float x1, float y1, float x2, float y2, ImU32 col = IM_COL32(128,255,128,255), bool filled = true);
277
278 //! Draw polygon over an image
279 void drawPoly(std::vector<cv::Point> const & pts, ImU32 col = IM_COL32(128,255,128,255), bool filled = true);
280
281 //! Draw polygon over an image
282 void drawPoly1(std::vector<cv::Point2f> const & pts, ImU32 col = IM_COL32(128,255,128,255), bool filled = true);
283
284 //! Draw polygon over an image
285 void drawPoly2(cv::Mat const & pts, ImU32 col = IM_COL32(128,255,128,255), bool filled = true);
286
287 //! Draw circle over an image
288 void drawCircle(float x, float y, float r, ImU32 col = IM_COL32(128,255,128,255), bool filled = true);
289
290 //! Draw text over an image
291 void drawText(float x, float y, char const * txt, ImU32 col = IM_COL32(128,255,128,255));
292
293 //! Get coordinates of the start of a given line of text to be drawn as overlay on top of an image
294 ImVec2 iline(int line = -1, char const * name = nullptr);
295
296 //! Draw some overlay text on top of an image
297 void itext(char const * txt, ImU32 const & col = IM_COL32_BLACK_TRANS, int line = -1);
298
299 //! Draw some overlay text on top of an image, default color and line
300 void itext2(char const * txt);
301
302 //! Display processing and video info at bottom of screen
303 void iinfo(jevois::InputFramePython const & inframe, std::string const & fpscpu,
304 unsigned short winw = 0, unsigned short winh = 0);
305
306 //! Release an image
307 void releaseImage(char const * name);
308
309 //! Release an image, second video stream
310 void releaseImage2(char const * name);
311
312 //! Finish current frame and render it
313 void endFrame();
314
315 //! Convert coordinates of a point from on-screen to within a rendered image
316 ImVec2 d2i(ImVec2 p, char const * name = nullptr);
317
318 //! Convert coordinates of a point from on-screen to within a rendered image
319 ImVec2 d2i1(float x, float y, char const * name = nullptr);
320
321 //! Convert a 2D size from on-screen to within a rendered image
322 ImVec2 d2is(ImVec2 p, char const * name = nullptr);
323
324 //! Convert a 2D size from on-screen to within a rendered image
325 ImVec2 d2is1(float x, float y, char const * name = nullptr);
326
327 //! Report an error in an overlay window
328 void reportError(std::string const & err);
329
330 //! Report current exception in a modal dialog, then ignore it
331 void reportAndIgnoreException(std::string const & prefix = "");
332
333 //! Report current exception in a modal dialog, then re-throw it
334 void reportAndRethrowException(std::string const & prefix = "");
335
336 //! ImGui helper: get mouse position
337 ImVec2 getMousePos();
338
339 //! ImGui helper: check if mouse button clicked
340 bool isMouseClicked(int button_num);
341
342 //! ImGui helper: check if mouse button double-clicked
343 bool isMouseDoubleClicked(int button_num);
344
345 //! ImGui helper: check if mouse button dragged
346 bool isMouseDragging(int button_num);
347
348 //! ImGui helper: check if mouse button pressed
349 bool isMouseDown(int button_num);
350
351 //! ImGui helper: check if mouse button released
352 bool isMouseReleased(int button_num);
353
354 private:
355 GUIhelper * itsGUIhelper;
356 };
357#endif
358
359 //! Wrapper module to allow users to develop new modules written in Python
360 /*! This wrapper module calls a process function written in Python on every frame. Note how sendSerial() is added
361 dynamically after the python class is defined, as a new member function of the class. \ingroup python */
362 class PythonModule : public Module, public PythonWrapper
363 {
364 public:
365 //! Constructor needs the full path to a Python source code file
366 /*! Note that, contrary to C++ modules, construction will not throw. This is so that the module is always valid
367 and initialized, and its module path can be set by Engine, which is necessary to allow saving the source code
368 from JeVois Inventor. Instead, any construction error is stored internally in this class and will be re-thrown
369 at any access to process(), parfseSerial(), etc. */
370 PythonModule(VideoMapping const & m);
371
372 //! Load python code and optionally call init() python module function, if implemented
373 void preInit() override;
374
375 //! Virtual destructor for safe inheritance
376 virtual ~PythonModule();
377
378 //! Processing function, version that receives a frame from camera and sends a frame out over USB
379 virtual void process(InputFrame && inframe, OutputFrame && outframe) override;
380
381 //! Processing function, version that receives a frame from camera and does not use USB
382 virtual void process(InputFrame && inframe) override;
383
384#ifdef JEVOIS_PRO
385 //! Processing function, version that receives a frame from camera, no USB, but GUI output on JeVois-Pro
386 virtual void process(InputFrame && inframe, GUIhelper & helper);
387#endif
388
389 //! Receive a string from a serial port which contains a user command
390 virtual void parseSerial(std::string const & str, std::shared_ptr<UserInterface> s) override;
391
392 //! Human-readable description of this Module's supported custom commands
393 virtual void supportedCommands(std::ostream & os) override;
394
395 //! Optionally call uninit() python module function, if implemented
396 void postUninit() override;
397
398 private:
399 std::string itsPyPath;
400 };
401
402 namespace dnn
403 {
404 class PreProcessor;
405
406 //! Pre-Processor interface exposed to the python side
407 /*! This wrapper is passed down to the process() function of a python post-processor, it provides a python-friendly
408 interface to b2i(), blobsizes(), etc \ingroup python */
409 class PreProcessorForPython
410 {
411 public:
412 //! Construct from an existing PreProcessor
413 /*! Caller must ensure that pp outlives us. */
414 PreProcessorForPython(PreProcessor * pp);
415
416 //! Access the last processed image size
417 /*! Returned as a tuple (width, height). */
418 boost::python::tuple imagesize() const;
419
420 //! Access the last computed blobs (or empty if process() has not yet been called)
421 boost::python::list blobs() const;
422
423 //! Access the width and height of a given blob, accounting for NCHW or NHWC
424 /*! Returned as a tuple (width, height). */
425 boost::python::tuple blobsize(size_t num) const;
426
427 //! Convert coordinates from blob back to original image
428 /*! Given coords x,y should be in [0..w-1]x[0..h-1] where w,h are the blob's width and height. This is useful to
429 convert detected boxes back into original input coordinates. Returned as a tuple (x, y). */
430 boost::python::tuple b2i(float x, float y, size_t blobnum);
431
432 //! Get unscaled crop rectangle in image coordinates
433 /*! This is useful to display an image overlay on top of the input image.
434 Returned as a tuple (x, y, w, h). */
435 boost::python::tuple getUnscaledCropRect(size_t blobnum);
436
437 //! Convert coordinates from image to blob
438 /*! Given coords x,y should be in [0..w-1]x[0..h-1] where w,h are the image's width and height. This is useful
439 to convert mouse coordinates (after they have been converted from screen to image coords) to locations
440 within an input blob. */
441 boost::python::tuple i2b(float x, float y, size_t blobnum);
442
443 private:
444 PreProcessor * itsPP;
445 };
446
447 class PostProcessorDetectYOLO;
448
449 //! YOLO post-processor exposed to python
450 /*! A bit hacky since PostProcessorDetectYOLO is a Component that holds parameters. This class will add a
451 PostProcessorDetectYOLO subcomponent to the current module, and then will forward yolo post-processing requests
452 to it. */
453 class PostProcessorDetectYOLOforPython
454 {
455 public:
456 //! Constructor constructs itsYOLO and adds it to current module
457 PostProcessorDetectYOLOforPython();
458
459 //! Destructor removes itsYOLO from current module
460 ~PostProcessorDetectYOLOforPython();
461
462 //! Freeze/unfreeze parameters that users should not change while running
463 void freeze(bool doit);
464
465 //! Generic raw YOLO processing
466 /*! The returned tuple has 3 elements: list of int for classIds, list of float for confidences, and list of
467 4-element tuples of floats for boxes (x, y, w, h). */
468 boost::python::tuple yolo(boost::python::list outs, int nclass, float boxThreshold,
469 float confThreshold, int bw, int bh, int fudge, int maxbox);
470
471 private:
472 std::shared_ptr<PostProcessorDetectYOLO> itsYOLO;
473 };
474
475 } // namespace dnn
476} // namespace jevois
int h
Definition GUIhelper.C:2491
Wrapper around GUIhelper to be used by Python.
void itext2(char const *txt)
Draw some overlay text on top of an image, default color and line.
void iinfo(jevois::InputFramePython const &inframe, std::string const &fpscpu, unsigned short winw=0, unsigned short winh=0)
Display processing and video info at bottom of screen.
ImVec2 getMousePos()
ImGui helper: get mouse position.
void reportError(std::string const &err)
Report an error in an overlay window.
void releaseImage(char const *name)
Release an image.
ImVec2 d2is1(float x, float y, char const *name=nullptr)
Convert a 2D size from on-screen to within a rendered image.
void reportAndRethrowException(std::string const &prefix="")
Report current exception in a modal dialog, then re-throw it.
ImVec2 d2is(ImVec2 p, char const *name=nullptr)
Convert a 2D size from on-screen to within a rendered image.
ImVec2 d2i(ImVec2 p, char const *name=nullptr)
Convert coordinates of a point from on-screen to within a rendered image.
void reportAndIgnoreException(std::string const &prefix="")
Report current exception in a modal dialog, then ignore it.
void drawCircle(float x, float y, float r, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw circle over an image.
ImVec2 d2i1(float x, float y, char const *name=nullptr)
Convert coordinates of a point from on-screen to within a rendered image.
boost::python::tuple drawInputFrame2(char const *name, InputFramePython const &frame, bool noalias=false, bool casync=false)
Draw the second (scaled) input video frame from the camera using zero-copy.
void drawPoly2(cv::Mat const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw polygon over an image.
void drawPoly1(std::vector< cv::Point2f > const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw polygon over an image.
ImVec2 i2d1(float x, float y, char const *name=nullptr)
Convert coordinates of a point from within a rendered image to on-screen.
void drawPoly(std::vector< cv::Point > const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw polygon over an image.
void endFrame()
Finish current frame and render it.
bool isMouseDown(int button_num)
ImGui helper: check if mouse button pressed.
ImVec2 iline(int line=-1, char const *name=nullptr)
Get coordinates of the start of a given line of text to be drawn as overlay on top of an image.
void drawText(float x, float y, char const *txt, ImU32 col=IM_COL32(128, 255, 128, 255))
Draw text over an image.
boost::python::tuple drawImage(char const *name, RawImage const &img, bool noalias=false, bool isoverlay=false)
Draw a RawImage, copying pixel data to an OpenGL texture.
boost::python::tuple drawImage3(char const *name, cv::Mat const &img, bool rgb, int x, int y, int w, int h, bool noalias=false, bool isoverlay=false)
Draw an OpenCV image, copying pixel data to an OpenGL texture.
ImVec2 i2d(ImVec2 p, char const *name=nullptr)
Convert coordinates of a point from within a rendered image to on-screen.
void releaseImage2(char const *name)
Release an image, second video stream.
bool isMouseReleased(int button_num)
ImGui helper: check if mouse button released.
boost::python::tuple drawImage1(char const *name, cv::Mat const &img, bool rgb, bool noalias=false, bool isoverlay=false)
Draw an OpenCV image, copying pixel data to an OpenGL texture.
ImVec2 i2ds1(float x, float y, char const *name=nullptr)
Convert a 2D size from within a rendered image to on-screen.
bool frameStarted() const
Helper to indicate that startFrame() was called, and thus endFrame() should be called.
ImVec2 i2ds(ImVec2 p, char const *name=nullptr)
Convert a 2D size from within a rendered image to on-screen.
void itext(char const *txt, ImU32 const &col=IM_COL32_BLACK_TRANS, int line=-1)
Draw some overlay text on top of an image.
bool isMouseDragging(int button_num)
ImGui helper: check if mouse button dragged.
bool isMouseClicked(int button_num)
ImGui helper: check if mouse button clicked.
void drawRect(float x1, float y1, float x2, float y2, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw rectangular box over an image.
boost::python::tuple startFrame()
Start a new rendering frame.
void drawLine(float x1, float y1, float x2, float y2, ImU32 col=IM_COL32(128, 255, 128, 255))
Draw line over an image.
boost::python::tuple drawImage2(char const *name, RawImage const &img, int x, int y, int w, int h, bool noalias=false, bool isoverlay=false)
Draw an OpenCV image, copying pixel data to an OpenGL texture.
boost::python::tuple drawInputFrame(char const *name, InputFramePython const &frame, bool noalias=false, bool casync=false)
Draw the input video frame from the camera using zero-copy.
bool isMouseDoubleClicked(int button_num)
ImGui helper: check if mouse button double-clicked.
Helper class to assist modules in creating graphical and GUI elements.
Definition GUIhelper.H:133
Wrapper around InputFrame to be used by Python.
RawImage const & getp() const
Get the next captured camera image that is intended for processing.
cv::Mat getCvGRAYp() const
Shorthand to get the input image for processing as a GRAY cv::Mat and release the raw buffer.
cv::Mat getCvRGBA() const
Shorthand to get the input image as a RGBA cv::Mat and release the raw buffer.
RawImage const & get2() const
Get the next captured camera image, ISP-scaled second frame.
RawImage const & get1(bool casync) const
Get the next captured camera image, thin wrapper for default arg value.
cv::Mat getCvRGBA1(bool casync) const
Shorthand to get the input image as a RGBA cv::Mat and release the raw buffer.
cv::Mat getCvRGBp() const
Shorthand to get the input image for processing as a RGB cv::Mat and release the raw buffer.
InputFramePython()=default
Default constructor to keep boost::python happy, object is not operational.
cv::Mat getCvRGBAp() const
Shorthand to get the input image for processing as a RGBA cv::Mat and release the raw buffer.
cv::Mat getCvBGR() const
Shorthand to get the input image as a BGR cv::Mat and release the raw buffer.
RawImage const & get() const
Get the next captured camera image, thin wrapper for default arg value.
cv::Mat getCvBGR1(bool casync) const
Shorthand to get the input image as a BGR cv::Mat and release the raw buffer.
cv::Mat getCvBGRp() const
Shorthand to get the input image for processing as a BGR cv::Mat and release the raw buffer.
cv::Mat getCvRGB() const
Shorthand to get the input image as a RGB cv::Mat and release the raw buffer.
RawImage const & get21(bool casync) const
Get the next captured camera image, ISP-scaled second frame.
void done() const
Indicate that user processing is done with the image previously obtained via get()
cv::Mat getCvGRAY1(bool casync) const
Shorthand to get the input image as a GRAY cv::Mat and release the raw buffer.
RawImage const & getp1(bool casync) const
Get the next captured camera image that is intended for processing.
cv::Mat getCvRGB1(bool casync) const
Shorthand to get the input image as a RGB cv::Mat and release the raw buffer.
void done2() const
Indicate that user processing is done with the ISP-scaled image previously obtained via get2()
bool hasScaledImage() const
Check whether a second input image scaled by the JeVoisPro Platform ISP is available.
cv::Mat getCvGRAY() const
Shorthand to get the input image as a GRAY cv::Mat and release the raw buffer.
Exception-safe wrapper around a raw camera input frame.
Definition InputFrame.H:51
Virtual base class for a vision processing module.
Definition Module.H:105
Wrapper around OutputFrame to be used by Python.
void sendScaledCvRGBA1(cv::Mat const &img, int quality) const
Shorthand to send a RGBA cv::Mat after scaling/converting it to the current output format.
void sendScaledCvBGR1(cv::Mat const &img, int quality) const
Shorthand to send a BGR cv::Mat after scaling/converting it to the current output format.
void sendScaledCvGRAY1(cv::Mat const &img, int quality) const
Shorthand to send a GRAY cv::Mat after scaling/converting it to the current output format.
RawImage const & get() const
Get the next captured camera image.
void sendCvRGB1(cv::Mat const &img, int quality) const
Shorthand to send a RGB cv::Mat after converting it to the current output format.
void sendScaledCvRGB1(cv::Mat const &img, int quality) const
Shorthand to send a RGB cv::Mat after scaling/converting it to the current output format.
void send() const
Indicate that user processing is done with the image previously obtained via get()
void sendScaledCvBGR(cv::Mat const &img) const
Shorthand to send a BGR cv::Mat after scaling/converting it to the current output format.
void sendCvGRAY1(cv::Mat const &img, int quality) const
Shorthand to send a GRAY cv::Mat after converting it to the current output format.
void sendCvBGR1(cv::Mat const &img, int quality) const
Shorthand to send a BGR cv::Mat after converting it to the current output format.
OutputFramePython()=default
Default constructor to keep boost::python happy, object is not operational.
void sendCvBGR(cv::Mat const &img) const
Shorthand to send a BGR cv::Mat after converting it to the current output format.
void sendScaledCvRGB(cv::Mat const &img) const
Shorthand to send a RGB cv::Mat after scaling/converting it to the current output format.
void sendScaledCvRGBA(cv::Mat const &img) const
Shorthand to send a RGBA cv::Mat after scaling/converting it to the current output format.
void sendCv1(cv::Mat const &img, int quality) const
Shorthand to send a cv::Mat after scaling/converting it to the current output format.
void sendCvRGB(cv::Mat const &img) const
Shorthand to send a RGB cv::Mat after converting it to the current output format.
void sendScaledCvGRAY(cv::Mat const &img) const
Shorthand to send a GRAY cv::Mat after scaling/converting it to the current output format.
void sendCvRGBA(cv::Mat const &img) const
Shorthand to send a RGBA cv::Mat after converting it to the current output format.
void sendCv(cv::Mat const &img) const
Shorthand to send a cv::Mat after scaling/converting it to the current output format.
void sendCvRGBA1(cv::Mat const &img, int quality) const
Shorthand to send a RGBA cv::Mat after converting it to the current output format.
void sendCvGRAY(cv::Mat const &img) const
Shorthand to send a GRAY cv::Mat after converting it to the current output format.
Exception-safe wrapper around a raw image to be sent over USB.
Definition OutputFrame.H:53
Wrapper module to allow users to develop new modules written in Python.
virtual void process(InputFrame &&inframe, OutputFrame &&outframe) override
Processing function, version that receives a frame from camera and sends a frame out over USB.
virtual void supportedCommands(std::ostream &os) override
Human-readable description of this Module's supported custom commands.
void postUninit() override
Optionally call uninit() python module function, if implemented.
virtual void parseSerial(std::string const &str, std::shared_ptr< UserInterface > s) override
Receive a string from a serial port which contains a user command.
void preInit() override
Load python code and optionally call init() python module function, if implemented.
virtual ~PythonModule()
Virtual destructor for safe inheritance.
Helper class to run python code from C++.
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
Definition RawImage.H:111
Main namespace for all JeVois classes and functions.
Definition Concepts.dox:2
Simple struct to hold video mapping definitions for the processing Engine.