Tomas Martinkovic
The project shows detection of chocolate cover from input image or frame of video. For each video or image may be chosen various combinations of detector with descriptor. For matching object of chocolate cover with input frame or image automatically is used FlannBasedMatcher or BruteForceMatcher. It depends on the chosen SurfDescriptorExtractor or FREAK algorithm.
Functions used: SurfFeatureDetector, FastFeatureDetector, SiftFeatureDetector, StarFeatureDetector, SurfDescriptorExtractor, FREAK, FlannBasedMatcher, BruteForceMatcher, findHomography
Process
- Preprocessing – Conversion to grayscale
cvtColor(frame, img_scene, CV_BGR2GRAY);
- Detect the keypoints
detector_Surf = getSurfFeatureDetector(); detector_Surf.detect( img_object, keypoints_object ); detector_Surf.detect( img_scene, keypoints_scene );
- Compute local descriptors
extractor_freak.compute( img_object, keypoints_object, descriptors_object ); extractor_freak.compute( img_scene, keypoints_scene, descriptors_scene );
- Matching local descriptors
BruteForceMatcher<Hamming> matcher; matcher.match( descriptors_object, descriptors_scene, matches );
- Draw good matches to frame
drawMatches( img_object, keypoints_object, img_scene, keypoints_scene, good_matches, img_matches, Scalar::all(-1), Scalar::all(-1), vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
- Finding homography and drawing frame of video
Mat H = findHomography( obj, scene, CV_RANSAC ); perspectiveTransform( obj_corners, scene_corners, H); imshow( "Object detection on video", img_matches );