Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 不支持指定的颜色空间格式。回到利比乌夫身上_Ios_Swift_Xcode_Camera_Avfoundation - Fatal编程技术网

Ios 不支持指定的颜色空间格式。回到利比乌夫身上

Ios 不支持指定的颜色空间格式。回到利比乌夫身上,ios,swift,xcode,camera,avfoundation,Ios,Swift,Xcode,Camera,Avfoundation,我目前正在开发一个摄像头应用程序。一切正常,但当我试图更改Vision视图的约束时,日志突然打印出这个错误 [警告]不支持指定的颜色空间格式。回到利比乌夫身上 我不知道它从哪里来,我应该改变什么。下面我将通过设置相机的相关代码 func initializeCameraSession() { // Set up Values //1: Create a new AV Session // ,

我目前正在开发一个摄像头应用程序。一切正常,但当我试图更改Vision视图的约束时,日志突然打印出这个错误

[警告]不支持指定的颜色空间格式。回到利比乌夫身上

我不知道它从哪里来,我应该改变什么。下面我将通过设置相机的相关代码

  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.")
                                avSession.commitConfiguration()
                                return
                            }
                    avSession.commitConfiguration()
                }
                
            } catch {
                print(error.localizedDescription)
            }
            
            //3:  Show output on a preview layer
            let captureOutput = AVCaptureVideoDataOutput()
            captureOutput.setSampleBufferDelegate(self, queue: DispatchQueue(label: "videoQueue"))
            captureOutput.videoSettings = [(kCVPixelBufferPixelFormatTypeKey as String) : NSNumber(value: kCVPixelFormatType_32BGRA )]
            avSession.addOutput(captureOutput)
        
            
            let previewLayer = AVCaptureVideoPreviewLayer(session: avSession)
            previewLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill
            previewLayer.connection?.videoOrientation =  .portrait
            previewLayer.frame = visionView.bounds
            
        
                visionView.layer.addSublayer(previewLayer)

                view.bringSubviewToFront(visionView)
                visionView.isHidden = true
            visionView.alpha = 0.0
               avSession.startRunning()
            
        }
    
}

你找到解决这个问题的办法了吗?我很感激你的疑惑。不幸的是,我没能解决它。你有什么想法吗?我能够解决我的问题,因为当我试图将UIImage传递给Google Vision时,它抛出了这个问题。我最终做了UIImage->JPEGData->UIImage,它“修复”了色彩空间问题,不管它们是什么。很抱歉,这对您没有多大帮助:/您是否从DID输出sampleBuffer委托使用sampleBuffer,并使用sampleBuffer使用VisionImage(缓冲区:sampleBuffer)创建VisionImage?@GurjinderSingh是的。为什么知道这一点很重要?谢谢你的回复