I am trying to figure out issue with my code. I am trying to process image using OpenCV in my iOS application. i have written method and did bridge-header as its here.
Here is my .h file:
#ifndef OpenCVWrapper_h
#define OpenCVWrapper_h
#endif
#import<UIKit/UIKit.h>
#import<Foundation/Foundation.h>
@interface OpenCVWrapper: NSObject
+(NSSTring*) processImageWithOpenCV:(UIImage*)inputImage;
@end
my .mm file is
#import <Foundation/Foundation.h>
#include "OpenCVWrapper.h"
#import "UIImage+OpenCV.h"
#import "UIKit/UIKit.h"
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
@implementation OpenCVWrapper : NSObject
+(NSString*) processImageWithOpenCV:(UIImage*)inputImage{
Mat mat = [inputImage CVMat];
/////////////Image processing etc
char *cstr = new char[Reading.length() + 1];
strcpy(cstr, Reading.c_str());
reverse(cstr, cstr + strlen(cstr));
const char* str = reinterpret_cast<const char*>(cstr);
NSString* string = [NSString stringWithUTF8String:str];
return string;
} /////// I get error here
@end
return "Success"
Here is how i am calling this method:
let reading = OpenCVWrapper.processImageWithOpenCV(Image)
I get error as mentioned in above code. First error is
`thread 1 signal sigabrt`
and when i try to continue. i get:
`Thread1: EXC_BAD_INSTRUCTION (code=EXC_i386_INVOP, subcode=0x0)`
I am stuck here for 2 days and unable to find right direction. There is no stack trace. just output of what i am printing in log.
Please point me to right direction.
Regards.