googlesamples / android-vision

Deprecated: The Mobile Vision API is now a part of ML Kit: Check out this repo:
https://github.com/firebase/quickstart-android/tree/master/mlkit
Apache License 2.0
2.92k stars 1.73k forks source link

My application cannot work correctly with the landmarks. #217

Open hady13 opened 7 years ago

hady13 commented 7 years ago

I already referred this issue. https://github.com/googlesamples/android-vision/issues/197

But I'm trying to draw landmark in real time video, not bitmap, so I have wrote like this.

1 2

But I still have wrong positions... From where do landmarks detect the position in this API? Please help me.

pm0733464 commented 7 years ago

I don't think that you have the scale right. See this example:

https://github.com/googlesamples/android-vision/blob/master/visionSamples/photo-demo/app/src/main/java/com/google/android/gms/samples/vision/face/photo/FaceView.java#L73

hady13 commented 7 years ago

Yes, as I said, I already referred that example. But that is for bitmap image, so I change the code like that... So How I chage this code..?

hipsterreed commented 7 years ago

@hady13 Did you ever figure out how to get the scale to properly place the landmarks in real time video? I am also having the same issue and have tried multiple things but no luck.

hipsterreed commented 7 years ago

Just got my landmarks to line up as they should by using the translate functions. The translate functions get the scale by subtracting the mOverlay width (or height) from the scaleFactor of the landmarks position. Posting this solution just in case someone else comes along.

for (Landmark landmark : face.getLandmarks()) {
    int cx = (int) translateX(landmark.getPosition().x);
    int cy = (int) translateY(landmark.getPosition().y);
    canvas.drawCircle(cx, cy, 10, mBoxPaint);
}