Ask Your Question
0

ImagemView being positioned in the preview camera

asked 2016-05-14 15:45:53 -0600

VCS_DEV gravatar image

updated 2016-05-14 15:55:06 -0600

I'm having problems when trying to position a imageView in JavaCameraView. I am using a ImagemView Instead of using a Mat to gain performance as it has a png image to be fixed around the eyes. I managed to locate opencv and have the eye area and can draw the area:

Core.rectangle(mRgba, eyeArea.tl(), eyeArea.br(),
                new Scalar(255, 0, 0, 255), 2);

But when trying to position and resize the ImagemView nothing is being right. Even catching the eye area position the ImageView is smaller and off the correct location and that the command above this drawing correctly. I saw that the JavaCameraView its size is different from the frame shown, I could adjust the ImageView the container to the same size frame but still there are problems in ImageView ...

Fix container size and position of the ImageView:

RelativeLayout rlMaskContainer = (RelativeLayout) findViewById(R.id.rlMaskContainer);
                        rlMaskContainer.getLayoutParams().height
= mOpenCvCameraView.dstRect.height();
                        rlMaskContainer.getLayoutParams().width
= mOpenCvCameraView.dstRect.width();
                        rlMaskContainer.setX(mOpenCvCameraView.dstLeftRect);
                        rlMaskContainer.setY(mOpenCvCameraView.dstTopRect);

Resize and positioning ImageView by EyeArea Rect:

 runOnUiThread(new Runnable() {
            @Override
            public void run() {
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(eyeArea.width, eyeArea.height);
    params.leftMargin = eyeArea.x;
    params.topMargin = eyeArea.y;
    ivMask.setLayoutParams(params);
    ivMask.setScaleType(ImageView.ScaleType.FIT_XY);


} });

Preview Camera (Red area is container RelativeLayout, rectangle is Rect EyeArea): image description

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-03-19 16:55:41 -0600

d_asad gravatar image

stuck on the same problem, btw can you share how did you make javacamera orientation to portrait this accurate ?

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-05-14 15:45:53 -0600

Seen: 149 times

Last updated: May 14 '16