An iOS C object converts coordinates from the position of an Absolute image to a coordinate system of the form

I use CIDetector to search for faces in the picture.

The coordinates of the faces that it returns are the absolute coordinates in the image file (image sizes are much larger than the screen size).

I tried using the convertRect: toView command. The image itself is not a UIView, so the command does not work, also I have several views embedded inside each other, where, finally, the image is displayed.

I want to convert the borders of the found faces in the image to the exact location of the face displayed on the screen in the embedded image.

How can I do that?

Thanks! The image displayed on the phone - the image is scaled to fit the screen, taking into account the correspondence

+4
source share
1 answer

Coordinates from CIDetecter (CoreImage) are inverted relative to UIKit coordinates. IOS Face Detection has tons of tutorials, but most of them are either incomplete or corrupted coordinates. Here is what is correct: http://nacho4d-nacho4d.blogspot.com/2012/03/coreimage-and-uikit-coordinates.html

One note: the tutorial uses a small image, so the received coordinates do not need to be scaled to represent the image on the screen (UIImageView). Assuming that you are using a photo taken using an iPad camera, you’ll have to scale the coordinates by the amount of scaling of the original image (if you do not reduce its size before starting the face detection procedure, maybe a good idea). You may also need to rotate the image for the correct orientation.

In one of the answers there is a routine for rotation / scaling: Previewing the UIImagePickerController camera - portrait in a landscape application

And this answer has a good routine for finding image scale when presenting a UIImageView using "aspect fit": How to get the size of a scalable UIImage in a UIImageView?

You will need to use the scale to map the coordinates of the CIDetector from the full-size image to the thumbnail shown in the UIImageView.

+8
source

All Articles