Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Opencv(3.10) android- How to draw an object's trajectory

$
0
0
I have a project in college where I have to draw the trajectory of an object based on the color of it. Is being built based on colorBlobDetection. This is part of the code I have so far: public Mat onCameraFrame(CvCameraViewFrame inputFrame) { mRgba = inputFrame.rgba(); if (mIsColorSelected) { mDetector.process(mRgba); List contours = mDetector.getContours(); Log.e(TAG, "Contours count: " + contours.size()); Imgproc.drawContours(mRgba, contours, -1, CONTOUR_COLOR); List mu = new ArrayList(contours.size()); for (int i = 0; i < contours.size(); i++) { mu.add(i, Imgproc.moments(contours.get(i), false)); Moments p = mu.get(i); int xContour = (int) (p.get_m10() / p.get_m00()); int yContour = (int) (p.get_m01() / p.get_m00()); Point ponto = new Point(xContour, yContour); //Imgproc.line(mRgba, ponto, ponto, CONTOUR_COLOR, 5, Imgproc.LINE_AA, 0); } At the moment I'm picking up the center of each contour. Through the positions of the contours I want to draw their trajectories when they move Ps. This 'Imgproc.line' was just to test if the center of each contour is correct. Please help.

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>