OpenCV (Java) : Draw a rectangle region on Camera View
I 'm trying to create a bank card scanner on android using OpenCV, first, I'm creating a region where the user can scan their cards then crop it after, I'm struggling with the rectangle region and place it on the center, Any suggestion on how I can do it? Thank you so much
Here's what I've done so far:
It's doing a rectangle and its centered but the size isn't enough I tried to change the numbers but the position isn't centering.
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
Mat mrgba = inputFrame.rgba();
int w = mrgba.width();
int h = mrgba.height();
Imgproc.rectangle(mrgba, new Point(w * 1 / 3, h * 1 / 3), new Point(
w * 2 / 3, h * 2 / 3 ), new Scalar( 255, 0, 0 ), 5
);
return mrgba;
}
OUTPUT
hey, it's just a maths problem ..
well, can you help me with that? I don't really quite understand how rect works. I need it to be dynamically centered no matter what the screen size is