21#include <opencv2/core/core.hpp>
22#include <opencv2/imgproc/imgproc.hpp>
32 "This is the size of the image crop that is taken around the most salient "
33 "location in each frame. The foa size must fit within the camera input frame size. To avoid "
34 "rescaling, it is best to use here the size that the deep network expects as input.",
35 cv::Size(128, 128), ParamCateg);
140 public jevois::Parameter<foa>
149 itsSaliency = addSubComponent<Saliency>(
"saliency");
183 int const smfac = (1 << smlev);
189 cv::Size roisiz = foa::get();
itsRw = roisiz.width;
itsRh = roisiz.height;
191 unsigned int const dmx = (mx << smlev) + (smfac >> 2);
192 unsigned int const dmy = (my << smlev) + (smfac >> 2);
198 if (
itsRw <= 0 ||
itsRh <= 0)
LFATAL(
"Ooops, foa size cannot be zero or negative");
219 cv::cvtColor(rawroi, rgbroi, cv::COLOR_YUV2RGB_YUYV);
228 int netinw, netinh, netinc;
itsTensorFlow->getInDims(netinw, netinh, netinc);
235 LINFO(
"Predicted in " << ptime <<
"ms");
240 catch (std::logic_error
const & e) { }
257 inimg.
require(
"input", w,
h, V4L2_PIX_FMT_YUYV);
262 outimg = outframe.get();
282 if ((jevois::frameNum() & 1) == 0 ||
itsRw == 0)
295 cv::cvtColor(rawroi, rgbroi, cv::COLOR_YUV2RGB_YUYV);
305 int netinw, netinh, netinc;
itsTensorFlow->getInDims(netinw, netinh, netinc);
312 float fac = float(outimg.
width - w) / float(rgbroi.cols);
313 cv::Size displaysize(outimg.
width - w,
int(rgbroi.rows * fac + 0.4999F));
324 paste_fut.get(); scale_fut.get();
330 itsRawInputCv.copyTo(outimgcv(cv::Rect(w, 0, dispw, disph)));
335 int y = disph + 3;
if (y +
itsTensorFlow->top::get() * 12 >
h - 21) y = 3;
361 std::string
const & fpscpu = timer.
stop();
JEVOIS_REGISTER_MODULE(ArUcoBlob)
Detect salient objects and identify them using TensorFlow deep neural network.
virtual ~TensorFlowSaliency()
Virtual destructor for safe inheritance.
std::vector< jevois::ObjReco > itsResults
std::shared_ptr< Saliency > itsSaliency
virtual void getSalROI(jevois::RawImage const &inimg)
Helper function: compute saliency ROI in a thread, return top-left corner and size.
std::shared_ptr< TensorFlow > itsTensorFlow
TensorFlowSaliency(std::string const &instance)
Constructor.
JEVOIS_DECLARE_PARAMETER(foa, cv::Size, "Width and height (in pixels) of the focus of attention. " "This is the size of the image crop that is taken around the most salient " "location in each frame. The foa size must fit within the camera input frame size. To avoid " "rescaling, it is best to use here the size that the deep network expects as input.", cv::Size(128, 128), ParamCateg)
Parameter.
virtual void process(jevois::InputFrame &&inframe) override
Processing function, no video output.
virtual void process(jevois::InputFrame &&inframe, jevois::OutputFrame &&outframe) override
Processing function with video output to USB.
virtual void postUninit() override
Un-initialization.
std::future< float > itsPredictFut
cv::Mat itsRawPrevOutputCv
void require(char const *info, unsigned int w, unsigned int h, unsigned int f) const
void sendSerialObjDetImg2D(unsigned int camw, unsigned int camh, float x, float y, float w, float h, std::vector< ObjReco > const &res)
StdModule(std::string const &instance)
std::string const & stop(double *seconds)
ENV_INTG32_TYPE intg32
32-bit signed integer
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 convertCvRGBtoCvYUYV(cv::Mat const &src, cv::Mat &dst)
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 LightPink
unsigned short constexpr White