Theoretical Laser Tracking…
I’m currently developing a laser-pointer and webcam pointing device for a 3D game. One of the issues one runs into with this situation arises when you’re setting up the webcam. What happens if the webcam does not have a direct angle on the surface it’s looking at? What you get is this weird quadrilateral that can’t be used to directly map the laser to the mouse.
I’ve written a test program in Processing to address this problem. The white squares define the edges of the usable area. The little red square controlled by the mouse represents the laser pointer, and the larger red circle represents the cursor as the final program would interpret it. The goal is to pretend the area in the box and the area of the program are two perspectives of the same element. Every frame, the program tries to track down the x and y position of the laser dot. It follows a guess and check algorithm, and each guess is shown as a line within the box.
Note that you may click and drag the white boxes to change the shape of the usable area. Check it out!