简体   繁体   中英

OpenCV Bounding Rectangle (Python)

I'm trying to write a report on my Computer Vision project that uses OpenCV's (Python) boundingRect function. However, I am not allowed to say that I used this function, but rather the algorithm/equation that this function uses. I have tried to find this online, but am not particularly good at identifying what it is I'm looking for. Would someone be able to suggest which algorithm the boundingRect equation uses? Thanks

Utilised by: cv2.boundingRect(contour) .

In Python/OpenCV, the axes aligned bounding rectangle is defined as X,Y,W,H , where X,Y are the coordinates of the minimum X,Y corner and W,H are the width and height of the box. Those values are found by testing every point (x,y) on the contour to find (the minimum and maximum of x and y each) minX, maxX, minY, maxY. The bounding rectangle values are then X=minX, Y=minY, W=(maxX-minX), H=(maxY-minY) . You find the min and max values by looping over each x (or y) and testing it against the previous min or max value. If the current value is lower or higher, respectively, replace the old min or max with the current value.

In other systems, the bounding box is defined by the minimum and maximum diagonally opposite corners (minX,minY) and (maxX,maxY)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM