从前置摄像头拍摄时总是看到镜像 iOS 5.0

发布于 2025-01-04 12:25:22 字数 793 浏览 1 评论 0原文

从前置摄像头捕获数据时,我总是获得镜像,如何才能获得在预览窗口中看到的内容。我已将 videoMirrored 设置为 TRUE。以下是代码片段:

AVCaptureConnection *lConnection = nil;

  for ( AVCaptureConnection *connection in [lHandle->m_output connections]) {
     for ( AVCaptureInputPort *port in [connection inputPorts] ) {
         if ( [[port mediaType] isEqual:AVMediaTypeVideo] ) {
             lConnection = connection;
             break;
         }
     }
 }
if ([lConnection isVideoOrientationSupported])
    [lConnection setVideoOrientation:AVCaptureVideoOrientationPortrait];
if ([lConnection isVideoMirroringSupported])
    [lConnection setVideoMirrored:TRUE];

setVideoMirrored 更改为 True/False 也不会改变任何内容 (isVideoMirroringSupported 返回成功)

While capturing data from Front camera I am always getting Mirror image, how can I get what I am seeing in my preview window. I have set videoMirrored to be TRUE. Following is the code snippet:

AVCaptureConnection *lConnection = nil;

  for ( AVCaptureConnection *connection in [lHandle->m_output connections]) {
     for ( AVCaptureInputPort *port in [connection inputPorts] ) {
         if ( [[port mediaType] isEqual:AVMediaTypeVideo] ) {
             lConnection = connection;
             break;
         }
     }
 }
if ([lConnection isVideoOrientationSupported])
    [lConnection setVideoOrientation:AVCaptureVideoOrientationPortrait];
if ([lConnection isVideoMirroringSupported])
    [lConnection setVideoMirrored:TRUE];

Changing setVideoMirrored to True/False also doesn't change anything
(isVideoMirroringSupported returns Success)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

带刺的爱情 2025-01-11 12:25:22

使用以下代码翻转镜像。

UIImage * flippedImage = [UIImage imageWithCGImage:picture.CGImage scale:picture.scale orientation:UIImageOrientationLeftMirrored];

Flip the mirrored image with the following code.

UIImage * flippedImage = [UIImage imageWithCGImage:picture.CGImage scale:picture.scale orientation:UIImageOrientationLeftMirrored];
最佳男配角 2025-01-11 12:25:22

Swift 版本:

let flippedImage = UIImage(CGImage: image.CGImage, scale: image.scale, orientation: .LeftMirrored)

Swift version:

let flippedImage = UIImage(CGImage: image.CGImage, scale: image.scale, orientation: .LeftMirrored)
巷子口的你 2025-01-11 12:25:22

您可以使用withHorizo​​ntallyFlippedOrientation()来翻转UIImage。

// first get an UIImage from the front camera
let sourceImg = UIImage(cgImage: image, scale: 1.0, orientation: .leftMirrored)
return sourceImg.withHorizontallyFlippedOrientation()

You can use the withHorizontallyFlippedOrientation() to flip an UIImage.

// first get an UIImage from the front camera
let sourceImg = UIImage(cgImage: image, scale: 1.0, orientation: .leftMirrored)
return sourceImg.withHorizontallyFlippedOrientation()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文