26#include <linux/videodev2.h>
27#include <opencv2/imgproc/imgproc.hpp>
166 itsDetector = addSubComponent<BlobDetector>(
"detector");
180 cv::Mat imghsv; cv::cvtColor(imgbgr, imghsv, cv::COLOR_BGR2HSV);
186 auto contours = itsDetector->detect(imghsv);
199 inimg.
require(
"input", w,
h, V4L2_PIX_FMT_YUYV);
206 outimg = outframe.get();
215 cv::Mat imghsv; cv::cvtColor(imgbgr, imghsv, cv::COLOR_BGR2HSV);
218 auto contours = itsDetector->detect(imghsv);
234 for (
auto const & c : contours)
238 cv::Moments moment = cv::moments(c);
239 double const area = moment.m00;
240 int const x = int(moment.m10 /
area + 0.4999);
241 int const y = int(moment.m01 /
area + 0.4999);
250 std::string
const & fpscpu = timer.
stop();
261 std::shared_ptr<BlobDetector> itsDetector;
JEVOIS_REGISTER_MODULE(ArUcoBlob)
double area(const std::vector< Point2D< T > > &polygon, const bool getsigned=false)
What is the area of a polygon?
Simple color-based object detection/tracking.
virtual void process(jevois::InputFrame &&inframe, jevois::OutputFrame &&outframe) override
Processing function, with USB video output.
virtual void process(jevois::InputFrame &&inframe) override
Processing function, no USB video output.
ObjectTracker(std::string const &instance)
Constructor.
virtual ~ObjectTracker()
Virtual destructor for safe inheritance.
void require(char const *info, unsigned int w, unsigned int h, unsigned int f) const
StdModule(std::string const &instance)
void sendSerialContour2D(unsigned int camw, unsigned int camh, std::vector< cv::Point_< T > > points, std::string const &id="", std::string const &extra="")
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 convertToCvBGR(RawImage const &src)
void drawCircle(RawImage &img, int x, int y, unsigned int rad, 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)
unsigned short constexpr LightPink
unsigned short constexpr White
unsigned short constexpr LightGreen