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

	<title>StereoPi Forum</title>
	<subtitle>StereoPi Forum</subtitle>
	<link href="https://forum.stereopi.com/index.php" />
	<updated>2020-10-26T13:27:12+00:00</updated>

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

		<entry>
		<author><name><![CDATA[Realizator]]></name></author>
		<updated>2020-10-26T13:27:12+00:00</updated>

		<published>2020-10-26T13:27:12+00:00</published>
		<id>https://forum.stereopi.com/viewtopic.php?p=2330#p2330</id>
		<link href="https://forum.stereopi.com/viewtopic.php?p=2330#p2330"/>
		<title type="html"><![CDATA[Re: Getting Real Distance]]></title>

		
		<content type="html" xml:base="https://forum.stereopi.com/viewtopic.php?p=2330#p2330"><![CDATA[
We have a lot of related questions for the real world coordinates. I'm planning to update our Gthub code, but will be able to do it in a few weeks only.<br>To simplify your first experiments, I'm attaching a test code from one of our current projects. You will find two sections here, which might help you in your code:<br>1. Saving point cloud in the "PLY" format. After that you can open it with Meshlab application (free), which you can rotate/zoom/review it with more comfort<br>2. Updated depth map function "stereo_depth_map(rectified_pair):" with added /16.0 division, so your 3D coordinates will be calculated in a right way.<br>Please note, that in this file function returns 3 arrays<div class="codebox"><p>Code: </p><pre><code> return disparity_color, disparity_fixtype, disparity.astype(np.float32) / 16.0</code></pre></div>You can leave the only one you need for the calculation, and replace this row with<div class="codebox"><p>Code: </p><pre><code> return disparity.astype(np.float32) / 16.0</code></pre></div>to work with your code.<br><br>Sorry for sharing a <em class="text-italics">draft</em> code. Yes, it is for 1280x720 resolution, and also builds a pointcloud for the single image only. But I hope it can help...<dl class="file"><dt><span class="imageset icon_topic_attach"></span> <a class="postlink" href="https://forum.stereopi.com/download/file.php?id=162">6_pointcloud.py.zip</a></dt></dl><p>Statistics: Posted by <a href="https://forum.stereopi.com/memberlist.php?mode=viewprofile&amp;u=2">Realizator</a> — Mon Oct 26, 2020 1:27 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Realizator]]></name></author>
		<updated>2020-03-04T09:39:19+00:00</updated>

		<published>2020-03-04T09:39:19+00:00</published>
		<id>https://forum.stereopi.com/viewtopic.php?p=1704#p1704</id>
		<link href="https://forum.stereopi.com/viewtopic.php?p=1704#p1704"/>
		<title type="html"><![CDATA[Re: Getting Real Distance]]></title>

		
		<content type="html" xml:base="https://forum.stereopi.com/viewtopic.php?p=1704#p1704"><![CDATA[
Noob, I've uploaded current version as an attachment to my previous post here.<p>Statistics: Posted by <a href="https://forum.stereopi.com/memberlist.php?mode=viewprofile&amp;u=2">Realizator</a> — Wed Mar 04, 2020 9:39 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[noob]]></name></author>
		<updated>2020-03-04T07:53:21+00:00</updated>

		<published>2020-03-04T07:53:21+00:00</published>
		<id>https://forum.stereopi.com/viewtopic.php?p=1703#p1703</id>
		<link href="https://forum.stereopi.com/viewtopic.php?p=1703#p1703"/>
		<title type="html"><![CDATA[Re: Getting Real Distance]]></title>

		
		<content type="html" xml:base="https://forum.stereopi.com/viewtopic.php?p=1703#p1703"><![CDATA[
Thank you very much for your reply, Do you mind informing us when you have uploaded the codes for 3D generation? <br>Thank you in advance.<p>Statistics: Posted by <a href="https://forum.stereopi.com/memberlist.php?mode=viewprofile&amp;u=348">noob</a> — Wed Mar 04, 2020 7:53 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Realizator]]></name></author>
		<updated>2020-03-03T12:26:38+00:00</updated>

		<published>2020-03-03T12:26:38+00:00</published>
		<id>https://forum.stereopi.com/viewtopic.php?p=1700#p1700</id>
		<link href="https://forum.stereopi.com/viewtopic.php?p=1700#p1700"/>
		<title type="html"><![CDATA[Re: Getting Real Distance]]></title>

		
		<content type="html" xml:base="https://forum.stereopi.com/viewtopic.php?p=1700#p1700"><![CDATA[
Hi Noob and Angelyn.mercado,<br>As I mentioned, my next script for the point cloud is not yet polished. But I can share it now "as is" to help you with all that stuff. But, before this, let me highlight some keypoints on moving from depth map to the point cloud.<br><br>1. You should know, that Depth Map actually returns you a numbers 16 times bigger. You can use them for 3D reconstruction, but in this case Z coordinates will have a very slight variations, but X and Y will be adequate (link to the <a href="https://stackoverflow.com/questions/17987465/how-is-the-camera-coordinate-system-in-opencv-oriented" class="postlink">cordinate system description</a>). <br>So in my latest code I use this conversion to get a real depth map data:<div class="codebox"><p>Code: </p><pre><code>disparity.astype(np.float32) / 16.0</code></pre></div>2. Normalization is a good idea just for the visualization of your disparity. Do not use it for the real disparity data you use for the points coordinates calculations.<br><br>3. Angelyn.mercado mentioned a link to another thread, where I mention "square_size = 2.5". Actually this data is not used in the OpenCV 4, it is a row from the old code used in OpenCV 3. So after the calibration you get X, Y and Z coordinates in "squares" of your chessboard. <br><br>4. In my case Point Cloud has a big quantity of points. If you use Python cycles to calculate X, Y and Z for each point, you will have a very poor performance. That's why I use a masking to remove invalid points (to decrease a number of calculations). And also I use cv2.reprojectImageTo3D, as it gives you X, Y and Z for all your points from disparity map in a very effective way.<br><br><br>5. Some highlights on my dirty code for the first play:<br>- use it as a last script, after finihsing all calibrations and depth map tuning from the stereopi-fisheye-robot tutorial<br>- use W, A, S, D keys to rotate pointcloud. Rotation angle steps can be set in lines 251-254<br>- use 1, 2 keys to "move" point cloud to/from camera (like "zoom")<br>- row 283: points_3, colors = calc_point_cloud(disparity, native_disparity, QQ) If you replace "disparity" with "imgRcut", your pointcloud will be colorized with the images from your camera, but not with the depth map colors<br>- rows 275 and 276 is a cut of images for creating depth map. You can use non-cutted frames<br>- line 193 is a calc_point_cloud definition. Here you get actual points with X, Y and Z coordinates <br><br>Sorry, this code is in alfa version now, but I think it is better to share it now with you, so you can get some useful info.<br><br>Noob, you can get X, Y and Z points for the test objects you put on, say, 1 meter from the camera. It will help you to calibrate real distance measurement.<dl class="file"><dt><span class="imageset icon_topic_attach"></span> <a class="postlink" href="https://forum.stereopi.com/download/file.php?id=64">22.py.zip</a></dt></dl><p>Statistics: Posted by <a href="https://forum.stereopi.com/memberlist.php?mode=viewprofile&amp;u=2">Realizator</a> — Tue Mar 03, 2020 12:26 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[angelyn.mercado]]></name></author>
		<updated>2020-03-03T09:07:58+00:00</updated>

		<published>2020-03-03T09:07:58+00:00</published>
		<id>https://forum.stereopi.com/viewtopic.php?p=1698#p1698</id>
		<link href="https://forum.stereopi.com/viewtopic.php?p=1698#p1698"/>
		<title type="html"><![CDATA[Re: Getting Real Distance]]></title>

		
		<content type="html" xml:base="https://forum.stereopi.com/viewtopic.php?p=1698#p1698"><![CDATA[
Had a similar question here: <a href="https://forum.stereopi.com/viewtopic.php?f=9&amp;t=810&amp;p=1414#p1414" class="postlink">https://forum.stereopi.com/viewtopic.ph ... 1414#p1414</a><br>That might help =)<p>Statistics: Posted by <a href="https://forum.stereopi.com/memberlist.php?mode=viewprofile&amp;u=300">angelyn.mercado</a> — Tue Mar 03, 2020 9:07 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[noob]]></name></author>
		<updated>2020-03-03T02:46:29+00:00</updated>

		<published>2020-03-03T02:46:29+00:00</published>
		<id>https://forum.stereopi.com/viewtopic.php?p=1697#p1697</id>
		<link href="https://forum.stereopi.com/viewtopic.php?p=1697#p1697"/>
		<title type="html"><![CDATA[Getting Real Distance]]></title>

		
		<content type="html" xml:base="https://forum.stereopi.com/viewtopic.php?p=1697#p1697"><![CDATA[
I have been trying to obtain the real distance of an object from a disparity map. The disparity map used is the one generated from 6_dm_video.py from the Stereopi tutorial. As far as I understand, the focal length of a pi camera in terms of pixel is 2571.4, while the distance betweeen my two cameras is 0.065m. so using this formula based on the triangulation method, <br><br>Distance = (focal length * distance between 2 camera)/disparity map. <br><br>I also generated a disparity map with the following code:<br><br>stereo = cv2.StereoBM_create(numDisparities=48, blockSize=25)<br>disparity = steeo.compute(rectified_pair[0], rectified_pair[1])<br>norm_image = cv2.normalize(disparity, None, alpha = 0, beta =1, norm_type=cv2.NORM_MINMAX, dtype=cv.CV_32F)<br><br>cv2.imshow(norm_image)<br>.<br>.<br>f = 2571.4             b = 0.065<br>distance = (b*f)/disparity<br><br>I realize my 'disparity' image range starts from -16.<br>I am getting negative values for both set of codes and I am unsure if this is a correct method to calculate distance. I have calibrated my cameras. <br><br>Thank you very much.<p>Statistics: Posted by <a href="https://forum.stereopi.com/memberlist.php?mode=viewprofile&amp;u=348">noob</a> — Tue Mar 03, 2020 2:46 am</p><hr />
]]></content>
	</entry>
	</feed>
