1 2 Previous Next 20 Replies Latest reply on May 18, 2018 8:16 AM by Intel Corporation

# How to compute object's height for D435?

Hi there,

I am trying to convert an object's height in pixels to its actual height in meters. The equation I use is simple geometry. See the diagram below. PH = (D * bh)/f, where PH is the object height I want to measure, D is the measured distance (in meters) between the object and the camera, bh is the object's height in pixels, and f is the focal length.

I know that D is accurate (checked against the ground truth); bh is accurate (visually checked on display); f is generated by the SDK API (‘intrinsic.fx’ or ‘intrinsic.fy’). At resolution 848x480, f is reported to be 423.499. Note f is obtained from the depth frame, as shown in the wiki API how-to (https://github.com/IntelRealSense/librealsense/wiki/API-How-To).

However, when I apply the numbers into the equation, the height is way off. For example, for a person standing 3.4 meters away from the camera, the height in pixels is 334, and the computed height is 2.68 meters. His actual height is about 1.68 meters.

Why is this happening? Is this a calibration issue? Does my equation not fit D435's optical model?

BTW, the same equation works very well for D415.

Thanks,

Robby

• ###### 1. Re: How to compute object's height for D435?

The first thing that comes to mind is that the D415 and D435 have different field of view (FOV) angles.  D435's is wider.

D415 is 69.4° x 42.5° x 77° and D435's FOV is 91.2 x 65.5 x 100.6.

• ###### 2. Re: How to compute object's height for D435?

Yes I am aware of that. In fact, I have verified VFoV with the focal length and the frame height:

At 848x480 resolution, VFoV = 59.0808 degrees, and the focal length is 423.499. Therefore, tan(VFoV/2) = 0.5667 = (480/2)/423.499

However, that does not seem to solve my problem.

-Robby

• ###### 3. Re: How to compute object's height for D435?

The focal length of the D415's left and right imagers is 1.88 mm and the focal length of the D435's left and right imagers is 1.93 mm.  The color sensor's focal length is 1.93 mm.  In the RealSense SDK 2.0 software, the focal length is described by a multiplication of the variables fx (pixel width) and fy (pixel height).  So as you say, focal length should be determined by resolution.

With math formulas, if you know for certain what some of the values are then you can rearrange the formula to make another value the target instead of PH.  So you know for certain what person height (PH), distance of the person from the camera (D) and focal length (f) should be.

If things were working correctly, the target value should be correct no matter how the formula is rearranged.  So if you rearranged to make focal length the target for example, the formula should give the correct focal length result when the other values are put into the rearranged formula.

Following the logic above, bh (the object's height in pixels) is the only unknown value that you haven't been able to measure by other means, such as a tape measure.  Putting on my Sherlock detective cap, if you are getting an incorrect PH result on the D435, it is likely because the object's pixel height is being miscalculated (because you have verified all the other values)

• ###### 4. Re: How to compute object's height for D435?

Thanks... The object's height in pixels is computed with OpenCV, from the color frame. How else can I measure it?

• ###### 5. Re: How to compute object's height for D435?

SDK 2.0 has an example script called 'Measure' for measuring the distance between two points, so you may be able to avoid using OpenCV to do the pixel height calculation if you adapt the code in that example.

• ###### 6. Re: How to compute object's height for D435?

Thanks. I may give that a try. Still I have no reason to suspect that OpenCV is giving me the wrong height in pixels. I have visually verified the height in the display; it looks  about right. Also, the same code gives me the accurate height estimation on D415.

Unless the height obtained from the color frame is very different from the height in the depth frame ... is that possible?

• ###### 7. Re: How to compute object's height for D435?

If you are using both the color and depth, I would recommend using the same resolution for both if you are not doing so already, to help ensure that the two are aligned.

• ###### 8. Re: How to compute object's height for D435?

Yes I am using 848x480 for both color and depth frames.

• ###### 9. Re: How to compute object's height for D435?

There is a long discussion on the link below by vision tech expert ThePaintedSnipe that attempts to work out why D415 and D435 images may have differences.

• ###### 10. Re: How to compute object's height for D435?

Thanks for the link. I skimmed through the threads. The discussion seems to be about a different problem.

As far as I can tell, my problem is not about the depth data quality -- I am only measuring one object, and the distance seems to be accurate. My problem arises when I convert the distance to height.

For my part, I'd like to know:

1. Will camera re-calibration solve my problem?

2 . If yes, how easy or difficult is it to re-calibrate D435?

• ###### 11. Re: How to compute object's height for D435?

It is hard to say if calibration will solve your issue.  Doing so is much easier on the 400 Series cameras though.

Re: Settings for best Z accuracy

• ###### 12. Re: How to compute object's height for D435?

Thanks. I'll look into that.

• ###### 13. Re: How to compute object's height for D435?

Robby, I'm just starting using D415 and thinking of trying to do the same calculations as you already did. I'm using OpenCV/ python. Would appreciate if you can share your code so I don't have to re-invent the wheel...

-albertr

• ###### 14. Re: How to compute object's height for D435?

Sorry this is part of a project and I can't share the source code now.

1 2 Previous Next