Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
How can I set options for CIDetector?
-
Hi,
I want to specify options to CIDetector. Which is the correct way? (or both incorrect?)
options = {'CIDetectorAccuracy': 'CIDetectorAccuracyHigh'} d = CIDetector.detectorOfType_context_options_('CIDetectorTypeFace', None, options)
or do I need to write as:
options = NSDictionary.dictionaryWithDictionary_({'CIDetectorAccuracy': 'CIDetectorAccuracyHigh'}) d = CIDetector.detectorOfType_context_options_('CIDetectorTypeFace', None, options)
Actually both looks working fine, but I cannot know whether the options is actually effective. I cannot tell the detection accuracy is better or not, from the result.
I'm new to iOS and pythonista, I'm very grad to be advised by experts.
Thanks,
-
do you have an example of this working in code?
The first appears to be valid, but only assuming those are valid option keys and values.
Can you read back the options after setting, and see they look valid? -
You migt try setting CIDetectorMinFeatureSize to see if you can effectively disable detection, that would let you know whether the options are working. You do seem to have the correct key names (sometimes apple is inconsistent in the strings constants, and you can't guess from the constant name)
-
Thanks,
I have no idea to read back the options from CIDetecotor (or maybe faceCoreDetector in this class), could you tell me how can I read the option after setting?
And I'll try to set CIDetectorMinFeatureSize later, sounds good to check it!
My code is in progress, here: https://www.dropbox.com/s/4jdeohur37kzflk/MaskFace.py?dl=0
Thank you,
-
As you advised, I've tried CIDetectorMinFeatureSize. It works as expected. Dict of parameters seems correct way to set the parameters.
opt = {'CIDetectorAccuracy': 'CIDetectorAccuracyHigh', 'CIDetectorMinFeatureSize': 0.2} d = CIDetector.detectorOfType_context_options_('CIDetectorTypeFace', None, opt) rects = d.featuresInImage_(ci_img)
The face can be detected when the param is small (0.1), not be detected when the param is large (>0.3). (Somehow larger parameters kill pythonista to home screen.)
I cannot still find the way to read the set option from CIDetector. If you know which API to use, could you show me?
Thank you so much.
-
Yes, I looked through CIDetector and it was not obvious how to read the options back.