How to add SURF?

asked 2014-09-25 23:20:37 -0500

madLokesh gravatar image

updated 2014-09-25 23:31:26 -0500

I am trying to fecth the feature descriptors and keypoints of the video frame.

I have created a new XCode project using openCV2 framework. I am getting error while importing nonfree module. I tried initializing the same bt with no luck.

Is there any SURF.cpp which I have to import and call its reference to my native code.

Following is the code


#import <UIKit/UIKit.h>
#import <opencv2/highgui/highgui_c.h>
#import <opencv2/videoio/cap_ios.h>

#include <opencv2/nonfree/features2d.hpp>
#include <opencv2/nonfree/nonfree.hpp>

using namespace cv;

@interface CVdemoViewController : UIViewController<CvVideoCameraDelegate>{
   UIButton *videoStart;
   UIImageView *previewImage;
   CvVideoCamera *videoCamera;

@property (nonatomic, retain) UIImageView *previewImage;
@property (nonatomic, retain) UIButton *videoStart;
@property (nonatomic, retain) CvVideoCamera *videoCamera;



#import "CVdemoViewController.h"

@implementation CVdemoViewController
@synthesize  videoStart, videoCamera, previewImage;

- (void)viewDidLoad

   [super viewDidLoad];
   // Do any additional setup after loading the view, typically from a nib.
   [self initialiseUIObjects];

   videoCamera = [[CvVideoCamera alloc]initWithParentView:previewImage];
   videoCamera.delegate = self;
   videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionBack;
   videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPreset352x288;
   videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
   videoCamera.defaultFPS = 30;
   videoCamera.grayscaleMode = NO;


   previewImage = [[UIImageView alloc]initWithFrame:CGRectMake(50,50,self.view.frame.size.width-100, self.view.frame.size.height-150)];
   previewImage.backgroundColor = [UIColor blackColor];
   [self.view addSubview:previewImage];

   videoStart = [[UIButton alloc]initWithFrame:CGRectMake((self.view.frame.size.width/2)-50, self.view.frame.size.height-80, 100, 50)];
  [videoStart setTitle:@"Start" forState:UIControlStateNormal];
  [videoStart setBackgroundColor:[UIColor blackColor]];
  [videoStart addTarget:self action:@selector(startOpenCV) forControlEvents:UIControlEventTouchUpInside];
  [self.view addSubview:videoStart];

#ifdef __cplusplus


    //Do I need to add SURF here ? If yes, HOW?


    if([videoStart.titleLabel.text isEqualToString:@"Start"]){
        [videoCamera start];
        [videoStart setTitle:@"Stop" forState:UIControlStateNormal];
        [videoCamera stop];
        [videoStart setTitle:@"Start" forState:UIControlStateNormal];



#import <Availability.h>

#ifndef __IPHONE_5_0
    #warning "This project uses features only available in iOS SDK 5.0 and later."

#ifdef __cplusplus
    #import <opencv2/opencv.hpp>

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
edit retag flag offensive close merge delete