44#include <opencv2/core/utils/filesystem.hpp>
60 void set(cv::FileNode
const & item, std::string
const & zf, cv::FileNode
const & node)
62 std::string k = item.name();
66 case cv::FileNode::INT: v = std::to_string((
int)item);
break;
67 case cv::FileNode::REAL: v = std::to_string((
float)item);
break;
68 case cv::FileNode::STRING: v = (std::string)item;
break;
71 LFATAL(
"Invalid global zoo parameter " << k <<
" type " << item.type() <<
" in " << zf);
73 LFATAL(
"Invalid zoo parameter " << k <<
" type " << item.type() <<
" in " << zf <<
" node " << node.name());
77 for (
auto & p : params) if (p.first == k) { p.second = v;
return; }
78 params.emplace_back(std::make_pair(k, v));
83 std::string pget(cv::FileNode & item, std::string
const & subname)
85 std::string
const v = (std::string)item[subname];
86 if (v.empty() ==
false)
return v;
87 for (
auto const & p : params) if (p.first == subname) return p.second;
93 void unset(std::string
const & name)
95 for (
auto itr = params.begin(); itr != params.end(); ++itr)
96 if (itr->first == name) { params.erase(itr);
return; }
100 std::vector<std::pair<std::string , std::string >> params;
106 jevois::
Component(instance), itsTpre(
"PreProc"), itsTnet(
"Network"), itsTpost(
"PstProc")
112 itsAccelerators[
"OpenCV"] = 1;
113 itsAccelerators[
"ORT"] = 1;
114 itsAccelerators[
"Python"] = 1;
115#ifdef JEVOIS_PLATFORM_PRO
116 itsAccelerators[
"VPUX"] = 1;
118 itsAccelerators[
"NPUX"] = 1;
121 itsAccelerators[
"NPU"] <<
" JeVois-Pro NPUs, " <<
122 itsAccelerators[
"SPU"] <<
" Hailo8 SPUs, " <<
123 itsAccelerators[
"TPU"] <<
" Coral TPUs, " <<
124 itsAccelerators[
"VPU"] <<
" Myriad-X VPUs.");
130 preproc::freeze(doit);
131 nettype::freeze(doit);
132 postproc::freeze(doit);
134 if (itsPreProcessor) itsPreProcessor->freeze(doit);
135 if (itsNetwork) itsNetwork->freeze(doit);
136 if (itsPostProcessor) itsPostProcessor->freeze(doit);
164 if (itsNetFut.valid())
167 if (itsNetFut.wait_for(std::chrono::seconds(5)) == std::future_status::timeout)
168 LERROR(
"Still waiting for network to finish running...");
172 try { itsNetFut.get(); }
catch (...) { }
182 if (val != filter::get()) itsZooChanged =
true;
190 if (val.empty() ==
false && val != zooroot::get()) itsZooChanged =
true;
198 statsfile::set(
"benchmark.html");
199 statsfile::freeze(
true);
203 statsfile::freeze(
false);
212 itsPreProcessor.reset();
214 itsPostProcessor.reset();
218 std::vector<std::string> pipes;
220 LINFO(
"Found a total of " << pipes.size() <<
" valid pipelines.");
224 "by the current filter",
225 pipes[0], pipes, jevois::dnn::pipeline::ParamCateg);
226 pipe::changeParameterDef(newdef);
232 itsZooChanged =
false;
236void jevois::dnn::Pipeline::scanZoo(std::filesystem::path
const & zoofile, std::string
const & filt,
237 std::vector<std::string> & pipes, std::string
const & indent)
239 LINFO(indent <<
"Scanning model zoo file " << zoofile <<
" with filter [" << filt <<
"]...");
240 int ntot = 0, ngood = 0;
242 bool has_vpu =
false;
243 auto itr = itsAccelerators.find(
"VPU");
244 if (itr != itsAccelerators.end() && itr->second > 0) has_vpu =
true;
247 cv::FileStorage fs(zoofile, cv::FileStorage::READ);
248 if (fs.isOpened() ==
false)
LFATAL(
"Could not open zoo file " << zoofile);
249 cv::FileNode fn = fs.root();
252 for (cv::FileNodeIterator fit = fn.begin(); fit != fn.end(); ++fit)
254 cv::FileNode item = *fit;
257 if (item.name() ==
"include")
262 else if (item.name() ==
"includedir")
265 for (
auto const & dent : std::filesystem::recursive_directory_iterator(dir))
266 if (dent.is_regular_file())
268 std::filesystem::path
const path = dent.path();
269 std::filesystem::path
const ext = path.extension();
270 if (ext ==
".yml" || ext ==
".yaml") scanZoo(path, filt, pipes, indent +
" ");
274 else if (item.name() ==
"unset")
276 ph.unset((std::string)item);
279 else if (! item.isMap())
281 ph.set(item, zoofile, item);
293 std::string typ = ph.pget(item,
"nettype");
297 std::string backend = ph.pget(item,
"backend");
298 std::string target = ph.pget(item,
"target");
300 if (backend ==
"InferenceEngine")
302 if (target ==
"Myriad")
304 if (has_vpu) typ =
"VPU";
305#ifdef JEVOIS_PLATFORM_PRO
311 else if (target ==
"CPU") typ =
"VPUX";
313 else if (backend ==
"TimVX" && target ==
"NPU") typ =
"NPUX";
317 bool has_accel =
false;
318 itr = itsAccelerators.find(typ);
319 if (itr != itsAccelerators.end() && itr->second > 0) has_accel =
true;
322 if ((filt ==
"All" || typ == filt) && has_accel)
324 std::string
const postproc = ph.pget(item,
"postproc");
325 pipes.emplace_back(typ +
':' + postproc +
':' + item.name());
331 LINFO(indent <<
"Found " << ntot <<
" pipelines, " << ngood <<
" passed the filter.");
339 itsShowDataPeek =
false;
340 itsDataPeekOutIdx = 0;
341 itsDataPeekFreeze =
false;
342 itsDataPeekStr.clear();
345 if (val.empty())
return;
346 itsPipeThrew =
false;
355 if (selectPipe(z, tok) ==
false)
356 LFATAL(
"Could not find pipeline entry [" << val <<
"] in zoo file " << z <<
" and its includes");
362bool jevois::dnn::Pipeline::selectPipe(std::string
const & zoofile, std::vector<std::string>
const & tok)
365 processing::freeze(
false);
366 processing::set(jevois::dnn::pipeline::Processing::Async);
369 bool has_vpu =
false;
370 auto itr = itsAccelerators.find(
"VPU");
371 if (itr != itsAccelerators.end() && itr->second > 0) has_vpu =
true;
372 bool vpu_emu =
false;
375 itsPreStats.clear(); itsNetStats.clear(); itsPstStats.clear();
376 itsStatsWarmup =
true;
379 cv::FileStorage fs(zoofile, cv::FileStorage::READ);
380 if (fs.isOpened() ==
false)
LFATAL(
"Could not open zoo file " << zoofile);
384 cv::FileNode fn = fs.root(), node;
386 for (cv::FileNodeIterator fit = fn.begin(); fit != fn.end(); ++fit)
388 cv::FileNode item = *fit;
391 if (item.name() ==
"include")
397 else if (item.name() ==
"includedir")
400 for (
auto const & dent : std::filesystem::recursive_directory_iterator(dir))
401 if (dent.is_regular_file())
403 std::filesystem::path
const path = dent.path();
404 std::filesystem::path
const ext = path.extension();
405 if (ext ==
".yml" || ext ==
".yaml")
if (selectPipe(path, tok))
return true;
410 else if (item.name() ==
"unset")
412 ph.unset((std::string)item);
415 else if (! item.isMap())
417 ph.set(item, zoofile, node);
422 if (item.name() != tok.back())
continue;
423 if (tok.size() == 1) { node = item;
break; }
427 std::string postproc = ph.pget(item,
"postproc");
428 if (postproc != tok[1] && postproc::strget() != tok[1])
continue;
430 std::string nettype = ph.pget(item,
"nettype");
431 std::string backend = ph.pget(item,
"backend");
432 std::string target = ph.pget(item,
"target");
436 if (nettype ==
"OpenCV" && backend ==
"InferenceEngine" && target ==
"Myriad")
437 { node = item;
break; }
439 else if (tok[0] ==
"VPUX")
441 if (nettype ==
"OpenCV" && backend ==
"InferenceEngine")
443 if (target ==
"Myriad" && has_vpu ==
false) { vpu_emu =
true; node = item;
break; }
444 else if (target ==
"CPU") { node = item;
break; }
447 else if (tok[0] ==
"NPUX")
449 if (nettype ==
"OpenCV" && backend ==
"TimVX" && target ==
"NPU")
450 { node = item;
break; }
454 if (nettype == tok[0])
455 { node = item;
break; }
461 if (node.empty())
return false;
465 itsPreProcessor.reset(); removeSubComponent(
"preproc",
false);
466 itsNetwork.reset(); removeSubComponent(
"network",
false);
467 itsPostProcessor.reset(); removeSubComponent(
"postproc",
false);
474 for (cv::FileNodeIterator fit = node.begin(); fit != node.end(); ++fit)
475 ph.set(*fit, zoofile, node);
477 for (
auto const & pp : ph.params)
479 if (vpu_emu && pp.first ==
"target") setZooParam(pp.first,
"CPU", zoofile, node);
480 else setZooParam(pp.first, pp.second, zoofile, node);
489 if (processing::get() != jevois::dnn::pipeline::Processing::Sync)
491 LERROR(
"Network of type Python cannot run Async if pre- or post- processor are also Python "
492 "-- FORCING Sync processing");
493 processing::set(jevois::dnn::pipeline::Processing::Sync);
495 processing::freeze(
true);
502void jevois::dnn::Pipeline::setZooParam(std::string
const & k, std::string
const & v,
503 std::string
const & zf, cv::FileNode
const & node)
507 bool hasparam =
false;
508 try { getParamStringUnique(k); hasparam =
true; }
catch (...) { }
512 LINFO(
"Setting ["<<k<<
"] to ["<<v<<
']');
514 try { setParamStringUnique(k, v); }
515 catch (std::exception
const & e)
516 {
LFATAL(
"While parsing [" << node.name() <<
"] in model zoo file " << zf <<
": " << e.what()); }
518 {
LFATAL(
"While parsing [" << node.name() <<
"] in model zoo file " << zf <<
": unknown error"); }
520 else if (paramwarn::get())
521 engine()->
reportError(
"WARNING: Unused parameter [" + k +
"] in " + zf +
" node [" + node.name() +
"]");
527 itsPreProcessor.reset(); removeSubComponent(
"preproc",
false);
531 case jevois::dnn::pipeline::PreProc::Blob:
532 itsPreProcessor = addSubComponent<jevois::dnn::PreProcessorBlob>(
"preproc");
535 case jevois::dnn::pipeline::PreProc::Python:
536 itsPreProcessor = addSubComponent<jevois::dnn::PreProcessorPython>(
"preproc");
540 if (itsPreProcessor)
LINFO(
"Instantiated pre-processor of type " << itsPreProcessor->className());
541 else LINFO(
"No pre-processor");
549 itsNetwork.reset(); removeSubComponent(
"network",
false);
553 case jevois::dnn::pipeline::NetType::OpenCV:
554 itsNetwork = addSubComponent<jevois::dnn::NetworkOpenCV>(
"network");
559 case jevois::dnn::pipeline::NetType::ORT:
560 itsNetwork = addSubComponent<jevois::dnn::NetworkONNX>(
"network");
563 case jevois::dnn::pipeline::NetType::NPU:
564#ifdef JEVOIS_PLATFORM
565 itsNetwork = addSubComponent<jevois::dnn::NetworkNPU>(
"network");
567 LFATAL(
"NPU network is only supported on JeVois-Pro Platform");
571 case jevois::dnn::pipeline::NetType::SPU:
572 itsNetwork = addSubComponent<jevois::dnn::NetworkHailo>(
"network");
575 case jevois::dnn::pipeline::NetType::TPU:
576 itsNetwork = addSubComponent<jevois::dnn::NetworkTPU>(
"network");
580 case jevois::dnn::pipeline::NetType::Python:
581 itsNetwork = addSubComponent<jevois::dnn::NetworkPython>(
"network");
585 if (itsNetwork)
LINFO(
"Instantiated network of type " << itsNetwork->className());
586 else LINFO(
"No network");
591 itsInputAttrs.clear();
593 itsNetInfo.emplace_back(
"* Input Tensors");
594 itsNetInfo.emplace_back(
"Initializing network...");
595 itsNetInfo.emplace_back(
"* Network");
596 itsNetInfo.emplace_back(
"Initializing network...");
597 itsNetInfo.emplace_back(
"* Output Tensors");
598 itsNetInfo.emplace_back(
"Initializing network...");
599 itsAsyncNetInfo = itsNetInfo;
600 itsAsyncNetworkTime =
"Network: -";
601 itsAsyncNetworkSecs = 0.0;
609 itsPostProcessor.reset(); removeSubComponent(
"postproc",
false);
613 case jevois::dnn::pipeline::PostProc::Classify:
614 itsPostProcessor = addSubComponent<jevois::dnn::PostProcessorClassify>(
"postproc");
616 case jevois::dnn::pipeline::PostProc::Detect:
617 itsPostProcessor = addSubComponent<jevois::dnn::PostProcessorDetect>(
"postproc");
619 case jevois::dnn::pipeline::PostProc::Segment:
620 itsPostProcessor = addSubComponent<jevois::dnn::PostProcessorSegment>(
"postproc");
622 case jevois::dnn::pipeline::PostProc::YuNet:
623 itsPostProcessor = addSubComponent<jevois::dnn::PostProcessorYuNet>(
"postproc");
625 case jevois::dnn::pipeline::PostProc::Python:
626 itsPostProcessor = addSubComponent<jevois::dnn::PostProcessorPython>(
"postproc");
628 case jevois::dnn::pipeline::PostProc::Stub:
629 itsPostProcessor = addSubComponent<jevois::dnn::PostProcessorStub>(
"postproc");
633 if (itsPostProcessor)
LINFO(
"Instantiated post-processor of type " << itsPostProcessor->className());
634 else LINFO(
"No post-processor");
640 return itsPreProcessor && itsNetwork && itsNetwork->ready() && itsPostProcessor;
646 if (itsNetFut.valid() && itsNetFut.wait_for(std::chrono::milliseconds(2)) == std::future_status::ready)
648 itsOuts = itsNetFut.get();
650 std::swap(itsNetInfo, itsAsyncNetInfo);
651 itsProcTimes[1] = itsAsyncNetworkTime;
652 itsProcSecs[1] = itsAsyncNetworkSecs;
663 if (itsZooChanged) zoo::set(zoo::get());
667 if (itsPipeThrew)
return;
669 bool const ovl = overlay::get();
671 bool refresh_data_peek =
false;
675 if (helper && idle ==
false)
678 ImGui::SetNextWindowPos(ImVec2(24, 159), ImGuiCond_FirstUseEver);
679 ImGui::SetNextWindowSize(ImVec2(464, 877), ImGuiCond_FirstUseEver);
682 ImGui::Begin((instanceName() +
':' + getParamStringUnique(
"pipe")).c_str());
699 if (helper) helper->
itext(instanceName() +
':' + getParamStringUnique(
"pipe"));
707 if (ready() ==
false)
709 char const * msg = itsNetwork ?
"Loading network..." :
"No network selected...";
720 if (idle ==
false) ImGui::TextUnformatted(msg);
721 if (ovl) helper->
itext(msg);
725 itsProcTimes = {
"PreProc: -",
"Network: -",
"PstProc: -" };
726 itsProcSecs = { 0.0, 0.0, 0.0 };
731 switch (processing::get())
734 case jevois::dnn::pipeline::Processing::Sync:
740 if (itsInputAttrs.empty()) itsInputAttrs = itsNetwork->inputShapes();
741 itsBlobs = itsPreProcessor->process(inimg, itsInputAttrs);
742 itsProcTimes[0] = itsTpre.stop(&itsProcSecs[0]);
743 itsPreProcessor->sendreport(mod, outimg, helper, ovl, idle);
748 itsOuts = itsNetwork->process(itsBlobs, itsNetInfo);
749 itsProcTimes[1] = itsTnet.stop(&itsProcSecs[1]);
752 showInfo(itsNetInfo, mod, outimg, helper, ovl, idle);
756 itsPostProcessor->process(itsOuts, itsPreProcessor.get());
757 itsProcTimes[2] = itsTpost.stop(&itsProcSecs[2]);
758 itsPostProcessor->report(mod, outimg, helper, ovl, idle);
759 refresh_data_peek =
true;
764 case jevois::dnn::pipeline::Processing::Async:
771 bool needpost = checkAsyncNetComplete();
774 if (itsNetFut.valid() ==
false)
778 if (itsInputAttrs.empty()) itsInputAttrs = itsNetwork->inputShapes();
779 itsBlobs = itsPreProcessor->process(inimg, itsInputAttrs);
780 itsProcTimes[0] = itsTpre.stop(&itsProcSecs[0]);
787 std::vector<cv::Mat> outs = itsNetwork->process(itsBlobs, itsAsyncNetInfo);
788 itsAsyncNetworkTime = itsTnet.stop(&itsAsyncNetworkSecs);
795 std::vector<cv::Mat> outscopy;
796 for (cv::Mat
const & m : outs) outscopy.emplace_back(m.clone());
802 itsPreProcessor->sendreport(mod, outimg, helper, ovl, idle);
805 showInfo(itsNetInfo, mod, outimg, helper, ovl, idle);
808 if (needpost && itsOuts.empty() ==
false)
811 itsPostProcessor->process(itsOuts, itsPreProcessor.get());
812 itsProcTimes[2] = itsTpost.stop(&itsProcSecs[2]);
813 refresh_data_peek =
true;
817 itsPostProcessor->report(mod, outimg, helper, ovl, idle);
823 itsSecsSum += itsProcSecs[0] + itsProcSecs[1] + itsProcSecs[2];
824 if (++itsSecsSumNum == 20) { itsSecsAvg = itsSecsSum / itsSecsSumNum; itsSecsSum = 0.0; itsSecsSumNum = 0; }
827 if (statsfile::get().empty() ==
false && itsOuts.empty() ==
false)
829 static std::vector<std::string> pipelines;
830 static bool statswritten =
false;
831 static size_t benchpipe = 0;
833 if (benchmark::get())
835 if (pipelines.empty())
839 std::string pipes = pipe::def().validValuesString();
840 size_t const idx = pipes.find(
'[');
841 pipes = pipes.substr(idx + 1, pipes.length() - idx - 2);
844 statswritten =
false;
845 pipe::set(pipelines[benchpipe]);
850 helper->
reportError(
"Benchmarking: " +pipelines[benchpipe]);
860 statswritten =
false;
861 if (benchpipe >= pipelines.size())
864 benchmark::set(
false);
866 if (helper) helper->
reportError(
"DNN benchmark complete.");
871 pipe::set(pipelines[benchpipe]);
873 if (helper) helper->
reportError(
"Benchmarking: " +pipelines[benchpipe]);
879 else pipelines.clear();
881 itsPreStats.push_back(itsProcSecs[0]);
882 itsNetStats.push_back(itsProcSecs[1]);
883 itsPstStats.push_back(itsProcSecs[2]);
886 if (itsStatsWarmup && itsPreStats.size() == 200)
887 { itsStatsWarmup =
false; itsPreStats.clear(); itsNetStats.clear(); itsPstStats.clear(); }
889 if (itsPreStats.size() == 500)
892 std::vector<double> tot;
893 for (
size_t i = 0; i < itsPreStats.size(); ++i)
894 tot.emplace_back(itsPreStats[i] + itsNetStats[i] + itsPstStats[i]);
898 std::ofstream ofs(fn, std::ios_base::app);
901 ofs <<
"<tr><td class=jvpipe>" << pipe::get() <<
" </td>";
903 std::vector<std::string> insizes;
904 for (cv::Mat
const & m : itsBlobs)
906 ofs <<
"<td class=jvnetin>" <<
jevois::join(insizes,
", ") <<
"</td>";
908 std::vector<std::string> outsizes;
909 for (cv::Mat
const & m : itsOuts)
911 ofs <<
"<td class=jvnetout>" <<
jevois::join(outsizes,
", ") <<
"</td>";
921 for (
double t : tot) avg += t;
923 if (avg) avg = 1.0 / avg;
924 ofs <<
"<td class=jvfps>" << std::fixed << std::showpoint << std::setprecision(1) <<
925 avg <<
" fps</td></tr>" << std::endl;
931 LINFO(
"Network stats appended to " << fn);
960 if (ImGui::CollapsingHeader(
"Processing Times", ImGuiTreeNodeFlags_DefaultOpen))
962 for (std::string
const & s : itsProcTimes) ImGui::TextUnformatted(s.c_str());
963 ImGui::Text(
"OVERALL: %s/inference", total.c_str());
968 if (ImGui::Button(
"Peek output data")) itsShowDataPeek =
true;
974 showDataPeekWindow(helper, refresh_data_peek);
979 for (std::string
const & s : itsProcTimes) helper->
itext(s);
980 helper->
itext(
"OVERALL: " + total +
"/inference");
984 (void)refresh_data_peek;
990 for (std::string
const & s : itsProcTimes)
1007 for (std::string
const & s : info)
1011 if (helper && idle ==
false)
1015 show = ImGui::CollapsingHeader(s.c_str() + 2, ImGuiTreeNodeFlags_DefaultOpen);
1020 else ImGui::TextUnformatted(s.c_str());
1024 (void)idle; (void)show; (void)helper;
1040 if (itsShowDataPeek ==
false)
return;
1043 ImGui::SetNextWindowPos(ImVec2(100, 50), ImGuiCond_FirstUseEver);
1044 ImGui::SetNextWindowSize(ImVec2(900, 600), ImGuiCond_FirstUseEver);
1047 ImGui::PushStyleColor(ImGuiCol_WindowBg, 0xf0ffe0e0);
1050 ImGui::Begin(
"DNN Output Peek", &itsShowDataPeek, ImGuiWindowFlags_HorizontalScrollbar);
1053 std::vector<std::string> outspecs;
1054 for (
size_t i = 0; cv::Mat
const & out : itsOuts)
1056 if (helper->
combo(
"##dataPeekOutSelect", outspecs, itsDataPeekOutIdx)) itsDataPeekFreeze =
false;
1058 ImGui::SameLine(); ImGui::TextUnformatted(
" "); ImGui::SameLine();
1063 if ( (itsDataPeekFreeze && itsDataPeekStr.empty() ==
false) || refresh ==
false)
1064 ImGui::TextUnformatted(itsDataPeekStr.c_str());
1068 cv::Mat
const & out = itsOuts[itsDataPeekOutIdx];
1069 std::vector<int> newsz;
1070 cv::MatSize
const & ms = out.size;
int const nd = ms.dims();
1071 for (
int i = 0; i < nd; ++i)
if (ms[i] > 1) newsz.emplace_back(ms[i]);
1072 cv::Mat
const out2(newsz, out.type(), out.data);
1076 std::ostringstream oss;
1077 if (newsz.size() > 3)
1078 throw "too many dims";
1079 else if (newsz.size() == 3)
1081 cv::Range ranges[3];
1082 ranges[2] = cv::Range::all();
1083 ranges[1] = cv::Range::all();
1084 for (
int i = 0; i < newsz[0]; ++i)
1086 oss <<
"-------------------------------------------------------------------------------\n";
1087 oss <<
"Third dimension index = " << i <<
":\n";
1088 oss <<
"-------------------------------------------------------------------------------\n\n";
1089 ranges[0] = cv::Range(i, i+1);
1090 cv::Mat slice = out2(ranges);
1091 cv::Mat slice2d(cv::Size(newsz[2], newsz[1]), slice.type(), slice.data);
1092 oss << slice2d <<
"\n\n";
1098 itsDataPeekStr = oss.str();
1100 catch (...) { itsDataPeekStr =
"Sorry, cannot display this type of tensor..."; }
1102 ImGui::TextUnformatted(itsDataPeekStr.c_str());
1104 if (out2.total() > 10000)
1106 helper->
reportError(
"Large data peek - Freezing data display\n"
1107 "Click the Freeze button to refresh once");
1108 itsDataPeekFreeze =
true;
1114 ImGui::PopStyleColor();
#define JEVOIS_SHARE_PATH
Base path for shared files (e.g., neural network weights, etc)
A component of a model hierarchy.
void clearErrors()
Clear all errors currently displayed in the JeVois-Pro GUI.
void reportError(std::string const &err)
Helper class to assist modules in creating graphical and GUI elements.
bool combo(std::string const &name, std::vector< std::string > const &items, int &selected_index)
Helper to draw a combobox from a vector of strings.
void reportAndIgnoreException(std::string const &prefix="")
Report current exception in a modal dialog, then ignore it.
void reportError(std::string const &err)
Report an error in an overlay window.
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 toggleButton(char const *name, bool *val)
Helper to draw a toggle button.
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
Base class for a module that supports standardized serial messages.
Wrapper around an OpenCV DNN neural network.
Wrapper around an DNN neural network invoked through python.
bool checkAsyncNetComplete()
void showInfo(std::vector< std::string > const &info, jevois::StdModule *mod, jevois::RawImage *outimg, jevois::OptGUIhelper *helper, bool ovl, bool idle)
void preUninit() override
Called before all sub-Components are uninit()ed.
void showDataPeekWindow(jevois::GUIhelper *helper, bool refresh)
void process(jevois::RawImage const &inimg, jevois::StdModule *mod, jevois::RawImage *outimg, jevois::OptGUIhelper *helper, bool idle=false)
Process an input image, send results to serial/image/gui.
void onParamChange(pipeline::zooroot const ¶m, std::string const &val) override
virtual ~Pipeline()
Destructor.
bool ready() const
Returns true when all three of preproc, net, and postproc are ready.
Pipeline(std::string const &instance)
Constructor.
void freeze(bool doit)
Freeze/unfreeze parameters that users should not change while running.
void postInit() override
Called after all sub-Components are init()ed.
Post-Processor for neural network pipeline.
Pre-Processor for neural network pipeline written in python.
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level.
std::string warnAndIgnoreException(std::string const &prefix="")
Convenience function to catch an exception, issue some LERROR (depending on type),...
#define LERROR(msg)
Convenience macro for users to print out console or syslog messages, ERROR level.
#define LINFO(msg)
Convenience macro for users to print out console or syslog messages, INFO level.
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.
void writeText(RawImage &img, std::string const &txt, int x, int y, unsigned int col, Font font=Font6x10)
Write some text in an image.
std::future< std::invoke_result_t< std::decay_t< Function >, std::decay_t< Args >... > > async(Function &&f, Args &&... args)
Async execution using a thread pool.
std::string join(std::vector< std::string > const &strings, std::string const &delimiter)
Concatenate a vector of tokens into a string.
std::string secs2str(double secs)
Report a duration given in seconds with variable units (ns, us, ms, or s), with precision of 2 decima...
std::filesystem::path absolutePath(std::filesystem::path const &root, std::filesystem::path const &path)
Compute an absolute path from two paths.
bool stringStartsWith(std::string const &str, std::string const &prefix)
Return true if str starts with prefix (including if both strings are equal)
std::vector< std::string > split(std::string const &input, std::string const ®ex="\\s+")
Split string into vector of tokens using a regex to specify what to split on; default regex splits by...
std::string replaceAll(std::string const &str, std::string const &from, std::string const &to)
Replace all instances of 'from' with 'to'.
unsigned short constexpr White
YUYV color value.
Main namespace for all JeVois classes and functions.
size_t getNumInstalledVPUs()
Get the number of Myriad-X VPUs present on this system.
size_t getNumInstalledNPUs()
Get the number of JeVois-Pro NPUs present on this system.
size_t getNumInstalledTPUs()
Get the number of Coral TPUs present on this system.
size_t getNumInstalledSPUs()
Get the number of Hailo8 SPUs present on this system.