<?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://pybullet.org/Bullet/phpBB3/app.php/feed/topic/13370" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2022-02-18T19:16:31+00:00</updated>

	<author><name><![CDATA[Real-Time Physics Simulation Forum]]></name></author>
	<id>https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/13370</id>

		<entry>
		<author><name><![CDATA[Erwin Coumans]]></name></author>
		<updated>2022-02-18T19:16:31+00:00</updated>

		<published>2022-02-18T19:16:31+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43870#p43870</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43870#p43870"/>
		<title type="html"><![CDATA[Re: How to get the depth info/images with p.getCameraImage]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43870#p43870"><![CDATA[
The images display after calling 'getCameraImage'.<br><br>See <a href="https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/examples/testrender_np.py" class="postlink">https://github.com/bulletphysics/bullet ... nder_np.py</a><br><br>Here is a snippet that shows depth (requires matplotlib and numpy, next to pybullet)<div class="codebox"><p>Code: </p><pre><code>import matplotlib.pyplot as pltimport numpy as npimport pybullet as pimport pybullet_data as pdp.connect(p.GUI)p.setAdditionalSearchPath(pd.getDataPath())p.loadURDF('plane.urdf')p.loadURDF('cube_small.urdf', basePosition=[0.0, 0.0, 0.025])width = 128height = 128fov = 60aspect = width / heightnear = 0.02far = 1view_matrix = p.computeViewMatrix([0, 0, 0.5], [0, 0, 0], [1, 0, 0])projection_matrix = p.computeProjectionMatrixFOV(fov, aspect, near, far)# Get depth values using the OpenGL rendererimages = p.getCameraImage(width, height, view_matrix, projection_matrix, renderer=p.ER_BULLET_HARDWARE_OPENGL)depth_buffer_opengl = np.reshape(images[3], [width, height])depth_opengl = far * near / (far - (far - near) * depth_buffer_opengl)# Get depth values using Tiny rendererimages = p.getCameraImage(width, height, view_matrix, projection_matrix, renderer=p.ER_TINY_RENDERER)depth_buffer_tiny = np.reshape(images[3], [width, height])depth_tiny = far * near / (far - (far - near) * depth_buffer_tiny)p.disconnect()# Plot both images - should show depth values of 0.45 over the cube and 0.5 over the planeplt.subplot(1, 2, 1)plt.imshow(depth_opengl, cmap='gray', vmin=0, vmax=1)plt.title('OpenGL Renderer')plt.subplot(1, 2, 2)plt.imshow(depth_tiny, cmap='gray', vmin=0, vmax=1)plt.title('Tiny Renderer')plt.show()</code></pre></div><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2">Erwin Coumans</a> — Fri Feb 18, 2022 7:16 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[msaid]]></name></author>
		<updated>2022-02-10T11:10:46+00:00</updated>

		<published>2022-02-10T11:10:46+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43850#p43850</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43850#p43850"/>
		<title type="html"><![CDATA[Re: How to get the depth info/images with p.getCameraImage]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43850#p43850"><![CDATA[
Thanks it runs but still no image i dont know why actually<dl class="file"><dt class="attach-image"><img src="https://pybullet.org/Bullet/phpBB3/download/file.php?id=1916" class="postimage" alt="Capture.PNG" onclick="viewableArea(this);" /></dt></dl><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14253">msaid</a> — Thu Feb 10, 2022 11:10 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Emkey]]></name></author>
		<updated>2022-02-09T13:28:41+00:00</updated>

		<published>2022-02-09T13:28:41+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43846#p43846</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43846#p43846"/>
		<title type="html"><![CDATA[Re: How to get the depth info/images with p.getCameraImage]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43846#p43846"><![CDATA[
Of course! (I am more or less managing, using open3d btw). <br>Try adding these lines!<br>   p.configureDebugVisualizer(p.COV_ENABLE_SEGMENTATION_MARK_PREVIEW, 1)<br>    p.configureDebugVisualizer(p.COV_ENABLE_DEPTH_BUFFER_PREVIEW, 1)<br>    p.configureDebugVisualizer(p.COV_ENABLE_RGB_BUFFER_PREVIEW, 1)<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14245">Emkey</a> — Wed Feb 09, 2022 1:28 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[msaid]]></name></author>
		<updated>2022-02-09T10:17:20+00:00</updated>

		<published>2022-02-09T10:17:20+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43845#p43845</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43845#p43845"/>
		<title type="html"><![CDATA[Re: How to get the depth info/images with p.getCameraImage]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43845#p43845"><![CDATA[
I would like to help you but i would like to ask you please how can i make the synthetic and depth image work inside ?<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14253">msaid</a> — Wed Feb 09, 2022 10:17 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Emkey]]></name></author>
		<updated>2022-02-04T08:50:16+00:00</updated>

		<published>2022-02-04T08:50:16+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43830#p43830</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43830#p43830"/>
		<title type="html"><![CDATA[How to get the depth info/images with p.getCameraImage]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43830#p43830"><![CDATA[
I am trying to get the images from the camera (Synthetic Camera RGB data and Synthetic Camera Depth data). I do get the RGB one, but the depth one is wrong. I cannot save it in a '.png' because of errors regarding the floats, so I save it in a '.tiff'. <div class="inline-attachment"><dl class="file"><dt class="attach-image"><img src="https://pybullet.org/Bullet/phpBB3/download/file.php?id=1908" class="postimage" alt="The views of the camera I want to get" onclick="viewableArea(this);" /></dt></dl></div><div class="codebox"><p>Code: </p><pre><code>img = p.getCameraImage(224, 224, renderer=p.ER_BULLET_HARDWARE_OPENGL)rgbBuffer = img[2] depthBuffer = img[3] # .astype(np.uint8) ?rgbim = Image.fromarray(rgbBuffer)depim = Image.fromarray(depthBuffer)rgbim.save('test_img/rgbtest'+str(counter)+'.png')depim.save('test_img/depth'+str(counter)+'.tiff')</code></pre></div>I am not sure if I need to work with the view and projection matrixes (I have tried, no result). Maybe I am managing wrong the depth data (depthBuffer). My main goal would be to save a PNG as depth image, and a JPG (although it does not really matter rn). But I can't seem to find the error because everything is working fine. But the depth image is wrong for some reason...<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14245">Emkey</a> — Fri Feb 04, 2022 8:50 am</p><hr />
]]></content>
	</entry>
	</feed>
