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

asked 2016-12-12 07:16:14 -0600

evfgs gravatar image

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<MatOfPoint> contours = mDetector.getContours();
    Log.e(TAG, "Contours count: " + contours.size());
    Imgproc.drawContours(mRgba, contours, -1, CONTOUR_COLOR);

    List<Moments> mu = new ArrayList<Moments>(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.

edit retag flag offensive close merge delete

Comments

1

currently, it's a bit unclear, where you're stuck. what is the problem now ?

berak gravatar imageberak ( 2016-12-12 08:30:40 -0600 )edit

I'm stuck in drawing the trajectory(tracking path) of the object, I have the coordinates of the object in a given frame, but I'm not figuring out a solution to draw the path.

evfgs gravatar imageevfgs ( 2016-12-12 11:21:28 -0600 )edit