When the condition is true my counter value is increasing continuously instead of only one value. If angle is greater than 90 degree it keeps increasing like 1,2,3,4,5 instead of 1 than 2 than 3 Shoulder = new float[] {landmarks.getLandmark(12).getX(),landmarks.getLandmark(12).getY()}; elbow =new float[] {landmarks.getLandmark(24).getX(),landmarks.getLandmark(24).getY()}; wrist = new float[] {landmarks.getLandmark(15).getX(),landmarks.getLandmark(15).getY()}; double angle = calculate_angle(Shoulder, elbow, wrist); System.out.println(angle);
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);
}