Measuring cubic boxes with credit card (L x w x h)

Hi all!

I recently came across OpenCV and saw all the great ways people are using it! I want to see if it is possible to do the following:

Take an object of a known size, for example a credit card and place it over an unknown box/cuboid/rectangular prism of unknown size. I want to be able to measure length, width and height. Accuracy can be within 1". See the attached picture of white box with a red credit card on the corner.

Is this possible? What would be a good resource to start? Thanks in advance!

edit retag close merge delete

https://en.wikipedia.org/wiki/Pinhole...

this trick only works, if both objects are at the exact same distance to the camera, so - yes for the front plane, but no for top or side planes.

also, if you have to hold something next to your object already, you better take a ruler and measure it directly, no need for computer-vision...

( 2017-11-04 04:02:06 -0500 )edit

Thank you for the follow-up berak.

The whole idea is that not a lot of people have rulers or measuring tapes handy, however, everyone has a credit card/bank card in their wallet.

Would there be any other way to measure the top or side planes?

Thanks again!

( 2017-11-04 04:09:46 -0500 )edit

yes. but that would require calibrating the camera (to obtain the fov)

(and i still would argue: ppl don't have rulers, but they do have a pc and a webcam ? that's absurd)

( 2017-11-04 04:16:09 -0500 )edit
1

Thank you for the link to the calibrating the camera documentation. Yes, believe it or not, lots of people have a camera (built into their phone) that can take pictures, but not a ruler or measuring tape. I guess we'll have to agree to disagree. :)

( 2017-11-04 04:23:02 -0500 )edit
1

You can actually do this, but I think you'd have to do each plane separately, or assume the angles are all 90 degrees, which might not be a good assumption.

Basically, you know the size of the card, so you find the plane of the card. Then you just project a line from the camera through the plane at each of the corners of the top of the box. And those are the four corners of the top of the box. Average a dozen frames of results, and you should get an ok result.

( 2017-11-04 15:10:02 -0500 )edit

Oh, and the camera would need to be calibrated, yes.

( 2017-11-04 15:10:59 -0500 )edit

Why would assuming the angles are all 90 degrees be a bad assumption? Let's say we are only measuring boxes. In instances where the boxes are bulging, how much bigger could they be? If precision needs to be +/- 1", I feel like we may be close enough. Correct me if I'm wrong.

Also, could the camera be calibrated in real time? As in, when the picture is taken with the card on the box, we already know the size of the card and can calibrate it at the same time as measuring the box's face.

( 2017-11-09 00:21:55 -0500 )edit

The camera cannot be calibrated very well in real-time, and would require a minimum of three pictures of the same scene from widely varying views. Really, it should be calibrated properly ahead of time.

Android at least lets you query the camera matrix and distortion, no idea how accurate it usually is.

As for accuracy. You'll have to do the math to determine what is an acceptable accuracy. Depending on the viewing angle though, 1 degree could be a significant percentage.

( 2017-11-09 17:59:47 -0500 )edit