我是IOS的初学者,在IOS中使用OpenCV,我将opencv2.framework拖到我的项目中,代码如下所示:
#import "opencv2/opencv.hpp"
#import "opencv2/highgui/ios.h"
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIImage* a = [UIImage imageNamed:@"jay1.jpg"];
cv::Mat b;
UIImageToMat(a, b);
cv::cvtColor(b, b, CV_BGR2GRAY);
UIImage* c = MatToUIImage(b);
self.view.backgroundColor = [UIColor colorWithPatternImage:c];
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Hello!" message:@"Welcome to OpenCV" delegate:self cancelButtonTitle:@"Continue" otherButtonTitles:nil];
[alert show];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
此代码可以在Simulator上成功运行。当我在真实设备上运行它时,我收到了一个错误,我无法获得更多详细信息(点击此错误消息时,没有响应)。
Apple Mach-O Linker (ld) Error:
error: linker command failed with exit code 1 (use -v to see invocation)
我的Xcode(8.3)和IOS(10.3)设备都是最新版本,OpenCV版本是2.4.9。我还拖了一些必要的框架,例如:
QuartzCore.framework
CoreVideo.framework
CoreMedia.framework
CoreImage.framework
AVFoundation.framework
AssetsLibrary.framework
Accelerate.framework
CoreGraphics.framework
Foundation.framework
UIKit.framework
opencv2.framework
有人能告诉我如何在我的真实设备上运行这些代码。感谢你们对我的帮助。
答案 0 :(得分:0)
这是因为您的opencv2.framework
仅使用x86和x86-64架构构建。您需要找到一个包含armv7,armv7s(用于32位iPhone)和arm64(用于iphone 6及更高版本),或者从源代码构建一个(参见instruction)。