Skip to content

ImageView (or another View) is not anchoring strictly to the eye. Apparently a bug. #111

@UserSty

Description

@UserSty

I use FaceTracker to overlay an image over the camera image and move it depending on the position of the eyes. But it does not work properly.
Use the following code:

imageView.setX(mPosition.x);
imageView.setY(mPosition.y);

not anchoring (blue square) strictly to the eye, you can see it in the screenshots with different distance from the photos:

See image: https://s32.postimg.org/gy6x8xded/All_steps_error.png

I already asked a question http://stackoverflow.com/questions/38292746/android-how-to-overlay-an-image-imageview-anchoring-the-to-the-eyes/38300203#38300203 but it did not help, and it seems to me that the problem is more deeply.

Help me please.

Activity

pm0733464

pm0733464 commented on Jul 18, 2016

@pm0733464
Contributor

I think that the response posted by theoreticalb@ w.r.t. translating the image coordinates to view coordinates is correct. If you have tried this, please post the code so that we can see what you've tried.

UserSty

UserSty commented on Jul 18, 2016

@UserSty
Author

@pm0733464 This is my code:

  @Override
    public void draw(Canvas canvas) {
        PointF detectLeftPosition = mLeftPosition;
        PointF detectRightPosition = mRightPosition;
        if ((detectLeftPosition == null) || (detectRightPosition == null)) {
            return;
        }

        PointF leftPosition =  new PointF(translateX(detectLeftPosition.x), translateY(detectLeftPosition.y));
        PointF rightPosition = new PointF(translateX(detectRightPosition.x), translateY(detectRightPosition.y));

        // Run in UI
        ((GooglyEyesActivity) mImageView.getContext()).runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mImageView.setX(translateX(leftPosition.x));
                mImageView.setY(translateY(leftPosition.y));
            }
        });
   }
pm0733464

pm0733464 commented on Jul 18, 2016

@pm0733464
Contributor

Looks like you are doing the translateX/Y twice (e.g., once to compute leftPosition and again for setX).

UserSty

UserSty commented on Jul 18, 2016

@UserSty
Author

@pm0733464 So and how me be? How should look like my code? Help me please.

pm0733464

pm0733464 commented on Jul 18, 2016

@pm0733464
Contributor

Just use leftPosition directly without calls to translate.

UserSty

UserSty commented on Jul 18, 2016

@UserSty
Author

@pm0733464
but I initially did so, and therefore published a question on stackoverflow. But it does not work and can be seen in the screenshots. What could be the solution?

UserSty

UserSty commented on Jul 19, 2016

@UserSty
Author

@pm0733464 If it doesn't work in two cases, it can be marked as a bug?

pm0733464

pm0733464 commented on Jul 19, 2016

@pm0733464
Contributor

I'd advise taking a closer look that the Googly Eyes code example:

https://github.com/googlesamples/android-vision/tree/master/visionSamples/googly-eyes

This example shows how to overlay graphics at the correct positions. I don't believe that there is a bug in the face detection code since this works.

I wouldn't be able to tell what's wrong with your app without seeing all of the code.

UserSty

UserSty commented on Jul 19, 2016

@UserSty
Author

@pm0733464
Actually I using a fully code from https://github.com/googlesamples/android-vision/tree/master/visionSamples/googly-eyes and do make only this is:

((GooglyEyesActivity) mImageView.getContext()).runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mImageView.setX(leftPosition.x);
                mImageView.setY(leftPosition.y);
            }
        });

and it doesn't work.
Who can help if it is not a bug?

UserSty

UserSty commented on Jul 26, 2016

@UserSty
Author

Any help, please.

pm0733464

pm0733464 commented on Jul 27, 2016

@pm0733464
Contributor

Please clarify your modification above. Where are you calling this from? Why did you need to make this change?

UserSty

UserSty commented on Aug 7, 2016

@UserSty
Author

@pm0733464

((GooglyEyesActivity) mImageView.getContext()).runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mImageView.setX(leftPosition.x);
                mImageView.setY(leftPosition.y);
            }
        });

This is I call, in the class of "GooglyEyesGraphic".
I need to do in order to keep the mask in imageView and move to face coordinates.

UserSty

UserSty commented on Aug 10, 2016

@UserSty
Author

Any ideas, please.

UserSty

UserSty commented on Aug 26, 2016

@UserSty
Author

Developers help!

2 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @UserSty@pm0733464@pchx-zz@mahmoudelfeel

        Issue actions

          ImageView (or another View) is not anchoring strictly to the eye. Apparently a bug. · Issue #111 · googlesamples/android-vision