JeVois  1.20
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
PythonSupport.C
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 #include <boost/python.hpp>
19 
21 #include <jevois/Core/Engine.H>
22 #include <jevois/Image/RawImage.H>
28 #include <jevois/Core/Serial.H>
29 #include <jevois/Util/Utils.H>
31 #include <jevois/Debug/Log.H>
32 #include <jevois/Debug/Timer.H>
33 #include <jevois/Debug/Profiler.H>
34 #include <jevois/Debug/SysInfo.H>
35 #include <jevois/Core/Camera.H>
36 #include <jevois/Core/IMU.H>
39 #include <jevois/DNN/Utils.H>
40 
41 #define PY_ARRAY_UNIQUE_SYMBOL pbcvt_ARRAY_API
43 
44 // ####################################################################################################
45 // Convenience macro to define a Python binding for a free function in the jevois namespace
46 #define JEVOIS_PYTHON_FUNC(funcname) \
47  boost::python::def(#funcname, jevois::funcname)
48 
49 // Convenience macro to define a Python binding for a free function in the jevois::rawimage namespace
50 #define JEVOIS_PYTHON_RAWIMAGE_FUNC(funcname) \
51  boost::python::def(#funcname, jevois::rawimage::funcname)
52 
53 // Convenience macro to define a python enum value where the value is in jevois::rawimage
54 #define JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(val) value(#val, jevois::rawimage::val)
55 
56 // Convenience macro to define a python enum value where the value is in jevois::python
57 #define JEVOIS_PYTHON_ENUM_VAL(val) value(#val, jevois::python::val)
58 
59 // Convenience macro to define a constant that exists in the global C++ namespace
60 #define JEVOIS_PYTHON_CONSTANT(cst) boost::python::scope().attr(#cst) = cst;
61 
62 // Convenience macro to define a Python binding for a free function in the jevois:dnn namespace
63 #define JEVOIS_PYTHON_DNN_FUNC(funcname) \
64  boost::python::def(#funcname, jevois::dnn::funcname)
65 
66 // ####################################################################################################
67 // Helper to provide jevois.sendSerial() function that emulates a C++ module's sendSerial()
68 namespace jevois
69 {
70  namespace python
71  {
73  }
74 }
75 
76 namespace
77 {
78  void * init_numpy()
79  {
80  // Initialize Python:
81  Py_SetProgramName(Py_DecodeLocale("", nullptr)); // black magic
82  Py_Initialize();
83 
84  // Initialize numpy array. Use the signal handler hack to prevent numpy from grabbing CTRL-C from
85  // https://stackoverflow.com/questions/28750774/
86  // python-import-array-makes-it-impossible-to-kill-embedded-python-with-ctrl-c
87  //PyOS_sighandler_t sighandler = PyOS_getsig(SIGINT);
88  import_array();
89  //PyOS_setsig(SIGINT,sighandler);
90  return nullptr; // was NUMPY_IMPORT_ARRAY_RETVAL in older numpy
91  }
92 }
93 
95 {
97  init_numpy();
98 }
99 
100 jevois::Engine * jevois::python::engine()
101 {
102  if (jevois::python::engineForPythonModule == nullptr) LFATAL("Internal error");
104 }
105 
106 // ####################################################################################################
107 // from https://stackoverflow.com/questions/39924912/finding-if-member-function-exists-in-a-boost-pythonobject
108 bool jevois::python::hasattr(boost::python::object & o, char const * name)
109 {
110  return PyObject_HasAttrString(o.ptr(), name);
111 }
112 
113 // ####################################################################################################
114 // Thin wrappers to handle default arguments or overloads in free functions
115 
116 namespace
117 {
118  void pythonSendSerial(std::string const & str)
119  { jevois::python::engine()->sendSerial(str); }
120 
121  size_t pythonFrameNum()
122  { return jevois::frameNum(); }
123 
124  void pythonWriteCamRegister(unsigned short reg, unsigned short val)
125  {
126  auto cam = jevois::python::engine()->camera();
127  if (!cam) LFATAL("Not using a Camera for video input");
128  cam->writeRegister(reg, val);
129  }
130 
131  unsigned short pythonReadCamRegister(unsigned short reg)
132  {
133  auto cam = jevois::python::engine()->camera();
134  if (!cam) LFATAL("Not using a Camera for video input");
135  return cam->readRegister(reg);
136  }
137 
138  void pythonWriteIMUregister(unsigned short reg, unsigned short val)
139  {
140  auto imu = jevois::python::engine()->imu();
141  if (!imu) LFATAL("No IMU driver loaded");
142  imu->writeRegister(reg, val);
143  }
144 
145  unsigned short pythonReadIMUregister(unsigned short reg)
146  {
147  auto imu = jevois::python::engine()->imu();
148  if (!imu) LFATAL("No IMU driver loaded");
149  return imu->readRegister(reg);
150  }
151 
152  void pythonWriteDMPregister(unsigned short reg, unsigned short val)
153  {
154  auto imu = jevois::python::engine()->imu();
155  if (!imu) LFATAL("No IMU driver loaded");
156  imu->writeDMPregister(reg, val);
157  }
158 
159  unsigned short pythonReadDMPregister(unsigned short reg)
160  {
161  auto imu = jevois::python::engine()->imu();
162  if (!imu) LFATAL("No IMU driver loaded");
163  return imu->readDMPregister(reg);
164  }
165 
166 #ifdef JEVOIS_LDEBUG_ENABLE
167  void pythonLDEBUG(std::string const & logmsg) { LDEBUG(logmsg); }
168 #else
169  void pythonLDEBUG(std::string const & JEVOIS_UNUSED_PARAM(logmsg)) { }
170 #endif
171  void pythonLINFO(std::string const & logmsg) { LINFO(logmsg); }
172  void pythonLERROR(std::string const & logmsg) { LERROR(logmsg); }
173  void pythonLFATAL(std::string const & logmsg) { LFATAL(logmsg); }
174 
175 
176  // ####################################################################################################
177  // Python parameter access support
178  std::string pythonGetParamStringUnique(boost::python::object & pyinst, std::string const & descriptor)
179  {
180  jevois::Component * comp = jevois::python::engine()->getPythonComponent(pyinst.ptr()->ob_type);
181  return comp->getParamStringUnique(descriptor);
182  }
183 
184  void pythonSetParamStringUnique(boost::python::object & pyinst, std::string const & descriptor,
185  std::string const & val)
186  {
187  jevois::Component * comp = jevois::python::engine()->getPythonComponent(pyinst.ptr()->ob_type);
188  comp->setParamStringUnique(descriptor, val);
189  }
190 
191 } // anonymous namespace
192 
193 // ####################################################################################################
194 namespace jevois
195 {
196  namespace python
197  {
198  // Aux enum for YUYV colors - keep this in sync with RawImage.H:
199  enum YUYV { Black = 0x8000, DarkGrey = 0x8050, MedGrey = 0x8080, LightGrey = 0x80a0, White = 0x80ff,
200  DarkGreen = 0x0000, MedGreen = 0x0040, LightGreen = 0x00ff, DarkTeal = 0x7070, MedTeal = 0x7090,
201  LightTeal = 0x70b0, DarkPurple = 0xa030, MedPurple = 0xa050, LightPurple = 0xa080,
202  DarkPink = 0xff00, MedPink = 0xff80, LightPink = 0xffff };
203  }
204 }
205 
206 // ####################################################################################################
207 #ifdef JEVOIS_PRO
208 BOOST_PYTHON_MODULE(libjevoispro)
209 #else
210 BOOST_PYTHON_MODULE(libjevois)
211 #endif
212 {
213  // #################### Initialize converters for cv::Mat support:
214  boost::python::to_python_converter<cv::Mat, pbcvt::matToNDArrayBoostConverter>();
216 
217  // #################### Define a few constants for python users:
218  // jevois.pro is True if running on JeVois-Pro
219 #ifdef JEVOIS_PRO
220  boost::python::scope().attr("pro") = true;
221 #else
222  boost::python::scope().attr("pro") = false;
223 #endif
224 
225  // jevois.platform is True if running on platform hardware
226 #ifdef JEVOIS_PLATFORM
227  boost::python::scope().attr("platform") = true;
228 #else
229  boost::python::scope().attr("platform") = false;
230 #endif
231 
232  // Jevois software version:
233  boost::python::scope().attr("version_major") = JEVOIS_VERSION_MAJOR;
234  boost::python::scope().attr("version_minor") = JEVOIS_VERSION_MINOR;
235  boost::python::scope().attr("version_patch") = JEVOIS_VERSION_PATCH;
236 
237  // Location of shared directories: jevois.share points to /jevois/share or /jevoispro/share
238  boost::python::scope().attr("share") = JEVOIS_SHARE_PATH;
239  boost::python::scope().attr("pydnn") = JEVOIS_PYDNN_PATH;
240 
241  // #################### module sendSerial() and other functions emulation:
242  boost::python::def("sendSerial", pythonSendSerial);
243  boost::python::def("frameNum", pythonFrameNum);
244  boost::python::def("writeCamRegister", pythonWriteCamRegister);
245  boost::python::def("readCamRegister", pythonReadCamRegister);
246  boost::python::def("writeIMUregister", pythonWriteIMUregister);
247  boost::python::def("readIMUregister", pythonReadIMUregister);
248  boost::python::def("writeDMPregister", pythonWriteDMPregister);
249  boost::python::def("readDMPregister", pythonReadDMPregister);
250 
251  // #################### Log.H
252  JEVOIS_PYTHON_CONSTANT(LOG_DEBUG);
253  JEVOIS_PYTHON_CONSTANT(LOG_INFO);
254  JEVOIS_PYTHON_CONSTANT(LOG_ERR);
255  JEVOIS_PYTHON_CONSTANT(LOG_CRIT);
256 
257  boost::python::def("LDEBUG", pythonLDEBUG);
258  boost::python::def("LINFO", pythonLINFO);
259  boost::python::def("LERROR", pythonLERROR);
260  boost::python::def("LFATAL", pythonLFATAL);
261 
262  // #################### Utils.H
273 
274  // #################### Coordinates.H
275  void (*imgToStd1)(float & x, float & y, jevois::RawImage const & camimg, float const eps) = jevois::coords::imgToStd;
276  void (*imgToStd2)(float & x, float & y, unsigned int const width, unsigned int const height, float const eps) =
278  boost::python::def("imgToStd", imgToStd1);
279  boost::python::def("imgToStd", imgToStd2);
280 
281  void (*stdToImg1)(float & x, float & y, jevois::RawImage const & camimg, float const eps) = jevois::coords::stdToImg;
282  void (*stdToImg2)(float & x, float & y, unsigned int const width, unsigned int const height, float const eps) =
284  boost::python::def("stdToImg", stdToImg1);
285  boost::python::def("stdToImg", stdToImg2);
286 
287  boost::python::def("imgToStdX", jevois::coords::imgToStdX);
288  boost::python::def("imgToStdY", jevois::coords::imgToStdY);
289  boost::python::def("imgToStdSize", jevois::coords::imgToStdSize);
290  boost::python::def("stdToImgSize", jevois::coords::stdToImgSize);
291 
292  // #################### RawImage.H
293  boost::python::class_<jevois::RawImage>("RawImage") // default constructor is included
294  .def("invalidate", &jevois::RawImage::invalidate)
295  .def("valid", &jevois::RawImage::valid)
296  .def("clear", &jevois::RawImage::clear)
297  .def("require", &jevois::RawImage::require)
298  .def_readwrite("width", &jevois::RawImage::width)
299  .def_readwrite("height", &jevois::RawImage::height)
300  .def_readwrite("fmt", &jevois::RawImage::fmt)
301  .def_readwrite("fps", &jevois::RawImage::fps)
302  .def("bytesperpix", &jevois::RawImage::bytesperpix)
303  .def("bytesize", &jevois::RawImage::bytesize)
304  .def("coordsOk", &jevois::RawImage::coordsOk)
305  //.def("pixels", &jevois::RawImage::pixelsw<unsigned char>,
306  // boost::python::return_value_policy<boost::python::reference_existing_object>())
307  ;
308 
309  boost::python::enum_<jevois::python::YUYV>("YUYV")
310  .JEVOIS_PYTHON_ENUM_VAL(Black)
311  .JEVOIS_PYTHON_ENUM_VAL(DarkGrey)
312  .JEVOIS_PYTHON_ENUM_VAL(MedGrey)
313  .JEVOIS_PYTHON_ENUM_VAL(LightGrey)
314  .JEVOIS_PYTHON_ENUM_VAL(White)
315  .JEVOIS_PYTHON_ENUM_VAL(DarkGreen)
316  .JEVOIS_PYTHON_ENUM_VAL(MedGreen)
317  .JEVOIS_PYTHON_ENUM_VAL(LightGreen)
318  .JEVOIS_PYTHON_ENUM_VAL(DarkTeal)
319  .JEVOIS_PYTHON_ENUM_VAL(MedTeal)
320  .JEVOIS_PYTHON_ENUM_VAL(LightTeal)
321  .JEVOIS_PYTHON_ENUM_VAL(DarkPurple)
322  .JEVOIS_PYTHON_ENUM_VAL(MedPurple)
323  .JEVOIS_PYTHON_ENUM_VAL(LightPurple)
324  .JEVOIS_PYTHON_ENUM_VAL(DarkPink)
325  .JEVOIS_PYTHON_ENUM_VAL(MedPink)
326  .JEVOIS_PYTHON_ENUM_VAL(LightPink)
327  ;
328 
329  JEVOIS_PYTHON_CONSTANT(V4L2_PIX_FMT_SRGGB8);
330  JEVOIS_PYTHON_CONSTANT(V4L2_PIX_FMT_YUYV);
331  JEVOIS_PYTHON_CONSTANT(V4L2_PIX_FMT_GREY);
332  JEVOIS_PYTHON_CONSTANT(V4L2_PIX_FMT_RGB565);
333  JEVOIS_PYTHON_CONSTANT(V4L2_PIX_FMT_MJPEG);
334  JEVOIS_PYTHON_CONSTANT(V4L2_PIX_FMT_BGR24);
335 
336  // #################### PythonModule.H
337  boost::python::class_<jevois::InputFramePython>("InputFrame")
338  .def("get", &jevois::InputFramePython::get1,
339  boost::python::return_value_policy<boost::python::reference_existing_object>())
340  .def("get", &jevois::InputFramePython::get,
341  boost::python::return_value_policy<boost::python::reference_existing_object>())
342  .def("hasScaledImage", &jevois::InputFramePython::hasScaledImage)
343  .def("get2", &jevois::InputFramePython::get21,
344  boost::python::return_value_policy<boost::python::reference_existing_object>())
345  .def("get2", &jevois::InputFramePython::get2,
346  boost::python::return_value_policy<boost::python::reference_existing_object>())
347  .def("getp", &jevois::InputFramePython::getp1,
348  boost::python::return_value_policy<boost::python::reference_existing_object>())
349  .def("getp", &jevois::InputFramePython::getp,
350  boost::python::return_value_policy<boost::python::reference_existing_object>())
351  .def("done", &jevois::InputFramePython::done)
352  .def("done2", &jevois::InputFramePython::done2)
353  .def("getCvGRAY", &jevois::InputFramePython::getCvGRAY1)
354  .def("getCvGRAY", &jevois::InputFramePython::getCvGRAY)
355  .def("getCvBGR", &jevois::InputFramePython::getCvBGR1)
356  .def("getCvBGR", &jevois::InputFramePython::getCvBGR)
357  .def("getCvRGB", &jevois::InputFramePython::getCvRGB1)
358  .def("getCvRGB", &jevois::InputFramePython::getCvRGB)
359  .def("getCvRGBA", &jevois::InputFramePython::getCvRGBA1)
360  .def("getCvRGBA", &jevois::InputFramePython::getCvRGBA)
361 
362  .def("getCvGRAYp", &jevois::InputFramePython::getCvGRAYp)
363  .def("getCvBGRp", &jevois::InputFramePython::getCvBGRp)
364  .def("getCvRGBp", &jevois::InputFramePython::getCvRGBp)
365  .def("getCvRGBAp", &jevois::InputFramePython::getCvRGBAp)
366  ;
367 
368  boost::python::class_<jevois::OutputFramePython>("OutputFrame")
369  .def("get", &jevois::OutputFramePython::get,
370  boost::python::return_value_policy<boost::python::reference_existing_object>())
371  .def("send", &jevois::OutputFramePython::send)
372 
373  .def("sendCv", &jevois::OutputFramePython::sendCv1)
374  .def("sendCv", &jevois::OutputFramePython::sendCv)
375 
376  .def("sendCvGRAY", &jevois::OutputFramePython::sendCvGRAY1)
377  .def("sendCvGRAY", &jevois::OutputFramePython::sendCvGRAY)
378  .def("sendCvBGR", &jevois::OutputFramePython::sendCvBGR1)
379  .def("sendCvBGR", &jevois::OutputFramePython::sendCvBGR)
380  .def("sendCvRGB", &jevois::OutputFramePython::sendCvRGB1)
381  .def("sendCvRGB", &jevois::OutputFramePython::sendCvRGB)
382  .def("sendCvRGBA", &jevois::OutputFramePython::sendCvRGBA1)
383  .def("sendCvRGBA", &jevois::OutputFramePython::sendCvRGBA)
384 
385  .def("sendScaledCvGRAY", &jevois::OutputFramePython::sendScaledCvGRAY1)
386  .def("sendScaledCvGRAY", &jevois::OutputFramePython::sendScaledCvGRAY)
387  .def("sendScaledCvBGR", &jevois::OutputFramePython::sendScaledCvBGR1)
388  .def("sendScaledCvBGR", &jevois::OutputFramePython::sendScaledCvBGR)
389  .def("sendScaledCvRGB", &jevois::OutputFramePython::sendScaledCvRGB1)
390  .def("sendScaledCvRGB", &jevois::OutputFramePython::sendScaledCvRGB)
391  .def("sendScaledCvRGBA", &jevois::OutputFramePython::sendScaledCvRGBA1)
392  .def("sendScaledCvRGBA", &jevois::OutputFramePython::sendScaledCvRGBA)
393  ;
394 
395  // #################### RawImageOps.H
408 
409  void (*drawRect1)(jevois::RawImage & img, int x, int y, unsigned int w,
410  unsigned int h, unsigned int thick, unsigned int col) = jevois::rawimage::drawRect;
411  void (*drawRect2)(jevois::RawImage & img, int x, int y, unsigned int w, unsigned int h, unsigned int col) =
413  boost::python::def("drawRect", drawRect1);
414  boost::python::def("drawRect", drawRect2);
416 
417  boost::python::enum_<jevois::rawimage::Font>("Font")
418  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font5x7)
419  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font6x10)
420  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font7x13)
421  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font8x13bold)
422  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font9x15bold)
423  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font10x20)
424  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font11x22)
425  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font12x22)
426  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font14x26)
427  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font15x28)
428  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font16x29)
429  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font20x38);
430 
431  void (*writeText1)(jevois::RawImage & img, std::string const & txt, int x, int y,
432  unsigned int col, jevois::rawimage::Font font) = jevois::rawimage::writeText;
433  boost::python::def("writeText", writeText1);
434 
447  boost::python::def("rescaleCv", jevois::rescaleCv);
448 
449  // #################### Timer.H
450  std::string const & (jevois::Timer::*timer_stop)() = &jevois::Timer::stop; // select overload with no args
451  boost::python::class_<jevois::Timer>("Timer", boost::python::init<char const *, size_t, int>())
452  .def("start", &jevois::Timer::start)
453  .def("stop", timer_stop, boost::python::return_value_policy<boost::python::copy_const_reference>());
454 
455  // #################### Profiler.H
456  boost::python::class_<jevois::Profiler>("Profiler", boost::python::init<char const *, size_t, int>())
457  .def("start", &jevois::Profiler::start)
458  .def("checkpoint", &jevois::Profiler::checkpoint)
459  .def("stop", &jevois::Profiler::stop, boost::python::return_value_policy<boost::python::copy_const_reference>());
460 
461  // #################### SysInfo.H
470 
471 #ifdef JEVOIS_PRO
472  // #################### GUIhelper.H
473  boost::python::class_<ImVec2>("ImVec2", boost::python::init<float, float>())
474  .def_readwrite("x", &ImVec2::x)
475  .def_readwrite("y", &ImVec2::y);
476 
477  boost::python::class_<ImVec4>("ImVec4", boost::python::init<float, float, float, float>())
478  .def_readwrite("x", &ImVec4::x)
479  .def_readwrite("y", &ImVec4::y)
480  .def_readwrite("z", &ImVec4::z)
481  .def_readwrite("w", &ImVec4::w);
482 
483  boost::python::class_<ImColor>("ImColor", boost::python::init<int, int, int, int>())
484  .def(boost::python::init<float, float, float, float>())
485  .def(boost::python::init<ImU32>())
486  .def_readwrite("Value", &ImColor::Value);
487 
488  boost::python::class_<jevois::GUIhelperPython>("GUIhelper", boost::python::init<jevois::GUIhelper *>())
489  .def("startFrame", &jevois::GUIhelperPython::startFrame)
490  .def("frameStarted", &jevois::GUIhelperPython::frameStarted)
491  .def("drawImage", &jevois::GUIhelperPython::drawImage)
492  .def("drawImage", &jevois::GUIhelperPython::drawImage1)
493  .def("drawImage", &jevois::GUIhelperPython::drawImage2)
494  .def("drawImage", &jevois::GUIhelperPython::drawImage3)
495  .def("drawInputFrame", &jevois::GUIhelperPython::drawInputFrame)
496  .def("drawInputFrame2", &jevois::GUIhelperPython::drawInputFrame2)
497  .def("i2d", &jevois::GUIhelperPython::i2d)
498  .def("i2d", &jevois::GUIhelperPython::i2d1)
499  .def("i2ds", &jevois::GUIhelperPython::i2ds)
500  .def("i2ds", &jevois::GUIhelperPython::i2ds1)
501  .def("drawLine", &jevois::GUIhelperPython::drawLine)
502  .def("drawRect", &jevois::GUIhelperPython::drawRect)
503  .def("drawPoly", &jevois::GUIhelperPython::drawPoly)
504  .def("drawPoly", &jevois::GUIhelperPython::drawPoly1)
505  .def("drawPoly", &jevois::GUIhelperPython::drawPoly2)
506  .def("drawCircle", &jevois::GUIhelperPython::drawCircle)
507  .def("drawText", &jevois::GUIhelperPython::drawText)
508  .def("iline", &jevois::GUIhelperPython::iline)
509  .def("itext", &jevois::GUIhelperPython::itext)
510  .def("iinfo", &jevois::GUIhelperPython::iinfo)
511  .def("releaseImage", &jevois::GUIhelperPython::releaseImage)
512  .def("releaseImage2", &jevois::GUIhelperPython::releaseImage2)
513  .def("endFrame", &jevois::GUIhelperPython::endFrame)
514  .def("d2i", &jevois::GUIhelperPython::d2i)
515  .def("d2i", &jevois::GUIhelperPython::d2i1)
516  .def("d2is", &jevois::GUIhelperPython::d2is)
517  .def("d2is", &jevois::GUIhelperPython::d2is1)
518  .def("reportError", &jevois::GUIhelperPython::reportError)
519  .def("reportAndIgnoreException", &jevois::GUIhelperPython::reportAndIgnoreException)
520  .def("reportAndRethrowException", &jevois::GUIhelperPython::reportAndRethrowException)
521  .def("getMousePos", &jevois::GUIhelperPython::getMousePos)
522  .def("isMouseClicked", &jevois::GUIhelperPython::isMouseClicked)
523  .def("isMouseDoubleClicked", &jevois::GUIhelperPython::isMouseDoubleClicked)
524  .def("isMouseDragging", &jevois::GUIhelperPython::isMouseDragging)
525  .def("isMouseDown", &jevois::GUIhelperPython::isMouseDown)
526  .def("isMouseReleased", &jevois::GUIhelperPython::isMouseReleased)
527  ;
528 #endif
529 
530  // #################### ParameterDef.H
531  boost::python::class_<jevois::ParameterCategory>("ParameterCategory", boost::python::init<std::string, std::string>())
532  .def_readonly("name", &jevois::ParameterCategory::name)
533  .def_readonly("description", &jevois::ParameterCategory::description)
534  ;
535 
536  // #################### Parameter support:
537  boost::python::def("getParamStr", pythonGetParamStringUnique);
538  boost::python::def("setParamStr", pythonSetParamStringUnique);
539 
540  // #################### Dynamic parameter support:
541  boost::python::class_<jevois::PythonParameter>("Parameter", boost::python::init<boost::python::object &,
542  std::string const &, std::string const &, std::string const &,
543  boost::python::object const &, jevois::ParameterCategory const &>())
544  .def("name", &jevois::PythonParameter::name,
545  boost::python::return_value_policy<boost::python::reference_existing_object>())
546  .def("descriptor", &jevois::PythonParameter::descriptor)
547  .def("get", &jevois::PythonParameter::get)
548  .def("set", &jevois::PythonParameter::set)
549  .def("strget", &jevois::PythonParameter::strget)
550  .def("strset", &jevois::PythonParameter::strset)
551  .def("freeze", &jevois::PythonParameter::freeze)
552  .def("reset", &jevois::PythonParameter::reset)
553  .def("setCallback", &jevois::PythonParameter::setCallback)
554  ;
555 
556  // #################### Allow python code to access dnn::PreProcessor helper functions:
557  // python cannot construct PreProcessor, but PostProcessorPython can use an existing one.
558  boost::python::class_<jevois::dnn::PreProcessorForPython>("PreProcessor", boost::python::no_init)
563  .def("getUnscaledCropRect", &jevois::dnn::PreProcessorForPython::getUnscaledCropRect)
565  ;
566 
567  // #################### Allow python code to use PostProcessorDetectYOLOforPython
568  boost::python::class_<jevois::dnn::PostProcessorDetectYOLOforPython>("PyPostYOLO")
571  ;
572 
573  // #################### DNN/Utils.H:
575  std::string (*shapestr1)(cv::Mat const & m) = jevois::dnn::shapestr;
576  boost::python::def("shapestr", shapestr1);
577 
578 }
jevois::getFanSpeed
int getFanSpeed()
Get fan speed in percent, only meaningful on JeVois-Pro Platform, all others return 0.
Definition: SysInfo.C:153
jevois::rawimage::convertBayerToYUYV
void convertBayerToYUYV(RawImage const &src, RawImage &dst)
Convert from Bayer to YUYV, only used internally by Camera class.
Definition: RawImageOps.C:1593
jevois::rawimage::Font15x28
@ Font15x28
Definition: RawImageOps.H:163
jevois::whiteColor
unsigned int whiteColor(unsigned int fcc)
Return a value that corresponds to white for the given video format.
Definition: Utils.C:197
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:244
jevois::rawimage::drawDisk
void drawDisk(RawImage &img, int x, int y, unsigned int rad, unsigned int col)
Draw a disk in a YUYV image.
Definition: RawImageOps.C:465
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:112
jevois::rawimage::convertCvRGBAtoCvYUYV
void convertCvRGBAtoCvYUYV(cv::Mat const &src, cv::Mat &dst)
OpenCV does not provide conversion from RGBA to YUYV in cvtColor(), so this function provides it.
Definition: RawImageOps.C:1256
jevois::rawimage::Font20x38
@ Font20x38
Definition: RawImageOps.H:165
jevois::coords::imgToStdY
void imgToStdY(float &y, unsigned int const height, float const eps=0.1F)
Transform Y coordinate in-place from camera to standardized, using given image width and height.
Definition: Coordinates.C:43
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:94
jevois::rawimage::Font9x15bold
@ Font9x15bold
Definition: RawImageOps.H:158
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:510
jevois::python::LightGreen
@ LightGreen
Definition: PythonSupport.C:200
jevois::RawImage::bytesperpix
unsigned int bytesperpix() const
Helper function to get the number of bytes/pixel given the RawImage pixel format.
Definition: RawImage.C:34
jevois::RawImage::clear
void clear()
Clear the pixels to all black.
Definition: RawImage.C:50
jevois::rawimage::convertCvRGBtoCvYUYV
void convertCvRGBtoCvYUYV(cv::Mat const &src, cv::Mat &dst)
OpenCV does not provide conversion from RGB to YUYV in cvtColor(), so this function provides it.
Definition: RawImageOps.C:1112
PythonSupport.H
jevois::coords::stdToImgSize
void stdToImgSize(float &x, float &y, unsigned int const width, unsigned int const height, float const eps=0.1F)
Transform size in-place from standardized to image, using a RawImage to establish image size.
Definition: Coordinates.C:74
Coordinates.H
LDEBUG
#define LDEBUG(msg)
Convenience macro for users to print out console or syslog messages, DEBUG level.
Definition: Log.H:173
stdToImg1
void(* stdToImg1)(float &x, float &y, jevois::RawImage const &camimg, float const eps)
Definition: PythonSupport.C:281
pbcvt::matFromNDArrayBoostConverter
Converter from Python numpy NDarray to cv::Mat.
Definition: PythonOpenCV.H:107
jevois::InputFramePython::get
const RawImage & get() const
Get the next captured camera image, thin wrapper for default arg value.
Definition: PythonModule.C:40
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:178
RawImageOps.H
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:320
jevois::rescaleCv
cv::Mat rescaleCv(cv::Mat const &img, cv::Size const &newdims)
Rescale an OpenCV image, choosing the right kind of interpolation.
Definition: RawImageOps.C:1624
jevois::rawimage::convertCvRGBtoRawImage
void convertCvRGBtoRawImage(cv::Mat const &src, RawImage &dst, int quality)
Convert a RGB cv::Mat to RawImage with already-allocated pixels and pixel type.
Definition: RawImageOps.C:1289
jevois::GUIhelperPython::isMouseReleased
bool isMouseReleased(int button_num)
ImGui helper: check if mouse button released.
Definition: PythonModule.C:580
jevois::python::MedPurple
@ MedPurple
Definition: PythonSupport.C:201
jevois::ParameterCategory::description
std::string description
An optional short description of the category.
Definition: ParameterDef.H:39
jevois::cvBytesPerPix
unsigned int cvBytesPerPix(unsigned int cvtype)
Return the number of bytes per pixel for a given OpenCV pixel type.
Definition: Utils.C:89
jevois::PythonParameter::strget
const std::string strget() const
Get the value as a string.
Definition: PythonParameter.C:142
jevois::PythonParameter::set
void set(boost::python::object const &newVal)
Set the value of this Parameter.
Definition: PythonParameter.C:138
jevois::rawimage::Font14x26
@ Font14x26
Definition: RawImageOps.H:162
jevois::flushcache
void flushcache()
Flush the caches, may sometimes be useful when running the camera in turbo mode.
Definition: Utils.C:449
jevois::python::MedGreen
@ MedGreen
Definition: PythonSupport.C:200
jevois::OutputFramePython::get
const RawImage & get() const
Get the next captured camera image.
Definition: PythonModule.C:166
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:444
jevois::getSysInfoMem
std::string getSysInfoMem()
Get memory info.
Definition: SysInfo.C:66
jevois::Profiler::checkpoint
void checkpoint(char const *description)
Note the time for a particular event.
Definition: Profiler.C:39
jevois::cvtypestr
std::string cvtypestr(unsigned int cvtype)
Convert cv::Mat::type() code to to a string (e.g., CV_8UC1, CV_32SC3, etc)
Definition: Utils.C:58
jevois::python::DarkGrey
@ DarkGrey
Definition: PythonSupport.C:199
jevois::InputFramePython::get1
const RawImage & get1(bool casync) const
Get the next captured camera image, thin wrapper for default arg value.
Definition: PythonModule.C:34
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:136
jevois::PythonParameter::name
const std::string & name() const
Get the parameter name.
Definition: PythonParameter.C:126
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:503
jevois::GUIhelperPython::drawImage3
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.
Definition: PythonModule.C:342
RawImage.H
jevois::Component
A component of a model hierarchy.
Definition: Component.H:181
jevois::PythonParameter::freeze
void freeze(bool doit)
Freeze/unfreeze this parameter, it becomes read-only and will not show up in the help message.
Definition: PythonParameter.C:150
jevois::OutputFramePython::send
void send() const
Indicate that user processing is done with the image previously obtained via get()
Definition: PythonModule.C:172
Utils.H
jevois::InputFramePython::getp
const RawImage & getp() const
Get the next captured camera image that is intended for processing.
Definition: PythonModule.C:70
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::convertToCvRGB
cv::Mat convertToCvRGB(RawImage const &src)
Convert RawImage to OpenCV doing color conversion from any RawImage source pixel to OpenCV RGB byte.
Definition: RawImageOps.C:307
StdioInterface.H
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:496
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:148
jevois::rawimage::Font
Font
Available fonts for writeText()
Definition: RawImageOps.H:152
stdToImg2
void(* stdToImg2)(float &x, float &y, unsigned int const width, unsigned int const height, float const eps)
Definition: PythonSupport.C:282
ParameterStringConversion.H
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::coords::imgToStdSize
void imgToStdSize(float &w, float &h, unsigned int const width, unsigned int const height, float const eps=0.1F)
Transform size in-place from camera to standardized, using given image width and height.
Definition: Coordinates.C:50
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:274
jevois::dnn::stringToRGBA
int stringToRGBA(std::string const &label, unsigned char alpha=128)
Compute a color from a label name.
Definition: Utils.C:75
jevois::rawimage::drawCircle
void drawCircle(RawImage &img, int x, int y, unsigned int rad, unsigned int thick, unsigned int col)
Draw a circle in a YUYV image.
Definition: RawImageOps.C:483
jevois::InputFramePython::done
void done() const
Indicate that user processing is done with the image previously obtained via get()
Definition: PythonModule.C:76
jevois::Timer::start
void start()
Start a time measurement period.
Definition: Timer.C:40
jevois::Component::getParamStringUnique
std::string getParamStringUnique(std::string const &paramdescriptor) const
Get a parameter value by string, simple version assuming only one parameter match.
Definition: Component.C:405
o
#define o
Definition: Font10x20.C:6
UserInterface.H
jevois::blackColor
unsigned int blackColor(unsigned int fcc)
Return a value that corresponds to black for the given video format.
Definition: Utils.C:172
jevois::GUIhelperPython::isMouseDown
bool isMouseDown(int button_num)
ImGui helper: check if mouse button pressed.
Definition: PythonModule.C:576
jevois::rawimage::convertToCvBGR
cv::Mat convertToCvBGR(RawImage const &src)
Convert RawImage to OpenCV doing color conversion from any RawImage source pixel to OpenCV BGR byte.
Definition: RawImageOps.C:282
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:451
jevois::rawimage::Font6x10
@ Font6x10
Definition: RawImageOps.H:155
jevois::ParameterCategory
A category to which multiple ParameterDef definitions can belong.
Definition: ParameterDef.H:33
jevois::RawImage::fps
float fps
Programmed frames/s as given by current video mapping, may not be actual.
Definition: RawImage.H:148
jevois::python::LightGrey
@ LightGrey
Definition: PythonSupport.C:199
PythonParameter.H
jevois::RawImage::valid
bool valid() const
Check whether the image has a valid pixel buffer.
Definition: RawImage.C:46
jevois::GUIhelperPython::frameStarted
bool frameStarted() const
Helper to indicate that startFrame() was called, and thus endFrame() should be called.
Definition: PythonModule.C:303
jevois::GUIhelperPython::endFrame
void endFrame()
Finish current frame and render it.
Definition: PythonModule.C:532
LERROR
#define LERROR(msg)
Convenience macro for users to print out console or syslog messages, ERROR level.
Definition: Log.H:211
jevois::rawimage::convertToCvGray
cv::Mat convertToCvGray(RawImage const &src)
Convert RawImage to OpenCV doing color conversion from any RawImage source pixel to OpenCV gray byte.
Definition: RawImageOps.C:246
jevois::RawImage::invalidate
void invalidate()
Invalidate the image by zero'ing out the pointer to pixel buffer and the dims and format.
Definition: RawImage.C:42
jevois::coords::imgToStdX
void imgToStdX(float &x, unsigned int const width, float const eps=0.1F)
Transform X coordinate in-place from camera to standardized, using given image width and height.
Definition: Coordinates.C:36
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::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:262
jevois::python::MedGrey
@ MedGrey
Definition: PythonSupport.C:199
jevois::dnn::PreProcessorForPython::imagesize
boost::python::tuple imagesize() const
Access the last processed image size.
Definition: PythonModule.C:670
jevois::PythonParameter::strset
void strset(std::string const &valstring)
Set the value from a string representation of it.
Definition: PythonParameter.C:146
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:489
jevois::python::LightPink
@ LightPink
Definition: PythonSupport.C:202
jevois::getSysInfoVersion
std::string getSysInfoVersion()
Get O.S. version info.
Definition: SysInfo.C:74
jevois::GUIhelperPython::isMouseDragging
bool isMouseDragging(int button_num)
ImGui helper: check if mouse button dragged.
Definition: PythonModule.C:572
PreProcessorPython.H
jevois::GUIhelperPython::d2i1
ImVec2 d2i1(float x, float y, char const *name=nullptr)
Convert coordinates of a point from on-screen to within a rendered image.
Definition: PythonModule.C:409
jevois::python::DarkTeal
@ DarkTeal
Definition: PythonSupport.C:200
jevois::rawimage::roipaste
void roipaste(RawImage const &src, int x, int y, unsigned int w, unsigned int h, RawImage &dest, int dx, int dy)
Paste an ROI from an image to within another of same pixel type.
Definition: RawImageOps.C:425
jevois::RawImage::width
unsigned int width
Image width in pixels.
Definition: RawImage.H:145
jevois::Timer::stop
const std::string & stop()
Same as the other signature of stop() except does not provide seconds, for python bindings.
Definition: Timer.C:140
jevois::python::LightPurple
@ LightPurple
Definition: PythonSupport.C:201
jevois::dnn::PostProcessorDetectYOLOforPython::freeze
void freeze(bool doit)
Freeze/unfreeze parameters that users should not change while running.
Definition: PythonModule.C:729
jevois::dnn::shapestr
std::string shapestr(cv::Mat const &m)
Get a string of the form: "nD AxBxC... TYPE" from an n-dimensional cv::Mat with data type TYPE.
Definition: Utils.C:104
jevois::GUIhelperPython::releaseImage2
void releaseImage2(char const *name)
Release an image, second video stream.
Definition: PythonModule.C:525
jevois::rawimage::writeText
void writeText(RawImage &img, std::string const &txt, int x, int y, unsigned int col, Font font=Font6x10)
Write some text in an image.
Definition: RawImageOps.C:689
jevois::rawimage::convertCvGRAYtoRawImage
void convertCvGRAYtoRawImage(cv::Mat const &src, RawImage &dst, int quality)
Convert a Gray cv::Mat to RawImage with already-allocated pixels and pixel type.
Definition: RawImageOps.C:1359
jevois
Definition: Concepts.dox:1
jevois::getNumInstalledNPUs
size_t getNumInstalledNPUs()
Get the number of JeVois-Pro NPUs present on this system.
Definition: SysInfo.C:127
jevois::getSysInfoCPU
std::string getSysInfoCPU()
Get CPU info: frequency, thermal, load.
Definition: SysInfo.C:24
jevois::GUIhelperPython::d2is1
ImVec2 d2is1(float x, float y, char const *name=nullptr)
Convert a 2D size from on-screen to within a rendered image.
Definition: PythonModule.C:423
Engine.H
jevois::GUIhelperPython::startFrame
boost::python::tuple startFrame()
Start a new rendering frame.
Definition: PythonModule.C:294
Log.H
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:190
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:154
jevois::system
std::string system(std::string const &cmd, bool errtoo=true)
Execute a command and grab stdout output to a string.
Definition: Utils.C:461
jevois::rawimage::Font8x13bold
@ Font8x13bold
Definition: RawImageOps.H:157
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:142
jevois::coords::stdToImg
void stdToImg(float &x, float &y, RawImage const &camimg, float const eps=0.1F)
Transform coordinates in-place from standardized to image, using a RawImage to establish image size.
Definition: Coordinates.C:60
jevois::rawimage::Font12x22
@ Font12x22
Definition: RawImageOps.H:161
jevois::python::DarkGreen
@ DarkGreen
Definition: PythonSupport.C:200
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:124
jevois::python::hasattr
bool hasattr(boost::python::object &o, char const *name)
Check whether a boost::python::object has an attribute.
Definition: PythonSupport.C:108
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:232
jevois::python::White
@ White
Definition: PythonSupport.C:199
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:214
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:130
SysInfo.H
jevois::v4l2BytesPerPix
unsigned int v4l2BytesPerPix(unsigned int fcc)
Return the number of bytes per pixel for a given V4L2_PIX_FMT_...
Definition: Utils.C:141
jevois::GUIhelperPython::reportAndIgnoreException
void reportAndIgnoreException(std::string const &prefix="")
Report current exception in a modal dialog, then ignore it.
Definition: PythonModule.C:546
jevois::python::MedTeal
@ MedTeal
Definition: PythonSupport.C:200
jevois::dnn::PreProcessorForPython::i2b
boost::python::tuple i2b(float x, float y, size_t blobnum)
Convert coordinates from image to blob.
Definition: PythonModule.C:700
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:310
jevois::InputFramePython::get2
const RawImage & get2() const
Get the next captured camera image, ISP-scaled second frame.
Definition: PythonModule.C:58
jevois::GUIhelperPython::isMouseDoubleClicked
bool isMouseDoubleClicked(int button_num)
ImGui helper: check if mouse button double-clicked.
Definition: PythonModule.C:568
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:395
JEVOIS_PYTHON_CONSTANT
#define JEVOIS_PYTHON_CONSTANT(cst)
Definition: PythonSupport.C:60
jevois::getNumInstalledTPUs
size_t getNumInstalledTPUs()
Get the number of Coral TPUs present on this system.
Definition: SysInfo.C:87
jevois::PythonParameter::get
boost::python::object get() const
Get the value of this Parameter.
Definition: PythonParameter.C:134
jevois::rawimage::Font5x7
@ Font5x7
Definition: RawImageOps.H:154
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:458
jevois::python::engineForPythonModule
Engine * engineForPythonModule
Definition: PythonSupport.C:72
jevois::InputFramePython::getp1
const RawImage & getp1(bool casync) const
Get the next captured camera image that is intended for processing.
Definition: PythonModule.C:64
Timer.H
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:381
jevois::PythonParameter::setCallback
void setCallback(boost::python::object const &cb)
Set the parameter's callback.
Definition: PythonParameter.C:158
jevois::fccstr
std::string fccstr(unsigned int fcc)
Convert a V4L2 four-cc code (V4L2_PIX_FMT_...) to a 4-char string.
Definition: Utils.C:45
Serial.H
jevois::Engine
JeVois processing engine - gets images from camera sensor, processes them, and sends results over USB...
Definition: Engine.H:387
jevois::dnn::PreProcessorForPython::blobs
boost::python::list blobs() const
Access the last computed blobs (or empty if process() has not yet been called)
Definition: PythonModule.C:676
jevois::rawimage::drawFilledRect
void drawFilledRect(RawImage &img, int x, int y, unsigned int w, unsigned int h, unsigned int col)
Draw a filled rectangle in a YUYV image.
Definition: RawImageOps.C:646
Profiler.H
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:238
jevois::python::DarkPurple
@ DarkPurple
Definition: PythonSupport.C:201
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:280
jevois::GUIhelperPython::d2i
ImVec2 d2i(ImVec2 p, char const *name=nullptr)
Convert coordinates of a point from on-screen to within a rendered image.
Definition: PythonModule.C:402
jevois::rawimage::hFlipYUYV
void hFlipYUYV(RawImage &img)
Flip a YUYV RawImage horizontally while preserving color information.
Definition: RawImageOps.C:1416
jevois::rawimage::convertCvRGBAtoRawImage
void convertCvRGBAtoRawImage(cv::Mat const &src, RawImage &dst, int quality)
Convert an RGBA cv::Mat to RawImage with already-allocated pixels and pixel type.
Definition: RawImageOps.C:1337
LFATAL
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level.
jevois::getNumInstalledSPUs
size_t getNumInstalledSPUs()
Get the number of Hailo8 SPUs present on this system.
Definition: SysInfo.C:138
jevois::GUIhelperPython::getMousePos
ImVec2 getMousePos()
ImGui helper: get mouse position.
Definition: PythonModule.C:560
jevois::rawimage::convertCvBGRtoRawImage
void convertCvBGRtoRawImage(cv::Mat const &src, RawImage &dst, int quality)
Convert a BGR cv::Mat to RawImage with already-allocated pixels and pixel type.
Definition: RawImageOps.C:1266
jevois::python::LightTeal
@ LightTeal
Definition: PythonSupport.C:201
jevois::rawimage::unpackCvRGBAtoGrayRawImage
void unpackCvRGBAtoGrayRawImage(cv::Mat const &src, RawImage &dst)
Split an RGBA cv::Mat into a 4x taller grey RawImage with already-allocated pixels.
Definition: RawImageOps.C:1312
jevois::GUIhelperPython::isMouseClicked
bool isMouseClicked(int button_num)
ImGui helper: check if mouse button clicked.
Definition: PythonModule.C:564
jevois::InputFramePython::hasScaledImage
bool hasScaledImage() const
Check whether a second input image scaled by the JeVoisPro Platform ISP is available.
Definition: PythonModule.C:46
jevois::python::setEngine
void setEngine(jevois::Engine *e)
Initialize Python, numpy, and allow python modules to send serial outputs through the JeVois Engine.
Definition: PythonSupport.C:94
JEVOIS_PYTHON_FUNC
#define JEVOIS_PYTHON_FUNC(funcname)
Definition: PythonSupport.C:46
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:388
jevois::getNumInstalledVPUs
size_t getNumInstalledVPUs()
Get the number of Myriad-X VPUs present on this system.
Definition: SysInfo.C:112
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:268
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:220
Camera.H
PythonModule.H
jevois::RawImage::height
unsigned int height
Image height in pixels.
Definition: RawImage.H:146
jevois::Profiler::start
void start()
Start a time measurement period.
Definition: Profiler.C:33
jevois::PythonParameter::reset
void reset()
Reset this parameter to its default value.
Definition: PythonParameter.C:154
jevois::rawimage::Font16x29
@ Font16x29
Definition: RawImageOps.H:164
jevois::coords::imgToStd
void imgToStd(float &x, float &y, RawImage const &camimg, float const eps=0.1F)
Transform coordinates in-place from camera to standardized, using a RawImage to establish image size.
Definition: Coordinates.C:22
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:437
jevois::RawImage::coordsOk
bool coordsOk(int x, int y) const
Helper function to check that coords are within image bounds.
Definition: RawImage.C:88
jevois::rawimage::Font11x22
@ Font11x22
Definition: RawImageOps.H:160
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:250
jevois::rawimage::cvImage
cv::Mat cvImage(RawImage const &src)
Create an OpenCV image from the existing RawImage data, sharing the pixel memory rather than copying ...
Definition: RawImageOps.C:31
jevois::dnn::PreProcessorForPython::getUnscaledCropRect
boost::python::tuple getUnscaledCropRect(size_t blobnum)
Get unscaled crop rectangle in image coordinates.
Definition: PythonModule.C:694
jevois::GUIhelperPython::releaseImage
void releaseImage(char const *name)
Release an image.
Definition: PythonModule.C:518
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:226
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:208
jevois::InputFramePython::done2
void done2() const
Indicate that user processing is done with the ISP-scaled image previously obtained via get2()
Definition: PythonModule.C:82
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:118
jevois::python::YUYV
YUYV
Definition: PythonSupport.C:199
JEVOIS_PYTHON_RAWIMAGE_FUNC
#define JEVOIS_PYTHON_RAWIMAGE_FUNC(funcname)
Definition: PythonSupport.C:50
jevois::rawimage::paste
void paste(RawImage const &src, RawImage &dest, int dx, int dy)
Paste an image within another of same pixel type.
Definition: RawImageOps.C:403
jevois::dnn::PreProcessorForPython::blobsize
boost::python::tuple blobsize(size_t num) const
Access the width and height of a given blob, accounting for NCHW or NHWC.
Definition: PythonModule.C:681
jevois::InputFramePython::get21
const RawImage & get21(bool casync) const
Get the next captured camera image, ISP-scaled second frame.
Definition: PythonModule.C:52
jevois::rawimage::drawRect
void drawRect(RawImage &img, int x, int y, unsigned int w, unsigned int h, unsigned int thick, unsigned int col)
Draw a rectangle in a YUYV image.
Definition: RawImageOps.C:607
jevois::RawImage::fmt
unsigned int fmt
Pixel format as a V4L2_PIX_FMT_XXX.
Definition: RawImage.H:147
jevois::GUIhelperPython::drawImage2
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.
Definition: PythonModule.C:330
Utils.H
jevois::v4l2ImageSize
unsigned int v4l2ImageSize(unsigned int fcc, unsigned int width, unsigned int height)
Return the image size in bytes for a given V4L2_PIX_FMT_..., width, height.
Definition: Utils.C:168
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:100
imgToStd1
void(* imgToStd1)(float &x, float &y, jevois::RawImage const &camimg, float const eps)
Definition: PythonSupport.C:275
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:430
PythonOpenCV.H
jevois::ParameterCategory::name
std::string name
The name of the category.
Definition: ParameterDef.H:38
jevois::Profiler::stop
void stop()
End a time measurement period, report time spent for each checkpoint if reporting interval is reached...
Definition: Profiler.C:74
jevois::rawimage::convertToCvRGBA
cv::Mat convertToCvRGBA(RawImage const &src)
Convert RawImage to OpenCV doing color conversion from any RawImage source pixel to OpenCV RGB-A byte...
Definition: RawImageOps.C:332
h
int h
Definition: GUIhelper.C:2373
jevois::python::Black
@ Black
Definition: PythonSupport.C:199
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:354
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:106
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:374
jevois::rawimage::convertCvBGRtoCvYUYV
void convertCvBGRtoCvYUYV(cv::Mat const &src, cv::Mat &dst)
OpenCV does not provide conversion from BGR to YUYV in cvtColor(), so this function provides it.
Definition: RawImageOps.C:1026
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:482
jevois::rawimage::Font7x13
@ Font7x13
Definition: RawImageOps.H:156
jevois::rawimage::drawLine
void drawLine(RawImage &img, int x1, int y1, int x2, int y2, unsigned int thick, unsigned int col)
Draw a line in a YUYV image.
Definition: RawImageOps.C:564
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:364
jevois::python::MedPink
@ MedPink
Definition: PythonSupport.C:202
jevois::PythonParameter::descriptor
std::string descriptor() const
Get the parameter fully-qualified name, aka descriptor, including names of owning Component and all p...
Definition: PythonParameter.C:130
jevois::dnn::PostProcessorDetectYOLOforPython::yolo
boost::python::tuple yolo(boost::python::list outs, int nclass, float boxThreshold, float confThreshold, int bw, int bh, int fudge, int maxbox)
Generic raw YOLO processing.
Definition: PythonModule.C:733
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:184
jevois::rawimage::Font10x20
@ Font10x20
Definition: RawImageOps.H:159
jevois::strfcc
unsigned int strfcc(std::string const &str)
Convert a JeVois video format string to V4L2 four-cc code (V4L2_PIX_FMT_...)
Definition: Utils.C:111
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:88
jevois::rawimage::pasteGreyToYUYV
void pasteGreyToYUYV(cv::Mat const &src, RawImage &dest, int dx, int dy)
Paste a grey byte image into a YUYV image.
Definition: RawImageOps.C:448
LINFO
#define LINFO(msg)
Convenience macro for users to print out console or syslog messages, INFO level.
Definition: Log.H:194
jevois::Component::setParamStringUnique
void setParamStringUnique(std::string const &paramdescriptor, std::string const &val)
Set a parameter value by string, simple version assuming only one parameter match.
Definition: Component.C:374
jevois::rawimage::convertGreyToYUYV
void convertGreyToYUYV(RawImage const &src, RawImage &dst)
Convert from Grey (monochrome) to YUYV, only used internally by Camera class.
Definition: RawImageOps.C:1613
jevois::python::DarkPink
@ DarkPink
Definition: PythonSupport.C:202
IMU.H
jevois::GUIhelperPython::reportAndRethrowException
void reportAndRethrowException(std::string const &prefix="")
Report current exception in a modal dialog, then re-throw it.
Definition: PythonModule.C:553
imgToStd2
void(* imgToStd2)(float &x, float &y, unsigned int const width, unsigned int const height, float const eps)
Definition: PythonSupport.C:276
jevois::dnn::PreProcessorForPython::b2i
boost::python::tuple b2i(float x, float y, size_t blobnum)
Convert coordinates from blob back to original image.
Definition: PythonModule.C:687
jevois::rawimage::byteSwap
void byteSwap(RawImage &img)
Swap pairs of bytes in a RawImage.
Definition: RawImageOps.C:368
jevois::rawimage::convertCvGRAYtoCvYUYV
void convertCvGRAYtoCvYUYV(cv::Mat const &src, cv::Mat &dst)
OpenCV does not provide conversion from GRAY to YUYV in cvtColor(), so this function provides it.
Definition: RawImageOps.C:1184
jevois::GUIhelperPython::reportError
void reportError(std::string const &err)
Report an error in an overlay window.
Definition: PythonModule.C:539
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:196
jevois::Timer
Simple timer class.
Definition: Timer.H:34
jevois::GUIhelperPython::d2is
ImVec2 d2is(ImVec2 p, char const *name=nullptr)
Convert a 2D size from on-screen to within a rendered image.
Definition: PythonModule.C:416
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:256
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:202
JEVOIS_PYTHON_DNN_FUNC
#define JEVOIS_PYTHON_DNN_FUNC(funcname)
Definition: PythonSupport.C:63