【发布时间】:2023-04-03 19:54:01
【问题描述】:
我最终决定使用 Google Mobile Vision sdk 来检测人脸并在相机中微笑,他们的 sdk 和样本看起来非常好,很有前途。
但是在我将他们的示例代码粘贴到我的项目中后,它总是在captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) 回调中崩溃。
这是总是抛出 BAD_ACCESS 异常的代码快照。
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
if (faceDetector == nil) {
self.faceDetector = GMVDetector(ofType: GMVDetectorTypeFace, options: [GMVDetectorFaceLandmarkType: GMVDetectorFaceLandmark.all.rawValue,
GMVDetectorFaceClassificationType: GMVDetectorFaceClassification.all.rawValue,
GMVDetectorFaceMinSize: 0.3,
GMVDetectorFaceTrackingEnabled: true])
}
guard let image = GMVUtility.sampleBufferTo32RGBA(sampleBuffer) else { // <-- this is where throws exception
print("Invalid sample buffer")
return
}
}
Google Face Detection crashing when converting to image and trying to detect face 可能重复,但没有正确答案。
提前致谢。
【问题讨论】:
标签: swift uiimage google-vision android-vision google-ios-vision