Ask Your Question

Measuring height and weight of rectangle

asked 2017-12-19 03:58:53 -0600

Tinto gravatar image

I have created an app which will detect the rectangle shapes using open cv. I am finding the edges using Imgproc.Scharr() method. Then drawing line over the detected image using drawContour() method. As per the requirement I need to find the actual height and width of the object. Please help me to do this. I am using android studio and java for the development

edit retag flag offensive close merge delete


"I need to find the actual height and width of the object." -- you mean, in the real world ?

have a look here , you need to know the focal length, and the distance. (or, at least an object with known size at the same distance)

also, there's a boundingRect() method for contours, look it up, please.

berak gravatar imageberak ( 2017-12-19 04:24:19 -0600 )edit

yes in real world

Tinto gravatar imageTinto ( 2017-12-19 04:30:12 -0600 )edit

so, try to understand the pinhole model.

berak gravatar imageberak ( 2017-12-19 04:33:17 -0600 )edit

2 answers

Sort by ยป oldest newest most voted

answered 2017-12-21 05:30:52 -0600

moHe gravatar image

updated 2017-12-21 21:33:45 -0600

Take look at the concept of "dpi", which is a measure between pixel number and inch. Maybe this will help you:)

width x height, width, height, horizontal_dpi, vertical_dpi, depth:

image description

image description

edit flag offensive delete link more


mohe, no. dpi is only relevant with printing. from the article above:

A digital image on the computer will never have DPI, cm or inch as the unit. It will only have pixels.

berak gravatar imageberak ( 2017-12-21 09:49:11 -0600 )edit

Hi, friend. In my win10, I right clicked the .jpg to see the property of the image, and you can find the dpi. I've update the answer, you can see the screenshots.

Besides, you can use PIL to check the dpi.

But I don't promise that except for the ".jpg" and ".png", the others can see the dpi, too.

moHe gravatar imagemoHe ( 2017-12-21 21:29:41 -0600 )edit

again, none of it relevant for computer-vision, and not relevant to the question. it is just some recommendation: IF you ever want to print this on paper, use 96 dpi, so it "looks best" there.

berak gravatar imageberak ( 2017-12-22 01:34:32 -0600 )edit

answered 2017-12-21 05:55:13 -0600

supra56 gravatar image

updated 2017-12-21 06:01:16 -0600

Here is good one. picture size sizet

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-12-19 03:58:53 -0600

Seen: 790 times

Last updated: Dec 21 '17