Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道是否可以在 Android 框架中检测图像中的矩形区域?
整个单个图像中矩形区域的尺寸不固定。我想要检测所有这些区域并裁剪它们并分别显示
您可以像这样获得 View 的绘图矩形:
Rect rect = new Rect(); mView.getDrawingRect(rect);
这将为您提供一个矩形,其中包含在屏幕上绘制视图的位置的坐标。
获取屏幕上视图的左侧和顶部坐标:
float viewLeftXCoord = rect.left; float viewTopXCoord = rect.top;