如何将 Android 的 Rect 对象转换为 OpenCV 的 Rect 对象

问题描述 投票:0回答:1

我正在尝试使用 OpenCV 制作一个应用程序。我面临一个简单的问题,但我没有解决这个问题的知识。

我需要在图像内取一个框来获取矩形并在 OpenCV 中使用它,但 Android 使用 android.graphics.Rect 和 OpenCV 需要 org.opencv.core.Rect 并且我正在尝试一个简单的转换,但是结果不好。

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

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

我没有发现 wait 是左上右下的表示,文档讨论了“侧面”,但我对从 android 转换为 opencv 感到困惑

谢谢你。

java android opencv converters rectangles
1个回答
0
投票

方程式为:

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

left = x
top = y
right = x + width
bottom = y + height
© www.soinside.com 2019 - 2024. All rights reserved.