omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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?

    Pythonista
    2
    6
    5191
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • longjie0723
      longjie0723 last edited by

      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,

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        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?

        1 Reply Last reply Reply Quote 1
        • JonB
          JonB last edited by

          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)

          1 Reply Last reply Reply Quote 1
          • longjie0723
            longjie0723 last edited by

            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,

            1 Reply Last reply Reply Quote 0
            • longjie0723
              longjie0723 last edited by

              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.

              1 Reply Last reply Reply Quote 0
              • JonB
                JonB last edited by

                Yes, I looked through CIDetector and it was not obvious how to read the options back.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Powered by NodeBB Forums | Contributors