Cropping an image in iOS using OpenCV face detection
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I used the below code to crop a face from an image, in my face detection code. But I am not getting the proper face images and I am getting some part of the image saved and not the face. What's wrong in my code? _faceCascade . detectMultiScale ( mat , faces , 1.1 , 2 , kHaarOptions , cv :: Size ( 40 , 40 )); And inside the displayfaces functions am cropping with this code: CGRect cropRect = CGRectMake ( faces [ i ]. x , faces [ i ]. y , faces [ i ]. width , faces [ i ]. width ); CGImageRef cropped_img = CGImageCreateWithImageInRect