Android-face-filters icon indicating copy to clipboard operation
Android-face-filters copied to clipboard

Sticker not properly set on face as per position of eye or face.

Open HEMAL-PATEL opened this issue 5 years ago • 5 comments

I have used this demo to implement live stickers on the face. But there is an issue that sticker does not set on the face properly. For example, glasses do not set on the eye position of the face. The similarly same thing happens for the other stickers.

Can you help I resolved this issue?

Please reply soon.............................

HEMAL-PATEL avatar Jun 11 '19 05:06 HEMAL-PATEL

i got same problem

poojan28 avatar Jun 20 '19 02:06 poojan28

 Face face = mFace;
        if (face == null) return;
        // Draws a circle at the position of the detected face, with the face's track id below.
        float x = translateX(face.getPosition().x + face.getWidth() / 2);
        float y = translateY(face.getPosition().y + face.getHeight() / 2);
        /*
        canvas.drawCircle(x, y, FACE_POSITION_RADIUS, mFacePositionPaint);
        canvas.drawText("id: " + mFaceId, x + ID_X_OFFSET, y + ID_Y_OFFSET, mIdPaint);
        canvas.drawText("happiness: " + String.format("%.2f", face.getIsSmilingProbability()), x - ID_X_OFFSET, y - ID_Y_OFFSET, mIdPaint);
        canvas.drawText("right eye: " + String.format("%.2f", face.getIsRightEyeOpenProbability()), x + ID_X_OFFSET * 2, y + ID_Y_OFFSET * 2, mIdPaint);
        canvas.drawText("left eye: " + String.format("%.2f", face.getIsLeftEyeOpenProbability()), x - ID_X_OFFSET*2, y - ID_Y_OFFSET*2, mIdPaint);
        */
        float xOffset = scaleX(face.getWidth()/2.00f);
        float yOffset = scaleY(face.getHeight()/1.20f);

        float left = x - xOffset;
        float top = y - yOffset;
        //float right = x + xOffset;
        //float bottom = y + yOffset;
        //canvas.drawRect(left, top, right, bottom, mBoxPaint);
        canvas.drawBitmap(op, left, top, new Paint());

after changing draw method like this, it is solved!

mhsnakdgn avatar Nov 19 '19 15:11 mhsnakdgn

Hi @HEMAL-PATEL , @poojan28 , @JDevelopes : I can close the issue?

gaetanozappi avatar Jun 07 '20 11:06 gaetanozappi

It is not clear Solution as on first line
Face face = mFace;

and
canvas.drawBitmap(op, left, top, new Paint()); what is op ??

AshishGarg1988 avatar Jul 03 '20 14:07 AshishGarg1988

anyone solve accurate face sticker problem?

Anonymousgaurav avatar Jul 30 '20 08:07 Anonymousgaurav