[I want to select an object in a photo and then count the number of these objectsenter image description here](https://i.stack.imgur.com/fuxAS.png)
func compareImages(fullImage: UIImage, fragmentImage: UIImage) {
guard let fullCIImage = CIImage(image: fullImage),
let fragmentCIImage = CIImage(image: fragmentImage) else {
fatalError("Unable to create CIImage")
}
guard let model = try? VNCoreMLModel(for: model) else {
fatalError("Unable to load CoreML model")
}
let request = VNCoreMLRequest(model: model) { (request, error) in
guard let results = request.results as? [VNClassificationObservation],
let topResult = results.first else {
fatalError("Unable to classify images")
}
DispatchQueue.main.async {
print(results)
}
}
let handler = VNImageRequestHandler(ciImage: fullCIImage, options: [:])
do {
try handler.perform([request])
} catch {
print(error)
}
}
`
New contributor
v_shimchenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.