简体   繁体   English

Android实时跟踪期间的计数问题

[英]Counting issues during real-time tracking on Android

I am making an app using ML KIT.我正在使用 ML KIT 制作应用程序。 I am currently implementing counting while doing squats.我目前正在做深蹲时进行计数。 The problem is that it counts when it goes down to a certain angle, but because it is a real-time tracking, it counts multiple times rather than once.问题是当它下降到某个角度时它会计数,但因为它是实时跟踪,它会计数多次而不是一次。 In other words, practically when I do one squat, the counting is much more than that.换句话说,实际上当我做一个深蹲时,计数远不止于此。 So I tried solving the problem using a timer handler.所以我尝试使用计时器处理程序解决问题。 But I failed.但我失败了。 Here is my code What should I do?这是我的代码我该怎么办?

     //going down
      if((rightKneeAngle<=90 && leftKneeAngle<=90) || (rightHipAngle<=135 && leftHipAngle<=135)){
        //Timer setting
        mTimer.schedule(new CustomTimer(), 2000);

    Log.d("PoseGraphic.class", "goingdown"+"rightKneeAngle : " + rightKneeAngle+ " leftKneeAngle : " + leftKneeAngle);
    Log.d("PoseGraphic.class","leftHip"+leftHipAngle+"RighHip"+rightHipAngle);
    Log.d("PoseGraphic.class", "cnt: " + cnt);


    //going up
    if((rightKneeAngle>170 && leftKneeAngle>90)|| (rightHipAngle>135 && leftHipAngle>135)){
      Log.d("PoseGraphic.class", "going up"+"rightKneeAngle : " + rightKneeAngle+ " leftKneeAngle : " + leftKneeAngle);
      Log.d("PoseGraphic.class","leftHip"+leftHipAngle+"RightHip"+rightHipAngle);

      if(cnt==12) {
        canvas.drawText("complete!", x, y, textPaint);
        //ExerciseCount.cnt = 0;
        cnt=0;
      }

    }

  }

//  TIMER handler class

    class CustomTimer extends TimerTask 
    @Override
    public void run() {
      cnt++;
    }

I cannot fully understand how you do it without seeing more code.如果没有看到更多代码,我无法完全理解你是如何做到的。

An suggestion would be: Instead of +1 to the count when the pose is in squat_down state, record the entering of that state with a boolean and +1 to the count only once the user exit squat_down and enter squat_up state. An suggestion would be: Instead of +1 to the count when the pose is in squat_down state, record the entering of that state with a boolean and +1 to the count only once the user exit squat_down and enter squat_up state. Then reset the state boolean.然后重置 state boolean。 By doing this, you will only +1 when user finish an entire cycle from squat_down to up.通过这样做,您只会在用户完成从下蹲到上的整个周期时 +1。

Actually, ML Kit just launched an example for squat and pushup classification and rep-counting.实际上,ML Kit 刚刚推出了一个用于深蹲和俯卧撑分类和重复计数的示例。 Here is the app you can try.这是您可以尝试的应用程序 If you want to classify some other poses, here is some guide and a Colab .如果你想对其他一些姿势进行分类,这里有一些指南和一个 Colab

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM