我知道尝试使用openCV进入iPhone/iPad的图像处理过程中我发现了一些很好的教程,但没有提供很多信息。将图像保存到iPhone时出错
嗯,我想保存图像从一个较大的图像时,Xcode的ROI裁剪和模拟器没有报告任何错误,但是当我尝试打开保存Finder中的图像报告了一个“损坏的文件后,或格式不识别“错误。
这对裁剪并保存图像的代码(它插入到脸部识别教程从nashruddin.com
cvSetImageROI(image, cvRect(cvrect.x * scale, cvrect.y * scale, cvrect.width * scale, cvrect.height * scale));
/* create destination image
Note that cvGetSize will return the width and the height of ROI */
IplImage *img2 = cvCreateImage(cvGetSize(image),
image->depth,
image->nChannels);
cvCopy(image, img2, NULL);
cvResetImageROI(image);
CvAttrList attributes;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; //2
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"prueba.jpg"];
cvSave([path UTF8String], img2, NULL, NULL, attributes);
预先感谢任何帮助提供
塞尔吉奥