Post

Replies

Boosts

Views

Activity

How to convert VNRectangleObservation item to UIImage in SwiftUI
I was able to identify squares from a images using VNDetectRectanglesRequest. Now I want those rectangles to store as separate images (UIImage or cgImage). Below is what I tried. let rectanglesDetection = VNDetectRectanglesRequest { request, error in rectangles = request.results as! [VNRectangleObservation] rectangles.sort{$0.boundingBox.origin.y > $1.boundingBox.origin.y} for rectangle in rectangles { let rect = rectangle.boundingBox let imageRef = cgImage.cropping(to: rect) let image = UIImage(cgImage: imageRef!, scale: image!.scale, orientation: image!.imageOrientation) checkBoxImages.append(image) } Can anybody point out what's wrong or what should be the best approach?
1
0
1.2k
Jan ’23
How to convert VNRectangleObservation item to UIImage in SwiftUI
I was able to identify squares from a images using VNDetectRectanglesRequest. Now I want those rectangles to store as separate images (UIImage or cgImage). Below is what I tried. let rectanglesDetection = VNDetectRectanglesRequest { request, error in rectangles = request.results as! [VNRectangleObservation] rectangles.sort{$0.boundingBox.origin.y > $1.boundingBox.origin.y} for rectangle in rectangles { let rect = rectangle.boundingBox let imageRef = cgImage.cropping(to: rect) let image = UIImage(cgImage: imageRef!, scale: image!.scale, orientation: image!.imageOrientation) checkBoxImages.append(image) } Can anybody point out what's wrong or what should be the best approach?
Replies
1
Boosts
0
Views
1.2k
Activity
Jan ’23