JeVois  1.17
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
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>
22 #include <boost/python.hpp>
23 #include <jevois/GPU/GUIhelper.H>
24 
25 namespace 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  //! Default constructor to keep boost::python happy, object is not operational
228  GUIhelperPython() = default;
229 
230  //! Construct from a regular GUIhelper that should be be coming from Engine
231  GUIhelperPython(GUIhelper * src);
232 
233  //! Start a new rendering frame
234  boost::python::tuple startFrame();
235 
236  //! Helper to indicate that startFrame() was called, and thus endFrame() should be called
237  bool frameStarted() const;
238 
239  //! Draw a RawImage, copying pixel data to an OpenGL texture
240  boost::python::tuple drawImage(char const * name, RawImage const & img,
241  bool noalias = false, bool isoverlay = false);
242 
243  //! Draw an OpenCV image, copying pixel data to an OpenGL texture
244  boost::python::tuple drawImage1(char const * name, cv::Mat const & img, bool rgb,
245  bool noalias = false, bool isoverlay = false);
246 
247  //! Draw the input video frame from the camera using zero-copy
248  boost::python::tuple drawInputFrame(char const * name, InputFramePython const & frame,
249  bool noalias = false, bool casync = false);
250 
251  //! Draw the second (scaled) input video frame from the camera using zero-copy
252  boost::python::tuple drawInputFrame2(char const * name, InputFramePython const & frame,
253  bool noalias = false, bool casync = false);
254 
255  //! Convert coordinates of a point from within a rendered image to on-screen
256  ImVec2 i2d(ImVec2 p, char const * name = nullptr);
257 
258  //! Convert coordinates of a point from within a rendered image to on-screen
259  ImVec2 i2d1(float x, float y, char const * name = nullptr);
260 
261  //! Convert a 2D size from within a rendered image to on-screen
262  ImVec2 i2ds(ImVec2 p, char const * name = nullptr);
263 
264  //! Convert a 2D size from within a rendered image to on-screen
265  ImVec2 i2ds1(float x, float y, char const * name = nullptr);
266 
267  //! Draw line over an image
268  void drawLine(float x1, float y1, float x2, float y2, ImU32 col = IM_COL32(128,255,128,255));
269 
270  //! Draw rectangular box over an image
271  void drawRect(float x1, float y1, float x2, float y2, ImU32 col = IM_COL32(128,255,128,255), bool filled = true);
272 
273  //! Draw polygon over an image
274  void drawPoly(std::vector<cv::Point> const & pts, ImU32 col = IM_COL32(128,255,128,255), bool filled = true);
275 
276  //! Draw polygon over an image
277  void drawPoly1(std::vector<cv::Point2f> const & pts, ImU32 col = IM_COL32(128,255,128,255), bool filled = true);
278 
279  //! Draw polygon over an image
280  void drawPoly2(cv::Mat const & pts, ImU32 col = IM_COL32(128,255,128,255), bool filled = true);
281 
282  //! Draw circle over an image
283  void drawCircle(float x, float y, float r, ImU32 col = IM_COL32(128,255,128,255), bool filled = true);
284 
285  //! Draw text over an image
286  void drawText(float x, float y, char const * txt, ImU32 col = IM_COL32(128,255,128,255));
287 
288  //! Get coordinates of the start of a given line of text to be drawn as overlay on top of an image
289  ImVec2 iline(int line = -1, char const * name = nullptr);
290 
291  //! Draw some overlay text on top of an image
292  void itext(char const * txt, ImU32 const & col = IM_COL32_BLACK_TRANS, int line = -1);
293 
294  //! Display processing and video info at bottom of screen
295  void iinfo(jevois::InputFramePython const & inframe, std::string const & fpscpu,
296  unsigned short winw = 0, unsigned short winh = 0);
297 
298  //! Release an image
299  void releaseImage(char const * name);
300 
301  //! Release an image, second video stream
302  void releaseImage2(char const * name);
303 
304  //! Finish current frame and render it
305  void endFrame();
306 
307  //! Report an error in an overlay window
308  void reportError(std::string const & err);
309 
310  //! Report current exception in a modal dialog, then ignore it
311  void reportAndIgnoreException(std::string const & prefix = "");
312 
313  //! Report current exception in a modal dialog, then re-throw it
314  void reportAndRethrowException(std::string const & prefix = "");
315 
316  private:
317  GUIhelper * itsGUIhelper;
318  };
319 #endif
320 
321  //! Wrapper module to allow users to develop new modules written in Python
322  /*! This wrapper module calls a process function written in Python on every frame. Note how sendSerial() is added
323  dynamically after the python class is defined, as a new member function of the class. \ingroup python */
324  class PythonModule : public Module
325  {
326  public:
327  //! Constructor needs the full path to a Python source code file
328  /*! Note that, contrary to C++ modules, construction will not throw. This is so that the module is always valid
329  and initialized, and its module path can be set by Engine, which is necessary to allow saving the source code
330  from JeVois Inventor. Instead, any construction error is stored internally in this class and will be re-thrown
331  at any access to process(), parfseSerial(), etc. */
332  PythonModule(VideoMapping const & m);
333 
334  //! Virtual destructor for safe inheritance
335  virtual ~PythonModule();
336 
337  //! Processing function, version that receives a frame from camera and sends a frame out over USB
338  virtual void process(InputFrame && inframe, OutputFrame && outframe) override;
339 
340  //! Processing function, version that receives a frame from camera and does not use USB
341  virtual void process(InputFrame && inframe) override;
342 
343 #ifdef JEVOIS_PRO
344  //! Processing function, version that receives a frame from camera, no USB, but GUI output on JeVois-Pro
345  virtual void process(InputFrame && inframe, GUIhelper & helper);
346 #endif
347 
348  //! Receive a string from a serial port which contains a user command
349  virtual void parseSerial(std::string const & str, std::shared_ptr<UserInterface> s) override;
350 
351  //! Human-readable description of this Module's supported custom commands
352  virtual void supportedCommands(std::ostream & os) override;
353 
354  //! Optionally call uninit() python module function, if implemented
355  void postUninit() override;
356 
357  private:
358  boost::python::object itsMainModule, itsMainNamespace;
359  boost::python::object itsInstance;
360  std::string itsConstructionError;
361  };
362 
363 } // namespace jevois
364 
jevois::OutputFramePython::sendScaledCvGRAY
void sendScaledCvGRAY(cv::Mat const &img) const
Shorthand to send a GRAY cv::Mat after scaling/converting it to the current output format.
Definition: PythonModule.C:239
jevois::InputFramePython::getCvRGB1
cv::Mat getCvRGB1(bool casync) const
Shorthand to get the input image as a RGB cv::Mat and release the raw buffer.
Definition: PythonModule.C:107
jevois::OutputFrame
Exception-safe wrapper around a raw image to be sent over USB.
Definition: OutputFrame.H:52
jevois::InputFramePython::getCvGRAY
cv::Mat getCvGRAY() const
Shorthand to get the input image as a GRAY cv::Mat and release the raw buffer.
Definition: PythonModule.C:89
Module.H
jevois::GUIhelperPython::iinfo
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.
Definition: PythonModule.C:445
jevois::InputFramePython::get
const RawImage & get() const
Get the next captured camera image, thin wrapper for default arg value.
Definition: PythonModule.C:35
jevois::OutputFramePython::sendCv1
void sendCv1(cv::Mat const &img, int quality) const
Shorthand to send a cv::Mat after scaling/converting it to the current output format.
Definition: PythonModule.C:173
jevois::GUIhelperPython::drawImage1
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.
Definition: PythonModule.C:315
jevois::OutputFramePython::get
const RawImage & get() const
Get the next captured camera image.
Definition: PythonModule.C:161
jevois::GUIhelperPython::drawPoly
void drawPoly(std::vector< cv::Point > const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw polygon over an image.
Definition: PythonModule.C:387
jevois::PythonModule
Wrapper module to allow users to develop new modules written in Python.
Definition: PythonModule.H:324
jevois::InputFramePython::get1
const RawImage & get1(bool casync) const
Get the next captured camera image, thin wrapper for default arg value.
Definition: PythonModule.C:29
jevois::InputFramePython::getCvGRAYp
cv::Mat getCvGRAYp() const
Shorthand to get the input image for processing as a GRAY cv::Mat and release the raw buffer.
Definition: PythonModule.C:131
jevois::GUIhelperPython::itext
void itext(char const *txt, ImU32 const &col=IM_COL32_BLACK_TRANS, int line=-1)
Draw some overlay text on top of an image.
Definition: PythonModule.C:438
jevois::PythonModule::process
virtual void process(InputFrame &&inframe, OutputFrame &&outframe) override
Processing function, version that receives a frame from camera and sends a frame out over USB.
Definition: PythonModule.C:559
jevois::OutputFramePython::send
void send() const
Indicate that user processing is done with the image previously obtained via get()
Definition: PythonModule.C:167
jevois::InputFramePython::getp
const RawImage & getp() const
Get the next captured camera image that is intended for processing.
Definition: PythonModule.C:65
jevois::GUIhelperPython::iline
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.
Definition: PythonModule.C:431
jevois::InputFramePython::getCvRGBp
cv::Mat getCvRGBp() const
Shorthand to get the input image for processing as a RGB cv::Mat and release the raw buffer.
Definition: PythonModule.C:143
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::OutputFramePython::sendScaledCvRGBA1
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.
Definition: PythonModule.C:269
jevois::InputFramePython::done
void done() const
Indicate that user processing is done with the image previously obtained via get()
Definition: PythonModule.C:71
jevois::GUIhelperPython::drawPoly1
void drawPoly1(std::vector< cv::Point2f > const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw polygon over an image.
Definition: PythonModule.C:394
jevois::GUIhelperPython::frameStarted
bool frameStarted() const
Helper to indicate that startFrame() was called, and thus endFrame() should be called.
Definition: PythonModule.C:298
jevois::GUIhelperPython::endFrame
void endFrame()
Finish current frame and render it.
Definition: PythonModule.C:467
jevois::GUIhelperPython
Wrapper around GUIhelper to be used by Python.
Definition: PythonModule.H:224
jevois::OutputFramePython::sendScaledCvRGB1
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.
Definition: PythonModule.C:257
jevois::PythonModule::~PythonModule
virtual ~PythonModule()
Virtual destructor for safe inheritance.
Definition: PythonModule.C:555
jevois::GUIhelper
Helper class to assist modules in creating graphical and GUI elements.
Definition: GUIhelper.H:108
jevois::GUIhelperPython::drawText
void drawText(float x, float y, char const *txt, ImU32 col=IM_COL32(128, 255, 128, 255))
Draw text over an image.
Definition: PythonModule.C:424
jevois::GUIhelperPython::GUIhelperPython
GUIhelperPython()=default
Default constructor to keep boost::python happy, object is not operational.
jevois::PythonModule::postUninit
void postUninit() override
Optionally call uninit() python module function, if implemented.
Definition: PythonModule.C:548
jevois::GUIhelperPython::releaseImage2
void releaseImage2(char const *name)
Release an image, second video stream.
Definition: PythonModule.C:460
jevois
Definition: Concepts.dox:1
jevois::GUIhelperPython::startFrame
boost::python::tuple startFrame()
Start a new rendering frame.
Definition: PythonModule.C:289
jevois::OutputFramePython::sendCvGRAY1
void sendCvGRAY1(cv::Mat const &img, int quality) const
Shorthand to send a GRAY cv::Mat after converting it to the current output format.
Definition: PythonModule.C:185
jevois::InputFramePython::getCvRGBAp
cv::Mat getCvRGBAp() const
Shorthand to get the input image for processing as a RGBA cv::Mat and release the raw buffer.
Definition: PythonModule.C:149
jevois::InputFramePython::getCvBGRp
cv::Mat getCvBGRp() const
Shorthand to get the input image for processing as a BGR cv::Mat and release the raw buffer.
Definition: PythonModule.C:137
jevois::InputFramePython::getCvRGBA1
cv::Mat getCvRGBA1(bool casync) const
Shorthand to get the input image as a RGBA cv::Mat and release the raw buffer.
Definition: PythonModule.C:119
jevois::OutputFramePython::sendCvRGBA
void sendCvRGBA(cv::Mat const &img) const
Shorthand to send a RGBA cv::Mat after converting it to the current output format.
Definition: PythonModule.C:227
jevois::OutputFramePython::sendCvRGB1
void sendCvRGB1(cv::Mat const &img, int quality) const
Shorthand to send a RGB cv::Mat after converting it to the current output format.
Definition: PythonModule.C:209
jevois::InputFramePython::getCvRGBA
cv::Mat getCvRGBA() const
Shorthand to get the input image as a RGBA cv::Mat and release the raw buffer.
Definition: PythonModule.C:125
jevois::GUIhelperPython::reportAndIgnoreException
void reportAndIgnoreException(std::string const &prefix="")
Report current exception in a modal dialog, then ignore it.
Definition: PythonModule.C:481
jevois::GUIhelperPython::drawImage
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.
Definition: PythonModule.C:305
jevois::InputFramePython::get2
const RawImage & get2() const
Get the next captured camera image, ISP-scaled second frame.
Definition: PythonModule.C:53
jevois::GUIhelperPython::i2ds1
ImVec2 i2ds1(float x, float y, char const *name=nullptr)
Convert a 2D size from within a rendered image to on-screen.
Definition: PythonModule.C:366
jevois::GUIhelperPython::drawPoly2
void drawPoly2(cv::Mat const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw polygon over an image.
Definition: PythonModule.C:401
jevois::PythonModule::supportedCommands
virtual void supportedCommands(std::ostream &os) override
Human-readable description of this Module's supported custom commands.
Definition: PythonModule.C:604
jevois::InputFramePython::getp1
const RawImage & getp1(bool casync) const
Get the next captured camera image that is intended for processing.
Definition: PythonModule.C:59
jevois::GUIhelperPython::i2d1
ImVec2 i2d1(float x, float y, char const *name=nullptr)
Convert coordinates of a point from within a rendered image to on-screen.
Definition: PythonModule.C:352
jevois::OutputFramePython::sendScaledCvGRAY1
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.
Definition: PythonModule.C:233
jevois::PythonModule::PythonModule
PythonModule(VideoMapping const &m)
Constructor needs the full path to a Python source code file.
Definition: PythonModule.C:508
jevois::OutputFramePython::sendScaledCvRGBA
void sendScaledCvRGBA(cv::Mat const &img) const
Shorthand to send a RGBA cv::Mat after scaling/converting it to the current output format.
Definition: PythonModule.C:275
jevois::OutputFramePython
Wrapper around OutputFrame to be used by Python.
Definition: PythonModule.H:129
VideoMapping.H
jevois::Module
Virtual base class for a vision processing module.
Definition: Module.H:104
jevois::InputFramePython::hasScaledImage
bool hasScaledImage() const
Check whether a second input image scaled by the JeVoisPro Platform ISP is available.
Definition: PythonModule.C:41
jevois::GUIhelperPython::i2ds
ImVec2 i2ds(ImVec2 p, char const *name=nullptr)
Convert a 2D size from within a rendered image to on-screen.
Definition: PythonModule.C:359
jevois::OutputFramePython::sendScaledCvRGB
void sendScaledCvRGB(cv::Mat const &img) const
Shorthand to send a RGB cv::Mat after scaling/converting it to the current output format.
Definition: PythonModule.C:263
jevois::OutputFramePython::sendCvRGB
void sendCvRGB(cv::Mat const &img) const
Shorthand to send a RGB cv::Mat after converting it to the current output format.
Definition: PythonModule.C:215
jevois::GUIhelperPython::drawRect
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.
Definition: PythonModule.C:380
jevois::OutputFramePython::sendScaledCvBGR1
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.
Definition: PythonModule.C:245
jevois::InputFrame
Exception-safe wrapper around a raw camera input frame.
Definition: InputFrame.H:50
jevois::GUIhelperPython::releaseImage
void releaseImage(char const *name)
Release an image.
Definition: PythonModule.C:453
jevois::OutputFramePython::sendCvRGBA1
void sendCvRGBA1(cv::Mat const &img, int quality) const
Shorthand to send a RGBA cv::Mat after converting it to the current output format.
Definition: PythonModule.C:221
jevois::OutputFramePython::OutputFramePython
OutputFramePython()=default
Default constructor to keep boost::python happy, object is not operational.
jevois::OutputFramePython::sendCvBGR
void sendCvBGR(cv::Mat const &img) const
Shorthand to send a BGR cv::Mat after converting it to the current output format.
Definition: PythonModule.C:203
jevois::InputFramePython::done2
void done2() const
Indicate that user processing is done with the ISP-scaled image previously obtained via get2()
Definition: PythonModule.C:77
jevois::InputFramePython::getCvRGB
cv::Mat getCvRGB() const
Shorthand to get the input image as a RGB cv::Mat and release the raw buffer.
Definition: PythonModule.C:113
jevois::InputFramePython::get21
const RawImage & get21(bool casync) const
Get the next captured camera image, ISP-scaled second frame.
Definition: PythonModule.C:47
jevois::InputFramePython::InputFramePython
InputFramePython()=default
Default constructor to keep boost::python happy, object is not operational.
jevois::InputFramePython::getCvBGR1
cv::Mat getCvBGR1(bool casync) const
Shorthand to get the input image as a BGR cv::Mat and release the raw buffer.
Definition: PythonModule.C:95
jevois::GUIhelperPython::drawLine
void drawLine(float x1, float y1, float x2, float y2, ImU32 col=IM_COL32(128, 255, 128, 255))
Draw line over an image.
Definition: PythonModule.C:373
jevois::GUIhelperPython::drawInputFrame
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.
Definition: PythonModule.C:325
jevois::InputFramePython::getCvBGR
cv::Mat getCvBGR() const
Shorthand to get the input image as a BGR cv::Mat and release the raw buffer.
Definition: PythonModule.C:101
jevois::GUIhelperPython::i2d
ImVec2 i2d(ImVec2 p, char const *name=nullptr)
Convert coordinates of a point from within a rendered image to on-screen.
Definition: PythonModule.C:345
jevois::GUIhelperPython::drawCircle
void drawCircle(float x, float y, float r, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw circle over an image.
Definition: PythonModule.C:417
jevois::GUIhelperPython::drawInputFrame2
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.
Definition: PythonModule.C:335
jevois::PythonModule::parseSerial
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.
Definition: PythonModule.C:592
jevois::OutputFramePython::sendCv
void sendCv(cv::Mat const &img) const
Shorthand to send a cv::Mat after scaling/converting it to the current output format.
Definition: PythonModule.C:179
jevois::InputFramePython::getCvGRAY1
cv::Mat getCvGRAY1(bool casync) const
Shorthand to get the input image as a GRAY cv::Mat and release the raw buffer.
Definition: PythonModule.C:83
jevois::GUIhelperPython::reportAndRethrowException
void reportAndRethrowException(std::string const &prefix="")
Report current exception in a modal dialog, then re-throw it.
Definition: PythonModule.C:488
GUIhelper.H
jevois::GUIhelperPython::reportError
void reportError(std::string const &err)
Report an error in an overlay window.
Definition: PythonModule.C:474
jevois::OutputFramePython::sendCvGRAY
void sendCvGRAY(cv::Mat const &img) const
Shorthand to send a GRAY cv::Mat after converting it to the current output format.
Definition: PythonModule.C:191
jevois::OutputFramePython::sendScaledCvBGR
void sendScaledCvBGR(cv::Mat const &img) const
Shorthand to send a BGR cv::Mat after scaling/converting it to the current output format.
Definition: PythonModule.C:251
jevois::OutputFramePython::sendCvBGR1
void sendCvBGR1(cv::Mat const &img, int quality) const
Shorthand to send a BGR cv::Mat after converting it to the current output format.
Definition: PythonModule.C:197
jevois::InputFramePython
Wrapper around InputFrame to be used by Python.
Definition: PythonModule.H:46