Ask Your Question

How to compute the center of a bounding box?

asked 2020-03-26 01:32:38 -0500

Pigeon gravatar image

updated 2020-03-26 01:33:21 -0500

I'm using the QRCodeDetector class to get a position on a SR Code. So I use the detectAndDecode() method to search for a QR code and it returns a bounding box with the QR code region.

I know how to calculate the center of a square or rectangle. But I don't understand how the bounding box data is set.

edit retag flag offensive close merge delete

1 answer

Sort by ┬╗ oldest newest most voted

answered 2020-03-26 03:56:03 -0500

berak gravatar image

since it returrns a vector<Point>, you could try:

vector<Point> pts;
Rect r = getBoundingRect(pts);
Point center(r.x+r.width/2, r.y+r.height/2);
edit flag offensive delete link more


I can't find any getBoundingRect() function.

Pigeon gravatar imagePigeon ( 2020-04-16 17:33:26 -0500 )edit

Question Tools

1 follower


Asked: 2020-03-26 01:32:38 -0500

Seen: 202 times

Last updated: Mar 26 '20