【问题标题】:Value is continuously increasing when the condition is true. Mediapipe library当条件为真时,值不断增加。媒体管道库
【发布时间】:2022-01-11 07:36:49
【问题描述】:

当条件为真时,我的计数器值不断增加,而不是只有一个值。如果角度大于 90 度,它会像 1、2、3、4、5 而不是 1 比 2 比 3 不断增加 肩=新浮动[] {landmarks.getLandmark(12).getX(),landmarks.getLandmark(12).getY()}; 肘=新浮动[] {landmarks.getLandmark(24).getX(),landmarks.getLandmark(24).getY()}; 手腕=新浮动[] {landmarks.getLandmark(15).getX(),landmarks.getLandmark(15).getY()}; 双角 = 计算角度(肩、肘、腕); System.out.println(角度);

                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                String stage="down";

                                // Stuff that updates the UI
                                if (angle > 90) {
                                    stage = "down";
                                    tv.setText(stage);

                                }
                                if (angle <=90 ){
                                    stage = "up";
                                    tv.setText(stage);
                                    doSomething();

                                    System.out.println("This is"+counter);

                                }







                            }
                        });

                        // Note: If eye_presence is false, these landmarks are useless.
                        Log.v(
                                TAG,
                                "[TS:"
                                        + packet.getTimestamp()
                                        + "] #Landmarks for iris: "
                                        + landmarks.getLandmarkCount());
                        Log.v(TAG, getLandmarksDebugString(landmarks));
                    } catch (InvalidProtocolBufferException e) {
                        Log.e(TAG, "Couldn't Exception received - " + e);
                        return;
                    }
                });
//        }
    }
    public int doSomething(){
        counter = counter +1;
        tv2.setText(String.valueOf(counter));

        System.out.println("This is bingo"+counter);
        return (counter);
    }

【问题讨论】:

    标签: android mediapipe


    【解决方案1】:

    您似乎想增加一些延迟。您需要篡改 UI 线程,即 Thread.sleeep() 或使用 System.currentTimeMillis() 来检查线程上次运行的时间。

    【讨论】:

      猜你喜欢
      • 2012-06-28
      • 1970-01-01
      • 2018-11-23
      • 2021-11-13
      • 1970-01-01
      • 2022-11-10
      • 1970-01-01
      • 1970-01-01
      • 2018-10-10
      相关资源
      最近更新 更多