iPhone - 使用 AVCaptureSession 和 AVCaptureDevice 使用前置或后置摄像头

发布于 2024-12-29 04:20:35 字数 179 浏览 4 评论 0原文

使用 AVCaptureSession 和 AVCaptureDevice 使用前置或后置摄像头的正确方法是什么?

我可以看到 AVCapturedevice 的 position 属性是只读的,并且我没有看到任何其他方法来告诉我们要使用哪个设备,因为它可以通过 UIImagePicker 来完成。 。

Which is the right way to use the front or the rear camera using AVCaptureSession and AVCaptureDevice?

I can see that the position attribute of the AVCapturedevice is read-only, and I don't see any other way to tell which device we want to use, as it can be done with the UIImagePicker...

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

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

发布评论

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

评论(1

仅一夜美梦 2025-01-05 04:20:35

您可以使用 [AVCaptureDevice devices] 枚举设备并查看 position 属性来区分前部和后部(它们存在的位置)。

zxing 中有一些示例代码。 (对于 iOS,ZXCaptureDeviceZXCapture 中的 AVCaptureDevice)。

You use [AVCaptureDevice devices] to enumerate the devices and look at the position property to distinguish the front and rear (where they exist).

There's some example code in zxing. (For iOS, ZXCaptureDevice is AVCaptureDevice in ZXCapture).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文