28#include <ovxlib/vsi_nn_pub.h>
47 "If not absolute, it is relative to this module's path",
52 "If not absolute, it is relative to zooroot",
53 "models.yml", ParamCateg);
59 "the 'pipe' parameter some class of models from the zoo",
60 Filter::All, Filter_Values, ParamCateg);
64 "top-level entry in the zoo file. Network execution types are: OpenCV: "
65 "on CPU, NPU: on JeVois NPU accelerator, TPU: on Coral Edge TPU if "
66 "available, VPU: on MyriadX VPU if available, NPUX: on NPU via TimVX "
67 "OpenCV extension, VPUX: on CPU via ARM-Compute OpenVino emulation "
68 "of VPU, and SPU: on Hailo8 SPU if available.",
76 "by selecting a pipeline from the zoo file",
77 PreProc::Blob, PreProc_Values, ParamCateg);
87 "automatically by selecting a pipeline from the zoo file",
88 NetType::OpenCV, NetType_Values, ParamCateg);
94 "by selecting a pipeline from the zoo file",
95 PostProc::Classify, PostProc_Values, ParamCateg);
101 "network, and post-processing sequentially for every frame. Use for fast "
102 "networks only, otherwise it will slow down the GUI... Async runs the network in "
103 "a thread and should be used for networks slower than the camera framerate.",
104 Processing::Async, Processing_Values, ParamCateg);
112 "a pipeline, but the pipeline's component is not using them. Warnings appear "
113 "in the console when the pipeline is loaded.",
118 "to the specified file if not empty. If path is relative, it is to " JEVOIS_SHARE_PATH,
123 "for each, run it for a while and append pre/net/post timing statistics "
129 "ones, in the pipe list; otherwise, only those not marked 'extramodel' "
130 "in their model zoo definition",
144 public jevois::Parameter<pipeline::zooroot, pipeline::zoo, pipeline::filter, pipeline::pipe,
145 pipeline::processing, pipeline::preproc, pipeline::nettype,
146 pipeline::postproc, pipeline::overlay, pipeline::paramwarn,
147 pipeline::statsfile, pipeline::benchmark, pipeline::extramodels>
151 Pipeline(std::string
const & instance);
202 void reloadZoo(std::string
const & root, std::string
const & filt, std::string
const & zoofile);
204 void onParamChange(pipeline::zooroot
const & param, std::string
const & val)
override;
205 void onParamChange(pipeline::zoo
const & param, std::string
const & val)
override;
206 void onParamChange(pipeline::filter
const & param, pipeline::Filter
const & val)
override;
207 void onParamChange(pipeline::pipe
const & param, std::string
const & val)
override;
208 void onParamChange(pipeline::nettype
const & param, pipeline::NetType
const & val)
override;
209 void onParamChange(pipeline::preproc
const & param, pipeline::PreProc
const & val)
override;
210 void onParamChange(pipeline::postproc
const & param, pipeline::PostProc
const & val)
override;
211 void onParamChange(pipeline::benchmark
const & param,
bool const & val)
override;
212 void onParamChange(pipeline::extramodels
const & param,
bool const & val)
override;
225 bool itsZooChanged =
false;
226 std::future<std::vector<cv::Mat>> itsNetFut;
227 std::array<std::string, 3> itsProcTimes {
"PreProc: -",
"Network: -",
"PstProc: -" };
228 std::array<double, 3> itsProcSecs { 0.0, 0.0, 0.0 };
229 std::vector<cv::Mat> itsBlobs, itsOuts;
230 std::vector<vsi_nn_tensor_attr_t> itsInputAttrs;
231 std::vector<std::string> itsNetInfo, itsAsyncNetInfo;
232 std::string itsAsyncNetworkTime =
"Network: -";
233 double itsAsyncNetworkSecs = 0.0;
234 double itsSecsSum = 0.0, itsSecsAvg = 0.0;
235 int itsSecsSumNum = 0;
236 bool itsPipeThrew =
false;
237 void scanZoo(std::filesystem::path
const & zoofile, std::string
const & filt, std::vector<std::string> & pipes,
238 std::string
const & indent);
239 bool selectPipe(std::string
const & zoofile, std::vector<std::string>
const & tok);
240 void setZooParam(std::string
const & name, std::string
const & value, std::string
const & zf,
241 cv::FileNode
const & node);
244 std::map<std::string, size_t> itsAccelerators;
245 std::vector<double> itsPreStats, itsNetStats, itsPstStats;
246 bool itsStatsWarmup =
true;
248 bool itsShowDataPeek =
false;
249 int itsDataPeekOutIdx = 0;
250 bool itsDataPeekFreeze =
false;
251 std::string itsDataPeekStr;
#define JEVOIS_SHARE_PATH
Base path for shared files (e.g., neural network weights, etc)
A component of a model hierarchy.
Helper class to assist modules in creating graphical and GUI elements.
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.
Simple one-shot timer class.
Neural processing pipeline.
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(preproc, PreProc, "Pre-Processor to use, usually set automatically " "by selecting a pipeline from the zoo file", PreProc::Blob, PreProc_Values, ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(nettype, NetType, "Network runtime framework to use, usually set " "automatically by selecting a pipeline from the zoo file", NetType::OpenCV, NetType_Values, ParamCateg)
Parameter.
std::vector< ObjDetectOBB > const & latestDetectionsOBB() const
Get the latest oriented bounded box (OBB) detection results, use with caution, not thread-safe.
JEVOIS_DEFINE_ENUM_CLASS(PostProc,(Classify)(Detect)(DetectOBB)(Segment)(YuNet)(Pose)(Python)(Stub))
Enum.
bool checkAsyncNetComplete()
void showInfo(std::vector< std::string > const &info, jevois::StdModule *mod, jevois::RawImage *outimg, jevois::OptGUIhelper *helper, bool ovl, bool idle)
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(extramodels, bool, "If true, show all available models, including older " "ones, in the pipe list otherwise, only those not marked 'extramodel' " "in their model zoo definition", false, ParamCateg)
Parameter.
std::shared_ptr< Network > itsNetwork
JEVOIS_DECLARE_PARAMETER(statsfile, std::string, "Append pre/net/post timing statistics in HTML table format " "to the specified file if not empty. If path is relative, it is to " JEVOIS_SHARE_PATH, "", ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER(processing, Processing, "Type of processing: Sync runs pre-processing, " "network, and post-processing sequentially for every frame. Use for fast " "networks only, otherwise it will slow down the GUI... Async runs the network in " "a thread and should be used for networks slower than the camera framerate.", Processing::Async, Processing_Values, ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(filter, Filter, "Filter to possibly only show as options in " "the 'pipe' parameter some class of models from the zoo", Filter::All, Filter_Values, ParamCateg)
Parameter.
void preUninit() override
Called before all sub-Components are uninit()ed.
void showDataPeekWindow(jevois::GUIhelper *helper, bool refresh)
std::vector< ObjReco > const & latestRecognitions() const
Get the latest recognition results, use with caution, not thread-safe.
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.
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(pipe, std::string, "Pipeline to use, which should correspond to a " "top-level entry in the zoo file. Network execution types are: OpenCV: " "on CPU, NPU: on JeVois NPU accelerator, TPU: on Coral Edge TPU if " "available, VPU: on MyriadX VPU if available, NPUX: on NPU via TimVX " "OpenCV extension, VPUX: on CPU via ARM-Compute OpenVino emulation " "of VPU, and SPU: on Hailo8 SPU if available.", "", ParamCateg)
Parameter.
JEVOIS_DEFINE_ENUM_CLASS(Processing,(Sync)(Async))
Enum.
JEVOIS_DEFINE_ENUM_CLASS(Filter,(All)(OpenCV)(TPU)(NPU)(VPU)(VPUX)(NPUX)(SPU)(ORT))
Enum.
void freeze(bool doit)
Freeze/unfreeze parameters that users should not change while running.
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(zoo, std::string, "Filename for neural network zoo file (.yml). " "If not absolute, it is relative to zooroot", "models.yml", ParamCateg)
Parameter.
std::vector< PoseSkeleton > const & latestSkeletons() const
Get the latest skeletons, use with caution, not thread-safe.
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(postproc, PostProc, "Post-Processor to use, usually set automatically " "by selecting a pipeline from the zoo file", PostProc::Classify, PostProc_Values, ParamCateg)
Parameter.
JEVOIS_DEFINE_ENUM_CLASS(PreProc,(Blob)(Python))
Enum.
std::shared_ptr< PostProcessor > itsPostProcessor
std::vector< ObjDetect > const & latestDetections() const
Get the latest detection results, use with caution, not thread-safe.
void reloadZoo(std::string const &root, std::string const &filt, std::string const &zoofile)
std::shared_ptr< PreProcessor > itsPreProcessor
void postInit() override
Called after all sub-Components are init()ed.
JEVOIS_DEFINE_ENUM_CLASS(NetType,(OpenCV)(ORT)(NPU)(TPU)(SPU)(Python))
Enum.
JEVOIS_DECLARE_PARAMETER(paramwarn, bool, "Issue warning if parameters are specified in the zoo file for " "a pipeline, but the pipeline's component is not using them. Warnings appear " "in the console when the pipeline is loaded.", true, ParamCateg)
Parameter.
void onParamChange(pipeline::filter const ¶m, pipeline::Filter const &val) override
JEVOIS_DECLARE_PARAMETER(overlay, bool, "Show some pipeline info as an overlay over output or GUI video", true, ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(benchmark, bool, "Cycle through all networks specified by filter and, " "for each, run it for a while and append pre/net/post timing statistics " "in HTML table format to " JEVOIS_SHARE_PATH "/benchmark.html", false, ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(zooroot, std::string, "Path where to find zoo files (.yml). " "If not absolute, it is relative to this module's path", JEVOIS_SHARE_PATH "/dnn", ParamCateg)
Parameter.
JEVOIS_DEFINE_ENUM_CLASS(CameraSensor,(any)(imx290)(os08a10)(ar0234))
Enum for different sensor models.
Main namespace for all JeVois classes and functions.
A category to which multiple ParameterDef definitions can belong.