How to detect object in a video using SURF and C?

為{幸葍}努か 提交于 2019-12-24 03:27:08

问题


I used a SURF program from a tutorial to detect object in a video frame. but that detects all the key points and descriptors. how i change the program to detect only specific object?

CvSeq *imageKeypoints = 0, *imageDescriptors = 0;
int i;


CvSURFParams params = cvSURFParams(500, 1);
cvExtractSURF( image, 0, &imageKeypoints, &imageDescriptors, storage, params );
printf("Image Descriptors: %d\n", imageDescriptors->total);


for( i = 0; i < imageKeypoints->total; i++ )
{
CvSURFPoint* r = (CvSURFPoint*)cvGetSeqElem( imageKeypoints, i );
CvPoint center;
int radius;
center.x = cvRound(r->pt.x);
center.y = cvRound(r->pt.y);
radius = cvRound(r->size*1.2/9.*2);
cvCircle( frame, center, radius, red_color[0], 1, 8, 0 );
}

回答1:


The algorithm is supossed to detect all the robust keypoints. The only way you have to detect a specific object with this kind of algorithms, is having a picture of the object you want to detect (called marker), to be able to compare those keypoints in the marker with the keypoints in the image. Those pairs that match mean that are common in the amrker and in the image.

It is important that you understand the method:

1 - You have your marker with the image you want to detect. You use SURF, FAST, SIFT or whatever algorithm to detect the keypoints. This is offline, you do it only onece at the beggining.

2 - You start getting frames from video, and you use SURF for each frame to detect keypoints in the video.

3 - Here it comes the real processing part, where you "match" points in the marker with points in the image. If you don't get matches the object it is not in the image.

Look at this example.



来源:https://stackoverflow.com/questions/10867412/how-to-detect-object-in-a-video-using-surf-and-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!