title: Distance detection using two webcams/images
body: <p>I'm in the starting blocks of trying to figure out how I can get the distance to any given point in an image. Given just a single image this is off course impossible without knowing the size of the objects I want to know the distance too and defining what this means in pixels.. </p>
  
  <p>The idea I have in mind for doing this is to mount two 720p webcams facing the same direction at a known distance to each other.. around 4 inches.. and then trying to compare the offset of the items in the image to try to get a fairly accurate guess of the distance (I only need this to work in the range of around 3 to 12 feet).</p>
  
  <p>The idea I have for the algorithm goes along the lines of:</p>
  
  <ol>
  <li>Capture two images at same point in time from the two separate cameras.</li>
  <li>Select small area in image 1 that I want to know the distance to.</li>
  <li>Try to align the chosen spot in the 1st image to the same spot in 2nd image.</li>
  <li>When I have aligned them I should be able to calculate the distance, knowing how much I had to adjust the images to match each other.</li>
  </ol>
  
  <p>So what I'm looking for help with is how point 3 in the list should be done, aligning the images.. Or if anyone has any completly different ideas for how this should be done I'm all ears.</p>
  
  <p>As a side note, I want to run this in python on a raspberry pi so I need to do all calculations with a minimum of processing power.</p>
  
  <p>This is going to be used in the context of an automatic rubber-band sentry gun. The parts above will be used to calculate at what incline the shots need to be fired to compensate for the rubber bands trajectory.</p>