How I can convert a Rect object from android to a Rect object of OpenCV

53 Views Asked by At

I'm trying to do an app using OpenCV. I'm facing a simple problem but I don't have the knowledge to resolve this.

I need to take a box inside an image to get a rectangle and use it in OpenCV, but Android use android.graphics.Rect and OpenCV expect a org.opencv.core.Rect and I'm trying a simple conversion, but the result is not good.

android.graphics.Rect(int left, int top, int right, int bottom)

org.opencv.core.Rect(int x, int y, int width, int height)

I'm not finding wait is the representation of left top right and bottom, the documentation talks about "side" but I'm confused to convert from android to opencv

Thank you.

1

There are 1 best solutions below

0
Christoph Rackwitz On

The equations are:

x = left
y = top
width = right - left
height = bottom - top

and

left = x
top = y
right = x + width
bottom = y + height