I also found this question on Apple Dev Forum.
Is it possible for a CIDetector
set with CIDetectorTypeRectangle
to return more than just one rectangle?
At the moment, this code always return a feature.count
of 0
or 1
, even if the picture is full of rectangles.
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
According to this talk in WWDC (http://asciiwwdc.com/2014/sessions/514), it is limited to only one rectangle.
Here is a quote for that:
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.