- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何一次在屏幕上显示多个相机预览?
如果我开始一个新的 AVCaptureSession,另一个就会停止。如果我使用与另一个 session 相同的 session 初始化一个新的 AVCaptureVideoPreviewLayer,则另一个 AVCaptureVideoPreviewLayer 将停止显示相机提要。我怎样才能克服这个问题,并在屏幕上的两个不同的地方显示相机提要?
最佳答案
// in this method get CameraView Buffer Image and set Preview view
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
@autoreleasepool
{
NSLog(@"Capturecall");
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
/*Lock the image buffer*/
CVPixelBufferLockBaseAddress(imageBuffer,0);
/*Get information about the image*/
uint8_t *baseAddress = (uint8_t *)CVPixelBufferGetBaseAddress(imageBuffer);
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer);
size_t width = CVPixelBufferGetWidth(imageBuffer);
size_t height = CVPixelBufferGetHeight(imageBuffer);
/*Create a CGImageRef from the CVImageBufferRef*/
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef newContext = CGBitmapContextCreate(baseAddress, width, height, 8, bytesPerRow, colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
CGImageRef newImage = CGBitmapContextCreateImage(newContext);
/*We release some components*/
CGContextRelease(newContext);
CGColorSpaceRelease(colorSpace);
UIImage *image= [UIImage imageWithCGImage:newImage scale:1.0 orientation:UIImageOrientationRight];
CGImageRelease(newImage);
dispatch_async(dispatch_get_main_queue(),
^{
UIImage * blurredImage=[imagefilters GaussianBlurWithImage:image AndRadius:_brightnessValue];
[self.backgroundpreview setImage:blurredImage];
});
CVPixelBufferUnlockBaseAddress(imageBuffer,0);
}}
关于avfoundation - 多个 AVCaptureVideoPreviewLayers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11513704/
我有这段代码,它发出黄色警告。我不知道如何编码,所以黄色警告消失了。从 Swift-2 -> 3 -> 4 转换后尝试清理我的代码。 if let previewLayer = AVCaptureVi
如何一次在屏幕上显示多个相机预览? 如果我开始一个新的 AVCaptureSession,另一个就会停止。如果我使用与另一个 session 相同的 session 初始化一个新的 AVCapture
我正在开发一个允许用户拍照的应用程序。我已经开始使用AVCam苹果提供了,但我实际上有一个问题只是我无法将相机层放置在我想要的位置,但它会自动放置在 View 的中心 在左侧,您可以看到我实际拥有的内
我在将 AVCaptureVideoPreviewLayer 安装在其父级范围内时遇到问题。 这是上下文代码: capturePreview = AVCaptureVideoPreviewLa
当我尝试扫描条形码时,我仍然将 AVCaptureVideoPreviewLayer 添加到我的整个 View 中,如果我将条形码放在 View 中心,它会扫描。请帮我解决问题 最佳答案 AVCapt
我试图首先让我的应用程序显示广角相机的相机预览。但我所做的只是没有显示出来。 (该应用程序具有视频和音频权限,正在 iPhone 7 Plus 上进行测试) 这是我的 session 配置代码: fu
我正在使用一个库,使用相机和视频在我的 swift 应用程序上创建自定义相机 https://github.com/yonat/CameraBackground 但是我遇到了延迟,当闪光灯设置关闭时,
是否可以像裁剪图像一样裁剪视频预览层? image .clipShape(Circle()) .overlay(Circle().stroke(Color.gr
我在 AVCaptureVideoPreviewLayer 方面遇到问题。我是这样创建的: self.previewLayer = [AVCaptureVideoPreviewLayer layerW
我正在尝试从 ios 设备的摄像头获取提要以显示在屏幕上,但我不想使用 ImagePickerController,因为我想更好地控制屏幕上 View 的外观,并且我想要更多地控制相机的光圈和采样率。
当我将我的设备从横向向左旋转到横向或从横向向右旋转时,AVCaptureVideoPreviewLayer 会上下颠倒。当我将设备从纵向模式旋转到横向模式时,它工作得很好。这是我的代码 { ov
我正在设置带有预览层的自定义相机。一切正常。我设置了方向和所有内容。请问如何设置自动对焦?第二,如何启动摄像头录制视频?(因为它只是显示前置摄像头显示的内容,你看到你了)...但是我想开始录制。 我更
我正在尝试在我的应用程序中显示自定义摄像头 View 的视频预览,但目前预览非常偏离中心 - 使用前置摄像头时尤其明显。 我是这样定位的: if let previewLayer = AVCaptur
我使用 AVCaptureVideoPreviewLayer 来显示预览视频层、来自该预览的样本图像并对其进行一些处理。该处理识别图像上的一些点并将它们返回。我想(几乎)实时地在预览层上显示这些点。
我有一个 iPhone 相机应用程序,我在其中使用了 AVCaptureVideoPreviewLayer。当有人拍摄照片/静止图像时,这会显示在新的 ViewController 中。一旦这个 Vi
我有一个 AVCaptureVideoPreviewLayer,我想将它填充到我的 UIView 的边界。不过,它似乎无法正常工作。它只显示在大约 3/4 的屏幕上。 CGRect bounds=se
我有一个应用程序可以添加一些实时动画和图像以在 AV Foundation 相机中预览 View 。我可以做“硬件屏幕截图”(按住侧边按钮和提高音量按钮),没问题。但是,我需要一个制作屏幕截图的按钮。
我正在使用 AVCaptureVideoPreviewLayer 来允许用户从 iPhone 相机拍摄照片。所以我有一个 AVCaptureSession,输入为 AVCaptureDeviceInp
如何获取 AVCaptureVideoPreviewLayer 中的图像大小: self.cameraPreviewLayer.frame = self.cameraView.frame; // (0
我目前正在我的 Swift 应用程序中处理 QR 扫描 View 。我想将 VideoPreview 置于 View 中间。 View 看起来像这样: View (白色)称为 ScanView,我想让
我是一名优秀的程序员,十分优秀!