Post

Replies

Boosts

Views

Activity

Reply to Help Needed: Error Codes in VCPHumanPoseImageRequest.mm[85] and NSArrayM insertObject
Thanks for the fast reply! We have built this into a camera output delegate, for real-time performance improvements (or attempting to), depending on the user request, certain pose requests are added. This is not crucial to the app, but it is something we'd like to implement, so any help is really appreciated! From our initial troubleshooting, this is the code causing the problem: public func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) { let imageRequestHandler = VNImageRequestHandler(cmSampleBuffer: sampleBuffer, orientation: .up) var requests: [VNRequest] = [] if self.selectedRequests.hand { let handPoseRequest = VNDetectHumanHandPoseRequest() requests.append(handPoseRequest) } if self.selectedRequests.body { let bodyPoseRequest = VNDetectHumanBodyPoseRequest() requests.append(bodyPoseRequest) } if self.selectedRequests.face { let faceRequest = VNDetectFaceLandmarksRequest() requests.append(faceRequest) } var spatialOutput = VisionOutput() // Perform the selected Vision requests do { try imageRequestHandler.perform(requests) // Process results for each request for request in requests { if let request = request as? VNDetectHumanHandPoseRequest { spatialOutput.handPose = detectedHandPose(request: request) } else if let request = request as? VNDetectHumanBodyPoseRequest { spatialOutput.bodyPose = detectedBodyPose(request: request) } else if let request = request as? VNDetectFaceLandmarksRequest { spatialOutput.facePose = detectedFacePose(request: request) } } } catch { Logger.vision(level: .error, "Unable to perform the requests: \(error.localizedDescription).") } // Process the sample buffer to get an image (common for all cases) guard let bufferTest = sampleBuffer.imageBuffer else { return } spatialOutput.outputImage = createCGImage(from: bufferTest) DispatchQueue.main.async { self.output = spatialOutput } } And for reference, here is one of the pose request functions: func detectedBodyPose(request: VNRequest) -> [VNHumanBodyPoseObservation.JointName: VNRecognizedPoint]? { guard let bodyPoseResults = request.results as? [VNHumanBodyPoseObservation] else { return nil } guard let bodyPoseParts = try? bodyPoseResults.first?.recognizedPoints(.all) else { return nil } let filteredBodyPoseParts = bodyPoseParts.filter { $0.value.confidence > self.confidence } return filteredBodyPoseParts } Any and all help is appreciated, when we have time, we can also provide a sample project with this.
Jul ’24