<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.stereopi.com/app.php/feed/topic/810" />

	<title>StereoPi Forum</title>
	<subtitle>StereoPi Forum</subtitle>
	<link href="https://forum.stereopi.com/index.php" />
	<updated>2019-12-06T12:08:24+00:00</updated>

	<author><name><![CDATA[StereoPi Forum]]></name></author>
	<id>https://forum.stereopi.com/app.php/feed/topic/810</id>

		<entry>
		<author><name><![CDATA[Realizator]]></name></author>
		<updated>2019-12-06T12:08:24+00:00</updated>

		<published>2019-12-06T12:08:24+00:00</published>
		<id>https://forum.stereopi.com/viewtopic.php?p=1421#p1421</id>
		<link href="https://forum.stereopi.com/viewtopic.php?p=1421#p1421"/>
		<title type="html"><![CDATA[Re: Getting Actual Distance Data (in cm) from Depth Map]]></title>

		
		<content type="html" xml:base="https://forum.stereopi.com/viewtopic.php?p=1421#p1421"><![CDATA[
Yes, Angelyn, please share your results! If you will have any questions - please ask it here. I will add all information from our discussion to upcoming article, and hope it will be useful for other StereoPi users too.<p>Statistics: Posted by <a href="https://forum.stereopi.com/memberlist.php?mode=viewprofile&amp;u=2">Realizator</a> — Fri Dec 06, 2019 12:08 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[angelyn.mercado]]></name></author>
		<updated>2019-12-06T04:11:25+00:00</updated>

		<published>2019-12-06T04:11:25+00:00</published>
		<id>https://forum.stereopi.com/viewtopic.php?p=1420#p1420</id>
		<link href="https://forum.stereopi.com/viewtopic.php?p=1420#p1420"/>
		<title type="html"><![CDATA[Re: Getting Actual Distance Data (in cm) from Depth Map]]></title>

		
		<content type="html" xml:base="https://forum.stereopi.com/viewtopic.php?p=1420#p1420"><![CDATA[
Wow! Thanks for your responses! I actually tried the triangulation formula but wasn't sure what to do with all the values since we get one per pixel. <br><br>I will check out the  "reprojectImageTo3D" function and will get back with my results. I'll also look into the 7_2d_map.py. Your codes are very user-friendly! <br><br>Thank you again!<p>Statistics: Posted by <a href="https://forum.stereopi.com/memberlist.php?mode=viewprofile&amp;u=300">angelyn.mercado</a> — Fri Dec 06, 2019 4:11 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Realizator]]></name></author>
		<updated>2019-12-05T10:11:24+00:00</updated>

		<published>2019-12-05T10:11:24+00:00</published>
		<id>https://forum.stereopi.com/viewtopic.php?p=1417#p1417</id>
		<link href="https://forum.stereopi.com/viewtopic.php?p=1417#p1417"/>
		<title type="html"><![CDATA[Re: Getting Actual Distance Data (in cm) from Depth Map]]></title>

		
		<content type="html" xml:base="https://forum.stereopi.com/viewtopic.php?p=1417#p1417"><![CDATA[
Hi Angelyn,<br>Actually I planned to cover this question in upcoming second part of my "<a href="https://medium.com/stereopi/a-robot-on-stereopi-part-1-fisheye-cameras-92aa56e73a94" class="postlink">StereoPi Fisheye robot</a>" article. I will do it later, but most of the code you need already published in my <a href="https://github.com/realizator/stereopi-fisheye-robot" class="postlink">Github repo</a>.<br><br>Key points for you:<br><br><strong class="text-strong">1. Connecting the real world with the calculated world</strong><br>First step for "connecting" virtual world, calculated from video frames, is correct settings of a square size on a chessboard at the moment of camera calibration. <br>For example, in this calibration script "<a href="https://github.com/realizator/stereopi-fisheye-robot/blob/master/4_calibration_fisheye.py" class="postlink">4_calibration_fisheye.py</a>" you can find this code:<br><div class="codebox"><p>Code: </p><pre><code># Chessboard parametersrows = 6columns = 9square_size = 2.5</code></pre></div>You need to set adequate square size for correct calculations in the future. You can find a lot of this question discussions, like <a href="https://stackoverflow.com/questions/37310210/camera-calibration-with-opencv-how-to-adjust-chessboard-square-size" class="postlink">this one</a>.<br><br><strong class="text-strong">2. Depth map is not a distance</strong><br>Depth map is actually a disparity between two points on a left and right images. For calculating real distance you can use a simple trigonometry calculations. Luckily, OpenCV has a special function for this, which recalculate disparity map to the real-world 3D coordinates X, Y and Z for each image point. This is "reprojectImageTo3D" function.<br><br><strong class="text-strong">3. Code example</strong><br>Actually I've already uploaded 7th script called "<a href="https://github.com/realizator/stereopi-fisheye-robot/blob/master/7_2d_map.py" class="postlink">7_2d_map.py</a>" to my repo, but not yet commented it.<br>To say briefly, we take a middle horisontal part of 3D map, choose the closest points to the camera, reconstruct it in 3D, equalize Z coordinates and get 2D obstacles map for indoor robot. As I understand, you do not need this approach, and can just use "reprojectImageTo3D" directly.<br><br>After calibration and 3D reconstruction you can use some object at, say, 2 meters from the camera, to calibrate your actual measurements.<br><br>One more notice: "front" direction in 3D reconstructed world is not coinciding with the "front" direction of your stereocamera. You will find this in your experiments.<br><br>p.s. Stereomaton, you've posted your answer while I was writing my. <img class="smilies" src="https://forum.stereopi.com/images/smilies/icon_e_smile.gif" width="15" height="17" alt=":-)" title="Smile"> You are right about calculations, and, as I mentioned, this feature is implemented in OpenCV. Also focal length is calculated automatically while calibration procedure.<p>Statistics: Posted by <a href="https://forum.stereopi.com/memberlist.php?mode=viewprofile&amp;u=2">Realizator</a> — Thu Dec 05, 2019 10:11 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stereomaton]]></name></author>
		<updated>2019-12-05T09:19:52+00:00</updated>

		<published>2019-12-05T09:19:52+00:00</published>
		<id>https://forum.stereopi.com/viewtopic.php?p=1415#p1415</id>
		<link href="https://forum.stereopi.com/viewtopic.php?p=1415#p1415"/>
		<title type="html"><![CDATA[Re: Getting Actual Distance Data (in cm) from Depth Map]]></title>

		
		<content type="html" xml:base="https://forum.stereopi.com/viewtopic.php?p=1415#p1415"><![CDATA[
I never did that, but if I remember my readings well, Z=F.B/D (depth = focal × base ÷ disparity) when infinity is at 0 disparity.<br>You can calibrate your cameras to get the focal length and the stereo base in the right units.<br>Alternatively, you can consider that F.B is constant (the distance between the cameras is fixed and the lens is not changed) and thus match a curve on measured data.<br><br>I wonder which accuracy you can get with stereo measures.<p>Statistics: Posted by <a href="https://forum.stereopi.com/memberlist.php?mode=viewprofile&amp;u=101">stereomaton</a> — Thu Dec 05, 2019 9:19 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[angelyn.mercado]]></name></author>
		<updated>2019-12-05T05:29:13+00:00</updated>

		<published>2019-12-05T05:29:13+00:00</published>
		<id>https://forum.stereopi.com/viewtopic.php?p=1414#p1414</id>
		<link href="https://forum.stereopi.com/viewtopic.php?p=1414#p1414"/>
		<title type="html"><![CDATA[Getting Actual Distance Data (in cm) from Depth Map]]></title>

		
		<content type="html" xml:base="https://forum.stereopi.com/viewtopic.php?p=1414#p1414"><![CDATA[
Hi! Our team has just bought 3 StereoPi kits for our robots. We are trying to make an altitude sensor. We thought about using the Depth Map to get depth data but we're not sure how to get the exact distance (in cm) of each pixel in the depth map. Any suggestions on how to do this? Thank you!<p>Statistics: Posted by <a href="https://forum.stereopi.com/memberlist.php?mode=viewprofile&amp;u=300">angelyn.mercado</a> — Thu Dec 05, 2019 5:29 am</p><hr />
]]></content>
	</entry>
	</feed>
