【问题标题】:CIDetector: CIFaceFeature with always zero boundsCIDetector:CIFaceFeature,边界始终为零
【发布时间】:2015-01-27 18:37:48
【问题描述】:

我不知道为什么我得到的 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);
}

根据 NSLogs 的数量,CIDetector.featuresInImage 似乎有效。

【问题讨论】:

  • 你能把你的代码作为实际文本而不是图像放在你的问题中吗?
  • @dpassage 非常感谢!

标签: ios swift core-image


【解决方案1】:

您应该使用println 记录信息。或者您可以使用以下内容,

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

【讨论】:

    【解决方案2】:

    几个问题可能会提供答案:

    • 对 CIImage(contentsOfURL:url) 的调用是否会产生有效的图像? 例如,生成的图像范围是否为非空矩形?
    • 图像是否有方向元数据?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-02
      • 2012-01-16
      • 2020-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多