Ask Your Question
1

How can i cluster moving objects in a video ?

asked 2016-03-08 10:42:02 -0500

Giorgos_ts gravatar image

updated 2016-03-08 13:11:23 -0500

berak gravatar image

I am relative new to opencv .
I have computed the optical flow but i need to use this information to detect the moving objects. How can i achieve that ? The camera is also moving in my problem. Should i try background substraction ?

Thank you in advance !

edit retag flag offensive close merge delete

Comments

1

If the camera is moving then it is impossible to know if movement in image is due to camera movement or to object movement. Optical flow does not work for your scenario

Pedro Batista gravatar imagePedro Batista ( 2016-03-08 11:04:03 -0500 )edit
2

@Pedro Batista, i would not say, that this is entirely hopeless, e.g. one could try to find the homography between previous and current points, and do a backprojection with the homography matrix. then, the "inliers" are most likely the camera motion, while the "outliers" are caused by object motion.

http://www.cv-foundation.org/openacce... , 3.1, step 3

berak gravatar imageberak ( 2016-03-08 11:30:37 -0500 )edit

I guess it may achieve some results if the camera movement is stable and uniform.

Pedro Batista gravatar imagePedro Batista ( 2016-03-09 04:17:48 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
3

answered 2016-03-09 03:08:28 -0500

berak gravatar image

updated 2016-03-09 03:43:45 -0500

no idea, if it will work in your case, but you could try to seperate foreground / background motion like in the paper mentioned above:

            // 3.1 Step 3: Camera/background motion estimation 
            // pointsPrev, pointsCur are vector<Point2f> from LK

            vector<Point2f> foreground;
            Mat H = findHomography(pointsPrev, pointsCur, RANSAC);
            cerr << H << endl;
            // now, backproject the points, and see, how far off they are:
            for(size_t i=0; i<pointsCur.size(); i++)
            {
                Point2f p0 = pointsPrev[i];
                Point2f p1 = pointsCur[i];
                // homogeneous point for mult:
                Mat_<double> col(3, 1);
                col << p0.x, p0.y, 1;
                col = H * col;
                col /= col(2); // divide by W
                double dist = sqrt(pow(col(0) - p1.x, 2) +
                                   pow(col(1) - p1.y, 2));
                // small distance == inlier == camera motion
                // large distance == outlier == object motion
                if (dist >= 1.5)  // some heuristical threshold value
                {
                    foreground.push_back(p1);
                }
            }
            cerr << "fg " << pointsCur.size() << " " << foreground.size()  << endl;
edit flag offensive delete link more

Comments

@berak And then how can I visualize the effect of that procedure ? What am I going to do ?

Giorgos_ts gravatar imageGiorgos_ts ( 2016-04-04 16:31:32 -0500 )edit
0

answered 2016-03-09 04:28:49 -0500

Sriram Kumar gravatar image

updated 2016-03-09 04:30:00 -0500

http://www.wisdom.weizmann.ac.il/~ira...

This paper is a bit complicated. but worth trying and implementing.

you are working with a problem where u need to distinguish between independent motion detection and motion of the camera which is the dominant motion.

For your information this is a research topic. And not easy to get a straight result

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-03-08 10:42:02 -0500

Seen: 206 times

Last updated: Mar 09 '16