JeVois  1.18
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 
40 #define PY_ARRAY_UNIQUE_SYMBOL pbcvt_ARRAY_API
42 
43 // ####################################################################################################
44 // Convenience macro to define a Python binding for a free function in the jevois namespace
45 #define JEVOIS_PYTHON_FUNC(funcname) \
46  boost::python::def(#funcname, jevois::funcname)
47 
48 // Convenience macro to define a Python binding for a free function in the jevois::rawimage namespace
49 #define JEVOIS_PYTHON_RAWIMAGE_FUNC(funcname) \
50  boost::python::def(#funcname, jevois::rawimage::funcname)
51 
52 // Convenience macro to define a python enum value where the value is in jevois::rawimage
53 #define JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(val) value(#val, jevois::rawimage::val)
54 
55 // Convenience macro to define a python enum value where the value is in jevois::python
56 #define JEVOIS_PYTHON_ENUM_VAL(val) value(#val, jevois::python::val)
57 
58 // Convenience macro to define a constant that exists in the global C++ namespace
59 #define JEVOIS_PYTHON_CONSTANT(cst) boost::python::scope().attr(#cst) = cst;
60 
61 // Convenience macro to define a Python binding for a free function in the jevois:dnn namespace
62 #define JEVOIS_PYTHON_DNN_FUNC(funcname) \
63  boost::python::def(#funcname, jevois::dnn::funcname)
64 
65 // ####################################################################################################
66 // Helper to provide jevois.sendSerial() function that emulates a C++ module's sendSerial()
67 namespace jevois
68 {
69  namespace python
70  {
72  }
73 }
74 
75 namespace
76 {
77  void * init_numpy()
78  {
79  // Initialize Python:
80  Py_SetProgramName(Py_DecodeLocale("", nullptr)); // black magic
81  Py_Initialize();
82 
83  // Initialize numpy array. Use the signal handler hack to prevent numpy from grabbing CTRL-C from
84  // https://stackoverflow.com/questions/28750774/
85  // python-import-array-makes-it-impossible-to-kill-embedded-python-with-ctrl-c
86  //PyOS_sighandler_t sighandler = PyOS_getsig(SIGINT);
87  import_array();
88  //PyOS_setsig(SIGINT,sighandler);
89  return nullptr; // was NUMPY_IMPORT_ARRAY_RETVAL in older numpy
90  }
91 }
92 
94 {
96  init_numpy();
97 }
98 
99 jevois::Engine * jevois::python::engine()
100 {
101  if (jevois::python::engineForPythonModule == nullptr) LFATAL("Internal error");
103 }
104 
105 // ####################################################################################################
106 // from https://stackoverflow.com/questions/39924912/finding-if-member-function-exists-in-a-boost-pythonobject
107 bool jevois::python::hasattr(boost::python::object & o, char const * name)
108 {
109  return PyObject_HasAttrString(o.ptr(), name);
110 }
111 
112 // ####################################################################################################
113 // Thin wrappers to handle default arguments or overloads in free functions
114 
115 namespace
116 {
117  void pythonSendSerial(std::string const & str)
118  { jevois::python::engine()->sendSerial(str); }
119 
120  size_t pythonFrameNum()
121  { return jevois::frameNum(); }
122 
123  void pythonWriteCamRegister(unsigned short reg, unsigned short val)
124  {
125  auto cam = jevois::python::engine()->camera();
126  if (!cam) LFATAL("Not using a Camera for video input");
127  cam->writeRegister(reg, val);
128  }
129 
130  unsigned short pythonReadCamRegister(unsigned short reg)
131  {
132  auto cam = jevois::python::engine()->camera();
133  if (!cam) LFATAL("Not using a Camera for video input");
134  return cam->readRegister(reg);
135  }
136 
137  void pythonWriteIMUregister(unsigned short reg, unsigned short val)
138  {
139  auto imu = jevois::python::engine()->imu();
140  if (!imu) LFATAL("No IMU driver loaded");
141  imu->writeRegister(reg, val);
142  }
143 
144  unsigned short pythonReadIMUregister(unsigned short reg)
145  {
146  auto imu = jevois::python::engine()->imu();
147  if (!imu) LFATAL("No IMU driver loaded");
148  return imu->readRegister(reg);
149  }
150 
151  void pythonWriteDMPregister(unsigned short reg, unsigned short val)
152  {
153  auto imu = jevois::python::engine()->imu();
154  if (!imu) LFATAL("No IMU driver loaded");
155  imu->writeDMPregister(reg, val);
156  }
157 
158  unsigned short pythonReadDMPregister(unsigned short reg)
159  {
160  auto imu = jevois::python::engine()->imu();
161  if (!imu) LFATAL("No IMU driver loaded");
162  return imu->readDMPregister(reg);
163  }
164 
165 #ifdef JEVOIS_LDEBUG_ENABLE
166  void pythonLDEBUG(std::string const & logmsg) { LDEBUG(logmsg); }
167 #else
168  void pythonLDEBUG(std::string const & JEVOIS_UNUSED_PARAM(logmsg)) { }
169 #endif
170  void pythonLINFO(std::string const & logmsg) { LINFO(logmsg); }
171  void pythonLERROR(std::string const & logmsg) { LERROR(logmsg); }
172  void pythonLFATAL(std::string const & logmsg) { LFATAL(logmsg); }
173 
174 
175  // ####################################################################################################
176  // Python parameter access support
177  std::string pythonGetParamStringUnique(boost::python::object & pyinst, std::string const & descriptor)
178  {
179  jevois::Component * comp = jevois::python::engine()->getPythonComponent(pyinst.ptr()->ob_type);
180  return comp->getParamStringUnique(descriptor);
181  }
182 
183  void pythonSetParamStringUnique(boost::python::object & pyinst, std::string const & descriptor,
184  std::string const & val)
185  {
186  jevois::Component * comp = jevois::python::engine()->getPythonComponent(pyinst.ptr()->ob_type);
187  comp->setParamStringUnique(descriptor, val);
188  }
189 
190 } // anonymous namespace
191 
192 // ####################################################################################################
193 namespace jevois
194 {
195  namespace python
196  {
197  // Aux enum for YUYV colors - keep this in sync with RawImage.H:
198  enum YUYV { Black = 0x8000, DarkGrey = 0x8050, MedGrey = 0x8080, LightGrey = 0x80a0, White = 0x80ff,
199  DarkGreen = 0x0000, MedGreen = 0x0040, LightGreen = 0x00ff, DarkTeal = 0x7070, MedTeal = 0x7090,
200  LightTeal = 0x70b0, DarkPurple = 0xa030, MedPurple = 0xa050, LightPurple = 0xa080,
201  DarkPink = 0xff00, MedPink = 0xff80, LightPink = 0xffff };
202  }
203 }
204 
205 // ####################################################################################################
206 #ifdef JEVOIS_PRO
207 BOOST_PYTHON_MODULE(libjevoispro)
208 #else
209 BOOST_PYTHON_MODULE(libjevois)
210 #endif
211 {
212  // #################### Initialize converters for cv::Mat support:
213  boost::python::to_python_converter<cv::Mat, pbcvt::matToNDArrayBoostConverter>();
215 
216  // #################### Define a few constants for python users:
217  // jevois.pro is True if running on JeVois-Pro
218 #ifdef JEVOIS_PRO
219  boost::python::scope().attr("pro") = true;
220 #else
221  boost::python::scope().attr("pro") = false;
222 #endif
223 
224  // jevois.platform is True if running on platform hardware
225 #ifdef JEVOIS_PLATFORM
226  boost::python::scope().attr("platform") = true;
227 #else
228  boost::python::scope().attr("platform") = false;
229 #endif
230 
231  // Jevois software version:
232  boost::python::scope().attr("version_major") = JEVOIS_VERSION_MAJOR;
233  boost::python::scope().attr("version_minor") = JEVOIS_VERSION_MINOR;
234  boost::python::scope().attr("version_patch") = JEVOIS_VERSION_PATCH;
235 
236  // Location of shared directories: jevois.share points to /jevois/share or /jevoispro/share
237  boost::python::scope().attr("share") = JEVOIS_SHARE_PATH;
238  boost::python::scope().attr("pydnn") = JEVOIS_PYDNN_PATH;
239 
240  // #################### module sendSerial() and other functions emulation:
241  boost::python::def("sendSerial", pythonSendSerial);
242  boost::python::def("frameNum", pythonFrameNum);
243  boost::python::def("writeCamRegister", pythonWriteCamRegister);
244  boost::python::def("readCamRegister", pythonReadCamRegister);
245  boost::python::def("writeIMUregister", pythonWriteIMUregister);
246  boost::python::def("readIMUregister", pythonReadIMUregister);
247  boost::python::def("writeDMPregister", pythonWriteDMPregister);
248  boost::python::def("readDMPregister", pythonReadDMPregister);
249 
250  // #################### Log.H
251  JEVOIS_PYTHON_CONSTANT(LOG_DEBUG);
252  JEVOIS_PYTHON_CONSTANT(LOG_INFO);
253  JEVOIS_PYTHON_CONSTANT(LOG_ERR);
254  JEVOIS_PYTHON_CONSTANT(LOG_CRIT);
255 
256  boost::python::def("LDEBUG", pythonLDEBUG);
257  boost::python::def("LINFO", pythonLINFO);
258  boost::python::def("LERROR", pythonLERROR);
259  boost::python::def("LFATAL", pythonLFATAL);
260 
261  // #################### Utils.H
272 
273  // #################### Coordinates.H
274  void (*imgToStd1)(float & x, float & y, jevois::RawImage const & camimg, float const eps) = jevois::coords::imgToStd;
275  void (*imgToStd2)(float & x, float & y, unsigned int const width, unsigned int const height, float const eps) =
277  boost::python::def("imgToStd", imgToStd1);
278  boost::python::def("imgToStd", imgToStd2);
279 
280  void (*stdToImg1)(float & x, float & y, jevois::RawImage const & camimg, float const eps) = jevois::coords::stdToImg;
281  void (*stdToImg2)(float & x, float & y, unsigned int const width, unsigned int const height, float const eps) =
283  boost::python::def("stdToImg", stdToImg1);
284  boost::python::def("stdToImg", stdToImg2);
285 
286  boost::python::def("imgToStdX", jevois::coords::imgToStdX);
287  boost::python::def("imgToStdY", jevois::coords::imgToStdY);
288  boost::python::def("imgToStdSize", jevois::coords::imgToStdSize);
289  boost::python::def("stdToImgSize", jevois::coords::stdToImgSize);
290 
291  // #################### RawImage.H
292  boost::python::class_<jevois::RawImage>("RawImage") // default constructor is included
293  .def("invalidate", &jevois::RawImage::invalidate)
294  .def("valid", &jevois::RawImage::valid)
295  .def("clear", &jevois::RawImage::clear)
296  .def("require", &jevois::RawImage::require)
297  .def_readwrite("width", &jevois::RawImage::width)
298  .def_readwrite("height", &jevois::RawImage::height)
299  .def_readwrite("fmt", &jevois::RawImage::fmt)
300  .def_readwrite("fps", &jevois::RawImage::fps)
301  .def("bytesperpix", &jevois::RawImage::bytesperpix)
302  .def("bytesize", &jevois::RawImage::bytesize)
303  .def("coordsOk", &jevois::RawImage::coordsOk)
304  //.def("pixels", &jevois::RawImage::pixelsw<unsigned char>,
305  // boost::python::return_value_policy<boost::python::reference_existing_object>())
306  ;
307 
308  boost::python::enum_<jevois::python::YUYV>("YUYV")
309  .JEVOIS_PYTHON_ENUM_VAL(Black)
310  .JEVOIS_PYTHON_ENUM_VAL(DarkGrey)
311  .JEVOIS_PYTHON_ENUM_VAL(MedGrey)
312  .JEVOIS_PYTHON_ENUM_VAL(LightGrey)
313  .JEVOIS_PYTHON_ENUM_VAL(White)
314  .JEVOIS_PYTHON_ENUM_VAL(DarkGreen)
315  .JEVOIS_PYTHON_ENUM_VAL(MedGreen)
316  .JEVOIS_PYTHON_ENUM_VAL(LightGreen)
317  .JEVOIS_PYTHON_ENUM_VAL(DarkTeal)
318  .JEVOIS_PYTHON_ENUM_VAL(MedTeal)
319  .JEVOIS_PYTHON_ENUM_VAL(LightTeal)
320  .JEVOIS_PYTHON_ENUM_VAL(DarkPurple)
321  .JEVOIS_PYTHON_ENUM_VAL(MedPurple)
322  .JEVOIS_PYTHON_ENUM_VAL(LightPurple)
323  .JEVOIS_PYTHON_ENUM_VAL(DarkPink)
324  .JEVOIS_PYTHON_ENUM_VAL(MedPink)
325  .JEVOIS_PYTHON_ENUM_VAL(LightPink)
326  ;
327 
328  JEVOIS_PYTHON_CONSTANT(V4L2_PIX_FMT_SRGGB8);
329  JEVOIS_PYTHON_CONSTANT(V4L2_PIX_FMT_YUYV);
330  JEVOIS_PYTHON_CONSTANT(V4L2_PIX_FMT_GREY);
331  JEVOIS_PYTHON_CONSTANT(V4L2_PIX_FMT_RGB565);
332  JEVOIS_PYTHON_CONSTANT(V4L2_PIX_FMT_MJPEG);
333  JEVOIS_PYTHON_CONSTANT(V4L2_PIX_FMT_BGR24);
334 
335  // #################### PythonModule.H
336  boost::python::class_<jevois::InputFramePython>("InputFrame")
337  .def("get", &jevois::InputFramePython::get1,
338  boost::python::return_value_policy<boost::python::reference_existing_object>())
339  .def("get", &jevois::InputFramePython::get,
340  boost::python::return_value_policy<boost::python::reference_existing_object>())
341  .def("hasScaledImage", &jevois::InputFramePython::hasScaledImage)
342  .def("get2", &jevois::InputFramePython::get21,
343  boost::python::return_value_policy<boost::python::reference_existing_object>())
344  .def("get2", &jevois::InputFramePython::get2,
345  boost::python::return_value_policy<boost::python::reference_existing_object>())
346  .def("getp", &jevois::InputFramePython::getp1,
347  boost::python::return_value_policy<boost::python::reference_existing_object>())
348  .def("getp", &jevois::InputFramePython::getp,
349  boost::python::return_value_policy<boost::python::reference_existing_object>())
350  .def("done", &jevois::InputFramePython::done)
351  .def("done2", &jevois::InputFramePython::done2)
352  .def("getCvGRAY", &jevois::InputFramePython::getCvGRAY1)
353  .def("getCvGRAY", &jevois::InputFramePython::getCvGRAY)
354  .def("getCvBGR", &jevois::InputFramePython::getCvBGR1)
355  .def("getCvBGR", &jevois::InputFramePython::getCvBGR)
356  .def("getCvRGB", &jevois::InputFramePython::getCvRGB1)
357  .def("getCvRGB", &jevois::InputFramePython::getCvRGB)
358  .def("getCvRGBA", &jevois::InputFramePython::getCvRGBA1)
359  .def("getCvRGBA", &jevois::InputFramePython::getCvRGBA)
360 
361  .def("getCvGRAYp", &jevois::InputFramePython::getCvGRAYp)
362  .def("getCvBGRp", &jevois::InputFramePython::getCvBGRp)
363  .def("getCvRGBp", &jevois::InputFramePython::getCvRGBp)
364  .def("getCvRGBAp", &jevois::InputFramePython::getCvRGBAp)
365  ;
366 
367  boost::python::class_<jevois::OutputFramePython>("OutputFrame")
368  .def("get", &jevois::OutputFramePython::get,
369  boost::python::return_value_policy<boost::python::reference_existing_object>())
370  .def("send", &jevois::OutputFramePython::send)
371 
372  .def("sendCv", &jevois::OutputFramePython::sendCv1)
373  .def("sendCv", &jevois::OutputFramePython::sendCv)
374 
375  .def("sendCvGRAY", &jevois::OutputFramePython::sendCvGRAY1)
376  .def("sendCvGRAY", &jevois::OutputFramePython::sendCvGRAY)
377  .def("sendCvBGR", &jevois::OutputFramePython::sendCvBGR1)
378  .def("sendCvBGR", &jevois::OutputFramePython::sendCvBGR)
379  .def("sendCvRGB", &jevois::OutputFramePython::sendCvRGB1)
380  .def("sendCvRGB", &jevois::OutputFramePython::sendCvRGB)
381  .def("sendCvRGBA", &jevois::OutputFramePython::sendCvRGBA1)
382  .def("sendCvRGBA", &jevois::OutputFramePython::sendCvRGBA)
383 
384  .def("sendScaledCvGRAY", &jevois::OutputFramePython::sendScaledCvGRAY1)
385  .def("sendScaledCvGRAY", &jevois::OutputFramePython::sendScaledCvGRAY)
386  .def("sendScaledCvBGR", &jevois::OutputFramePython::sendScaledCvBGR1)
387  .def("sendScaledCvBGR", &jevois::OutputFramePython::sendScaledCvBGR)
388  .def("sendScaledCvRGB", &jevois::OutputFramePython::sendScaledCvRGB1)
389  .def("sendScaledCvRGB", &jevois::OutputFramePython::sendScaledCvRGB)
390  .def("sendScaledCvRGBA", &jevois::OutputFramePython::sendScaledCvRGBA1)
391  .def("sendScaledCvRGBA", &jevois::OutputFramePython::sendScaledCvRGBA)
392  ;
393 
394  // #################### RawImageOps.H
407 
408  void (*drawRect1)(jevois::RawImage & img, int x, int y, unsigned int w,
409  unsigned int h, unsigned int thick, unsigned int col) = jevois::rawimage::drawRect;
410  void (*drawRect2)(jevois::RawImage & img, int x, int y, unsigned int w, unsigned int h, unsigned int col) =
412  boost::python::def("drawRect", drawRect1);
413  boost::python::def("drawRect", drawRect2);
415 
416  boost::python::enum_<jevois::rawimage::Font>("Font")
417  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font5x7)
418  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font6x10)
419  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font7x13)
420  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font8x13bold)
421  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font9x15bold)
422  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font10x20)
423  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font11x22)
424  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font12x22)
425  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font14x26)
426  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font15x28)
427  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font16x29)
428  .JEVOIS_PYTHON_RAWIMAGE_ENUM_VAL(Font20x38);
429 
430  void (*writeText1)(jevois::RawImage & img, std::string const & txt, int x, int y,
431  unsigned int col, jevois::rawimage::Font font) = jevois::rawimage::writeText;
432  boost::python::def("writeText", writeText1);
433 
446  boost::python::def("rescaleCv", jevois::rescaleCv);
447 
448  // #################### Timer.H
449  std::string const & (jevois::Timer::*timer_stop)() = &jevois::Timer::stop; // select overload with no args
450  boost::python::class_<jevois::Timer>("Timer", boost::python::init<char const *, size_t, int>())
451  .def("start", &jevois::Timer::start)
452  .def("stop", timer_stop, boost::python::return_value_policy<boost::python::copy_const_reference>());
453 
454  // #################### Profiler.H
455  boost::python::class_<jevois::Profiler>("Profiler", boost::python::init<char const *, size_t, int>())
456  .def("start", &jevois::Profiler::start)
457  .def("checkpoint", &jevois::Profiler::checkpoint)
458  .def("stop", &jevois::Profiler::stop, boost::python::return_value_policy<boost::python::copy_const_reference>());
459 
460  // #################### SysInfo.H
464 
465 #ifdef JEVOIS_PRO
466  // #################### GUIhelper.H
467  boost::python::class_<ImVec2>("ImVec2", boost::python::init<float, float>())
468  .def_readwrite("x", &ImVec2::x)
469  .def_readwrite("y", &ImVec2::y);
470 
471  boost::python::class_<ImVec4>("ImVec4", boost::python::init<float, float, float, float>())
472  .def_readwrite("x", &ImVec4::x)
473  .def_readwrite("y", &ImVec4::y)
474  .def_readwrite("z", &ImVec4::z)
475  .def_readwrite("w", &ImVec4::w);
476 
477  boost::python::class_<ImColor>("ImColor", boost::python::init<int, int, int, int>())
478  .def(boost::python::init<float, float, float, float>())
479  .def(boost::python::init<ImU32>())
480  .def_readwrite("Value", &ImColor::Value);
481 
482  boost::python::class_<jevois::GUIhelperPython>("GUIhelper", boost::python::init<jevois::GUIhelper *>())
483  .def("startFrame", &jevois::GUIhelperPython::startFrame)
484  .def("frameStarted", &jevois::GUIhelperPython::frameStarted)
485  .def("drawImage", &jevois::GUIhelperPython::drawImage)
486  .def("drawImage", &jevois::GUIhelperPython::drawImage1)
487  .def("drawInputFrame", &jevois::GUIhelperPython::drawInputFrame)
488  .def("drawInputFrame2", &jevois::GUIhelperPython::drawInputFrame2)
489  .def("i2d", &jevois::GUIhelperPython::i2d)
490  .def("i2d", &jevois::GUIhelperPython::i2d1)
491  .def("i2ds", &jevois::GUIhelperPython::i2ds)
492  .def("i2ds", &jevois::GUIhelperPython::i2ds1)
493  .def("drawLine", &jevois::GUIhelperPython::drawLine)
494  .def("drawRect", &jevois::GUIhelperPython::drawRect)
495  .def("drawPoly", &jevois::GUIhelperPython::drawPoly)
496  .def("drawPoly", &jevois::GUIhelperPython::drawPoly1)
497  .def("drawPoly", &jevois::GUIhelperPython::drawPoly2)
498  .def("drawCircle", &jevois::GUIhelperPython::drawCircle)
499  .def("drawText", &jevois::GUIhelperPython::drawText)
500  .def("iline", &jevois::GUIhelperPython::iline)
501  .def("itext", &jevois::GUIhelperPython::itext)
502  .def("iinfo", &jevois::GUIhelperPython::iinfo)
503  .def("releaseImage", &jevois::GUIhelperPython::releaseImage)
504  .def("releaseImage2", &jevois::GUIhelperPython::releaseImage2)
505  .def("endFrame", &jevois::GUIhelperPython::endFrame)
506  .def("d2i", &jevois::GUIhelperPython::d2i)
507  .def("d2i", &jevois::GUIhelperPython::d2i1)
508  .def("d2is", &jevois::GUIhelperPython::d2is)
509  .def("d2is", &jevois::GUIhelperPython::d2is1)
510  .def("reportError", &jevois::GUIhelperPython::reportError)
511  .def("reportAndIgnoreException", &jevois::GUIhelperPython::reportAndIgnoreException)
512  .def("reportAndRethrowException", &jevois::GUIhelperPython::reportAndRethrowException)
513  ;
514 #endif
515 
516  // #################### ParameterDef.H
517  boost::python::class_<jevois::ParameterCategory>("ParameterCategory", boost::python::init<std::string, std::string>())
518  .def_readonly("name", &jevois::ParameterCategory::name)
519  .def_readonly("description", &jevois::ParameterCategory::description)
520  ;
521 
522  // #################### Parameter support:
523  boost::python::def("getParamStr", pythonGetParamStringUnique);
524  boost::python::def("setParamStr", pythonSetParamStringUnique);
525 
526  // #################### Dynamic parameter support:
527  boost::python::class_<jevois::PythonParameter>("Parameter", boost::python::init<boost::python::object &,
528  std::string const &, std::string const &, std::string const &,
529  boost::python::object const &, jevois::ParameterCategory const &>())
530  .def("name", &jevois::PythonParameter::name,
531  boost::python::return_value_policy<boost::python::reference_existing_object>())
532  .def("descriptor", &jevois::PythonParameter::descriptor)
533  .def("get", &jevois::PythonParameter::get)
534  .def("set", &jevois::PythonParameter::set)
535  .def("strget", &jevois::PythonParameter::strget)
536  .def("strset", &jevois::PythonParameter::strset)
537  .def("freeze", &jevois::PythonParameter::freeze)
538  .def("reset", &jevois::PythonParameter::reset)
539  .def("setCallback", &jevois::PythonParameter::setCallback)
540  ;
541 
542  // #################### Allow python code to access dnn::PreProcessor helper functions:
543  // python cannot construct PreProcessor, but PostProcessorPython can use an existing one.
544  boost::python::class_<jevois::dnn::PreProcessorForPython>("PreProcessor", boost::python::no_init)
549  .def("getUnscaledCropRect", &jevois::dnn::PreProcessorForPython::getUnscaledCropRect)
550  ;
551 
552 }
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:188
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:242
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:110
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:92
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:484
jevois::python::LightGreen
@ LightGreen
Definition: PythonSupport.C:199
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:280
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:38
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:176
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:318
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::python::MedPurple
@ MedPurple
Definition: PythonSupport.C:200
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:429
jevois::python::MedGreen
@ MedGreen
Definition: PythonSupport.C:199
jevois::OutputFramePython::get
const RawImage & get() const
Get the next captured camera image.
Definition: PythonModule.C:164
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:418
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::dnn::PreProcessorForPython::b2i
cv::Point2f b2i(float x, float y, size_t blobnum)
Convert coordinates from blob back to original image.
Definition: PythonModule.C:629
jevois::python::DarkGrey
@ DarkGrey
Definition: PythonSupport.C:198
jevois::InputFramePython::get1
const RawImage & get1(bool casync) const
Get the next captured camera image, thin wrapper for default arg value.
Definition: PythonModule.C:32
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:134
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:477
jevois::dnn::PreProcessorForPython::getUnscaledCropRect
cv::Rect getUnscaledCropRect(size_t blobnum)
Get unscaled crop rectangle in image coordinates.
Definition: PythonModule.C:632
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:170
jevois::InputFramePython::getp
const RawImage & getp() const
Get the next captured camera image that is intended for processing.
Definition: PythonModule.C:68
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:470
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:146
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:281
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:272
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:74
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:166
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:425
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:198
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:301
jevois::GUIhelperPython::endFrame
void endFrame()
Finish current frame and render it.
Definition: PythonModule.C:506
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:77
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:260
jevois::python::MedGrey
@ MedGrey
Definition: PythonSupport.C:198
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:463
jevois::python::LightPink
@ LightPink
Definition: PythonSupport.C:201
jevois::getSysInfoVersion
std::string getSysInfoVersion()
Get O.S. version info.
Definition: SysInfo.C:74
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:383
jevois::python::DarkTeal
@ DarkTeal
Definition: PythonSupport.C:199
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:200
jevois::GUIhelperPython::releaseImage2
void releaseImage2(char const *name)
Release an image, second video stream.
Definition: PythonModule.C:499
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::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:397
Engine.H
jevois::GUIhelperPython::startFrame
boost::python::tuple startFrame()
Start a new rendering frame.
Definition: PythonModule.C:292
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:188
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:152
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:441
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:140
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:199
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:122
jevois::python::hasattr
bool hasattr(boost::python::object &o, char const *name)
Check whether a boost::python::object has an attribute.
Definition: PythonSupport.C:107
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:230
jevois::python::White
@ White
Definition: PythonSupport.C:198
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:212
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:128
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:138
jevois::GUIhelperPython::reportAndIgnoreException
void reportAndIgnoreException(std::string const &prefix="")
Report current exception in a modal dialog, then ignore it.
Definition: PythonModule.C:520
jevois::python::MedTeal
@ MedTeal
Definition: PythonSupport.C:199
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:308
jevois::InputFramePython::get2
const RawImage & get2() const
Get the next captured camera image, ISP-scaled second frame.
Definition: PythonModule.C:56
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:369
JEVOIS_PYTHON_CONSTANT
#define JEVOIS_PYTHON_CONSTANT(cst)
Definition: PythonSupport.C:59
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:432
jevois::python::engineForPythonModule
Engine * engineForPythonModule
Definition: PythonSupport.C:71
jevois::InputFramePython::getp1
const RawImage & getp1(bool casync) const
Get the next captured camera image that is intended for processing.
Definition: PythonModule.C:62
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:355
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:381
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:623
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:236
jevois::python::DarkPurple
@ DarkPurple
Definition: PythonSupport.C:200
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:278
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:376
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::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:200
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::InputFramePython::hasScaledImage
bool hasScaledImage() const
Check whether a second input image scaled by the JeVoisPro Platform ISP is available.
Definition: PythonModule.C:44
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:93
JEVOIS_PYTHON_FUNC
#define JEVOIS_PYTHON_FUNC(funcname)
Definition: PythonSupport.C:45
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:362
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:266
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:218
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:411
jevois::RawImage::coordsOk
bool coordsOk(int x, int y) const
Helper function to check that coords are within image bounds.
Definition: RawImage.C:85
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:248
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::GUIhelperPython::releaseImage
void releaseImage(char const *name)
Release an image.
Definition: PythonModule.C:492
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:224
jevois::dnn::PreProcessorForPython::imagesize
cv::Size imagesize() const
Access the last processed image size.
Definition: PythonModule.C:620
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:206
jevois::InputFramePython::done2
void done2() const
Indicate that user processing is done with the ISP-scaled image previously obtained via get2()
Definition: PythonModule.C:80
jevois::dnn::PreProcessorForPython::blobsize
cv::Size blobsize(size_t num) const
Access the width and height of a given blob, accounting for NCHW or NHWC.
Definition: PythonModule.C:626
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:116
jevois::python::YUYV
YUYV
Definition: PythonSupport.C:198
JEVOIS_PYTHON_RAWIMAGE_FUNC
#define JEVOIS_PYTHON_RAWIMAGE_FUNC(funcname)
Definition: PythonSupport.C:49
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::InputFramePython::get21
const RawImage & get21(bool casync) const
Get the next captured camera image, ISP-scaled second frame.
Definition: PythonModule.C:50
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
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:162
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:98
imgToStd1
void(* imgToStd1)(float &x, float &y, jevois::RawImage const &camimg, float const eps)
Definition: PythonSupport.C:274
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:404
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:1968
jevois::python::Black
@ Black
Definition: PythonSupport.C:198
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:328
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:104
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:348
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:456
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:338
jevois::python::MedPink
@ MedPink
Definition: PythonSupport.C:201
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::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:182
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:86
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:201
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:527
imgToStd2
void(* imgToStd2)(float &x, float &y, unsigned int const width, unsigned int const height, float const eps)
Definition: PythonSupport.C:275
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:513
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:194
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:390
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:254
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:200