This example shows a new method for tracking significant points in video, representing people or moving objects. This method uses several OpenCV functions.
- The opening video file
VideoCapture MojeVideo („cesta k súboru");
- Retrieve the next frame (picture)
Mat FarebnaSnimka; MojeVideo >> FarebnaSnimka;
- Converting color images to grayscale image
Mat Snimka1; cvtColor(FarebnaSnimka, Snimka1, CV_RGB2GRAY);
- Getting significant (well observable) points
vector<cv::Point2f> VyznacneBody; goodFeaturesToTrack(Snimka1, VyznacneBody, 300, 0.06, 0);
- Getting the next frame and its conversion
- Finding significant points from the previous frame to the next
vector<cv::Point2f> PosunuteBody; vector<uchar> PlatneBody; calcOpticalFlowPyrLK(Snimka1, Snimka2, VyznacneBody, PosunuteBody, PlatneBody, err);
- Calculation of the velocity vector for each significant point
- Clustering of significant points according to their average velocity vectors
- Assign a color to cluster
- Plotting points on a slide
- Plotting arrows at the center points of clusters – average of the average velocity vectors
- Dumping the clusters and other places for the classification of points into them (to preserve the color of the cluster) + eventual creation of new clusters
- Landmarks declining over time – the time when they need to re-designate
- This method is faster than OpenCV method for detecting people.
- It also works when only part of person is visible, position is unusual or person is rotated.
- Person is divided to parts.
- It does not distinguish between persons or other moving objects.