I am developing a Face Detection app. In this app, I have to draw circles nearby the eyes and mouth of the face and the user can click to drag circles for setting the position of the same according to him on the detected face. So, all circles have been drawn successfully on the face but I can't able to click on the particular circle and move on throughout the face with zoom out option. Please suggest me for the right solution regarding the same.
Thanks in advance.
To draw arcs or circles, we use the arc() or arcTo() methods.
In order to draw your shape, you must compile the shader code, add them to a OpenGL ES program object and then link the program. Do this in your drawn object's constructor, so it is only done once.
Override onDraw() The parameter to onDraw() is a Canvas object that the view can use to draw itself. The Canvas class defines methods for drawing text, lines, bitmaps, and many other graphics primitives. You can use these methods in onDraw() to create your custom user interface (UI).
Math.sqrt(Math.pow(clickX - centerX, 2) + Math.pow(clickY - centerY, 2));
Calculate the distance between the center of your point and the touch event - if the distance is smaller than the radius of your circle - you pressed on the circle
Here is an example I used for rectangles. See if you can adjust the code to use circles instead.
@Override
public boolean onTouchEvent( MotionEvent event) {
super.onTouchEvent(event);
int x = (int)event.getX();
int y = (int)event.getY();
xStored = x; yStored=y;
if (event.getAction()==MotionEvent.ACTION_UP){
}else if(event.getAction()==MotionEvent.ACTION_DOWN){
System.out.println("Touching down!");
for(Rect rect : rectangles){
if(rect.contains(x,y)){
System.out.println("Touched Rectangle, start activity."+x+","+y);
invalidate();
}else{
}
}
}else if(event.getAction()==MotionEvent.ACTION_MOVE){
}
this.postInvalidate();
return true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With