ios - 使用 CvVideoCamera 拍照

标签 ios opencv objective-c++

我正在尝试在我的 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/

相关文章:

javascript - Doubletaptogo 响应式菜单在手机上不起作用

php - 使用基于 PHP XML 的 Web API 的 iOS 应用程序

jquery - 使用 Mobile Safari "form assistant"更改事件不会在选定元素上触发

ios - 当我在 Xcode 中将 Compile Source As Objective-C 更改为外部库时出现错误

iOS SoundTouch 框架 BPM 检测示例

ios - "Potential Loss of Keychain Access"?我可以忽略它吗?为该应用付费的现有应用用户会有问题吗?

c++ - 查找点相对于整个图像的 X 和 Y 坐标

c++ - 如何在 Opencv API 中实现 GPUImage 过滤器?

python - SimpleCV网络摄像头黑色图像

c++ - Objective-C 和 Swift 之间的委托(delegate)问题