# Simulating stereo vision using VTK

**URL:** https://discourse.vtk.org/t/simulating-stereo-vision-using-vtk/780
**Category:** Support
**Created:** [April 18, 2019, 3:00pm UTC](https://discourse.vtk.org/t/simulating-stereo-vision-using-vtk/780 "2019-04-18T15:00:17Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![abaldur](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/8797f3/32.png) [@abaldur](https://discourse.vtk.org/u/abaldur)
#### Post date: [April 18, 2019, 3:00pm UTC](https://discourse.vtk.org/t/simulating-stereo-vision-using-vtk/780/1 "2019-04-18T15:00:17Z")

</div>

Hi

Suppose I want to use VTK to simulate a stereo vision system composed of a  
line laser and a camera. The laser is capable of projecting a uniform line  
beam onto some 3D geometry, which I have in the form of an STL file. The  
camera is located somewhere next to the laser and captures the light that is  
reflected from the surface. The result is a 2D image where the intersection  
between the laser beam and the 3d geometry is highlighted. Based on this  
image I would like to test various algorithms.

My question is: Does VTK have tools that are suitable for this task?

Best regards,  
/abaldur

---

<div class="post-metadata">

### Author: ![pettaa123](https://discourse.vtk.org/user_avatar/discourse.vtk.org/pettaa123/32/218_2.png) [@pettaa123](https://discourse.vtk.org/u/pettaa123)
#### Post date: [April 18, 2019, 8:19pm UTC](https://discourse.vtk.org/t/simulating-stereo-vision-using-vtk/780/2 "2019-04-18T20:19:07Z")

</div>

I wouldnt know how to realize this with vtk, but if there is a way I would also be very interested

---

<div class="post-metadata">

### Author: ![Michael](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michael/32/16_2.png) [@Michael](https://discourse.vtk.org/u/Michael)
#### Post date: [April 19, 2019, 9:10am UTC](https://discourse.vtk.org/t/simulating-stereo-vision-using-vtk/780/3 "2019-04-19T09:10:23Z")

</div>

You can use the slice filter with the plane defined by the laser beam:

 ![2019-04-19-110747_763x501](https://discourse.vtk.org/uploads/default/original/1X/d552b7afb16dda1464717ce1fbcaa56783f5a963.png)

Is this what you are looking for?

---

<div class="post-metadata">

### Author: ![pettaa123](https://discourse.vtk.org/user_avatar/discourse.vtk.org/pettaa123/32/218_2.png) [@pettaa123](https://discourse.vtk.org/u/pettaa123)
#### Post date: [April 19, 2019, 2:28pm UTC](https://discourse.vtk.org/t/simulating-stereo-vision-using-vtk/780/4 "2019-04-19T14:28:16Z")

</div>

Awesome. Can you post a code snippet?

---

<div class="post-metadata">

### Author: ![Michael](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michael/32/16_2.png) [@Michael](https://discourse.vtk.org/u/Michael)
#### Post date: [April 19, 2019, 3:16pm UTC](https://discourse.vtk.org/t/simulating-stereo-vision-using-vtk/780/5 "2019-04-19T15:16:01Z")

</div>

I have generated this with ParaView but in VTK, you have to use `vtkCutter` using a `vtkPlane` as implicit function. The output is a polydata containing the contour (a polyline) of the initial surface. Create two actors for both the initial surface and the contour (set color to red and line width to 3) and that’s basically it.  
The plane equation can be computed based on the `vtkCamera` parameters.

---

<div class="post-metadata">

### Author: ![abaldur](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/8797f3/32.png) [@abaldur](https://discourse.vtk.org/u/abaldur)
#### Post date: [April 19, 2019, 10:57pm UTC](https://discourse.vtk.org/t/simulating-stereo-vision-using-vtk/780/6 "2019-04-19T22:57:19Z")

</div>

@Michael, looks exactly like the solution I was searching for.

Thank you for the help.

/ abaldur
