标签: avcapturedevice

如何为AVCaptureDevice计算focusPointOfInterest?

如何计算给定AVCaptureDevice的focusPointOfInterest(介于0,0和1,1之间的CGPoint值)?

我一直在关注最新WWDC的代码示例,但我真的不明白如何进行计算.此外,我的应用程序坐在横向与纵向(如示例中)...所以除了不了解事情的计算方式之外,我不确定为了解释横向问题需要做出哪些调整.

任何帮助,将不胜感激.

谢谢 - wg

iphone objective-c avfoundation ios4 avcapturedevice

5
推荐指数
1
解决办法
3034
查看次数

为AVCaptureSession设置自定义AVFrameRateRange

我试图用AVCaptureSession每秒拍摄5张照片,我不确定我理解AVFrameRange的含义.目前我有一些设置设备的代码:

AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
Run Code Online (Sandbox Code Playgroud)

并尝试设置activeVideoMinFrameDurationactiveVideoMaxFrameDuration自定义值CMTimeMake(1, 5).Apple告诉我,我只能使用他们提供的AVFrameRanges之一.

当我对它们进行NSLog时,我得到(2,30),(2,60)和(2,24).我首先想知道这意味着什么?这是相机运行的帧速率还是捕获帧的间隔(即我正在尝试做什么)?

如果不是,我该怎样做才能在sampleBufferDelegate方法上每秒保存5帧?目前它给了我每一个帧,因为每次有一个帧时都会调用该方法,所以我只需要一些指针来说明我每秒只能抓5个.

objective-c ios avcapturesession avcapturedevice

5
推荐指数
2
解决办法
6030
查看次数

如何使用Swift XCode访问Mac默认相机

今天,我第一次为Mac编码。我想做的是访问默认相机并显示预览。第二步,如果需要,我将记录或快速拍摄。对于第一步,我编写了以下代码

import Cocoa
import AVFoundation
class ViewController: NSViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        var session:AVCaptureSession = AVCaptureSession()
        session.sessionPreset = AVCaptureSessionPresetLow
        var device:AVCaptureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
        //Preview
        var previewLayer:AVCaptureVideoPreviewLayer = AVCaptureVideoPreviewLayer(session: session)
        var myView:NSView = self.view
        previewLayer.frame = myView.bounds
        previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
        self.view.layer?.addSublayer(previewLayer)
        session.startRunning()
    }
    override var representedObject: AnyObject? {
        didSet {
        // Update the view, if already loaded.
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我看不到此代码打开了我的笔记本电脑默认相机或在视图上显示任何内容。我在这里做错了什么?我可以寻找任何方向或任何示例,即使它在Obj-C中确实很有帮助。TIA。

macos xcode avcapturedevice swift

5
推荐指数
1
解决办法
7138
查看次数

无法使用AVCaptureDevice获取设备

我设法找到一些代码,可以让我访问手机设备(如相机).问题是,当我使用Xcode编译代码(我正在打印不同的设备)时,我得到一个空数组.

这是我写的:

import UIKit
import AVFoundation

class ViewController: UIViewController {

  let captureSession = AVCaptureSession()
  var previewLayer : AVCaptureVideoPreviewLayer?

  // If we find a device we'll store it here for later us
  var captureDevice : AVCaptureDevice?

  override func viewDidLoad() {
    super.viewDidLoad()            
    // Do any additional setup after loading the view, typically from a nib.

    captureSession.sessionPreset = AVCaptureSessionPresetHigh

    let devices = AVCaptureDevice.devices()
    println(devices)
    // Loop through all the capture devices on this phone
    for (device in devices) {
        // Make sure this …
Run Code Online (Sandbox Code Playgroud)

camera ios avcapturesession avcapturedevice swift

5
推荐指数
1
解决办法
5330
查看次数

捕获设备处于活动状态时,AVAudioSessionInterruptionNotification未触发

我在iOS 7.0.4上遇到" AVAudioSessionInterruptionNotification " 问题.
我在NSNotificationCenter上注册,然后激活AVAudioSession.一切正常,但如果激活相机,则不再触发该特定通知,无论是中断开始还是结束.
我通过在iPhone4上接收手机通话来测试音频中断,并在应用程序运行时发出警报响铃.我也尝试使用"AVCam"示例应用程序的通知,我有同样的问题.
音频中断和相机激活之间有什么关系?如果开启相机,为什么会停止触发音频中断?这可能是iOS错误吗?

编辑2014年1月10日:我更新到iOS 7.1 beta 3,问题仍然存在.

谢谢.

audio interruption avcapturedevice avaudiosession ios7

4
推荐指数
1
解决办法
1798
查看次数

应用程序在*前景*时,红色录音状态栏"闪烁"

关于双倍高度红色录音状态栏有很多问题(这里,这里),但当应用程序退回到后台时,所有问题都会引用闪烁.我得到了一个闪光灯,我假设从一个AVCaptureSession设置,而应用程序在前台.

有谁之前经历过这个吗?

avcapturesession avcapturedevice ios8

4
推荐指数
1
解决办法
1626
查看次数

AVCaptureSession旋转| 视频传输时的方向

我正在开发视频流应用,其中我需要捕获前置摄像头视频帧并编码然后转移到另一端,典型的流程是这样的

AVCaptureSession - > AVCaptureDeviceInput - > AVCaptureVideoDataOutput - >捕获帧 - >编码帧 - >发送帧到另一端,

它工作正常,我已将kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange设置为帧格式.

还有用于显示预览的预览图层,

当设备方向发生变化时,问题就出现了,如果设备从纵向移动到横向,那么在另一端框架旋转90度,我期待自从预览层支持方向,所以我将在Capture回调中自动接收旋转缓冲区,但看起来,预览层只显示捕获的缓冲区的预览和UI orating缓冲区,而在另一端我会得到咆哮的缓冲区,

所以我想知道,有没有任何配置可以让它改变,或者我需要在Capture缓冲区回调中旋转/转换缓冲区.

video objective-c++ ios avcapturesession avcapturedevice

4
推荐指数
1
解决办法
6458
查看次数

Objective-C AVCaptureDevice前置摄像头

我遵循了一个教程,通过一种方式来制作一个自定义但简单的相机应用程序,几乎完全符合我想要的使用需求.我实际上有两个问题需要改变,但我现在将重点关注第一个问题.

以下代码允许使用后置摄像头,但我基本上需要对其进行更改,以便我可以使用前置摄像头.我还会在这里链接我从中获取的视频给予他们的信任,然后我按照其中一位评论者所说的使用前置摄像头但答案根本没有帮助.

https://www.youtube.com/watch?v=Xv1FfqVy-KM

我根本不擅长编码,但试图学习.任何帮助,将不胜感激!非常感谢.

@interface ViewController ()

@end

@implementation ViewController

AVCaptureSession *session;
AVCaptureStillImageOutput *StillImageOutput;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewWillAppear:(BOOL)animated {

    session = [[AVCaptureSession alloc] init];

    [session setSessionPreset:AVCaptureSessionPresetPhoto];

    AVCaptureDevice *inputDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

    NSError *error;

    AVCaptureDeviceInput *deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:inputDevice error:&error];



    if ([session canAddInput:deviceInput]) {

        [session addInput:deviceInput];

    }



    AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];

    [previewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];

    CALayer *rootLayer = [[self view] layer];

    [rootLayer setMasksToBounds:YES];

    CGRect …
Run Code Online (Sandbox Code Playgroud)

camera objective-c ios avcapture avcapturedevice

4
推荐指数
1
解决办法
6101
查看次数

GPUImage - 点击和曝光无法正常工作 - 缺少某些东西?

我有一个用于AVFoundation设置相机的启动项目,它工作得很好.现在我需要将Camera机制转换为GPUImage.我在两个项目中都使用了相同的焦点和曝光方法(在项目中工作得很好AVFoundation),但在GPUImage项目中它没有正确聚焦而且总是错误的.

不介意应用过滤器,它们在所有过滤器上都是相同的

示例: 在屏幕的右上角,您可以看到羊羔.这就是它如何聚焦+曝光.

在此输入图像描述

设置GPU:

stillCamera = GPUImageStillCamera(sessionPreset: AVCaptureSessionPreset640x480, cameraPosition: .Front)
    CorrectPosition =  AVCaptureDevicePosition.Front
    stillCamera!.outputImageOrientation = .Portrait;
    stillCamera?.horizontallyMirrorFrontFacingCamera = true
    filter = GPUImageFilter()
    stillCamera?.addTarget(filter)
    filter?.addTarget(self.view as! GPUImageView)
    (self.view as! GPUImageView).fillMode = GPUImageFillModeType.init(2)
Run Code Online (Sandbox Code Playgroud)

TouchBegan方法:

   override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        var tap : CGPoint!
        if let touch = touches.first as UITouch! {
            tap = touch.locationInView(self.view)
        }
        let device: AVCaptureDevice! = self.stillCamera?.inputCamera!
        var error: NSError? = nil
        do {
            try device.lockForConfiguration()
            if …
Run Code Online (Sandbox Code Playgroud)

focus ios avcapturedevice gpuimage gpuimagestillcamera

4
推荐指数
1
解决办法
1025
查看次数

AVCaptureDevice isInUseByAnotherApplication 始终返回 false

我正在 Objective-C 和 AVFoundation 框架上做一个基本的应用程序,我想检测 Mac 的内置摄像头是否正在被另一个应用程序使用,我已经设法做到了,但它总是返回 false,即使我在将相机与其他软件一起使用。

我有一个函数包装此代码并每 2 秒执行一次:

NSArray *devices =  [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
    for(AVCaptureDevice *camera in devices){
        NSLog([camera isInUseByAnotherApplication] ? @"YES DEVICE BEING USED": @"DEVICE NOT BEING USED");
        NSLog([camera isSuspended] ? @"YES DEVICE SUSPENDED": @"DEVICE NOT suspended");
        NSLog([camera manufacturer]);
        NSLog([camera localizedName]);

    }
Run Code Online (Sandbox Code Playgroud)

问题是,我总是得到相同的结果:

2017-01-06 13:02:24.657 Befective Agent[13749:175226] DEVICE NOT BEING USED
2017-01-06 13:02:24.658 Befective Agent[13749:175226] DEVICE NOT suspended
2017-01-06 13:02:24.658 Befective Agent[13749:175226] Apple Inc.
2017-01-06 13:02:24.658 Befective Agent[13749:175226] FaceTime HD Camera (Built-in)
Run Code Online (Sandbox Code Playgroud)

编辑

软件上出现的摄像头和这个是一样的,而且我只有MacBook Pro的内置摄像头。

提前致谢!

编辑 …

objective-c avfoundation avcapturedevice

4
推荐指数
1
解决办法
472
查看次数