Start/Stop food detection
func setupPreviewLayer() {
guard videoLayer == nil else { return }
if let videoLayer = passioSDK.getPreviewLayer() {
self.videoLayer = videoLayer
videoLayer.frame = view.bounds
DispatchQueue.main.async { [weak self] in
self?.view.layer.insertSublayer(videoLayer, at: 0)
}
}
}func startFoodDetection() {
setupPreviewLayer()
DispatchQueue.global(qos: .userInitiated).async { [weak self] in
guard let self else { return }
let config = FoodDetectionConfiguration(detectVisual: true,
volumeDetectionMode: .none,
detectBarcodes: true,
detectPackagedFood: true)
passioSDK.startFoodDetection(detectionConfig: config,
foodRecognitionDelegate: self) { ready in
print("SDK was not configured correctly")
}
}
}Last updated