iOS 人脸检测在模拟器和设备中的工作方式不同

发布于 2025-01-06 12:43:02 字数 863 浏览 0 评论 0原文

我正在尝试使用 iOS 5 面部检测,我发现当我在模拟器上运行代码时,它会检测到具有正确框架的面部。但是,如果我在设备上的同一张图像上运行完全相同的代码,它会返回不正确的尺寸。 这是我的代码:

CIImage* image = [CIImage imageWithCGImage:someImage.CGImage];

NSDictionary *detectorOptions =
[NSDictionary dictionaryWithObjectsAndKeys:
 CIDetectorAccuracyHigh, CIDetectorAccuracy,
 nil];

CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace
                                          context:nil
                                          options:detectorOptions];


NSArray *faceFeatures = [detector featuresInImage:image];
for (CIFeature *f in faceFeatures) {
  NSLog(@"Feature: %@", NSStringFromRect(f.bounds));
}

模拟器的输出(正确): 特征:{{78, 153}, {200, 200}}

设备的输出(不正确): 功能:{{104, 199}, {272, 272}}

这是一个错误吗?还是我使用人脸检测代码不当?我还尝试使用 featuresInImage:options 并传入另一个具有设备方向的字典

I am trying to use iOS 5 facedetection, and I'm finding that when I run the code on the simulator, it detects a face with correct frame. However, if I run the exact same code on the same image on the device, it returns incorrect dimensions.
Here's my code:

CIImage* image = [CIImage imageWithCGImage:someImage.CGImage];

NSDictionary *detectorOptions =
[NSDictionary dictionaryWithObjectsAndKeys:
 CIDetectorAccuracyHigh, CIDetectorAccuracy,
 nil];

CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace
                                          context:nil
                                          options:detectorOptions];


NSArray *faceFeatures = [detector featuresInImage:image];
for (CIFeature *f in faceFeatures) {
  NSLog(@"Feature: %@", NSStringFromRect(f.bounds));
}

The output from the simulator (correct):
Feature: {{78, 153}, {200, 200}}

The output from the device (incorrect):
Feature: {{104, 199}, {272, 272}}

Is this a bug? Or am I improperly using the face detection code? I've also tried using featuresInImage:options and passing in another dictionary with the device orientation

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文