我正在使用openCv框架来检测人脸。我已阻止自动旋转。我正在使用这种方法来获得面子。
detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, cv::Size(100, 100));
当我将iPhone保持为纵向模式时,面部检测可以正常工作,但是当我将iPhone旋转至横向模式时,面部检测将失败。
这是CvVideoCamera的植入
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:self.imageView];
self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionFront;
self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPreset352x288;
self.videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
self.videoCamera.defaultFPS = 30;
self.videoCamera.grayscaleMode = NO;
self.videoCamera.delegate = self;
最佳答案
快速解决
在初始化CVVideoCamera之前,请添加以下这些行
NSNumber * value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
[[UIDevice currentDevice] setValue:键值:@“方向”的值];
self.videoCamera = [[CvVideoCamera分配] initWithParentView:self.previewImage];
self.videoCamera.delegate =自我;
关于iphone - iOS人脸检测在横向模式下失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16464692/