我正在尝试使用openCV用iPhone相机检测名片的边缘(并绘制它们).我是这个框架的新手,还有Computer Vision或C. 
  
 
我正在尝试使用这里解释的解决方案:https://stackoverflow.com/a/14123682/3708095,其中github项目是https://github.com/foundry/OpenCVSquares
它适用于预定义的图像,但我正在尝试使用相机.
为此,我正在使用CvVideoCameraDelegate协议在CVViewController.mm中实现它,就像他们在http://docs.opencv.org/doc/tutorials/ios/video_processing/video_processing.html中解释的那样:
#ifdef __cplusplus
-(void)processImage:(cv::Mat &)matimage
{
//NSLog (@"Processing Image");
dispatch_async(dispatch_get_global_queue(disPATCH_QUEUE_PRIORITY_DEFAULT,0),^{
    matimage = CVSquares::detectedSquaresInImage(matimage,self.tolerance,self.threshold,self.levels,[self accuracy]);
    UIImage *image = [[UIImage alloc]initWithCVMat:matimage orientation:UIImageOrientationDown];
    dispatch_async(dispatch_get_main_queue(),^{
        self.imageView.image = image;
    });
});
}
#endif 
 编辑:
如果我这样做,它给了我一个EXC_BAD_ACCESS …
如果我在处理它之前克隆matimage,通过记录它,它似乎处理图像甚至找到矩形,但矩形不会被绘制到图像输出到imageView.
cv::Mat temp = matimage.clone();    
dispatch_async(dispatch_get_global_queue(disPATCH_QUEUE_PRIORITY_DEFAULT,^{
    UIImage *image = [[UIImage alloc]CVSquares::detectedSquaresInImage(temp,[self accuracy])
                                       orientation:UIImageOrientationDown];
    dispatch_async(dispatch_get_main_queue(),^{
        self.imageView.image = image;
    });
}); 
 我很确定我错过了一些东西,可能是因为我没有正确传递某个对象,指向对象的指针等等,而我需要修改的对象则没有.
无论如何,如果这不是正确的方法,我真的很感谢他们做这样的事情的教程或例子,使用openCV或GPUImage(也不熟悉它)…
解决方法
 所以解决方案实际上非常简单…… 
  
 
        它不需要尝试使用matimage来设置imageView.image,而只需要将matimage转换为在imageView中实际修改,因为CvVideoCamera已经初始化为(并链接到)imageView:
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:self.imageView];
最后这个功能是这样的:
#ifdef __cplusplus
-(void)processImage:(cv::Mat &)matimage
{
    matimage = CVSquares::detectedSquaresInImage(matimage,self.angletolerance,self.accuracy);
}
#endif