【发布时间】:2020-12-24 03:14:32
【问题描述】:
我正在尝试将 Vision 与我训练的自定义模型一起使用,但我没有找到一种方法来获取 Vision 在框架中检测到的边界框。
模型:我使用 CreateML 训练了模型,它可以检测 2 个特定项目。 我在 CreateML 中使用各种图像测试了模型,它正确检测了这两个项目并在它们周围放置了一个框。那么,Vision 不应该也可以给我边界框吗?
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)
}
}
【问题讨论】: