JeVois
1.19
JeVois Smart Embedded Machine Vision Toolkit
|
Share this page: |
|
|
|
 |
 |
|
Go to the documentation of this file.
33 classes::freeze(doit);
38 std::string
const & val)
40 if (val.empty())
return;
44 dd.back() =
"network"; dd.emplace_back(
"dataroot");
45 std::string
const dataroot = engine()->getParamStringUnique(
jevois::join(dd,
":"));
54 if (outs.size() != 1 && itsFirstTime)
57 LERROR(
"Expected 1 output tensor, got " << outs.size() <<
" - USING FIRST ONE");
60 cv::Mat
const & out = outs[0]; uint32_t
const sz = out.total();
61 if (out.type() != CV_32F)
LFATAL(
"Need FLOAT32 tensor");
62 uint32_t topk =
top::get();
if (topk > sz) topk = sz;
66 uint32_t MaxClass[topk];
float fMaxProb[topk];
69 float sm[out.total()];
78 for (uint32_t i = 0; i < topk; ++i)
80 if (fMaxProb[i] * fac < t)
break;
82 itsObjRec.push_back(
o);
93 if (outimg && overlay)
97 220, y, jevois::yuyv::White);
103 220, y, jevois::yuyv::White);
112 if (idle ==
false && ImGui::CollapsingHeader(
"Classification results", ImGuiTreeNodeFlags_DefaultOpen))
114 ImGui::Text(
"Top-%u classes above threshold %.2f", topk,
cthresh::get());
117 for (
jevois::ObjReco const &
o : itsObjRec) { ImGui::Text(
"%s: %.2F",
o.category.c_str(),
o.score); ++done; }
118 while (done++ < topk) ImGui::TextUnformatted(
"-");
126 while (done++ < topk) helper->
itext(
"-");
130 (void)idle; (void)helper;
std::string descriptor() const
Get our full descriptor (including all parents) as [Instancename]:[...]:[...].
Data collection mode RAW means that the latest available raw data is returned each time get() is called
void itext(char const *txt, ImU32 const &col=IM_COL32_BLACK_TRANS, int line=-1)
Draw some overlay text on top of an image.
std::string sformat(char const *fmt,...) __attribute__((format(__printf__
Create a string using printf style arguments.
void report(jevois::StdModule *mod, jevois::RawImage *outimg=nullptr, jevois::OptGUIhelper *helper=nullptr, bool overlay=true, bool idle=false) override
Report what happened in last process() to console/output video/GUI.
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...
size_t softmax(float const *input, size_t const n, size_t const stride, float const fac, float *output, bool maxonly)
Apply softmax to a float vector.
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
void onParamChange(postprocessor::classes const ¶m, std::string const &val) override
std::map< int, std::string > readLabelsFile(std::string const &fname)
Read a label file.
#define LERROR(msg)
Convenience macro for users to print out console or syslog messages, ERROR level.
Helper class to assist modules in creating graphical and GUI elements.
std::filesystem::path absolutePath(std::filesystem::path const &root, std::filesystem::path const &path)
Compute an absolute path from two paths.
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::string getLabel(std::map< int, std::string > const &labels, int id)
Get a label from an id.
A trivial struct to store object recognition results.
Pre-Processor for neural network pipeline.
void freeze(bool doit) override
Freeze/unfreeze parameters that users should not change while running.
std::string join(std::vector< std::string > const &strings, std::string const &delimiter)
Concatenate a vector of tokens into a string.
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level.
virtual ~PostProcessorClassify()
Destructor.
void process(std::vector< cv::Mat > const &outs, PreProcessor *preproc) override
Process outputs and draw/send some results.
Base class for a module that supports standardized serial messages.
void topK(float const *pfProb, float *pfMaxProb, uint32_t *pMaxClass, uint32_t outputCount, uint32_t topNum)
Get top-k entries and their indices.
void sendSerialObjReco(std::vector< ObjReco > const &res)
Send a standardized object recognition message.