JeVoisBase
1.20
JeVois Smart Embedded Machine Vision Toolkit Base Modules
|
Share this page: |
|
|
|
|
|
|
Go to the documentation of this file.
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);
230 cv::drawContours(outuc2, contours, -1, jevois::yuyv::LightPink, 2, 8);
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);
247 3,
h + 2, jevois::yuyv::White);
250 std::string
const & fpscpu = timer.
stop();
261 std::shared_ptr<BlobDetector> itsDetector;
virtual void process(jevois::InputFrame &&inframe) override
Processing function, no USB video output.
void sendSerialContour2D(unsigned int camw, unsigned int camh, std::vector< cv::Point_< T > > points, std::string const &id="", std::string const &extra="")
std::future< std::invoke_result_t< std::decay_t< Function >, std::decay_t< Args >... > > async(Function &&f, Args &&... args)
void drawCircle(RawImage &img, int x, int y, unsigned int rad, unsigned int thick, unsigned int col)
JEVOIS_REGISTER_MODULE(ObjectTracker)
cv::Mat convertToCvBGR(RawImage const &src)
void require(char const *info, unsigned int w, unsigned int h, unsigned int f) const
Simple color-based object detection/tracking.
void writeText(RawImage &img, std::string const &txt, int x, int y, unsigned int col, Font font=Font6x10)
double area(const std::vector< Point2D< T > > &polygon, const bool getsigned=false)
What is the area of a polygon?
const std::string & stop(double *seconds)
void drawFilledRect(RawImage &img, int x, int y, unsigned int w, unsigned int h, unsigned int col)
StdModule(std::string const &instance)
std::string to_string(T const &val)
cv::Mat cvImage(RawImage const &src)
ObjectTracker(std::string const &instance)
Constructor.
virtual void process(jevois::InputFrame &&inframe, jevois::OutputFrame &&outframe) override
Processing function, with USB video output.
void paste(RawImage const &src, RawImage &dest, int dx, int dy)
virtual ~ObjectTracker()
Virtual destructor for safe inheritance.