I am using the version of OpenCV for iPhone, and I have encountered a somewhat strange error. In using the stitcher, some of the imported headers are now complaining about an unmatched '{' on this line:
enum { NO, FEATHER, MULTI_BAND };
NO
is a macro from objc.h which is defined as
#define NO __objc_no
And the compiler is expecting a '}' to match the opening of the enum, even though there is one just a little later on. What is happening?
I have been having the same problem for a long time and I have just now discovered a workaround. As you stated correctly it is a problem with definition of the NO-makro in UIKit. What you need to do is go to your .pch-file and replace
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif
with
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#import <opencv2/stitching/detail/blenders.hpp>
#import <opencv2/stitching/detail/exposure_compensate.hpp>
#endif
So your resulting .pch should look something like this:
//
// Prefix header for all source files of the 'Project' target in the 'Project' project
//
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iOS SDK 3.0 and later."
#endif
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#import <opencv2/stitching/detail/blenders.hpp>
#import <opencv2/stitching/detail/exposure_compensate.hpp>
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
This way the NO-enums in blenders.hpp and exposure_compensate.hpp are defined before the NO-makro in UIKit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With