drawing a rectangle on an image after identifying the area using ROI (OpenCV)

我试图在OpenCV中使用函数ROI来识别轮廓,稍后..在那个ROI中,我正在识别一个特定的颜色..所以我想绘制矩形或圆形围绕此形状,但在原始图像..问题我正在检索的位置是为了投资回报率,而不是整个图像..任何想法?


You know the offset of the ROI within the original image (say the coordinates of its top-left corner) -- just add these to the coordinates of the location within the ROI (ie where the top-left corner of the ROI is (0,0)), and that gives the location in global coordinates.

eg:

 ______________
|    __        |
|   |  |       |
|   |x_|       |
|______________|

Say the outer rectangle is the image, top-left corner (0,0), and the inner square is the ROI, top-left corner (1,3).

The X is the location of the thing you want to outline - it has coordinates (1,0) with respect to the square.

Add (1,0) (X coordinates with respect to ROI) to the (1,3) (ROI coordinates with respect to image) and you'll get (2,3) , the coordinates of X with respect to the image.

链接地址: http://www.djcxy.com/p/89724.html

上一篇: OpenCV:检查像素是否在边界矩形内,由等高线分隔

下一篇: 在使用ROI(OpenCV)识别区域之后在图像上绘制矩形