我正在尝试在我的 iOS 应用程序中实现 OpenCV。
CvVideoCamera 很棒,因为它有一个委托(delegate)方法,可以让我处理相机预览的每一帧,但我不知道如何提取一帧并将其保存为图像(也就是拍照)。
我怎样才能做到这一点?
谢谢
最佳答案
嗯..我的解决方案也是最好的方法,但它仍然有效。我要做屏幕截图并保存到我的相册中。这是我的代码
-(IBAction)takePhoto:(id)sender {
UIGraphicsBeginImageContext(imageView.frame.size);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
CGRect cropRect = CGRectMake(0 ,0 ,imageView.frame.size.width,imageView.frame.size.height);
CGImageRef imageRef = CGImageCreateWithImageInRect([screenshot CGImage], cropRect);
CGImageRelease(imageRef);
UIImageWriteToSavedPhotosAlbum(screenshot , nil, nil, nil);
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(screenshot , nil, nil, nil);
}
我唯一的问题是质量问题。我怎样才能提高他的质量?
最好的问候, 纳扎尔
关于ios - 使用 CvVideoCamera 拍照,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33397449/