JeVois  1.20
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
PythonModule.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 
21 #include <jevois/Core/Engine.H>
23 #include <jevois/DNN/Utils.H>
26 
27 // ####################################################################################################
28 // ####################################################################################################
29 // ####################################################################################################
30 
32 { }
33 
35 {
36  if (itsInputFrame == nullptr) LFATAL("Internal error");
37  return itsInputFrame->get(casync);
38 }
39 
41 {
42  if (itsInputFrame == nullptr) LFATAL("Internal error");
43  return itsInputFrame->get();
44 }
45 
47 {
48  if (itsInputFrame == nullptr) LFATAL("Internal error");
49  return itsInputFrame->hasScaledImage();
50 }
51 
53 {
54  if (itsInputFrame == nullptr) LFATAL("Internal error");
55  return itsInputFrame->get2(casync);
56 }
57 
59 {
60  if (itsInputFrame == nullptr) LFATAL("Internal error");
61  return itsInputFrame->get2();
62 }
63 
65 {
66  if (itsInputFrame == nullptr) LFATAL("Internal error");
67  return itsInputFrame->getp(casync);
68 }
69 
71 {
72  if (itsInputFrame == nullptr) LFATAL("Internal error");
73  return itsInputFrame->getp();
74 }
75 
77 {
78  if (itsInputFrame == nullptr) LFATAL("Internal error");
79  itsInputFrame->done();
80 }
81 
83 {
84  if (itsInputFrame == nullptr) LFATAL("Internal error");
85  itsInputFrame->done2();
86 }
87 
88 cv::Mat jevois::InputFramePython::getCvGRAY1(bool casync) const
89 {
90  if (itsInputFrame == nullptr) LFATAL("Internal error");
91  return itsInputFrame->getCvGRAY(casync);
92 }
93 
95 {
96  if (itsInputFrame == nullptr) LFATAL("Internal error");
97  return itsInputFrame->getCvGRAY();
98 }
99 
100 cv::Mat jevois::InputFramePython::getCvBGR1(bool casync) const
101 {
102  if (itsInputFrame == nullptr) LFATAL("Internal error");
103  return itsInputFrame->getCvBGR(casync);
104 }
105 
107 {
108  if (itsInputFrame == nullptr) LFATAL("Internal error");
109  return itsInputFrame->getCvBGR();
110 }
111 
112 cv::Mat jevois::InputFramePython::getCvRGB1(bool casync) const
113 {
114  if (itsInputFrame == nullptr) LFATAL("Internal error");
115  return itsInputFrame->getCvRGB(casync);
116 }
117 
119 {
120  if (itsInputFrame == nullptr) LFATAL("Internal error");
121  return itsInputFrame->getCvRGB();
122 }
123 
124 cv::Mat jevois::InputFramePython::getCvRGBA1(bool casync) const
125 {
126  if (itsInputFrame == nullptr) LFATAL("Internal error");
127  return itsInputFrame->getCvRGBA(casync);
128 }
129 
131 {
132  if (itsInputFrame == nullptr) LFATAL("Internal error");
133  return itsInputFrame->getCvRGBA();
134 }
135 
137 {
138  if (itsInputFrame == nullptr) LFATAL("Internal error");
139  return itsInputFrame->getCvGRAYp();
140 }
141 
143 {
144  if (itsInputFrame == nullptr) LFATAL("Internal error");
145  return itsInputFrame->getCvBGRp();
146 }
147 
149 {
150  if (itsInputFrame == nullptr) LFATAL("Internal error");
151  return itsInputFrame->getCvRGBp();
152 }
153 
155 {
156  if (itsInputFrame == nullptr) LFATAL("Internal error");
157  return itsInputFrame->getCvRGBAp();
158 }
159 
160 // ####################################################################################################
161 // ####################################################################################################
162 // ####################################################################################################
164 { }
165 
167 {
168  if (itsOutputFrame == nullptr) LFATAL("Internal error");
169  return itsOutputFrame->get();
170 }
171 
173 {
174  if (itsOutputFrame == nullptr) LFATAL("Internal error");
175  itsOutputFrame->send();
176 }
177 
178 void jevois::OutputFramePython::sendCv1(cv::Mat const & img, int quality) const
179 {
180  if (itsOutputFrame == nullptr) LFATAL("Internal error");
181  itsOutputFrame->sendCv(img, quality);
182 }
183 
184 void jevois::OutputFramePython::sendCv(cv::Mat const & img) const
185 {
186  if (itsOutputFrame == nullptr) LFATAL("Internal error");
187  itsOutputFrame->sendCv(img);
188 }
189 
190 void jevois::OutputFramePython::sendCvGRAY1(cv::Mat const & img, int quality) const
191 {
192  if (itsOutputFrame == nullptr) LFATAL("Internal error");
193  itsOutputFrame->sendCvGRAY(img, quality);
194 }
195 
196 void jevois::OutputFramePython::sendCvGRAY(cv::Mat const & img) const
197 {
198  if (itsOutputFrame == nullptr) LFATAL("Internal error");
199  itsOutputFrame->sendCvGRAY(img);
200 }
201 
202 void jevois::OutputFramePython::sendCvBGR1(cv::Mat const & img, int quality) const
203 {
204  if (itsOutputFrame == nullptr) LFATAL("Internal error");
205  itsOutputFrame->sendCvBGR(img, quality);
206 }
207 
208 void jevois::OutputFramePython::sendCvBGR(cv::Mat const & img) const
209 {
210  if (itsOutputFrame == nullptr) LFATAL("Internal error");
211  itsOutputFrame->sendCvBGR(img);
212 }
213 
214 void jevois::OutputFramePython::sendCvRGB1(cv::Mat const & img, int quality) const
215 {
216  if (itsOutputFrame == nullptr) LFATAL("Internal error");
217  itsOutputFrame->sendCvRGB(img, quality);
218 }
219 
220 void jevois::OutputFramePython::sendCvRGB(cv::Mat const & img) const
221 {
222  if (itsOutputFrame == nullptr) LFATAL("Internal error");
223  itsOutputFrame->sendCvRGB(img);
224 }
225 
226 void jevois::OutputFramePython::sendCvRGBA1(cv::Mat const & img, int quality) const
227 {
228  if (itsOutputFrame == nullptr) LFATAL("Internal error");
229  itsOutputFrame->sendCvRGBA(img, quality);
230 }
231 
232 void jevois::OutputFramePython::sendCvRGBA(cv::Mat const & img) const
233 {
234  if (itsOutputFrame == nullptr) LFATAL("Internal error");
235  itsOutputFrame->sendCvRGBA(img);
236 }
237 
238 void jevois::OutputFramePython::sendScaledCvGRAY1(cv::Mat const & img, int quality) const
239 {
240  if (itsOutputFrame == nullptr) LFATAL("Internal error");
241  itsOutputFrame->sendScaledCvGRAY(img, quality);
242 }
243 
244 void jevois::OutputFramePython::sendScaledCvGRAY(cv::Mat const & img) const
245 {
246  if (itsOutputFrame == nullptr) LFATAL("Internal error");
247  itsOutputFrame->sendScaledCvGRAY(img);
248 }
249 
250 void jevois::OutputFramePython::sendScaledCvBGR1(cv::Mat const & img, int quality) const
251 {
252  if (itsOutputFrame == nullptr) LFATAL("Internal error");
253  itsOutputFrame->sendScaledCvBGR(img, quality);
254 }
255 
256 void jevois::OutputFramePython::sendScaledCvBGR(cv::Mat const & img) const
257 {
258  if (itsOutputFrame == nullptr) LFATAL("Internal error");
259  itsOutputFrame->sendScaledCvBGR(img);
260 }
261 
262 void jevois::OutputFramePython::sendScaledCvRGB1(cv::Mat const & img, int quality) const
263 {
264  if (itsOutputFrame == nullptr) LFATAL("Internal error");
265  itsOutputFrame->sendScaledCvRGB(img, quality);
266 }
267 
268 void jevois::OutputFramePython::sendScaledCvRGB(cv::Mat const & img) const
269 {
270  if (itsOutputFrame == nullptr) LFATAL("Internal error");
271  itsOutputFrame->sendScaledCvRGB(img);
272 }
273 
274 void jevois::OutputFramePython::sendScaledCvRGBA1(cv::Mat const & img, int quality) const
275 {
276  if (itsOutputFrame == nullptr) LFATAL("Internal error");
277  itsOutputFrame->sendScaledCvRGBA(img, quality);
278 }
279 
280 void jevois::OutputFramePython::sendScaledCvRGBA(cv::Mat const & img) const
281 {
282  if (itsOutputFrame == nullptr) LFATAL("Internal error");
283  itsOutputFrame->sendScaledCvRGBA(img);
284 }
285 
286 // ####################################################################################################
287 // ####################################################################################################
288 // ####################################################################################################
289 #ifdef JEVOIS_PRO
291 { }
292 
293 // ####################################################################################################
295 {
296  if (itsGUIhelper == nullptr) LFATAL("Internal error");
297  unsigned short w, h;
298  bool idle = itsGUIhelper->startFrame(w, h);
299  return boost::python::make_tuple(idle, w, h);
300 }
301 
302 // ####################################################################################################
304 {
305  if (itsGUIhelper == nullptr) LFATAL("Internal error");
306  return itsGUIhelper->frameStarted();
307 }
308 
309 // ####################################################################################################
310 boost::python::tuple jevois::GUIhelperPython::drawImage(char const * name, RawImage const & img,
311  bool noalias, bool isoverlay)
312 {
313  if (itsGUIhelper == nullptr) LFATAL("Internal error");
314  int x = 0, y = 0; unsigned short w = 0, h = 0;
315  itsGUIhelper->drawImage(name, img, x, y, w, h, noalias, isoverlay);
316  return boost::python::make_tuple(x, y, w, h);
317 }
318 
319 // ####################################################################################################
320 boost::python::tuple jevois::GUIhelperPython::drawImage1(char const * name, cv::Mat const & img, bool rgb,
321  bool noalias, bool isoverlay)
322 {
323  if (itsGUIhelper == nullptr) LFATAL("Internal error");
324  int x = 0, y = 0; unsigned short w = 0, h = 0;
325  itsGUIhelper->drawImage(name, img, rgb, x, y, w, h, noalias, isoverlay);
326  return boost::python::make_tuple(x, y, w, h);
327 }
328 
329 // ####################################################################################################
330 boost::python::tuple jevois::GUIhelperPython::drawImage2(char const * name, RawImage const & img,
331  int x, int y, int w, int h, bool noalias, bool isoverlay)
332 {
333  if (itsGUIhelper == nullptr) LFATAL("Internal error");
334  if (w < 0) LFATAL("w must be positive");
335  if (h < 0) LFATAL("h must be positive");
336  unsigned short ww = (unsigned short)(w); unsigned short hh = (unsigned short)(h);
337  itsGUIhelper->drawImage(name, img, x, y, ww, hh, noalias, isoverlay);
338  return boost::python::make_tuple(x, y, w, h);
339 }
340 
341 // ####################################################################################################
342 boost::python::tuple jevois::GUIhelperPython::drawImage3(char const * name, cv::Mat const & img, bool rgb,
343  int x, int y, int w, int h, bool noalias, bool isoverlay)
344 {
345  if (itsGUIhelper == nullptr) LFATAL("Internal error");
346  if (w < 0) LFATAL("w must be positive");
347  if (h < 0) LFATAL("h must be positive");
348  unsigned short ww = (unsigned short)(w); unsigned short hh = (unsigned short)(h);
349  itsGUIhelper->drawImage(name, img, rgb, x, y, ww, hh, noalias, isoverlay);
350  return boost::python::make_tuple(x, y, w, h);
351 }
352 
353 // ####################################################################################################
354 boost::python::tuple jevois::GUIhelperPython::drawInputFrame(char const * name, InputFramePython const & frame,
355  bool noalias, bool casync)
356 {
357  if (itsGUIhelper == nullptr) LFATAL("Internal error");
358  int x = 0, y = 0; unsigned short w = 0, h = 0;
359  itsGUIhelper->drawInputFrame(name, *frame.itsInputFrame, x, y, w, h, noalias, casync);
360  return boost::python::make_tuple(x, y, w, h);
361 }
362 
363 // ####################################################################################################
364 boost::python::tuple jevois::GUIhelperPython::drawInputFrame2(char const * name, InputFramePython const & frame,
365  bool noalias, bool casync)
366 {
367  if (itsGUIhelper == nullptr) LFATAL("Internal error");
368  int x = 0, y = 0; unsigned short w = 0, h = 0;
369  itsGUIhelper->drawInputFrame(name, *frame.itsInputFrame, x, y, w, h, noalias, casync);
370  return boost::python::make_tuple(x, y, w, h);
371 }
372 
373 // ####################################################################################################
374 ImVec2 jevois::GUIhelperPython::i2d(ImVec2 p, char const * name)
375 {
376  if (itsGUIhelper == nullptr) LFATAL("Internal error");
377  return itsGUIhelper->i2d(p, name);
378 }
379 
380 // ####################################################################################################
381 ImVec2 jevois::GUIhelperPython::i2d1(float x, float y, char const * name)
382 {
383  if (itsGUIhelper == nullptr) LFATAL("Internal error");
384  return itsGUIhelper->i2d(x, y, name);
385 }
386 
387 // ####################################################################################################
388 ImVec2 jevois::GUIhelperPython::i2ds(ImVec2 p, char const * name)
389 {
390  if (itsGUIhelper == nullptr) LFATAL("Internal error");
391  return itsGUIhelper->i2ds(p, name);
392 }
393 
394 // ####################################################################################################
395 ImVec2 jevois::GUIhelperPython::i2ds1(float x, float y, char const * name)
396 {
397  if (itsGUIhelper == nullptr) LFATAL("Internal error");
398  return itsGUIhelper->i2ds(x, y, name);
399 }
400 
401 // ####################################################################################################
402 ImVec2 jevois::GUIhelperPython::d2i(ImVec2 p, char const * name)
403 {
404  if (itsGUIhelper == nullptr) LFATAL("Internal error");
405  return itsGUIhelper->d2i(p, name);
406 }
407 
408 // ####################################################################################################
409 ImVec2 jevois::GUIhelperPython::d2i1(float x, float y, char const * name)
410 {
411  if (itsGUIhelper == nullptr) LFATAL("Internal error");
412  return itsGUIhelper->d2i(x, y, name);
413 }
414 
415 // ####################################################################################################
416 ImVec2 jevois::GUIhelperPython::d2is(ImVec2 p, char const * name)
417 {
418  if (itsGUIhelper == nullptr) LFATAL("Internal error");
419  return itsGUIhelper->d2is(p, name);
420 }
421 
422 // ####################################################################################################
423 ImVec2 jevois::GUIhelperPython::d2is1(float x, float y, char const * name)
424 {
425  if (itsGUIhelper == nullptr) LFATAL("Internal error");
426  return itsGUIhelper->d2is(x, y, name);
427 }
428 
429 // ####################################################################################################
430 void jevois::GUIhelperPython::drawLine(float x1, float y1, float x2, float y2, ImU32 col)
431 {
432  if (itsGUIhelper == nullptr) LFATAL("Internal error");
433  itsGUIhelper->drawLine(x1, y1, x2, y2, col);
434 }
435 
436 // ####################################################################################################
437 void jevois::GUIhelperPython::drawRect(float x1, float y1, float x2, float y2, ImU32 col, bool filled)
438 {
439  if (itsGUIhelper == nullptr) LFATAL("Internal error");
440  itsGUIhelper->drawRect(x1, y1, x2, y2, col, filled);
441 }
442 
443 // ####################################################################################################
444 void jevois::GUIhelperPython::drawPoly(std::vector<cv::Point> const & pts, ImU32 col, bool filled)
445 {
446  if (itsGUIhelper == nullptr) LFATAL("Internal error");
447  itsGUIhelper->drawPoly(pts, col, filled);
448 }
449 
450 // ####################################################################################################
451 void jevois::GUIhelperPython::drawPoly1(std::vector<cv::Point2f> const & pts, ImU32 col, bool filled)
452 {
453  if (itsGUIhelper == nullptr) LFATAL("Internal error");
454  itsGUIhelper->drawPoly(pts, col, filled);
455 }
456 
457 // ####################################################################################################
458 void jevois::GUIhelperPython::drawPoly2(cv::Mat const & pts, ImU32 col, bool filled)
459 {
460  if (itsGUIhelper == nullptr) LFATAL("Internal error");
461  if (pts.total() == 0) return;
462 
463  // Convert mat to vectors of Point2f (one poly per mat row), and draw each poly:
464  int imax;
465  if (pts.type() == CV_32FC2) imax = pts.cols * 2;
466  else if (pts.type() == CV_32F) imax = pts.cols;
467  else LFATAL("Incorrect input " << jevois::dnn::shapestr(pts) << ": should be 32F or 32FC2");
468 
469  if (imax < 4) return; // need at least 2 vertices
470 
471  float const * ptr = pts.ptr<float>(0);
472 
473  for (int j = 0; j < pts.rows; ++j)
474  {
475  std::vector<cv::Point2f> p;
476  for (int i = 0; i < imax; i += 2) { p.emplace_back(cv::Point2f(ptr[0], ptr[1])); ptr += 2; }
477  itsGUIhelper->drawPoly(p, col, filled);
478  }
479 }
480 
481 // ####################################################################################################
482 void jevois::GUIhelperPython::drawCircle(float x, float y, float r, ImU32 col, bool filled)
483 {
484  if (itsGUIhelper == nullptr) LFATAL("Internal error");
485  itsGUIhelper->drawCircle(x, y, r, col, filled);
486 }
487 
488 // ####################################################################################################
489 void jevois::GUIhelperPython::drawText(float x, float y, char const * txt, ImU32 col)
490 {
491  if (itsGUIhelper == nullptr) LFATAL("Internal error");
492  itsGUIhelper->drawText(x, y, txt, col);
493 }
494 
495 // ####################################################################################################
496 ImVec2 jevois::GUIhelperPython::iline(int line, char const * name)
497 {
498  if (itsGUIhelper == nullptr) LFATAL("Internal error");
499  return itsGUIhelper->iline(line, name);
500 }
501 
502 // ####################################################################################################
503 void jevois::GUIhelperPython::itext(char const * txt, ImU32 const & col, int line)
504 {
505  if (itsGUIhelper == nullptr) LFATAL("Internal error");
506  itsGUIhelper->itext(txt, col, line);
507 }
508 
509 // ####################################################################################################
510 void jevois::GUIhelperPython::iinfo(jevois::InputFramePython const & inframe, std::string const & fpscpu,
511  unsigned short winw, unsigned short winh)
512 {
513  if (itsGUIhelper == nullptr) LFATAL("Internal error");
514  itsGUIhelper->iinfo(*inframe.itsInputFrame, fpscpu, winw, winh);
515 }
516 
517 // ####################################################################################################
519 {
520  if (itsGUIhelper == nullptr) LFATAL("Internal error");
521  itsGUIhelper->releaseImage(name);
522 }
523 
524 // ####################################################################################################
526 {
527  if (itsGUIhelper == nullptr) LFATAL("Internal error");
528  itsGUIhelper->releaseImage2(name);
529 }
530 
531 // ####################################################################################################
533 {
534  if (itsGUIhelper == nullptr) LFATAL("Internal error");
535  itsGUIhelper->endFrame();
536 }
537 
538 // ####################################################################################################
539 void jevois::GUIhelperPython::reportError(std::string const & err)
540 {
541  if (itsGUIhelper == nullptr) LFATAL("Internal error");
542  itsGUIhelper->reportError(err);
543 }
544 
545 // ####################################################################################################
547 {
548  if (itsGUIhelper == nullptr) LFATAL("Internal error");
549  itsGUIhelper->reportAndIgnoreException(prefix);
550 }
551 
552 // ####################################################################################################
554 {
555  if (itsGUIhelper == nullptr) LFATAL("Internal error");
556  itsGUIhelper->reportAndRethrowException(prefix);
557 }
558 
559 // ####################################################################################################
561 { return ImGui::GetMousePos(); }
562 
563 // ####################################################################################################
565 { return ImGui::IsMouseClicked(button_num); }
566 
567 // ####################################################################################################
569 { return ImGui::IsMouseDoubleClicked(button_num); }
570 
571 // ####################################################################################################
573 { return ImGui::IsMouseDragging(button_num); }
574 
575 // ####################################################################################################
577 { return ImGui::IsMouseDown(button_num); }
578 
579 // ####################################################################################################
581 { return ImGui::IsMouseReleased(button_num); }
582 
583 #endif // JEVOIS_PRO
584 
585 // ####################################################################################################
586 // ####################################################################################################
587 // ####################################################################################################
588 jevois::PythonModule::PythonModule(jevois::VideoMapping const & m) : jevois::Module(m.modulename), itsPyPath(m.sopath())
589 {
590  if (m.ispython == false) LFATAL("Passed video mapping is not for a python module");
591 }
592 
593 // ####################################################################################################
595 {
596  // Load the python code and instantiate the python class:
597  PythonWrapper::pythonload(itsPyPath);
598 
599  // Call python module's init() function if implemented:
601 }
602 
603 // ####################################################################################################
605 {
606  // Call python module's uninit() function if implemented:
607  if (jevois::python::hasattr(PythonWrapper::pyinst(), "uninit")) PythonWrapper::pyinst().attr("uninit")();
608 }
609 
610 // ####################################################################################################
612 { }
613 
614 // ####################################################################################################
616 {
617  jevois::InputFramePython inframepy(&inframe);
618  jevois::OutputFramePython outframepy(&outframe);
619  PythonWrapper::pyinst().attr("process")(boost::ref(inframepy), boost::ref(outframepy));
620 }
621 
622 // ####################################################################################################
624 {
625  jevois::InputFramePython inframepy(&inframe);
626  PythonWrapper::pyinst().attr("processNoUSB")(boost::ref(inframepy));
627 }
628 
629 #ifdef JEVOIS_PRO
630 
631 // ####################################################################################################
633 {
634  jevois::InputFramePython inframepy(&inframe);
635  jevois::GUIhelperPython helperpy(&helper);
636  PythonWrapper::pyinst().attr("processGUI")(boost::ref(inframepy), boost::ref(helperpy));
637 }
638 
639 #endif
640 
641 // ####################################################################################################
642 void jevois::PythonModule::parseSerial(std::string const & str, std::shared_ptr<UserInterface> s)
643 {
644  if (jevois::python::hasattr(PythonWrapper::pyinst(), "parseSerial"))
645  {
646  boost::python::object ret = PythonWrapper::pyinst().attr("parseSerial")(str);
647  std::string retstr = boost::python::extract<std::string>(ret);
648  if (retstr.empty() == false) s->writeString(retstr);
649  }
650  else jevois::Module::parseSerial(str, s);
651 }
652 
653 // ####################################################################################################
655 {
656  if (jevois::python::hasattr(PythonWrapper::pyinst(), "supportedCommands"))
657  {
658  boost::python::object ret = PythonWrapper::pyinst().attr("supportedCommands")();
659  std::string retstr = boost::python::extract<std::string>(ret);
660  if (retstr.empty() == false) os << retstr;
662 }
663 
664 // ####################################################################################################
665 // ####################################################################################################
666 // ####################################################################################################
668 { }
669 
671 {
672  cv::Size const s = itsPP->imagesize();
673  return boost::python::make_tuple(s.width, s.height);
674 }
675 
676 boost::python::list jevois::dnn::PreProcessorForPython::blobs() const
677 {
678  return jevois::python::pyVecToList(itsPP->blobs());
679 }
680 
681 boost::python::tuple jevois::dnn::PreProcessorForPython::blobsize(size_t num) const
682 {
683  cv::Size s = itsPP->blobsize(num);
684  return boost::python::make_tuple(s.width, s.height);
685 }
686 
687 boost::python::tuple jevois::dnn::PreProcessorForPython::b2i(float x, float y, size_t blobnum)
688 {
689  float px = x, py = y;
690  itsPP->b2i(px, py, blobnum);
691  return boost::python::make_tuple(px, py);
692 }
693 
695 {
696  cv::Rect const r = itsPP->getUnscaledCropRect(blobnum);
697  return boost::python::make_tuple(r.x, r.y, r.width, r.height);
698 }
699 
700 boost::python::tuple jevois::dnn::PreProcessorForPython::i2b(float x, float y, size_t blobnum)
701 {
702  float px = x, py = y;
703  itsPP->i2b(px, py, blobnum);
704  return boost::python::make_tuple(px, py);
705 }
706 
707 
708 // ####################################################################################################
709 // ####################################################################################################
710 // ####################################################################################################
712 {
713  // We need to add our sub under an existing "pypost" sub of our module. The hierarchy typically is:
714  // DNN->pipeline->postproc->pypost
715  std::shared_ptr<Module> m = jevois::python::engine()->module();
716  if (!m) LFATAL("Cannot instantiate without a current running module");
717  std::shared_ptr<Component> pi = m->getSubComponent("pipeline");
718  if (!pi) LFATAL("Cannot instantiate without a current DNN pipeline");
719  std::shared_ptr<Component> pp = pi->getSubComponent("postproc");
720  if (!pp) LFATAL("Cannot instantiate without a current python-type post-processor");
721  std::shared_ptr<Component> ppp = pp->getSubComponent("pypost");
722  if (!ppp) LFATAL("Cannot instantiate without a current pypost post-processor");
723  itsYOLO = ppp->addSubComponent<PostProcessorDetectYOLO>("yolo");
724 }
725 
727 { }
728 
730 { itsYOLO->freeze(doit); }
731 
732 boost::python::tuple
733 jevois::dnn::PostProcessorDetectYOLOforPython::yolo(boost::python::list outs, int nclass,
734  float boxThreshold, float confThreshold,
735  int bw, int bh, int fudge, int maxbox)
736 {
737  std::vector<cv::Mat> const outvec = jevois::python::pyListToVec<cv::Mat>(outs);
738 
739  std::vector<int> classIds;
740  std::vector<float> confidences;
741  std::vector<cv::Rect> boxes;
742 
743  itsYOLO->yolo(outvec, classIds, confidences, boxes, nclass, boxThreshold, confThreshold,
744  cv::Size(bw, bh), fudge, maxbox);
745 
746  boost::python::list ids = jevois::python::pyVecToList(classIds);
747  boost::python::list conf = jevois::python::pyVecToList(confidences);
748  boost::python::list b;
749  for (cv::Rect const & r : boxes) b.append(boost::python::make_tuple(r.x, r.y, r.width, r.height));
750 
751  return boost::python::make_tuple(ids, conf, b);
752 }
753 
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::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::OutputFrame
Exception-safe wrapper around a raw image to be sent over USB.
Definition: OutputFrame.H:52
jevois::InputFramePython::getCvGRAY
cv::Mat getCvGRAY() const
Shorthand to get the input image as a GRAY cv::Mat and release the raw buffer.
Definition: PythonModule.C:94
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
PythonSupport.H
PostProcessorDetectYOLO.H
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
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::dnn::PostProcessorDetectYOLO
Post-Processor sub-component for raw YOLO decoding.
Definition: PostProcessorDetectYOLO.H:27
jevois::GUIhelperPython::isMouseReleased
bool isMouseReleased(int button_num)
ImGui helper: check if mouse button released.
Definition: PythonModule.C:580
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::python::pyVecToList
boost::python::list pyVecToList(std::vector< T > const &v)
Helper to convert std::vector<T> to python list.
jevois::PythonWrapper::pyinst
boost::python::object & pyinst()
Get the python class pyinst, or throw if construction error occurred (e.g., file not found)
Definition: PythonWrapper.C:85
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::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::PythonModule::process
virtual void process(InputFrame &&inframe, OutputFrame &&outframe) override
Processing function, version that receives a frame from camera and sends a frame out over USB.
Definition: PythonModule.C:615
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
jevois::UserInterface::writeString
virtual void writeString(std::string const &str)=0
Write a string.
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::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
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
Definition: RawImage.H:110
jevois::OutputFramePython::sendScaledCvRGBA1
void sendScaledCvRGBA1(cv::Mat const &img, int quality) const
Shorthand to send a RGBA cv::Mat after scaling/converting it to the current output format.
Definition: PythonModule.C:274
jevois::Module::parseSerial
virtual void parseSerial(std::string const &str, std::shared_ptr< UserInterface > s)
Receive a string from a serial port which contains a user command.
Definition: Module.C:63
jevois::InputFramePython::done
void done() const
Indicate that user processing is done with the image previously obtained via get()
Definition: PythonModule.C:76
UserInterface.H
jevois::GUIhelperPython::isMouseDown
bool isMouseDown(int button_num)
ImGui helper: check if mouse button pressed.
Definition: PythonModule.C:576
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::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
jevois::GUIhelperPython
Wrapper around GUIhelper to be used by Python.
Definition: PythonModule.H:224
jevois::OutputFramePython::sendScaledCvRGB1
void sendScaledCvRGB1(cv::Mat const &img, int quality) const
Shorthand to send a RGB cv::Mat after scaling/converting it to the current output format.
Definition: PythonModule.C:262
jevois::dnn::PreProcessorForPython::imagesize
boost::python::tuple imagesize() const
Access the last processed image size.
Definition: PythonModule.C:670
jevois::PythonModule::~PythonModule
virtual ~PythonModule()
Virtual destructor for safe inheritance.
Definition: PythonModule.C:611
jevois::GUIhelper
Helper class to assist modules in creating graphical and GUI elements.
Definition: GUIhelper.H:128
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::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::PythonModule::postUninit
void postUninit() override
Optionally call uninit() python module function, if implemented.
Definition: PythonModule.C:604
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
Definition: Concepts.dox:1
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
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::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::dnn::PreProcessor
Pre-Processor for neural network pipeline.
Definition: PreProcessor.H:108
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::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
jevois::GUIhelperPython::reportAndIgnoreException
void reportAndIgnoreException(std::string const &prefix="")
Report current exception in a modal dialog, then ignore it.
Definition: PythonModule.C:546
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::PythonModule::preInit
void preInit() override
Load python code and optionally call init() python module function, if implemented.
Definition: PythonModule.C:594
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::PythonModule::supportedCommands
virtual void supportedCommands(std::ostream &os) override
Human-readable description of this Module's supported custom commands.
Definition: PythonModule.C:654
jevois::InputFramePython::getp1
const RawImage & getp1(bool casync) const
Get the next captured camera image that is intended for processing.
Definition: PythonModule.C:64
jevois::dnn::PostProcessorDetectYOLOforPython::~PostProcessorDetectYOLOforPython
~PostProcessorDetectYOLOforPython()
Destructor removes itsYOLO from current module.
Definition: PythonModule.C:726
jevois::dnn::PreProcessorForPython::PreProcessorForPython
PreProcessorForPython(PreProcessor *pp)
Construct from an existing PreProcessor.
Definition: PythonModule.C:667
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::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::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::PythonModule::PythonModule
PythonModule(VideoMapping const &m)
Constructor needs the full path to a Python source code file.
Definition: PythonModule.C:588
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
LFATAL
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level.
jevois::GUIhelperPython::getMousePos
ImVec2 getMousePos()
ImGui helper: get mouse position.
Definition: PythonModule.C:560
jevois::OutputFramePython
Wrapper around OutputFrame to be used by Python.
Definition: PythonModule.H:129
jevois::Module
Virtual base class for a vision processing module.
Definition: Module.H:104
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::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::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
PythonModule.H
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::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::InputFrame
Exception-safe wrapper around a raw camera input frame.
Definition: InputFrame.H:50
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::OutputFramePython
OutputFramePython()=default
Default constructor to keep boost::python happy, object is not operational.
jevois::OutputFramePython::sendCvBGR
void sendCvBGR(cv::Mat const &img) const
Shorthand to send a BGR cv::Mat after converting it to the current output format.
Definition: PythonModule.C: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::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::InputFramePython::InputFramePython
InputFramePython()=default
Default constructor to keep boost::python happy, object is not operational.
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
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
jevois::PythonWrapper::pythonload
void pythonload(std::string const &path)
Init from path if default constructor was used.
Definition: PythonWrapper.C:34
jevois::dnn::PostProcessorDetectYOLOforPython::PostProcessorDetectYOLOforPython
PostProcessorDetectYOLOforPython()
Constructor constructs itsYOLO and adds it to current module.
Definition: PythonModule.C:711
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
jevois::GUIhelperPython::GUIhelperPython
GUIhelperPython(GUIhelper *src)
Construct from a regular GUIhelper that should be be coming from Engine.
Definition: PythonModule.C:290
PythonException.H
h
int h
Definition: GUIhelper.C:2373
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::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::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::PythonModule::parseSerial
virtual void parseSerial(std::string const &str, std::shared_ptr< UserInterface > s) override
Receive a string from a serial port which contains a user command.
Definition: PythonModule.C:642
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::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::GUIhelperPython::reportAndRethrowException
void reportAndRethrowException(std::string const &prefix="")
Report current exception in a modal dialog, then re-throw it.
Definition: PythonModule.C:553
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::Module::supportedCommands
virtual void supportedCommands(std::ostream &os)
Human-readable description of this Module's supported custom commands.
Definition: Module.C:68
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::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::InputFramePython
Wrapper around InputFrame to be used by Python.
Definition: PythonModule.H:46