Ask Your Question

Revision history [back]

Hi everyone,

The sample code published by chicio inspired me because i'm trying to do the same stuff. I am encountering an issue on the Descriptor Extractor compute method using an Mat vector argument (EXC_BAD_ACCESS below). Do you faced the same issue ?

By the way, Is it possible to see all your code ? Do you explored/tried the ORB method ?

Here is my code :

//-- Step 0: Create image references
UIImage *objectImage1 = [UIImage imageNamed:@"star.png"];
Mat object1 = [self cvMatFromUIImage:objectImage1];
cvtColor(object1, object1, CV_BGRA2BGR);


UIImage *objectImage2 = [UIImage imageNamed:@"spawn.png"];
Mat object2 = [self cvMatFromUIImage:objectImage2];
cvtColor(object2, object2, CV_BGRA2BGR);

vector<Mat> trainImgCollection;
trainImgCollection.push_back(object1);
trainImgCollection.push_back(object2);

//-- Step 1: Detect the keypoints using XXX Detector
NSLog(@"Create ORB Detector");
int minHessian = 400;

OrbFeatureDetector detector( minHessian );

vector<vector<KeyPoint> > trainPointCollection;
vector<KeyPoint> queryPoints;
detector.detect(queryImage, queryPoints );
detector.detect(trainImgCollection, trainPointCollection );

//-- Step 2: Calculate descriptors (feature vectors)
NSLog(@"Create ORB Extractor");
DescriptorExtractor *extractor = DescriptorExtractor::create("SURF");

vector<Mat> trainDescCollection;
Mat queryDescriptors;

//extractor.compute(myMat, keypoints_2, descriptors_2 );
NSLog(@"Compute descriptors");
//extractor.compute(queryImage, queryPoints, queryDescriptors );
extractor->compute(trainImgCollection, trainPointCollection, trainDescCollection); <== EXC_BAD_ACCESS HERE

Thanks in advance, Regards