简体   繁体   English

CIDetector:CIFaceFeature的边界始终为零

[英]CIDetector: CIFaceFeature with always zero bounds

I have no idea why CIFaceFeature I get always returns zero Rectangle: 我不知道为什么我得到的CIFaceFeature总是返回零矩形:

import Cocoa
import QuartzCore

let url = NSURL(string:"http://cs620522.vk.me/v620522149/12b59/ijvZ6XJWrw0.jpg");
let ciimg:CIImage = CIImage(contentsOfURL:url);
let cid:CIDetector = CIDetector(ofType:CIDetectorTypeFace, context:nil, options:[CIDetectorAccuracy: CIDetectorAccuracyHigh]);
let results:NSArray = cid.featuresInImage(ciimg, options: NSDictionary());
for r in results {
    let face:CIFaceFeature = r as CIFaceFeature;
    NSLog("Face found at (%f,%f) of dimensions %fx%f", face.bounds.origin.x, face.bounds.origin.y, face.bounds.width, face.bounds.height);
}

在此处输入图片说明

According to amount of NSLogs it seems CIDetector.featuresInImage works. 根据NSLogs的数量,似乎CIDetector.featuresInImage起作用。

You should use println to log the info. 您应该使用println记录信息。 Or you can use the following, 或者您可以使用以下内容,

NSLog("%@ face", face.bounds.origin.x.description)

A few questions the might inform an answer: 一些问题可能会为您提供答案:

  • Is the call to CIImage(contentsOfURL:url) resulting in a valid image? 调用CIImage(contentsOfURL:url)是否会生成有效图像? For example, is the resulting image extent a non empty rect? 例如,结果图像范围是否为非空白区域?
  • Does the image have orientation metadata? 图像是否包含方向元数据?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM