我也发现了这个问题on Apple Dev Forum。
CIDetector
设置CIDetectorTypeRectangle
是否可以返回多于一个矩形?
目前,即使图片中充满了矩形,此代码也会返回feature.count
0
或1
。
let context = CIContext()
let opts = [CIDetectorAccuracy : CIDetectorAccuracyHigh]
let detector = CIDetector(ofType: CIDetectorTypeRectangle, context: context, options: opts)
let image = CIImage(image: self.photoTaken)
let features = detector.features(in: image)
print(features.count) // never more than 1
答案 0 :(得分:4)
根据WWDC(http://asciiwwdc.com/2014/sessions/514)中的这个讲话,它仅限于一个矩形。
以下是对此的引用:
所以我们创建了一个通用的矩形探测器对象,它需要一个 选项参数,它是我们要搜索的宽高比。
同样,您可以要求探测器返回特征数组。
现在,它只返回一个矩形,但可能会改变 未来。