How can I find the distance between webcam and red dot laser point.

Web Cam: Logitech C270 HD Webcam
Laser Dot: Red Colour
Requesting you to please provide code related to this or provide reference to solve this.
Please find below requirement details:
  1. Maximum distance between webcam and laser red dot would be: 1 meter
  2. While recording video by webcam need to identify the distance between laser red dot and web cam.
  3. Webcam connected with Laptop by USB.

4 Comments

Think twice.
All information we have, is that you have a "webcam" and a "red dot laser point". While it does neither matter if the camera is a "web" or whatever cam nor if the color of the dot is red or blue, all useful details are missing:
  • Do you have any information about the geometry, e.g. does the camera translate or rotate around the point?
  • How is "distance" defined here? A webcam has a spatial extent.
  • What is the connection to Matlab?
  • What inputs do you have? Perhaps a recorded movie?
Do not let the readers guess all details, if you want to get an answer.
Where is the origin of the laser dot? Is it mounted on the webcam and the task is to figure out, with the assistance of the dot, how far away the webcam is from the surface? Or is the laser pointer being held and shone towards the webcam and the task is to figure out how far away it is being held? Or is the laser pointer mounted at a fixed point and being aimed towards the webcam and the task is to figure out how far away the webcam is ?
Is the webcam (or laser) moving with only one degree of freedom, closer or further?
How is "distance" defined, if "Web cam will move back and forth between laser red dot"? The graphics are very nice, but it looks like you want to determine the distance to the laser pointer device, not to the dot created by the laser.
Your "Webcam connected with Laptop by USB" is not fast enough to do something like Lidar at a distance of 1 m. Best solution still seems like measuring tape: https://en.wikipedia.org/wiki/Tape_measure.

Sign in to comment.

Answers (3)

measuring tape, from an actual toolbox

2 Comments

What you want to do seems VERY difficult via imaging techniques... Laser usually saturate the camera and forms airy disks. You could use the divergence angle data of lasers to figure out how far the laser source is to the surface (which needs the size-distance calibration as Walter mentioned), but that doesn't tell how far the webcam is to the laser and you have to determine what the "true spot size" is - this is difficult as the laser intensity profile is gaussian (no clean circular edge) and very small (lots of error, pixelated).
Even with stereo vision, accuracy drops off with laser spot distance and closeness of the two cameras. You could use focal planes to estimate distance (again after another calibration), but webcams have limited zooming capabilities. Last, you could use a reference object, but this'll fail on plain backgrounds (projector screen), and you'll need a database of object sizes to use - that means more image recognition and processing...
In some situations if you know the position of the webcam and the position of the laser emitter, and some characteristics of the surface being shone onto, then you can calculate the distance between the camera and the dot as a matter of geometry using Angle Side Angle.

Sign in to comment.

If you do not have stereo views then you can only calculate the distance under some geometries such as if the laser is shining on a flat object of known distance and tilt relative to the camera.
In the absence of any other complicating requirements, this is so easy: just use a tape measure. You have a friend hold the end at the webcam, and you walk over to the red spot and then read off the distance. Of course to satisfy the requirement, have the webcam recording during the process.
Alternatively you could use a laser type of range finder you can also find at any hardware store.
It's not clear what "move back and forth between laser red dot" means. You didn't finish the sentence. Between the dot and WHAT? Would that be along the 1-to-3 dotted blue line? Or can it move along any of the 6 Euler values (x,y,z,roll, pitch, yaw)? I'm thinking that the number of pixels that the red dot occupies on the web cam will be so small, since webcam's often have a very wide field of view, that the dot won't change in size much as the dot-to-camera distance changes.

Asked:

on 27 Sep 2017

Edited:

on 29 Sep 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!