<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://boofcv.org/index.php?action=history&amp;feed=atom&amp;title=Example_Stereo_Mesh</id>
	<title>Example Stereo Mesh - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://boofcv.org/index.php?action=history&amp;feed=atom&amp;title=Example_Stereo_Mesh"/>
	<link rel="alternate" type="text/html" href="https://boofcv.org/index.php?title=Example_Stereo_Mesh&amp;action=history"/>
	<updated>2026-05-14T11:45:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.36.2</generator>
	<entry>
		<id>https://boofcv.org/index.php?title=Example_Stereo_Mesh&amp;diff=3241&amp;oldid=prev</id>
		<title>Peter at 02:49, 3 September 2022</title>
		<link rel="alternate" type="text/html" href="https://boofcv.org/index.php?title=Example_Stereo_Mesh&amp;diff=3241&amp;oldid=prev"/>
		<updated>2022-09-03T02:49:42Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:49, 3 September 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;center&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;center&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;gallery heights=350 widths=350 perrow=4 &amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;gallery heights=350 widths=350 perrow=4 &amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;File:Example_disparity_mesh_cloudcompare.jpg| Mesh generated &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;in BoofCV &lt;/del&gt;from stereo image &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;displayed in Cloud Compare&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;File:Example_disparity_mesh_cloudcompare.jpg| Mesh &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;viewed in Cloud Compare and &lt;/ins&gt;generated from &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;a &lt;/ins&gt;stereo &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;disparity &lt;/ins&gt;image&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/gallery&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/gallery&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/center&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/center&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Peter</name></author>
	</entry>
	<entry>
		<id>https://boofcv.org/index.php?title=Example_Stereo_Mesh&amp;diff=3233&amp;oldid=prev</id>
		<title>Peter at 01:01, 3 September 2022</title>
		<link rel="alternate" type="text/html" href="https://boofcv.org/index.php?title=Example_Stereo_Mesh&amp;diff=3233&amp;oldid=prev"/>
		<updated>2022-09-03T01:01:45Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 01:01, 3 September 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l17&quot;&gt;Line 17:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 17:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Related Examples:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Related Examples:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Example_Stereo_Disparity| Stereo Disparity]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Example_Stereo_Disparity| Stereo Disparity]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* [[Example Stereo Disparity 3D| Disparity to 3D Cloud]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Example Code =&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Example Code =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Peter</name></author>
	</entry>
	<entry>
		<id>https://boofcv.org/index.php?title=Example_Stereo_Mesh&amp;diff=3232&amp;oldid=prev</id>
		<title>Peter: Created page with &quot;&lt;center&gt; &lt;gallery heights=350 widths=350 perrow=4 &gt; File:Example_disparity_mesh_cloudcompare.jpg| Mesh generated in BoofCV from stereo image displayed in Cloud Compare &lt;/galle...&quot;</title>
		<link rel="alternate" type="text/html" href="https://boofcv.org/index.php?title=Example_Stereo_Mesh&amp;diff=3232&amp;oldid=prev"/>
		<updated>2022-09-03T01:00:29Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;center&amp;gt; &amp;lt;gallery heights=350 widths=350 perrow=4 &amp;gt; File:Example_disparity_mesh_cloudcompare.jpg| Mesh generated in BoofCV from stereo image displayed in Cloud Compare &amp;lt;/galle...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;gallery heights=350 widths=350 perrow=4 &amp;gt;&lt;br /&gt;
File:Example_disparity_mesh_cloudcompare.jpg| Mesh generated in BoofCV from stereo image displayed in Cloud Compare&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Shows you how to convert a disparity image into a 3D mesh. Meshes are typically easier to view in 3rd party libraries.&lt;br /&gt;
&lt;br /&gt;
Example Code:&lt;br /&gt;
* [https://github.com/lessthanoptimal/BoofCV/blob/v0.41/examples/src/main/java/boofcv/examples/stereo/ExampleStereoMesh.java ExampleStereoMesh.java]&lt;br /&gt;
&lt;br /&gt;
Concepts:&lt;br /&gt;
* Stereo Disparity&lt;br /&gt;
* Filtering&lt;br /&gt;
&lt;br /&gt;
Related Examples:&lt;br /&gt;
* [[Example_Stereo_Disparity| Stereo Disparity]]&lt;br /&gt;
&lt;br /&gt;
= Example Code =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * Example showing how you can convert a disparity image into a 3D mesh.&lt;br /&gt;
 *&lt;br /&gt;
 * @author Peter Abeles&lt;br /&gt;
 */&lt;br /&gt;
public class ExampleStereoMesh {&lt;br /&gt;
	static int disparityMin = 5;&lt;br /&gt;
	static int disparityRange = 60;&lt;br /&gt;
&lt;br /&gt;
	public static void main( String[] args ) {&lt;br /&gt;
		String calibDir = UtilIO.pathExample(&amp;quot;calibration/stereo/Bumblebee2_Chess/&amp;quot;);&lt;br /&gt;
		String imageDir = UtilIO.pathExample(&amp;quot;stereo/&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
		StereoParameters param = CalibrationIO.load(new File(calibDir, &amp;quot;stereo.yaml&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
		// load and convert images into a BoofCV format&lt;br /&gt;
		BufferedImage origLeft = UtilImageIO.loadImage(imageDir, &amp;quot;sundial01_left.jpg&amp;quot;);&lt;br /&gt;
		BufferedImage origRight = UtilImageIO.loadImage(imageDir, &amp;quot;sundial01_right.jpg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
		GrayU8 distLeft = ConvertBufferedImage.convertFrom(origLeft, (GrayU8)null);&lt;br /&gt;
		GrayU8 distRight = ConvertBufferedImage.convertFrom(origRight, (GrayU8)null);&lt;br /&gt;
&lt;br /&gt;
		// rectify images&lt;br /&gt;
		GrayU8 rectLeft = distLeft.createSameShape();&lt;br /&gt;
		GrayU8 rectRight = distRight.createSameShape();&lt;br /&gt;
&lt;br /&gt;
		// Using a previous example, rectify then compute the disparity image&lt;br /&gt;
		RectifyCalibrated rectifier = ExampleStereoDisparity.rectify(distLeft, distRight, param, rectLeft, rectRight);&lt;br /&gt;
		GrayF32 disparity = ExampleStereoDisparity.denseDisparitySubpixel(&lt;br /&gt;
				rectLeft, rectRight, 3, disparityMin, disparityRange);&lt;br /&gt;
&lt;br /&gt;
		// Remove speckle and smooth the disparity image. Typically this results in a less chaotic 3D model&lt;br /&gt;
		var configSpeckle = new ConfigSpeckleFilter();&lt;br /&gt;
		configSpeckle.similarTol = 1.0f; // Two pixels are connected if their disparity is this similar&lt;br /&gt;
		configSpeckle.maximumArea.setFixed(200); // probably the most important parameter, speckle size&lt;br /&gt;
		DisparitySmoother&amp;lt;GrayU8, GrayF32&amp;gt; smoother =&lt;br /&gt;
				FactoryStereoDisparity.removeSpeckle(configSpeckle, GrayF32.class);&lt;br /&gt;
&lt;br /&gt;
		smoother.process(rectLeft, disparity, disparityRange);&lt;br /&gt;
&lt;br /&gt;
		// Put disparity parameters into a format that the meshing algorithm can understand&lt;br /&gt;
		var parameters = new DisparityParameters();&lt;br /&gt;
		parameters.disparityRange = disparityRange;&lt;br /&gt;
		parameters.disparityMin = disparityMin;&lt;br /&gt;
		PerspectiveOps.matrixToPinhole(rectifier.getCalibrationMatrix(), rectLeft.width, rectLeft.height, parameters.pinhole);&lt;br /&gt;
		parameters.baseline = param.getBaseline()/10;&lt;br /&gt;
&lt;br /&gt;
		// Convert the disparity image into a polygon mesh&lt;br /&gt;
		var alg = new DepthImageToMeshGridSample();&lt;br /&gt;
		alg.samplePeriod.setFixed(2);&lt;br /&gt;
		alg.processDisparity(parameters, disparity, /* max disparity jump */ 2);&lt;br /&gt;
		VertexMesh mesh = alg.getMesh();&lt;br /&gt;
&lt;br /&gt;
		// Specify the color of each vertex&lt;br /&gt;
		var colors = new DogArray_I32(mesh.vertexes.size());&lt;br /&gt;
		DogArray&amp;lt;Point2D_F64&amp;gt; pixels = alg.getVertexPixels();&lt;br /&gt;
		for (int i = 0; i &amp;lt; pixels.size; i++) {&lt;br /&gt;
			Point2D_F64 p = pixels.get(i);&lt;br /&gt;
			int v = rectLeft.get((int)p.x, (int)p.y);&lt;br /&gt;
			colors.add(v &amp;lt;&amp;lt; 16 | v &amp;lt;&amp;lt; 8 | v);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		// Save results. Display using a 3rd party application&lt;br /&gt;
		try (OutputStream out = new FileOutputStream(&amp;quot;mesh.ply&amp;quot;)) {&lt;br /&gt;
			PointCloudIO.save3D(PointCloudIO.Format.PLY, mesh, colors, out);&lt;br /&gt;
		} catch (IOException e) {&lt;br /&gt;
			throw new RuntimeException(e);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Peter</name></author>
	</entry>
</feed>