我也发现了这个问题on Apple Dev Forum .
设置为 CIDetectorTypeRectangle
的 CIDetector
是否有可能返回不止一个矩形?
目前,此代码始终返回 0
或 1
的 feature.count
,即使图片中充满了矩形。
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
最佳答案
根据 WWDC(http://asciiwwdc.com/2014/sessions/514)中的这个演讲,它仅限于一个矩形。
引用一段话:
So we've created a generic rectangle detector object and it takes one option parameter which is the aspect ratio that we want to search for.
And again, you can ask the detector to return the features array.
Now right now, it just returns one rectangle but that may change in the future.
关于ios - CIDetector 能否返回多个 CIDetectorTypeRectangle 类型的 CIFeature?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40021560/