21#include <opencv2/core/core.hpp>
22#include <opencv2/imgproc/imgproc.hpp>
31 "This is the size of the central image crop that is taken in each frame and fed to the "
32 "deep neural network. If the foa size does not fit within the camera input frame size, "
33 "it will be shrunk to fit. To avoid spending CPU resources on rescaling the selected "
34 "image region, it is best to use here the size that the deep network expects as input.",
35 cv::Size(128, 128), ParamCateg);
155 public jevois::Parameter<foa>
182 cv::Size foasiz = foa::get();
int foaw = foasiz.width, foah = foasiz.height;
183 if (foaw > w) { foaw = w; foah = std::min(foah, foaw); }
184 if (foah >
h) { foah =
h; foaw = std::min(foaw, foah); }
187 int const offx = ((w - foaw) / 2) & (~1);
188 int const offy = ((
h - foah) / 2) & (~1);
191 cv::Mat crop = cvimg(cv::Rect(offx, offy, foaw, foah));
194 cv::Mat rgbroi; cv::cvtColor(crop, rgbroi, cv::COLOR_YUV2RGB_YUYV);
203 int netinw, netinh, netinc;
itsTensorFlow->getInDims(netinw, netinh, netinc);
210 LINFO(
"Predicted in " << ptime <<
"ms");
215 catch (std::logic_error
const & e) { }
232 inimg.
require(
"input", w,
h, V4L2_PIX_FMT_YUYV);
235 cv::Size foasiz = foa::get();
int foaw = foasiz.width, foah = foasiz.height;
236 if (foaw > w) { foaw = w; foah = std::min(foah, foaw); }
237 if (foah >
h) { foah =
h; foaw = std::min(foaw, foah); }
238 int const offx = ((w - foaw) / 2) & (~1);
239 int const offy = ((
h - foah) / 2) & (~1);
244 outimg = outframe.get();
245 outimg.
require(
"output", outimg.
width,
h + 68, V4L2_PIX_FMT_YUYV);
260 cv::Mat crop = cvimg(cv::Rect(offx, offy, foaw, foah));
263 cv::Mat rgbroi; cv::cvtColor(crop, rgbroi, cv::COLOR_YUV2RGB_YUYV);
266 paste_fut.get(); inframe.done();
272 int netinw, netinh, netinc;
itsTensorFlow->getInDims(netinw, netinh, netinc);
291 catch (std::logic_error
const & e)
309 std::string
const & fpscpu = timer.
stop();
JEVOIS_REGISTER_MODULE(ArUcoBlob)
Identify objects using TensorFlow deep neural network.
virtual void process(jevois::InputFrame &&inframe) override
Processing function, no video output.
std::shared_ptr< TensorFlow > itsTensorFlow
TensorFlowEasy(std::string const &instance)
Constructor.
virtual ~TensorFlowEasy()
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(foa, cv::Size, "Width and height (in pixels) of the fixed, central focus of attention. " "This is the size of the central image crop that is taken in each frame and fed to the " "deep neural network. If the foa size does not fit within the camera input frame size, " "it will be shrunk to fit. To avoid spending CPU resources on rescaling the selected " "image region, it is best to use here the size that the deep network expects as input.", cv::Size(128, 128), ParamCateg)
Parameter.
std::vector< jevois::ObjReco > itsResults
void require(char const *info, unsigned int w, unsigned int h, unsigned int f) const
void sendSerialObjReco(std::vector< ObjReco > const &res)
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)
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)
void drawRect(RawImage &img, int x, int y, unsigned int w, unsigned int h, unsigned int thick, unsigned int col)
std::future< std::invoke_result_t< std::decay_t< Function >, std::decay_t< Args >... > > async(Function &&f, Args &&... args)
std::string sformat(char const *fmt,...) __attribute__((format(__printf__
unsigned short constexpr Black
unsigned short constexpr White
unsigned short constexpr MedGrey