I'm trying to use Vision with a custom model I trained, but I don't see a way to get the bounding box where Vision detected it in the frame.
The model: I've trained the model using CreateML, and it can detect 2 specific items. I tested the model in CreateML with various images and it detects the 2 items correctly and places a box around them. So, shouldn't Vision be able to give me the bounding box as well?
func prepare() {
do {
let vnModel = try VNCoreMLModel(for: modelFile.model)
let coreMlRequest = VNCoreMLRequest(model: vnModel,
completionHandler: { (request, error) in
guard
let results = request.results
as? [VNClassificationObservation] // is this the right cast?
else { return }
// how do I get the bounding box from the results?
})
vnRequests = [coreMlRequest]
}
catch {
print(error)
}
}
func run(arFrame: ARFrame) {
do {
let requestHandler = VNImageRequestHandler(cvPixelBuffer: arFrame.capturedImage,
options: [:])
try requestHandler.perform(self.vnRequests)
}
catch {
print(error)
}
}