小编Bru*_*ann的帖子

IOS:照亮 ARKit 和 Vision 的流媒体

我目前正在开发我的应用程序的一项功能,该功能可识别相机流中的人脸。我正在阅读具有里程碑意义的特征,例如嘴巴等。当光照条件充足时,一切正常。但在黑暗中,ARKit 和 Vision 都遇到了麻烦。有没有办法自动使流明亮度适应背景照明以保持功能?

研究表明,曝光时间是图像亮度的核心。因此,我尝试了一种适应曝光时间的功能。如果没有识别到​​人脸,图像变暗,曝光时间将增加 0.01。类似于本文中的函数。但要么没用,要么太亮了,脸都认不出来了。正因为如此,我尝试了自动版本,captureDevice.focusMode = .continuousAutoFocus但我没有注意到任何显着的改进。

这是我的代码:

视觉API

        let devices = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .front).devices

        //2:  Select a capture device
        do {
            if let captureDevice = devices.first {
                let captureDeviceInput = try AVCaptureDeviceInput(device: captureDevice)



                if(captureDevice.isLowLightBoostSupported){
                try captureDevice.lockForConfiguration()
                captureDevice.automaticallyEnablesLowLightBoostWhenAvailable = true
                captureDevice.unlockForConfiguration()
                }

                if(captureDevice.isExposureModeSupported(.continuousAutoExposure)){
                try captureDevice.lockForConfiguration()
                captureDevice.exposureMode = .continuousAutoExposure
                captureDevice.unlockForConfiguration()
                }


                if(captureDevice.isFocusModeSupported(.continuousAutoFocus)) {
                    try! captureDevice.lockForConfiguration()
                    captureDevice.focusMode = .continuousAutoFocus
                }

                try! captureDevice.lockForConfiguration()
                captureDevice.automaticallyAdjustsVideoHDREnabled = true
                captureDevice.unlockForConfiguration()


                avSession.addInput(captureDeviceInput)
            }

        } catch {
            print(error.localizedDescription)
        }

        let …
Run Code Online (Sandbox Code Playgroud)

brightness ios swift apple-vision arkit

5
推荐指数
0
解决办法
114
查看次数

'NSInvalidArgumentException',原因:'+[FIRInstanceIDCheckinPreferencespreferencesFromKeychainContents:]:'无法识别的选择器发送到类'

当我尝试使用 Firebase 中的 MLModelInterpreter 在 Xcode 项目中加载 tflite 文件时,在 Launchsreen 完全可见后出现以下错误:

\n\n
*** Terminating app due to uncaught exception \'NSInvalidArgumentException\', reason: \'+[FIRInstanceIDCheckinPreferences preferencesFromKeychainContents:]: unrecognized selector sent to class 0x10235ca58\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的代码基于 Firebase 的教程,因此令我惊讶的是它不起作用。这是代码:

\n\n
import Firebase\n\n\n    var interpreter: ModelInterpreter?\n\n    func convertTheModel(){\n\n\n        guard let modelPath = Bundle.main.path( forResource: "model", ofType: "tflite", inDirectory: ""\n            )\n            else {\n                print("not able to load model")\n                return\n\n        }\n\n        let localModel = CustomLocalModel(modelPath: modelPath)\n        interpreter =  ModelInterpreter.modelInterpreter(localModel: localModel)\n\n        let ioOptions = ModelInputOutputOptions()\n        do {\n            try ioOptions.setInputFormat(index: 0, …
Run Code Online (Sandbox Code Playgroud)

xcode compiler-errors ios firebase swift

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

不支持指定的色彩空间格式。回到 libyuv

我目前正在开发一个相机应用程序。一切正常,但是当我尝试更改 Vision View 的约束时,日志突然打印了此错误。

[警告]不支持指定的色彩空间格式。回到 libyuv。

我不知道它来自哪里以及我应该改变什么。下面我将介绍设置相机的相关代码。

  func initializeCameraSession() {
            //  Set up Values
            
            //1:  Create a new AV Session
//            , xf           , AVCaptureVideoDataOutputSampleBufferDelegate           // Get camera devices
            let devices = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .front).devices
            //2:  Select a capture device
            
            avSession.sessionPreset = .low
            do {
                if let captureDevice = devices.first {
                
                    let captureDeviceInput = try AVCaptureDeviceInput(device: captureDevice)



                    }
                   avSession.beginConfiguration()
                    if avSession.canAddInput(captureDeviceInput) {
                        avSession.addInput(captureDeviceInput)
                            self.videoDeviceInput = captureDeviceInput
                                
                    } else {
                                print("Couldn't add video device input to the session.") …
Run Code Online (Sandbox Code Playgroud)

xcode camera avfoundation ios swift

5
推荐指数
0
解决办法
679
查看次数