Question

I am creating an android application. In which I am recognizing the Line(Both vertical & horizontal). I have used the following steps.

1) Creating straight lines gesture file using "Gestures Builder" application. 
2) Added the "gestures" file in my application and used the "OnGesturePerformedListener" to recognize the line.

The problem is,
I can't recognize the vertical lines(Both Top to Bottom & Bottom to Top).

I can recognize the straight lines other than vertical lines. Can anybody know how to get the vertical line detection?

Code snippet:

public class GestureActivity extends Activity implements OnGesturePerformedListener {
    private GestureLibrary mLibrary;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GestureOverlayView gestureOverlayView = new GestureOverlayView(this);
    View inflate = getLayoutInflater().inflate(R.layout.activity_gesture,
            null);
    gestureOverlayView.addView(inflate);
    gestureOverlayView.addOnGesturePerformedListener(this);
    mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
    if (!mLibrary.load()) {
        finish();
    }
    setContentView(gestureOverlayView);
}

@Override
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
    ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
    if (predictions.size() > 0) {
        Prediction prediction = predictions.get(0);
        if (prediction.name.equals("Line") && prediction.score > 1.0) {
            Toast.makeText(this, "Line", Toast.LENGTH_LONG).show();
        }
    }

}

}

Was it helpful?

Solution

Finally I found the solution. The answer is given below.

gestureOverlayView.setGestureStrokeAngleThreshold( 90.0f);

Ref: https://stackoverflow.com/a/22807326/1485254

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top