24#include <opencv2/core/core.hpp>
25#include <opencv2/imgproc/imgproc.hpp>
26#include <opencv2/video/background_segm.hpp>
29#include <linux/videodev2.h>
95 inimg.
require(
"input", w,
h, V4L2_PIX_FMT_YUYV);
107 outimg = outframe.get();
108 outimg.
require(
"output", w * 2,
h, V4L2_PIX_FMT_YUYV);
116 bgs->apply(imgbgr, fgmask);
145 unsigned short winw, winh;
149 int x = 0, y = 0;
unsigned short iw = 0, ih = 0;
151 helper.
itext(
"JeVois-Pro Background Subtraction");
154 cv::Mat imgbgr = inframe.getCvRGBp();
160 bgs->apply(imgbgr, fgmask);
163 cv::Mat chans[4] { fgmask, fgmask, fgmask, fgmask };
164 cv::Mat mask; cv::merge(chans, 4, mask);
167 helper.
drawImage(
"fgmask", mask,
true, x, y, iw, ih,
false ,
true );
170 std::string
const & fpscpu = timer.
stop();
171 helper.
iinfo(inframe, fpscpu, winw, winh);
180 cv::Ptr<cv::BackgroundSubtractor>
bgs;
JEVOIS_REGISTER_MODULE(ArUcoBlob)
Background subtraction to detect moving objects.
virtual void process(jevois::InputFrame &&inframe, jevois::GUIhelper &helper) override
Processing function with zero-copy and GUI on JeVois-Pro.
virtual void process(jevois::InputFrame &&inframe, jevois::OutputFrame &&outframe) override
Processing function.
DemoBackgroundSubtract(std::string const &instance)
Constructor.
cv::Ptr< cv::BackgroundSubtractor > bgs
virtual ~DemoBackgroundSubtract()
Virtual destructor for safe inheritance.
jevois::Timer itsProcessingTimer
friend friend class Module
void drawInputFrame(char const *name, InputFrame const &frame, int &x, int &y, unsigned short &w, unsigned short &h, bool noalias=false, bool casync=false)
bool startFrame(unsigned short &w, unsigned short &h)
void iinfo(jevois::InputFrame const &inframe, std::string const &fpscpu, unsigned short winw=0, unsigned short winh=0)
void itext(char const *txt, ImU32 const &col=IM_COL32_BLACK_TRANS, int line=-1)
void drawImage(char const *name, RawImage const &img, int &x, int &y, unsigned short &w, unsigned short &h, bool noalias=false, bool isoverlay=false)
void require(char const *info, unsigned int w, unsigned int h, unsigned int f) const
std::string const & stop(double *seconds)
void paste(RawImage const &src, RawImage &dest, int dx, int dy)
void writeText(RawImage &img, std::string const &txt, int x, int y, unsigned int col, Font font=Font6x10)
cv::Mat convertToCvBGR(RawImage const &src)
void pasteGreyToYUYV(cv::Mat const &src, RawImage &dest, int dx, int dy)
std::future< std::invoke_result_t< std::decay_t< Function >, std::decay_t< Args >... > > async(Function &&f, Args &&... args)
unsigned short constexpr White