JeVois  1.21
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
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{ if (itsInputFrame == nullptr) LFATAL("Internal error"); }
33
35{
36 return itsInputFrame->get(casync);
37}
38
40{
41 return itsInputFrame->get();
42}
43
45{
46 return itsInputFrame->hasScaledImage();
47}
48
50{
51 return itsInputFrame->get2(casync);
52}
53
55{
56 return itsInputFrame->get2();
57}
58
60{
61 return itsInputFrame->getp(casync);
62}
63
65{
66 return itsInputFrame->getp();
67}
68
70{
71 itsInputFrame->done();
72}
73
75{
76 itsInputFrame->done2();
77}
78
79cv::Mat jevois::InputFramePython::getCvGRAY1(bool casync) const
80{
81 return itsInputFrame->getCvGRAY(casync);
82}
83
85{
86 return itsInputFrame->getCvGRAY();
87}
88
89cv::Mat jevois::InputFramePython::getCvBGR1(bool casync) const
90{
91 return itsInputFrame->getCvBGR(casync);
92}
93
95{
96 return itsInputFrame->getCvBGR();
97}
98
99cv::Mat jevois::InputFramePython::getCvRGB1(bool casync) const
100{
101 return itsInputFrame->getCvRGB(casync);
102}
103
105{
106 return itsInputFrame->getCvRGB();
107}
108
109cv::Mat jevois::InputFramePython::getCvRGBA1(bool casync) const
110{
111 return itsInputFrame->getCvRGBA(casync);
112}
113
115{
116 return itsInputFrame->getCvRGBA();
117}
118
120{
121 return itsInputFrame->getCvGRAYp();
122}
123
125{
126 return itsInputFrame->getCvBGRp();
127}
128
130{
131 return itsInputFrame->getCvRGBp();
132}
133
135{
136 return itsInputFrame->getCvRGBAp();
137}
138
139// ####################################################################################################
140// ####################################################################################################
141// ####################################################################################################
143{ if (itsOutputFrame == nullptr) LFATAL("Internal error"); }
144
146{
147 return itsOutputFrame->get();
148}
149
151{
152 itsOutputFrame->send();
153}
154
155void jevois::OutputFramePython::sendCv1(cv::Mat const & img, int quality) const
156{
157 itsOutputFrame->sendCv(img, quality);
158}
159
160void jevois::OutputFramePython::sendCv(cv::Mat const & img) const
161{
162 itsOutputFrame->sendCv(img);
163}
164
165void jevois::OutputFramePython::sendCvGRAY1(cv::Mat const & img, int quality) const
166{
167 itsOutputFrame->sendCvGRAY(img, quality);
168}
169
170void jevois::OutputFramePython::sendCvGRAY(cv::Mat const & img) const
171{
172 itsOutputFrame->sendCvGRAY(img);
173}
174
175void jevois::OutputFramePython::sendCvBGR1(cv::Mat const & img, int quality) const
176{
177 itsOutputFrame->sendCvBGR(img, quality);
178}
179
180void jevois::OutputFramePython::sendCvBGR(cv::Mat const & img) const
181{
182 itsOutputFrame->sendCvBGR(img);
183}
184
185void jevois::OutputFramePython::sendCvRGB1(cv::Mat const & img, int quality) const
186{
187 itsOutputFrame->sendCvRGB(img, quality);
188}
189
190void jevois::OutputFramePython::sendCvRGB(cv::Mat const & img) const
191{
192 itsOutputFrame->sendCvRGB(img);
193}
194
195void jevois::OutputFramePython::sendCvRGBA1(cv::Mat const & img, int quality) const
196{
197 itsOutputFrame->sendCvRGBA(img, quality);
198}
199
200void jevois::OutputFramePython::sendCvRGBA(cv::Mat const & img) const
201{
202 itsOutputFrame->sendCvRGBA(img);
203}
204
205void jevois::OutputFramePython::sendScaledCvGRAY1(cv::Mat const & img, int quality) const
206{
207 itsOutputFrame->sendScaledCvGRAY(img, quality);
208}
209
210void jevois::OutputFramePython::sendScaledCvGRAY(cv::Mat const & img) const
211{
212 itsOutputFrame->sendScaledCvGRAY(img);
213}
214
215void jevois::OutputFramePython::sendScaledCvBGR1(cv::Mat const & img, int quality) const
216{
217 itsOutputFrame->sendScaledCvBGR(img, quality);
218}
219
220void jevois::OutputFramePython::sendScaledCvBGR(cv::Mat const & img) const
221{
222 itsOutputFrame->sendScaledCvBGR(img);
223}
224
225void jevois::OutputFramePython::sendScaledCvRGB1(cv::Mat const & img, int quality) const
226{
227 itsOutputFrame->sendScaledCvRGB(img, quality);
228}
229
230void jevois::OutputFramePython::sendScaledCvRGB(cv::Mat const & img) const
231{
232 itsOutputFrame->sendScaledCvRGB(img);
233}
234
235void jevois::OutputFramePython::sendScaledCvRGBA1(cv::Mat const & img, int quality) const
236{
237 itsOutputFrame->sendScaledCvRGBA(img, quality);
238}
239
240void jevois::OutputFramePython::sendScaledCvRGBA(cv::Mat const & img) const
241{
242 itsOutputFrame->sendScaledCvRGBA(img);
243}
244
245// ####################################################################################################
246// ####################################################################################################
247// ####################################################################################################
248#ifdef JEVOIS_PRO
250{ if (itsGUIhelper == nullptr) LFATAL("Internal error"); }
251
252// ####################################################################################################
254{
255 unsigned short w, h;
256 bool idle = itsGUIhelper->startFrame(w, h);
257 return boost::python::make_tuple(idle, w, h);
258}
259
260// ####################################################################################################
262{
263 return itsGUIhelper->frameStarted();
264}
265
266// ####################################################################################################
267boost::python::tuple jevois::GUIhelperPython::drawImage(char const * name, RawImage const & img,
268 bool noalias, bool isoverlay)
269{
270 int x = 0, y = 0; unsigned short w = 0, h = 0;
271 itsGUIhelper->drawImage(name, img, x, y, w, h, noalias, isoverlay);
272 return boost::python::make_tuple(x, y, w, h);
273}
274
275// ####################################################################################################
276boost::python::tuple jevois::GUIhelperPython::drawImage1(char const * name, cv::Mat const & img, bool rgb,
277 bool noalias, bool isoverlay)
278{
279 int x = 0, y = 0; unsigned short w = 0, h = 0;
280 itsGUIhelper->drawImage(name, img, rgb, x, y, w, h, noalias, isoverlay);
281 return boost::python::make_tuple(x, y, w, h);
282}
283
284// ####################################################################################################
285boost::python::tuple jevois::GUIhelperPython::drawImage2(char const * name, RawImage const & img,
286 int x, int y, int w, int h, bool noalias, bool isoverlay)
287{
288 if (w < 0) LFATAL("w must be positive");
289 if (h < 0) LFATAL("h must be positive");
290 unsigned short ww = (unsigned short)(w); unsigned short hh = (unsigned short)(h);
291 itsGUIhelper->drawImage(name, img, x, y, ww, hh, noalias, isoverlay);
292 return boost::python::make_tuple(x, y, w, h);
293}
294
295// ####################################################################################################
296boost::python::tuple jevois::GUIhelperPython::drawImage3(char const * name, cv::Mat const & img, bool rgb,
297 int x, int y, int w, int h, bool noalias, bool isoverlay)
298{
299 if (w < 0) LFATAL("w must be positive");
300 if (h < 0) LFATAL("h must be positive");
301 unsigned short ww = (unsigned short)(w); unsigned short hh = (unsigned short)(h);
302 itsGUIhelper->drawImage(name, img, rgb, x, y, ww, hh, noalias, isoverlay);
303 return boost::python::make_tuple(x, y, w, h);
304}
305
306// ####################################################################################################
307boost::python::tuple jevois::GUIhelperPython::drawInputFrame(char const * name, InputFramePython const & frame,
308 bool noalias, bool casync)
309{
310 int x = 0, y = 0; unsigned short w = 0, h = 0;
311 itsGUIhelper->drawInputFrame(name, *frame.itsInputFrame, x, y, w, h, noalias, casync);
312 return boost::python::make_tuple(x, y, w, h);
313}
314
315// ####################################################################################################
316boost::python::tuple jevois::GUIhelperPython::drawInputFrame2(char const * name, InputFramePython const & frame,
317 bool noalias, bool casync)
318{
319 int x = 0, y = 0; unsigned short w = 0, h = 0;
320 itsGUIhelper->drawInputFrame(name, *frame.itsInputFrame, x, y, w, h, noalias, casync);
321 return boost::python::make_tuple(x, y, w, h);
322}
323
324// ####################################################################################################
325ImVec2 jevois::GUIhelperPython::i2d(ImVec2 p, char const * name)
326{
327 return itsGUIhelper->i2d(p, name);
328}
329
330// ####################################################################################################
331ImVec2 jevois::GUIhelperPython::i2d1(float x, float y, char const * name)
332{
333 return itsGUIhelper->i2d(x, y, name);
334}
335
336// ####################################################################################################
337ImVec2 jevois::GUIhelperPython::i2ds(ImVec2 p, char const * name)
338{
339 return itsGUIhelper->i2ds(p, name);
340}
341
342// ####################################################################################################
343ImVec2 jevois::GUIhelperPython::i2ds1(float x, float y, char const * name)
344{
345 return itsGUIhelper->i2ds(x, y, name);
346}
347
348// ####################################################################################################
349ImVec2 jevois::GUIhelperPython::d2i(ImVec2 p, char const * name)
350{
351 return itsGUIhelper->d2i(p, name);
352}
353
354// ####################################################################################################
355ImVec2 jevois::GUIhelperPython::d2i1(float x, float y, char const * name)
356{
357 return itsGUIhelper->d2i(x, y, name);
358}
359
360// ####################################################################################################
361ImVec2 jevois::GUIhelperPython::d2is(ImVec2 p, char const * name)
362{
363 return itsGUIhelper->d2is(p, name);
364}
365
366// ####################################################################################################
367ImVec2 jevois::GUIhelperPython::d2is1(float x, float y, char const * name)
368{
369 return itsGUIhelper->d2is(x, y, name);
370}
371
372// ####################################################################################################
373void jevois::GUIhelperPython::drawLine(float x1, float y1, float x2, float y2, ImU32 col)
374{
375 itsGUIhelper->drawLine(x1, y1, x2, y2, col);
376}
377
378// ####################################################################################################
379void jevois::GUIhelperPython::drawRect(float x1, float y1, float x2, float y2, ImU32 col, bool filled)
380{
381 itsGUIhelper->drawRect(x1, y1, x2, y2, col, filled);
382}
383
384// ####################################################################################################
385void jevois::GUIhelperPython::drawPoly(std::vector<cv::Point> const & pts, ImU32 col, bool filled)
386{
387 itsGUIhelper->drawPoly(pts, col, filled);
388}
389
390// ####################################################################################################
391void jevois::GUIhelperPython::drawPoly1(std::vector<cv::Point2f> const & pts, ImU32 col, bool filled)
392{
393 itsGUIhelper->drawPoly(pts, col, filled);
394}
395
396// ####################################################################################################
397void jevois::GUIhelperPython::drawPoly2(cv::Mat const & pts, ImU32 col, bool filled)
398{
399 itsGUIhelper->drawPoly(pts, col, filled);
400}
401
402// ####################################################################################################
403void jevois::GUIhelperPython::drawCircle(float x, float y, float r, ImU32 col, bool filled)
404{
405 itsGUIhelper->drawCircle(x, y, r, col, filled);
406}
407
408// ####################################################################################################
409void jevois::GUIhelperPython::drawText(float x, float y, char const * txt, ImU32 col)
410{
411 itsGUIhelper->drawText(x, y, txt, col);
412}
413
414// ####################################################################################################
415ImVec2 jevois::GUIhelperPython::iline(int line, char const * name)
416{
417 return itsGUIhelper->iline(line, name);
418}
419
420// ####################################################################################################
421void jevois::GUIhelperPython::itext(char const * txt, ImU32 const & col, int line)
422{
423 itsGUIhelper->itext(txt, col, line);
424}
425
426// ####################################################################################################
428{
429 itsGUIhelper->itext(txt, 0, -1);
430}
431
432// ####################################################################################################
433void jevois::GUIhelperPython::iinfo(jevois::InputFramePython const & inframe, std::string const & fpscpu,
434 unsigned short winw, unsigned short winh)
435{
436 itsGUIhelper->iinfo(*inframe.itsInputFrame, fpscpu, winw, winh);
437}
438
439// ####################################################################################################
441{
442 itsGUIhelper->releaseImage(name);
443}
444
445// ####################################################################################################
447{
448 itsGUIhelper->releaseImage2(name);
449}
450
451// ####################################################################################################
453{
454 itsGUIhelper->endFrame();
455}
456
457// ####################################################################################################
458void jevois::GUIhelperPython::reportError(std::string const & err)
459{
460 itsGUIhelper->reportError(err);
461}
462
463// ####################################################################################################
465{
466 itsGUIhelper->reportAndIgnoreException(prefix);
467}
468
469// ####################################################################################################
471{
472 itsGUIhelper->reportAndRethrowException(prefix);
473}
474
475// ####################################################################################################
477{ return ImGui::GetMousePos(); }
478
479// ####################################################################################################
481{ return ImGui::IsMouseClicked(button_num); }
482
483// ####################################################################################################
485{ return ImGui::IsMouseDoubleClicked(button_num); }
486
487// ####################################################################################################
489{ return ImGui::IsMouseDragging(button_num); }
490
491// ####################################################################################################
493{ return ImGui::IsMouseDown(button_num); }
494
495// ####################################################################################################
497{ return ImGui::IsMouseReleased(button_num); }
498
499#endif // JEVOIS_PRO
500
501// ####################################################################################################
502// ####################################################################################################
503// ####################################################################################################
505 jevois::Module(m.modulename), itsPyPath(m.sopath())
506{
507 if (m.ispython == false) LFATAL("Passed video mapping is not for a python module");
508}
509
510// ####################################################################################################
512{
513 // Load the python code and instantiate the python class:
514 PythonWrapper::pythonload(itsPyPath);
515
516 // Call python module's init() function if implemented:
518}
519
520// ####################################################################################################
522{
523 // Call python module's uninit() function if implemented:
524 if (jevois::python::hasattr(PythonWrapper::pyinst(), "uninit")) PythonWrapper::pyinst().attr("uninit")();
525}
526
527// ####################################################################################################
530
531// ####################################################################################################
533{
534 jevois::InputFramePython inframepy(&inframe);
535 jevois::OutputFramePython outframepy(&outframe);
536 PythonWrapper::pyinst().attr("process")(boost::ref(inframepy), boost::ref(outframepy));
537}
538
539// ####################################################################################################
541{
542 jevois::InputFramePython inframepy(&inframe);
543 PythonWrapper::pyinst().attr("processNoUSB")(boost::ref(inframepy));
544}
545
546#ifdef JEVOIS_PRO
547
548// ####################################################################################################
550{
551 jevois::InputFramePython inframepy(&inframe);
552 jevois::GUIhelperPython helperpy(&helper);
553 PythonWrapper::pyinst().attr("processGUI")(boost::ref(inframepy), boost::ref(helperpy));
554}
555
556#endif
557
558// ####################################################################################################
559void jevois::PythonModule::parseSerial(std::string const & str, std::shared_ptr<UserInterface> s)
560{
562 {
563 boost::python::object ret = PythonWrapper::pyinst().attr("parseSerial")(str);
564 std::string retstr = boost::python::extract<std::string>(ret);
565 if (retstr.empty() == false) s->writeString(retstr);
566 }
567 else jevois::Module::parseSerial(str, s);
568}
569
570// ####################################################################################################
572{
573 if (jevois::python::hasattr(PythonWrapper::pyinst(), "supportedCommands"))
574 {
575 boost::python::object ret = PythonWrapper::pyinst().attr("supportedCommands")();
576 std::string retstr = boost::python::extract<std::string>(ret);
577 if (retstr.empty() == false) os << retstr;
579}
580
581// ####################################################################################################
582// ####################################################################################################
583// ####################################################################################################
584jevois::dnn::PreProcessorForPython::PreProcessorForPython(PreProcessor * pp) : itsPP(pp)
585{ }
586
587boost::python::tuple jevois::dnn::PreProcessorForPython::imagesize() const
588{
589 cv::Size const s = itsPP->imagesize();
590 return boost::python::make_tuple(s.width, s.height);
591}
592
593boost::python::list jevois::dnn::PreProcessorForPython::blobs() const
594{
595 return jevois::python::pyVecToList(itsPP->blobs());
596}
597
598boost::python::tuple jevois::dnn::PreProcessorForPython::blobsize(size_t num) const
599{
600 cv::Size s = itsPP->blobsize(num);
601 return boost::python::make_tuple(s.width, s.height);
602}
603
604boost::python::tuple jevois::dnn::PreProcessorForPython::b2i(float x, float y, size_t blobnum)
605{
606 float px = x, py = y;
607 itsPP->b2i(px, py, blobnum);
608 return boost::python::make_tuple(px, py);
609}
610
611boost::python::tuple jevois::dnn::PreProcessorForPython::getUnscaledCropRect(size_t blobnum)
612{
613 cv::Rect const r = itsPP->getUnscaledCropRect(blobnum);
614 return boost::python::make_tuple(r.x, r.y, r.width, r.height);
615}
616
617boost::python::tuple jevois::dnn::PreProcessorForPython::i2b(float x, float y, size_t blobnum)
618{
619 float px = x, py = y;
620 itsPP->i2b(px, py, blobnum);
621 return boost::python::make_tuple(px, py);
622}
623
624
625// ####################################################################################################
626// ####################################################################################################
627// ####################################################################################################
628jevois::dnn::PostProcessorDetectYOLOforPython::PostProcessorDetectYOLOforPython()
629{
630 // We need to add our sub under an existing "pypost" sub of our module. The hierarchy typically is:
631 // DNN->pipeline->postproc->pypost
632 std::shared_ptr<Module> m = jevois::python::engine()->module();
633 if (!m) LFATAL("Cannot instantiate without a current running module");
634 std::shared_ptr<Component> pi = m->getSubComponent("pipeline");
635 if (!pi) LFATAL("Cannot instantiate without a current DNN pipeline");
636 std::shared_ptr<Component> pp = pi->getSubComponent("postproc");
637 if (!pp) LFATAL("Cannot instantiate without a current python-type post-processor");
638 std::shared_ptr<Component> ppp = pp->getSubComponent("pypost");
639 if (!ppp) LFATAL("Cannot instantiate without a current pypost post-processor");
640 itsYOLO = ppp->addSubComponent<PostProcessorDetectYOLO>("yolo");
641}
642
643jevois::dnn::PostProcessorDetectYOLOforPython::~PostProcessorDetectYOLOforPython()
644{ }
645
646void jevois::dnn::PostProcessorDetectYOLOforPython::freeze(bool doit)
647{ itsYOLO->freeze(doit); }
648
649boost::python::tuple
650jevois::dnn::PostProcessorDetectYOLOforPython::yolo(boost::python::list outs, int nclass,
651 float boxThreshold, float confThreshold,
652 int bw, int bh, int fudge, int maxbox)
653{
654 std::vector<cv::Mat> const outvec = jevois::python::pyListToVec<cv::Mat>(outs);
655
656 std::vector<int> classIds;
657 std::vector<float> confidences;
658 std::vector<cv::Rect> boxes;
659
660 itsYOLO->yolo(outvec, classIds, confidences, boxes, nclass, boxThreshold, confThreshold,
661 cv::Size(bw, bh), fudge, maxbox);
662
663 boost::python::list ids = jevois::python::pyVecToList(classIds);
664 boost::python::list conf = jevois::python::pyVecToList(confidences);
665 boost::python::list b;
666 for (cv::Rect const & r : boxes) b.append(boost::python::make_tuple(r.x, r.y, r.width, r.height));
667
668 return boost::python::make_tuple(ids, conf, b);
669}
670
int h
Definition GUIhelper.C:2491
Wrapper around GUIhelper to be used by Python.
void itext2(char const *txt)
Draw some overlay text on top of an image, default color and line.
void iinfo(jevois::InputFramePython const &inframe, std::string const &fpscpu, unsigned short winw=0, unsigned short winh=0)
Display processing and video info at bottom of screen.
ImVec2 getMousePos()
ImGui helper: get mouse position.
void reportError(std::string const &err)
Report an error in an overlay window.
GUIhelperPython(GUIhelper *src)
Construct from a regular GUIhelper that should be be coming from Engine.
void releaseImage(char const *name)
Release an image.
ImVec2 d2is1(float x, float y, char const *name=nullptr)
Convert a 2D size from on-screen to within a rendered image.
void reportAndRethrowException(std::string const &prefix="")
Report current exception in a modal dialog, then re-throw it.
ImVec2 d2is(ImVec2 p, char const *name=nullptr)
Convert a 2D size from on-screen to within a rendered image.
ImVec2 d2i(ImVec2 p, char const *name=nullptr)
Convert coordinates of a point from on-screen to within a rendered image.
void reportAndIgnoreException(std::string const &prefix="")
Report current exception in a modal dialog, then ignore it.
void drawCircle(float x, float y, float r, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw circle over an image.
ImVec2 d2i1(float x, float y, char const *name=nullptr)
Convert coordinates of a point from on-screen to within a rendered image.
boost::python::tuple drawInputFrame2(char const *name, InputFramePython const &frame, bool noalias=false, bool casync=false)
Draw the second (scaled) input video frame from the camera using zero-copy.
void drawPoly2(cv::Mat const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw polygon over an image.
void drawPoly1(std::vector< cv::Point2f > const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw polygon over an image.
ImVec2 i2d1(float x, float y, char const *name=nullptr)
Convert coordinates of a point from within a rendered image to on-screen.
void drawPoly(std::vector< cv::Point > const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw polygon over an image.
void endFrame()
Finish current frame and render it.
bool isMouseDown(int button_num)
ImGui helper: check if mouse button pressed.
ImVec2 iline(int line=-1, char const *name=nullptr)
Get coordinates of the start of a given line of text to be drawn as overlay on top of an image.
void drawText(float x, float y, char const *txt, ImU32 col=IM_COL32(128, 255, 128, 255))
Draw text over an image.
boost::python::tuple drawImage(char const *name, RawImage const &img, bool noalias=false, bool isoverlay=false)
Draw a RawImage, copying pixel data to an OpenGL texture.
boost::python::tuple drawImage3(char const *name, cv::Mat const &img, bool rgb, int x, int y, int w, int h, bool noalias=false, bool isoverlay=false)
Draw an OpenCV image, copying pixel data to an OpenGL texture.
ImVec2 i2d(ImVec2 p, char const *name=nullptr)
Convert coordinates of a point from within a rendered image to on-screen.
void releaseImage2(char const *name)
Release an image, second video stream.
bool isMouseReleased(int button_num)
ImGui helper: check if mouse button released.
boost::python::tuple drawImage1(char const *name, cv::Mat const &img, bool rgb, bool noalias=false, bool isoverlay=false)
Draw an OpenCV image, copying pixel data to an OpenGL texture.
ImVec2 i2ds1(float x, float y, char const *name=nullptr)
Convert a 2D size from within a rendered image to on-screen.
bool frameStarted() const
Helper to indicate that startFrame() was called, and thus endFrame() should be called.
ImVec2 i2ds(ImVec2 p, char const *name=nullptr)
Convert a 2D size from within a rendered image to on-screen.
void itext(char const *txt, ImU32 const &col=IM_COL32_BLACK_TRANS, int line=-1)
Draw some overlay text on top of an image.
bool isMouseDragging(int button_num)
ImGui helper: check if mouse button dragged.
bool isMouseClicked(int button_num)
ImGui helper: check if mouse button clicked.
void drawRect(float x1, float y1, float x2, float y2, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw rectangular box over an image.
boost::python::tuple startFrame()
Start a new rendering frame.
void drawLine(float x1, float y1, float x2, float y2, ImU32 col=IM_COL32(128, 255, 128, 255))
Draw line over an image.
boost::python::tuple drawImage2(char const *name, RawImage const &img, int x, int y, int w, int h, bool noalias=false, bool isoverlay=false)
Draw an OpenCV image, copying pixel data to an OpenGL texture.
boost::python::tuple drawInputFrame(char const *name, InputFramePython const &frame, bool noalias=false, bool casync=false)
Draw the input video frame from the camera using zero-copy.
bool isMouseDoubleClicked(int button_num)
ImGui helper: check if mouse button double-clicked.
Helper class to assist modules in creating graphical and GUI elements.
Definition GUIhelper.H:133
Wrapper around InputFrame to be used by Python.
RawImage const & getp() const
Get the next captured camera image that is intended for processing.
cv::Mat getCvGRAYp() const
Shorthand to get the input image for processing as a GRAY cv::Mat and release the raw buffer.
cv::Mat getCvRGBA() const
Shorthand to get the input image as a RGBA cv::Mat and release the raw buffer.
RawImage const & get2() const
Get the next captured camera image, ISP-scaled second frame.
RawImage const & get1(bool casync) const
Get the next captured camera image, thin wrapper for default arg value.
cv::Mat getCvRGBA1(bool casync) const
Shorthand to get the input image as a RGBA cv::Mat and release the raw buffer.
cv::Mat getCvRGBp() const
Shorthand to get the input image for processing as a RGB cv::Mat and release the raw buffer.
InputFramePython()=default
Default constructor to keep boost::python happy, object is not operational.
cv::Mat getCvRGBAp() const
Shorthand to get the input image for processing as a RGBA cv::Mat and release the raw buffer.
cv::Mat getCvBGR() const
Shorthand to get the input image as a BGR cv::Mat and release the raw buffer.
RawImage const & get() const
Get the next captured camera image, thin wrapper for default arg value.
cv::Mat getCvBGR1(bool casync) const
Shorthand to get the input image as a BGR cv::Mat and release the raw buffer.
cv::Mat getCvBGRp() const
Shorthand to get the input image for processing as a BGR cv::Mat and release the raw buffer.
cv::Mat getCvRGB() const
Shorthand to get the input image as a RGB cv::Mat and release the raw buffer.
RawImage const & get21(bool casync) const
Get the next captured camera image, ISP-scaled second frame.
void done() const
Indicate that user processing is done with the image previously obtained via get()
cv::Mat getCvGRAY1(bool casync) const
Shorthand to get the input image as a GRAY cv::Mat and release the raw buffer.
RawImage const & getp1(bool casync) const
Get the next captured camera image that is intended for processing.
cv::Mat getCvRGB1(bool casync) const
Shorthand to get the input image as a RGB cv::Mat and release the raw buffer.
void done2() const
Indicate that user processing is done with the ISP-scaled image previously obtained via get2()
bool hasScaledImage() const
Check whether a second input image scaled by the JeVoisPro Platform ISP is available.
cv::Mat getCvGRAY() const
Shorthand to get the input image as a GRAY cv::Mat and release the raw buffer.
Exception-safe wrapper around a raw camera input frame.
Definition InputFrame.H:51
Virtual base class for a vision processing module.
Definition Module.H:105
virtual void supportedCommands(std::ostream &os)
Human-readable description of this Module's supported custom commands.
Definition Module.C:67
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
Wrapper around OutputFrame to be used by Python.
void sendScaledCvRGBA1(cv::Mat const &img, int quality) const
Shorthand to send a RGBA cv::Mat after scaling/converting it to the current output format.
void sendScaledCvBGR1(cv::Mat const &img, int quality) const
Shorthand to send a BGR cv::Mat after scaling/converting it to the current output format.
void sendScaledCvGRAY1(cv::Mat const &img, int quality) const
Shorthand to send a GRAY cv::Mat after scaling/converting it to the current output format.
RawImage const & get() const
Get the next captured camera image.
void sendCvRGB1(cv::Mat const &img, int quality) const
Shorthand to send a RGB cv::Mat after converting it to the current output format.
void sendScaledCvRGB1(cv::Mat const &img, int quality) const
Shorthand to send a RGB cv::Mat after scaling/converting it to the current output format.
void send() const
Indicate that user processing is done with the image previously obtained via get()
void sendScaledCvBGR(cv::Mat const &img) const
Shorthand to send a BGR cv::Mat after scaling/converting it to the current output format.
void sendCvGRAY1(cv::Mat const &img, int quality) const
Shorthand to send a GRAY cv::Mat after converting it to the current output format.
void sendCvBGR1(cv::Mat const &img, int quality) const
Shorthand to send a BGR cv::Mat after converting it to the current output format.
OutputFramePython()=default
Default constructor to keep boost::python happy, object is not operational.
void sendCvBGR(cv::Mat const &img) const
Shorthand to send a BGR cv::Mat after converting it to the current output format.
void sendScaledCvRGB(cv::Mat const &img) const
Shorthand to send a RGB cv::Mat after scaling/converting it to the current output format.
void sendScaledCvRGBA(cv::Mat const &img) const
Shorthand to send a RGBA cv::Mat after scaling/converting it to the current output format.
void sendCv1(cv::Mat const &img, int quality) const
Shorthand to send a cv::Mat after scaling/converting it to the current output format.
void sendCvRGB(cv::Mat const &img) const
Shorthand to send a RGB cv::Mat after converting it to the current output format.
void sendScaledCvGRAY(cv::Mat const &img) const
Shorthand to send a GRAY cv::Mat after scaling/converting it to the current output format.
void sendCvRGBA(cv::Mat const &img) const
Shorthand to send a RGBA cv::Mat after converting it to the current output format.
void sendCv(cv::Mat const &img) const
Shorthand to send a cv::Mat after scaling/converting it to the current output format.
void sendCvRGBA1(cv::Mat const &img, int quality) const
Shorthand to send a RGBA cv::Mat after converting it to the current output format.
void sendCvGRAY(cv::Mat const &img) const
Shorthand to send a GRAY cv::Mat after converting it to the current output format.
Exception-safe wrapper around a raw image to be sent over USB.
Definition OutputFrame.H:53
virtual void process(InputFrame &&inframe, OutputFrame &&outframe) override
Processing function, version that receives a frame from camera and sends a frame out over USB.
PythonModule(VideoMapping const &m)
Constructor needs the full path to a Python source code file.
virtual void supportedCommands(std::ostream &os) override
Human-readable description of this Module's supported custom commands.
void postUninit() override
Optionally call uninit() python module function, if implemented.
virtual void parseSerial(std::string const &str, std::shared_ptr< UserInterface > s) override
Receive a string from a serial port which contains a user command.
void preInit() override
Load python code and optionally call init() python module function, if implemented.
virtual ~PythonModule()
Virtual destructor for safe inheritance.
void pythonload(std::string const &path)
Init from path if default constructor was used.
boost::python::object & pyinst()
Get the python class pyinst, or throw if construction error occurred (e.g., file not found)
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
Definition RawImage.H:111
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level.
Definition Log.H:230
boost::python::list pyVecToList(std::vector< T > const &v)
Helper to convert std::vector<T> to python list.
bool hasattr(boost::python::object &o, char const *name)
Check whether a boost::python::object has an attribute.
Main namespace for all JeVois classes and functions.
Definition Concepts.dox:2
Simple struct to hold video mapping definitions for the processing Engine.
bool ispython
True if the module is written in Python; affects behavior of sopath() only.