Tal Zion
Tal Zion

Reputation: 6526

How to use CIDetector and CIFaceFeature with large images and different aspect ratios

I've been working on this for days and all examples out there are if the image size is the same as the UIImageView. In addition, a lot of the answered on Stack are outdated.

I have an app where the user can add an image, which can be of any size, and different aspect ratio, for example 750X750, 1280X920. The UIImageView is smaller of course, and the content mode is set to Aspect Fill. I did a lot of testing so this is what I have done so far:

  1. I convert the CoreImage coordinates to UIKit using affin transform

  2. I get the scale ratio from the large image with the image width / by the UIImageView width to scale down.

Now both of the above would work I assume, if the image was an exact aspect ratio of the UIImageView, but as it may be bigger by using Aspect Fill, the width can go out of bounds, and therefore the Face Rect will be incorrect as the scale factor is agains the UIImageView width.

Thank you for your help in advance.

Upvotes: 1

Views: 353

Answers (0)

Related Questions