21#include <opencv2/core/core.hpp>
22#include <opencv2/imgproc/imgproc.hpp>
31 "to make it match camera frame size. NOTE: for YOLO v3 sizes must be multiples of 32.",
32 cv::Size(320, 224), ParamCateg);
120 public jevois::Parameter<netin>
128 itsYolo = addSubComponent<Yolo>(
"yolo");
150 int ready =
true;
float ptime = 0.0F;
160 cv::Size nsz = netin::get();
161 if (nsz.width != 0 && nsz.height != 0)
163 itsYolo->resizeInDims(nsz.width, nsz.height);
168 itsYolo->resizeInDims(cvimg.cols, cvimg.rows);
178 try { ptime =
itsYolo->predict(
itsNetInput); }
catch (std::logic_error
const & e) { ready =
false; }
182 LINFO(
"Predicted in " << ptime <<
"ms");
206 inimg.
require(
"input", w,
h, V4L2_PIX_FMT_YUYV);
211 outimg = outframe.get();
235 if (
itsPredictFut.wait_for(std::chrono::milliseconds(5)) == std::future_status::ready)
239 bool success =
true;
float ptime = 0.0F;
257 itsYolo->drawDetections(outimg, w,
h, w, 0);
292 cv::Size nsz = netin::get();
293 if (nsz.width != 0 && nsz.height != 0)
295 itsYolo->resizeInDims(nsz.width, nsz.height);
300 itsYolo->resizeInDims(cvimg.cols, cvimg.rows);
314 catch (std::logic_error
const & e) { }
324 std::string
const & fpscpu = timer.
stop();
JEVOIS_REGISTER_MODULE(ArUcoBlob)
Detect multiple objects in scenes using the Darknet YOLO deep neural network.
DarknetYOLO(std::string const &instance)
Constructor.
virtual void postUninit() override
Un-initialization.
std::future< float > itsPredictFut
std::shared_ptr< Yolo > itsYolo
virtual ~DarknetYOLO()
Virtual destructor for safe inheritance.
virtual void process(jevois::InputFrame &&inframe, jevois::OutputFrame &&outframe) override
Processing function with video output to USB.
JEVOIS_DECLARE_PARAMETER(netin, cv::Size, "Width and height (in pixels) of the neural network input layer, or [0 0] " "to make it match camera frame size. NOTE: for YOLO v3 sizes must be multiples of 32.", cv::Size(320, 224), ParamCateg)
Parameter.
cv::Mat itsRawPrevOutputCv
virtual void process(jevois::InputFrame &&inframe) override
Processing function, no video output.
void require(char const *info, unsigned int w, unsigned int h, unsigned int f) const
StdModule(std::string const &instance)
std::string const & stop(double *seconds)
void paste(RawImage const &src, RawImage &dest, int dx, int dy)
cv::Mat cvImage(RawImage const &src)
void writeText(RawImage &img, std::string const &txt, int x, int y, unsigned int col, Font font=Font6x10)
cv::Mat convertToCvRGB(RawImage const &src)
void drawFilledRect(RawImage &img, int x, int y, unsigned int w, unsigned int h, unsigned int col)
cv::Mat rescaleCv(cv::Mat const &img, cv::Size const &newdims)
std::future< std::invoke_result_t< std::decay_t< Function >, std::decay_t< Args >... > > async(Function &&f, Args &&... args)
unsigned short constexpr Black
unsigned short constexpr White