AVCaptureDevice focusPointOfInterest 不变

发布于 2024-10-07 14:47:00 字数 634 浏览 7 评论 0原文

我有一个带有以下代码的 IBAction:

.h 文件:

AVCaptureDevice *device;

.m 文件:

- (IBAction)focusInfo {
 if (device == nil) {
  device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
 }

 NSLog(@"Camera focus point of interest: %d, %d", device.focusPointOfInterest.x, device.focusPointOfInterest.y);
}

这连接到 CustomCameraOverlay 上的按钮。当我在移动相机时按下按钮时,没有任何变化。控制台日志始终相同:

Camera focus point of interest: 0, 1071644672

为什么当相机改变焦点时它没有改变?我做错了什么?我还尝试获取属性 isAdjustingFocus,但它也没有改变。

我想为这些属性添加Obserwer,但卡在这里,如果值不改变,观察者将无法工作。

I have an IBAction with this code:

.h file:

AVCaptureDevice *device;

.m file:

- (IBAction)focusInfo {
 if (device == nil) {
  device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
 }

 NSLog(@"Camera focus point of interest: %d, %d", device.focusPointOfInterest.x, device.focusPointOfInterest.y);
}

This is conneted to button on CustomCameraOverlay. When I am pressing the button while moving the camera nothing changes. The console log is all the time the same:

Camera focus point of interest: 0, 1071644672

Why it is not changing while camera is changing focus? What I am doing wrong? I tried also to get property isAdjustingFocus, but it is not changing as well.

I wanted to addObserwer for those properties, but stucked in here, observer won't work if value won't change.

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

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

发布评论

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

评论(2

明月松间行 2024-10-14 14:47:00

focusPointOfInterest 的类型为 CGPoint,由 CGFloat 组成。尝试使用 %f 而不是 %d

focusPointOfInterest is of type CGPoint, which consists ofCGFloats. Try %f instead of %d.

假扮的天使 2024-10-14 14:47:00

记录 CGPoint(或其他 CGxxx 结构)时最好使用 NSStringFromCGPoint

NSLog(@"Camera focus point of interest: %@",
        NSStringFromCGPoint(device.focusPointOfInterest);

It's better to use NSStringFromCGPoint when logging CGPoint (or other CGxxx structs)

NSLog(@"Camera focus point of interest: %@",
        NSStringFromCGPoint(device.focusPointOfInterest);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文