user1244643
user1244643

Reputation: 61

How to find height and width of a rectangle in OpenCV?

How can I find the width and height of a rectangle drawn with the function cvRectangle with the following parameters?

cvRectangle( input1, cvPoint(200,178), cvPoint(190,110),color ,1, 8 );

Upvotes: 0

Views: 3531

Answers (1)

Bart
Bart

Reputation: 20048

You set the parameters, so calculating width and height should be trivial, shouldn't it? width = (200-190) and height = (178-110). But, as @bubble suggests, since you're most likely dealing with pixels, don't forget to add 1, resulting in (200 - 190) + 1 for width and (178 - 110) + 1 for height.

Or do you expect cvRectangle to give you some rectangle "object" you can get these values from? It doesn't.

Upvotes: 1

Related Questions