1

I used OpenCV Surf method to fetch the keypoints and descriptors , it is working fine but taking so much time .

My code is : -

NSLog(@"Keypoint Detects");
//-- Step 1: Detect the keypoints using SURF Detector

int minHessian = 400;
SurfFeatureDetector detector( minHessian );
std::vector<KeyPoint> keypoints_object, keypoints_scene;
detector.detect( img_1, keypoints_object );
detector.detect( img_2, keypoints_scene );

//-- Step 2: Calculate descriptors (feature vectors)
NSLog(@"Descriptor Detects");
SurfDescriptorExtractor extractor;
Mat descriptors_object, descriptors_scene;
extractor.compute( img_1, keypoints_object, descriptors_object );
extractor.compute( img_2, keypoints_scene, descriptors_scene );

//-- Step 3: Matching descriptor vectors using FLANN matcher
NSLog(@"Matching Detects");
FlannBasedMatcher matcher;
std::vector< DMatch > matches;
matcher.match( descriptors_object, descriptors_scene, matches );

Xcode result of time : -

2015-10-26 13:22:27.282 AVDemo[288:26112] Keypoint Detects

2015-10-26 13:22:28.361 AVDemo[288:26112] Descriptor Detects

2015-10-26 13:22:30.077 AVDemo[288:26112] Matching Detects

Here it is taking 2 seconds to compute


I also used another method to fetch as : -

NSLog(@"Detect Keypoints");
cv::Ptr<cv::BRISK> ptrBrisk = cv::BRISK::create();
ptrBrisk->detect(img_1, camkeypoints);

//for keypoints
NSLog(@"Compute Keypoints");
ptrBrisk->compute(img_1, camkeypoints,camdescriptors);
if(camdescriptors.type()!=CV_32F) {
    camdescriptors.convertTo(camdescriptors, CV_32F);
}
NSLog(@"camera image conversion end");

This is also working fine but having same problem of Time Xcode result : -

2015-10-26 14:19:47.939 AVDemo[305:32700] Detect Keypoints

2015-10-26 14:19:49.787 AVDemo[305:32700] Compute Keypoints

2015-10-26 14:19:49.818 AVDemo[305:32700] camera image conversion end

How can minimize this time ?

Now I used FASTfeatureDetector, that minimizes some time but still SurfDescriptorExtractor is taking time.

New Code is : -

NSLog(@"Keypoint Detects");

//-- Step 1: Detect the keypoints using SURF Detector
int minHessian = 15;

FastFeatureDetector detector( minHessian );

std::vector<KeyPoint> keypoints_object, keypoints_scene;

detector.detect( img_1, keypoints_object );
detector.detect( img_2, keypoints_scene );

//-- Step 2: Calculate descriptors (feature vectors)
NSLog(@"Descriptor Detects");
SurfDescriptorExtractor extractor;

Mat descriptors_object, descriptors_scene;

extractor.compute( img_1, keypoints_object, descriptors_object );
extractor.compute( img_2, keypoints_scene, descriptors_scene );

//-- Step 3: Matching descriptor vectors using FLANN matcher
NSLog(@"Matching Detects");
FlannBasedMatcher matcher;
std::vector< DMatch > matches;
matcher.match( descriptors_object, descriptors_scene, matches );

Xcode : -

2015-10-26 16:06:19.018 AVDemo[375:47824] Keypoint Detects

2015-10-26 16:06:19.067 AVDemo[375:47824] Descriptor Detects

2015-10-26 16:06:21.117 AVDemo[375:47824] Matching Detects

  • Trying to resize image should help. – karttinen Oct 27 '15 at 12:59
  • Thanks #karttinen, but I am using like this type , I am already converting all the image to a smaller upto 10 kb. Yesterday also i found ORB Algorithm, through it I am able to minimize time, but unable to fetch the perfect match(as this issue will be in SURF also). – Atul Prakash Oct 27 '15 at 13:59
  • Performance and computational complexity are usually enemy of each other in this context. Therefore you need to sacrifice one of them =) If there's any way, you can try to minimize your search space. Let's say your image MxN, and your resized image(whole image) is (M/k)x(N/k). If you can somehow reduce your search space into (M/k)x(N/k), spatial resolution of the area that you extract the features will be bigger and therefore you will get a more detailed feature description- – karttinen Oct 28 '15 at 07:10
  • Did you find the solution? – Nam Vu Jan 11 '16 at 03:50
  • No not yet , Currently we switched on some other work . as sooner we find the solution will start work again. – Atul Prakash Jan 13 '16 at 05:08

0 Answers0