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

南笙酒味 提交于 2020-01-06 02:55:08

问题


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.

来源:https://stackoverflow.com/questions/36099735/how-to-use-cidetector-and-cifacefeature-with-large-images-and-different-aspect-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!