- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在努力解决的缩放问题仍然存在。我尝试按照 link1 中的代码使用 AVCaptureSession 获取图像和 link2 .
一切都很好,除了当我尝试实现相机变焦时,事情不会如我所愿地执行。
我尝试在 AVCaptureDevice 对象上使用 videoZoomFactor 方法,如下面的代码所示。
为什么 videoZoomFactor 没有任何效果,您有什么建议吗??
您将如何按预期使用 AVCaptureSession 为静止图像采集创建缩放??
- (void)addVideoInput {
AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if (videoDevice) {
// SOMEHOW NOT HAVING AN EFFECT AT ALL - WHY ?????
if ([videoDevice lockForConfiguration:nil]) {
float zoomFactor = videoDevice.activeFormat.videoZoomFactorUpscaleThreshold;
[videoDevice setVideoZoomFactor:zoomFactor];
// [videoDevice setVideoZoomFactor:3];
// videoDevice.videoZoomFactor = 3;
[videoDevice unlockForConfiguration];
}
// that all works again nicely...
NSError *error;
AVCaptureDeviceInput *videoIn = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
if (!error) {
if ([[self captureSession] canAddInput:videoIn]) {
[[self captureSession] addInput:videoIn];
}
else
NSLog(@"Couldn't add video input");
}
else
NSLog(@"Couldn't create video input");
}
else
NSLog(@"Couldn't create video capture device");
}
最佳答案
并非所有格式都支持缩放。如果您打印当前格式
NSLog(@"Current format: %@, max zoom factor: %f", videoDevice.activeFormat, videoDevice.activeFormat.videoMaxZoomFactor);
您可能会得到这样的结果(没有缩放级别)。
Current format: <AVCaptureDeviceFormat: 0x1559b3a0 'vide'/'420v' 1280x 720, { 1- 30 fps}, fov:49.240>, max zoom level: 1.000000
那么如果你打印所有格式
NSLog(@"All formats: %@", videoDevice.formats);
你会注意到其中一些有缩放因子,有些没有缩放因子
All formats: (
"<AVCaptureDeviceFormat: 0x1556aef0 'vide'/'420v' 192x 144, { 1- 30 fps}, fov:64.000, binned>",
"<AVCaptureDeviceFormat: 0x1556f4e0 'vide'/'420f' 192x 144, { 1- 30 fps}, fov:64.000, binned>",
"<AVCaptureDeviceFormat: 0x1556f3e0 'vide'/'420v' 352x 288, { 1- 30 fps}, fov:61.260, binned>",
"<AVCaptureDeviceFormat: 0x1556f3f0 'vide'/'420f' 352x 288, { 1- 30 fps}, fov:61.260, binned>",
"<AVCaptureDeviceFormat: 0x1556f360 'vide'/'420v' 480x 360, { 1- 30 fps}, fov:64.000, binned>",
"<AVCaptureDeviceFormat: 0x1556f370 'vide'/'420f' 480x 360, { 1- 30 fps}, fov:64.000, binned>",
"<AVCaptureDeviceFormat: 0x1556ae30 'vide'/'420v' 640x 480, { 1- 30 fps}, fov:64.000, binned>",
"<AVCaptureDeviceFormat: 0x1556ae40 'vide'/'420f' 640x 480, { 1- 30 fps}, fov:64.000, binned>",
"<AVCaptureDeviceFormat: 0x1556f5c0 'vide'/'420v' 960x 540, { 1- 30 fps}, fov:58.460, binned>",
"<AVCaptureDeviceFormat: 0x1556f5d0 'vide'/'420f' 960x 540, { 1- 30 fps}, fov:58.460, binned>",
"<AVCaptureDeviceFormat: 0x1556f3a0 'vide'/'420v' 1280x 720, { 1- 30 fps}, fov:49.240>",
"<AVCaptureDeviceFormat: 0x1556f3b0 'vide'/'420f' 1280x 720, { 1- 30 fps}, fov:49.240>",
"<AVCaptureDeviceFormat: 0x1556aa60 'vide'/'420v' 2592x1936, { 1- 15 fps}, fov:64.000, max zoom:121.00 (upscales @1.00)>",
"<AVCaptureDeviceFormat: 0x1556aa70 'vide'/'420f' 2592x1936, { 1- 15 fps}, fov:64.000, max zoom:121.00 (upscales @1.00)>"
在我的例子中,最后两个具有最大缩放。在这种情况下,我将我的 activeFormat 设置为最后一个(最大缩放大于 1(1 = 无缩放))。你不应该把它当作我的例子(lastObject),你应该首先检查哪种格式的缩放大于1。
videoDevice.activeFormat = [videoDevice.formats lastObject];
现在您可以设置 1.0 和 videoMaxZoomFactor 之间的任意数字。
[videoDevice setVideoZoomFactor:5.0];
关于ios - videoZoomFactor 不适用于 AVCaptureSession,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25125077/
我正在开发一个视频录制应用程序,需要能够使用蓝牙麦克风作为音频输入(如果已连接)。 我有以下代码来配置 AVCaptureSession 的音频输入: self.captureSession.uses
对于这个“愚蠢”的问题,我提前表示歉意,但我觉得我已经用尽了所有资源。我对 Swift 和一般编码几乎没有经验,但根据过去的经验和基于对象的编程(如 MAX MSP)的使用,我了解了很多。 我正在尝试
我正在尝试将捕获的帧记录为视频,同时并行地对帧执行图像处理任务。 我有一个 AVCaptureSession,我已将两个单独的输出添加到 - AVCaptureVideoDataOutput AVCa
当我尝试构建我的应用程序时,XCode 向我显示此错误 AVCaptureSession 之前应有“(” 有人可以帮我解决这个警告吗?这是我的代码: ViewController.h #import
我能够根据 http://developer.apple.com/iphone/library/qa/qa2010/qa1702.html 使用 AVCaptureSession 从相机捕获视频帧。但
我正在开发一个处理高清照片的应用程序。我正在使用 AVCaptureSession 拍照,停止它,然后对该照片应用效果。 让我疯狂的是,一切都运行良好,仪器告诉我,我正确且按时地释放了我使用的所有内存
我正在构建一个应用程序,允许用户使用 iPhone 相机拍照,并在可用时使用 AVFoundation (iOS4),以便用户可以使用点击对焦功能,即使使用自定义叠加层也是如此。 我遇到的问题是cap
所以这是一个普遍问题,但我们正在寻找有关如何让实时相机 View 能够在顶部添加图像并拍照的线索。所以基本上你可以选择像“帽子”一样覆盖在相机上的图像,调整其大小和位置,然后拍照,“帽子”将出现在你拍
我正在做一个 iOS 应用程序,需要使用这样的层次结构对 QR 码进行验证: View ---Scan View ---Image View - cardBG ---Inside View 加载 Vi
我正在尝试使用 AVCaptureSession 制作自定义相机。 代码和一切工作正常。唯一的问题是 VideoOutput 层被缩放。这使我的照片默认缩放。 我尝试了每件事,但无法找到解决方案。这是
我正在使用 AVCaptureSession 创建带有 AVCaptureMetadataOutput 的 QR 码扫描仪。 一切都按预期工作,但是我想在扫描仪上放置图形叠加层。这样做时,我希望扫描仪
弹出 View Controller 时,我在使用 AVCaptureSession 时遇到一些困难。我在导航 Controller 中有一个 View Controller ,用户可以在其中拍照。捕
有人知道如何使用 AVFoundation (AVCaptureStillImageOutput) 在自定义 iOS 相机中设置自定义分辨率吗? 我知道您可以使用 AVCaptureSession 选
我需要做这样的事情。我的应用程序使用 AVCapturesession 进行录制,但它应该能够流式传输带有我播放过的背景音乐的实时提要。 请记住,我可以使用 AVCapturesession 播放背景
当 AVCaptureSession 的 session 运行到本地 NSMutableArray 中捕获图像时,我收到 didReceiveMemoryWarning 调用。稍作测试后,我发现它发生
我正在尝试将 AVCaptureSession 的音频静音和取消静音。开始 session 后,我可以启用和禁用音频连接,但是一旦我播放视频,所有音频部分都会被推回视频的前面,只留下视频的结尾没有声音
我已经为 ios 应用程序添加了二维码阅读器代码现在我想使用可以用作 ios 中的 Today 扩展的相同代码。我已将以下代码用于应用程序和扩展。该应用程序运行良好,但不适用于扩展程序。 我用过htt
如何使用 AVCaptureSession 录制方形视频?如果在录制时不可能,那么我如何在 didFinishRecordingTo 委托(delegate)方法中裁剪它? 提前致谢! 最佳答案 您可
我收到一条警告: (sending "ViewController *const_strong' to parameter of incompatible type 'id' 执行这行代码时 [out
在我的应用程序中,我录制长达 30 秒的视频。我使用以下行来执行此操作。 [imagePicker setVideoMaximumDuration:30]; 一切正常。然后我决定从 UIImagePi
我是一名优秀的程序员,十分优秀!