gpt4 book ai didi

ios - AVCaptureVideoPreviewLayer 前置摄像头在传递给 opengl 着色器之前翻转(取消镜像)像素缓冲区

转载 作者:技术小花猫 更新时间:2023-10-29 11:22:34 25 4
gpt4 key购买 nike

我正在使用 AVCaptureVideoPreviewLayer 传递实时视频并实时应用 openGL 着色器。使用前置摄像头时,视频是镜像的,我想在应用着色器之前取消镜像。

有人可以帮忙吗?

添加:切换到前置摄像头的代码:

-(void)showFrontCamera{
NSLog(@"inside showFrontCamera");
[captureSession removeInput:videoInput];
// Grab the front-facing camera
AVCaptureDevice *backFacingCamera = nil;
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice *device in devices) {
if ([device position] == AVCaptureDevicePositionFront) {
backFacingCamera = device;
}
}
// Add the video input
NSError *error = nil;
videoInput = [[[AVCaptureDeviceInput alloc] initWithDevice:backFacingCamera error:&error] autorelease];

if ([captureSession canAddInput:videoInput]) {
[captureSession addInput:videoInput];
}

}

最佳答案

如果你已经有一个预览层,你只需要更新连接:

[[previewLayer connection] setAutomaticallyAdjustsVideoMirroring:NO];
[[previewLayer connection] setVideoMirrored:NO];

关于ios - AVCaptureVideoPreviewLayer 前置摄像头在传递给 opengl 着色器之前翻转(取消镜像)像素缓冲区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17364004/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com