Note that there are some explanatory texts on larger screens.

plurals
  1. POSet xy position to a imageView using faceDetection
    text
    copied!<p>I am detecting a face in my app. I use two ImageView, the first for the face and the second for a mask. I need set the mask position over the calculated face position and then can move the mask with touch event. For the touch event I did use of this tutorial: <a href="http://blahti.wordpress.com/2011/01/17/moving-views-part-2/" rel="nofollow">http://blahti.wordpress.com/2011/01/17/moving-views-part-2/</a></p> <p>The method for mask scalling can return the face position. I tried set the XY position to the mask Imageview but ever is showed in the position 0.0. over the face. Then I can move the mask ImageView over the face. "view" is my mask. Ideally I need initialize the mask imageview over the face position.</p> <p>PD: Sorry my english is bad.</p> <pre><code>protected Bitmap draw(int mode) { Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.c10); int width = bitmap.getWidth(); int height = bitmap.getHeight(); Point position = new Point(); xRatio = anchoCara * 1.0f / anchoCara; yRatio = altoCara * 1.0f / altoCara; Bitmap resizedBitmap = null; float factor = 9.6f;//9.6 for (int i = 0; i &lt; eyesMidPts.length; i++) { if (eyesMidPts[i] != null) { pOuterBullsEye.setStrokeWidth(eyesDistance[i] / 6); float newWidth = eyesDistance[i] * factor; float newHeight = eyesDistance[i] * factor; float scaleWidth = (newWidth) / width; float scaleHeight = (newHeight) / height; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); position.set( (int) ((eyesMidPts[i].x * xRatio) - (eyesDistance[i] * factor) ),//2 (int) ((eyesMidPts[i].y * yRatio) - (eyesDistance[i] * factor) )); Log.e("Face", "positio x : " + position.x); Log.e("Face", "positio y : " + position.y); Log.e("Face", "mascara width : " + resizedBitmap.getWidth()); Log.e("Face", "mascara heigth : " + resizedBitmap.getHeight()); // view.setBackgroundDrawable(new BitmapDrawable(resizedBitmap)); // view.setAdjustViewBounds(true); // Log.i("Face", "positio x : " + view.getScrollX()); // Log.i("Face", "positio y : " + view.getScrollY()); } } return resizedBitmap; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload