I've zero knowledge in optics, but I've to estimate the geometric dimensions of objects from the values of the number of pixels and the camera information given here: https://www.raspberrypi.org/documentation/hardware/camera/README.md

The heights (h) and the widths (w) of the objects are given as follows, in terms of the number of pixels:

h=numpy.array([572.75, 567.75, 562.75, 556.75, 558.75, 632.75, 646.75, 670.75,
       596.75, 598.75, 598.75, 599.75])

w=numpy.array([203., 198., 203., 203., 201., 221., 230., 241., 224., 218., 221.,

I'd appreciate if you could let me know how to measure the actual product sizes from h, w, and the information on camera.

Thanks in advance!


The short answer is, you cannot. You need extra information. Namely the distance to the object.

To estimate the actual size of an object in a given dimension (let's say the actual width) you need the apparent angular width which can be obtained from the camera info and the widths you wrote above in pixels by just a rule of proportions $$\theta = \textrm{apparent angular width} \equiv \textrm{measured pixels}\times \frac{\textrm{field of view of the camera/lens}}{\textrm{total number of pixels in x}}$$ the actual width would be $$ w = \textrm{distance}\times \arctan(\theta/2) $$

where $\textrm{measured pixels (for width)} = x_2 - x_1$ from the diagonal points you have.

Alternatively, if you knew one of the actual dimensions, let's say the height, then you can compute the distance from the height and using what I wrote before, you can compute the other; in this case the width.

  • $\begingroup$ Val: Thanks for your answer. Which field of view (horzontal/vertical as stated in the website I gave) should I use? And for the no. of pixels in x, what should I use from the website? I see plenty of info-pixel size, optical size, sensor resolution...what should I write here?Thanks again! $\endgroup$ – Sus_Q May 7 '18 at 14:23
  • $\begingroup$ And no, we don't know any of the height and width of the objects. I've to perform a clustering task (in machine learning) from the pixel number information I gave (numpy arrays) and the camera info. But the problem is, the distance varies, and hence the bigger objects may look small if we increase the distance. $\endgroup$ – Sus_Q May 7 '18 at 14:26
  • $\begingroup$ @Sus_Q For the fields of view: if you want the width then horizontal, if you want the height then vertical. If the approach is machine learning I may not be able to say if you actually need all this. You might be able to train with some known sizes and then you dont need anything else. I wont be able to go down to the specifics of the camera, but you need to extract the angle that the camera sees for an object, given: the total pixels and the field of view. $\endgroup$ – ohneVal May 7 '18 at 14:37
  • $\begingroup$ Thanks again! I'm doing clustering based on the image co-ordinates first (these images were taken at several distances), so we can't train, so to speak. It's all unsupervised to start with. I've one last question, you can answer for the width, I can translate for height. So I see that, in "apparent angular width", you mentioned "measured pixels" and "no of pixels in x". My question is: I've only the co-ordinates of the two diagonal points (x1,y1) and (x2,y2) of the bounding boxes of images in terms of no of pixels. So what should I plug in "measured pixels" and in "no pixels in x"? Thanks! $\endgroup$ – Sus_Q May 7 '18 at 14:48
  • $\begingroup$ For example, if I've (x1,y1)=(500,200) in terms of no of pixels from a fixed origin, how do I estimate the actual width (or height), given the distance to the camera? $\endgroup$ – Sus_Q May 7 '18 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.