0

I am working on a exercise counter using Openpose. Right now I am in testing phase the Issue that I am encountering is i have this code snippet

            if len(pose) > 0:
            print ("Start Pushup")
            if (lh_angle and ll_angle and rh_angle  and rl_angle != 0 ):

                if (lh_angle < 75  and ll_angle < 35 and rh_angle < 75  and rl_angle < 35 ):
                    print ('Pushup Detected')
                    a = "Pushup"
                    reps = reps + 1

                    if (reps == 2):
                        sets = sets + 1
                        reps = 0

                    else:
                        sets = sets

                else:
                    print ('No Pushup')
                    a = "No Pushup"
                    reps = reps***

but the issue is since the person stays in pushup position the counter keeps on increasing. Is there any solution to this problem that the counter does not keep on increasing and increases only once

Miki
  • 40,887
  • 13
  • 123
  • 202
  • 3
    Add a `pushup` flag which is set to `True` or `False` accordingly. If it was False and should now be set to True, this is a new pushup. – Michael Butscher Apr 15 '20 at 21:40
  • I would suggest you to add sleep in code as it will read the input each time and it will increase the counter. time.sleep() should help you. – Vikas Mulaje Apr 16 '20 at 09:00

1 Answers1

0

This will stop doublecounting:

bool inPushup = false
whileloop {
   if (pushup detected){
      if(inPushup == false) {
         reps = reps + 1
      }
      inPushup = true
   }else{
      inPushup = false
   }  
}
Marcus Gee
  • 126
  • 2