OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Sat, 26 Sep 2020 17:43:25 -0500How to convert stereo camera distances, pixels to mmhttp://answers.opencv.org/question/235420/how-to-convert-stereo-camera-distances-pixels-to-mm/Hello.
I calibrated and stereo-parallelized the stereo camera.I would like to know how to find the coefficient to convert from pixels to mm.
From the Q matrix obtained by stereo rectification, Tx: baseline and f: focal length were determined.
As you know, the depth z is found by the following formula
z = Bf/(x-x') z:[pixels]
However, the units of z obtained from this formula are pixels.
A factor k[mm/pixel] is needed to convert it to mm.
Then the equation is as follows
z = (Bf/(x-x'))*k z:[mm]
Is there a smart way to find this coefficient k?
Please use something other than how to actually measure z several times to derive k, or how to examine the pitch pixels of the camera's image sensor.
In the case of HALCON, I was able to find it by a function instead of using the method described above.
Couldn't it be calculated from the camera and Q matrices obtained from calibration and stereo parallelization?
Thank you.
![image description](/upfiles/16006860981727479.png)
![image description](/upfiles/1600686034748941.jpg)Mon, 21 Sep 2020 06:31:18 -0500http://answers.opencv.org/question/235420/how-to-convert-stereo-camera-distances-pixels-to-mm/Comment by Eduardo for <p>Hello.</p>
<p>I calibrated and stereo-parallelized the stereo camera.I would like to know how to find the coefficient to convert from pixels to mm.</p>
<p>From the Q matrix obtained by stereo rectification, Tx: baseline and f: focal length were determined.
As you know, the depth z is found by the following formula</p>
<p>z = Bf/(x-x') z:[pixels]</p>
<p>However, the units of z obtained from this formula are pixels.
A factor k[mm/pixel] is needed to convert it to mm.
Then the equation is as follows</p>
<p>z = (Bf/(x-x'))*k z:[mm]</p>
<p>Is there a smart way to find this coefficient k?
Please use something other than how to actually measure z several times to derive k, or how to examine the pitch pixels of the camera's image sensor.</p>
<p>In the case of HALCON, I was able to find it by a function instead of using the method described above.</p>
<p>Couldn't it be calculated from the camera and Q matrices obtained from calibration and stereo parallelization?
Thank you.</p>
<p><img alt="image description" src="/upfiles/16006860981727479.png"></p>
<p><img alt="image description" src="/upfiles/1600686034748941.jpg"></p>
http://answers.opencv.org/question/235420/how-to-convert-stereo-camera-distances-pixels-to-mm/?comment=235695#post-id-235695See [reprojectImageTo3D()](https://docs.opencv.org/4.4.0/d9/d0c/group__calib3d.html#ga1bc1152bd57d63bc524204f21fde6e02).Sat, 26 Sep 2020 09:00:45 -0500http://answers.opencv.org/question/235420/how-to-convert-stereo-camera-distances-pixels-to-mm/?comment=235695#post-id-235695Answer by yoshihiko for <p>Hello.</p>
<p>I calibrated and stereo-parallelized the stereo camera.I would like to know how to find the coefficient to convert from pixels to mm.</p>
<p>From the Q matrix obtained by stereo rectification, Tx: baseline and f: focal length were determined.
As you know, the depth z is found by the following formula</p>
<p>z = Bf/(x-x') z:[pixels]</p>
<p>However, the units of z obtained from this formula are pixels.
A factor k[mm/pixel] is needed to convert it to mm.
Then the equation is as follows</p>
<p>z = (Bf/(x-x'))*k z:[mm]</p>
<p>Is there a smart way to find this coefficient k?
Please use something other than how to actually measure z several times to derive k, or how to examine the pitch pixels of the camera's image sensor.</p>
<p>In the case of HALCON, I was able to find it by a function instead of using the method described above.</p>
<p>Couldn't it be calculated from the camera and Q matrices obtained from calibration and stereo parallelization?
Thank you.</p>
<p><img alt="image description" src="/upfiles/16006860981727479.png"></p>
<p><img alt="image description" src="/upfiles/1600686034748941.jpg"></p>
http://answers.opencv.org/question/235420/how-to-convert-stereo-camera-distances-pixels-to-mm/?answer=235672#post-id-235672Pixel shear is not defined either, so opencv is useless.Fri, 25 Sep 2020 22:19:55 -0500http://answers.opencv.org/question/235420/how-to-convert-stereo-camera-distances-pixels-to-mm/?answer=235672#post-id-235672Answer by yoshihiko for <p>Hello.</p>
<p>I calibrated and stereo-parallelized the stereo camera.I would like to know how to find the coefficient to convert from pixels to mm.</p>
<p>From the Q matrix obtained by stereo rectification, Tx: baseline and f: focal length were determined.
As you know, the depth z is found by the following formula</p>
<p>z = Bf/(x-x') z:[pixels]</p>
<p>However, the units of z obtained from this formula are pixels.
A factor k[mm/pixel] is needed to convert it to mm.
Then the equation is as follows</p>
<p>z = (Bf/(x-x'))*k z:[mm]</p>
<p>Is there a smart way to find this coefficient k?
Please use something other than how to actually measure z several times to derive k, or how to examine the pitch pixels of the camera's image sensor.</p>
<p>In the case of HALCON, I was able to find it by a function instead of using the method described above.</p>
<p>Couldn't it be calculated from the camera and Q matrices obtained from calibration and stereo parallelization?
Thank you.</p>
<p><img alt="image description" src="/upfiles/16006860981727479.png"></p>
<p><img alt="image description" src="/upfiles/1600686034748941.jpg"></p>
http://answers.opencv.org/question/235420/how-to-convert-stereo-camera-distances-pixels-to-mm/?answer=235719#post-id-235719I didn't know there was such a useful function. Thank you.Sat, 26 Sep 2020 17:43:25 -0500http://answers.opencv.org/question/235420/how-to-convert-stereo-camera-distances-pixels-to-mm/?answer=235719#post-id-235719