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.


    face_detector.py strange behavior

    Pythonista
    4
    24
    8819
    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.
    • JonB
      JonB last edited by

      You might consider adding a way for frame_counter and last frame time to be periodically reset to 0 if frame_xounter ever gets to be large.

      Or, have a label that gets updated with frame time, frame_counter , and now time -- since these are used in the logic inside the callback.

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

        Did you test? Same here?

        1 Reply Last reply Reply Quote 0
        • mikael
          mikael @pavlinb last edited by

          @pavlinb, works as-is for me, iPhone 11 Pro.

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

            So, the fps measurement at the top didn’t hang after 80-90 seconds?

            mikael 1 Reply Last reply Reply Quote 0
            • _zaez
              _zaez last edited by _zaez

              Do you fix the problem ?
              because this is my problem too

              1 Reply Last reply Reply Quote 0
              • mikael
                mikael @pavlinb last edited by

                @pavlinb, earlier you said 80-90 frames, which would be about 3 seconds. I have not yet let it run for minutes.

                pavlinb 1 Reply Last reply Reply Quote 0
                • mikael
                  mikael @pavlinb last edited by

                  @pavlinb, if this was originally run on iPhone 6, I bet we can do better than 5 fps on the face detection today. Have you studied enough to know whether we really need to initialize the face detector with options every time it is used?

                  pavlinb 1 Reply Last reply Reply Quote 0
                  • pavlinb
                    pavlinb @mikael last edited by

                    @mikael My goal is not face detection. I need the method to obtain frames from video camera and use them continuously.

                    1 Reply Last reply Reply Quote 0
                    • pavlinb
                      pavlinb @mikael last edited by

                      @mikael Correct duration should be 80-90 passes of face detector.

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

                        When phone wakes up after auto lock, script makes another 80-90 passes and hangs again.

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

                          I wonder if you need an autorelease pool. There was a thread on this recently, there is a context manager in objc_util.

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

                            Also, get rid of wait_modal, but instead stop everything in a custom view will_close method. Wait_modal keeps your background thread from doing anything else.

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

                              @JonB Tried, but same behaviour.

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

                                Other way of obtaining video camera frames continuously is welcome.

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

                                  For data processing or just displaying as a preview?

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

                                    @JonB For data processing.

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

                                      ok, i do see some issues..

                                      first, we need to implement the didDropSampleBuffer delegate method, and display the reason for a late frame.

                                      second, we need to set the minFrameDuration, so that the delegate is never called more than you need it. on older versions, i believe this was in output.minFrameDuration. in newer iOS versions, i believe you set on the connection, output.connections[0].videoMinFrameDuration

                                      third, there is an issue regarding what dispatch queue things are called on. or, the delegate needs to always return as fast as possible, calling heavy lifting on another thread, and dropping data otherwise. i think what is happening is that your delegate gets called on a background thread, and just keeps falling farther and farther behind. it might be better to ensure the delegate is called on the main thread.

                                      ill post a gist later with some improvements.

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

                                        @JonB I have tested another good example here

                                        In this script is implemented

                                        self.captureOutput.setMinFrameDuration_(CMTimeMake(1, 2), argtypes=[CMTime], restype=None)

                                        I have plaeyd with CMTimeMake(.,.).

                                        Unfotunately this script also hangs.

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

                                          I have a version based of Cethric's. I'll clean it up and post later. I've implemented the drop frame callback so you can see what the issues are.

                                          One problem I have found is that the various ways to set minFrameDuration don't work. That means the callback gets called at a high rate.

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

                                            It seems that setMinFrameDuration is in camera.captureOutput object ('AVCaptureVideoDataOutput').

                                            But there is also setActiveVideoMinFrameDuration in camera.captureDevice ('AVCaptureDevice').

                                            I couldn't make them working too both.

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