android-vision
android-vision copied to clipboard
Problems with real time landmarks detection
I have a problem. I want see eyes landmarks on the detected face. I see 12 landmarks, however, when I cover the left or right eye, face detector detects always 12 landmarks, also when I hide the left or right ear. When I cover the eye, the point vibrates but not disappears. Why? In this code I want see only eyes.
` public void draw(Canvas canvas) { Face face = mFace; if (face == null) { return; }
// Draws a circle at the position of the detected face, with the face's track id below.
x = translateX(face.getPosition().x + face.getWidth() / 2);
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);
// Draws a bounding box around the face.
xOffset = scaleX(face.getWidth() / 2.0f);
yOffset = scaleY(face.getHeight() / 2.0f);
float left = x - xOffset;
float top = y - yOffset;
float right = x + xOffset;
float bottom = y + yOffset;
Landmark leftEye = null;
Landmark rightEye = null;
for (Landmark landmark : face.getLandmarks()) {
if (landmark.getType() == Landmark.LEFT_EYE)
leftEye = landmark;
else if (landmark.getType() == Landmark.RIGHT_EYE)
rightEye = landmark;
}
if(leftEye != null) {
xs = translateX(leftEye.getPosition().x);
ys = translateY(leftEye.getPosition().y);
canvas.drawCircle(xs, ys, FACE_POSITION_RADIUS/2, mFacePositionPaint);
}
if(rightEye != null) {
xd = translateX(rightEye.getPosition().x);
yd = translateY(rightEye.getPosition().y);
canvas.drawCircle(xd, yd, FACE_POSITION_RADIUS/2, mFacePositionPaint);
}
canvas.drawRect(left, top, right, bottom, mBoxPaint);
}`