问题
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