<?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/918" />

	<title>StereoPi Forum</title>
	<subtitle>StereoPi Forum</subtitle>
	<link href="https://forum.stereopi.com/index.php" />
	<updated>2020-04-30T08:46:21+00:00</updated>

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

		<entry>
		<author><name><![CDATA[Realizator]]></name></author>
		<updated>2020-04-30T08:46:21+00:00</updated>

		<published>2020-04-30T08:46:21+00:00</published>
		<id>https://forum.stereopi.com/viewtopic.php?p=1913#p1913</id>
		<link href="https://forum.stereopi.com/viewtopic.php?p=1913#p1913"/>
		<title type="html"><![CDATA[Re: 3D Distance from Disparity Map]]></title>

		
		<content type="html" xml:base="https://forum.stereopi.com/viewtopic.php?p=1913#p1913"><![CDATA[
Hi vivvyk,<br>1. Please look at <a href="https://forum.stereopi.com/viewtopic.php?f=9&amp;t=878&amp;p=1700&amp;hilit=pointcloud#p1700" class="postlink">this topic</a>. You can find a (draft) code I plan to add to the fisheye repo after polishing. Please use division by 16 I've implemented here. This will really "fix" your real distance (as it affects on a trigonometry logic). I have a lot of questions from users on this, so I hope to release some polished code during a week or so.<br>upd&gt; you need to divide disparity by 16 (look line 111 in attached 22.py in the mentioned topic):<div class="codebox"><p>Code: </p><pre><code>return disparity_color, disparity_fixtype, disparity.astype(np.float32) / 16.0</code></pre></div>After that your "cv2.reprojectImageTo3D(disp, Q)" will give you another results, which can be linearly scaled to get your real size.<br><br>2. Please play with the point cloud (doing "view from the top" projection on ZX pane). You will see a distance map "top view", and this will help you to understand real and relative distance to the objects on your scene for tuning your distance. Put a couple of a test object at different distances (and with the different size).<br><br>3. If you noticed it, in OpenCV 4.x calibration the chessboard size is <em class="text-italics">ignored</em>. I.e. you get your distance measured in "squares" of the chessboard. So multiplying it on a real square size will give you a real distance.<p>Statistics: Posted by <a href="https://forum.stereopi.com/memberlist.php?mode=viewprofile&amp;u=2">Realizator</a> — Thu Apr 30, 2020 8:46 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[vivvyk]]></name></author>
		<updated>2020-04-29T21:33:26+00:00</updated>

		<published>2020-04-29T21:33:26+00:00</published>
		<id>https://forum.stereopi.com/viewtopic.php?p=1911#p1911</id>
		<link href="https://forum.stereopi.com/viewtopic.php?p=1911#p1911"/>
		<title type="html"><![CDATA[3D Distance from Disparity Map]]></title>

		
		<content type="html" xml:base="https://forum.stereopi.com/viewtopic.php?p=1911#p1911"><![CDATA[
Hello,<br><br>After some earlier advice we've managed to create a high quality disparity map! However, we're having a lot of trouble getting the actual distance from our disparity map. <br><br>Here are two frames from our video of a tissue box:<br><div class="inline-attachment"><dl class="file"><dt class="attach-image"><img src="https://forum.stereopi.com/download/file.php?id=75" class="postimage" alt="tissueframes.png" onclick="viewableArea(this);" /></dt></dl></div>Here is our disparity map:<div class="inline-attachment"><dl class="file"><dt class="attach-image"><img src="https://forum.stereopi.com/download/file.php?id=74" class="postimage" alt="tissue-disparity.png" onclick="viewableArea(this);" /></dt></dl></div>To get the distance, we've followed the procedure in 7_2d_map.py; using <div class="codebox"><p>Code: </p><pre><code>cv2.reprojectImageTo3D(disp, Q)</code></pre></div> and the Q matrix obtained in calibration. This returns a three dimensional matrix. We take a pixel from the center/box and it looks like <blockquote class="uncited"><div>array([-0.25788638,  0.1133885 ,  1.1743402 ], dtype=float32)</div></blockquote>The tissue box is 200mm away. We're guessing that the third value is (Z/W) is what we need but we aren't sure of the units. We read somewhere that the disparity map returned by opencv is scaled by <strong class="text-strong">16</strong>, and we've made the assumption that the returned units are <strong class="text-strong">cm</strong>. This gives us 1.1743402 * 16 * 10 = about 192mm, which is our best result thus far.<br><br>We aren't sure if this is the correct approach. We've struggled to find documentation or the correct way to do this. We'd appreciate any input on how to correctly calculate distance, or any other feedback on our approach thus far.<br><br>I'd be happy to provide our disparity map, Q matrix, our code, or anything else that's needed. Let me know! We'd very much appreciate some input on this!<br><br>Thanks!<p>Statistics: Posted by <a href="https://forum.stereopi.com/memberlist.php?mode=viewprofile&amp;u=350">vivvyk</a> — Wed Apr 29, 2020 9:33 pm</p><hr />
]]></content>
	</entry>
	</feed>
