Web cam finder
Web cam finder - dating videos on utube
A simple algorithm is run over the image looking for the brightest pixels.
This way, we could calculate the range for each column of the image rather than just one column.
I used a piece of cardboard to hold a laser pointer to a webcam so that the laser pointer points in a direction that is parallel to that of the camera.
The parts seen below are laid out on a one inch grid for reference.
It is possible to perform machine vision tasks such as obstacle identification and avoidance though the use of a webcam (or mini wireless camera interfaced to a computer via USB adaptor).
Better yet, two webcams can provide stereo machine vision thus improving obstacle avoidance because depth can be determined.
This "stray light" is caused by internal reflections in the camera.
The reflected dot loses intensity as it bounces within the camera so it does not interfere with the algorithm that detects the brightest pixel in the image.The vc code can be put together for free (assuming that you have visual studio), while the vb code requires the purchase of a third party software package (also in addition to visual studio). Set Error Messages False ' Init control If (Not Video OCX. Display error message and end sub Msg Box Video OCX. Get Width ' Image processing code ' The laser dot should not be seen above the middle row (with a little pad) For r = height / 2 - 20 To height - 1 ' Our physical setup is roughly calibrated to make the laser ' dot in the middle columns..bother lookng too far away For c = width / 2 - 25 To width / 2 24 ' Look for the largest red pixel value in the scene (red laser) If (matrix(c, r, 2) max_red) Then max_red = matrix(c, r, 2) max_r = r max_c = c End If Next c Next r ' Calculate the distance for the laser dot from middle of frame pixels_from_center = max_r - 120 ' Calculate range in cm based on calibrated parameters range = h_cm / Tan(pixels_from_center * gain offset) ' Print laser dot position row and column to screen row_val. Caption = max_c ' Print range to laser illuminated object to screen range_val.The visual basic code that I have written is available as a package named vb_laser_at the bottom of this page. Get Last Error String, vb OKOnly, "Video OCX Error" End Else ' Allocate memory for global image handle capture_image = Video OCX. Close End If End Sub Private Sub Timer1_Timer() ' Timer for capturing - handles video OCXTools Dim matrix As Variant Dim height, width As Integer Dim r, c As Integer Dim max_r, max_c As Integer Dim max_red As Integer Dim gain, offset As Variant Dim h_cm As Variant Dim range As Integer Dim pixels_from_center As Integer ' Calibrated parameter for pixel to distance conversion gain = 0.0024259348 offset = -0.056514344 h_cm = 5.842 max_red = 0 ' Capture an image If (Video OCX. Show capture_image ' Matrix transformation initialization matrix = Video OCX. Caption = range ' Draw a red vertical line to intersect target For r = 0 To height - 1 matrix(max_c, r, 2) = 255 Next r ' Draw a red horizontal line to intersect target For c = 0 To width - 1 matrix(c, max_r, 2) = 255 Next c Video OCX.The Web Cam Sensor service is primarily intended for applications that do not use depth data.The Generic Web Cam Sensor service provides the following operations. Unlike the Web Cam, you can Subscribe to the Web Cam Sensor and it will send frames as notifications (Replace messages). The state of a Web Cam Sensor is represented the following properties.Below are two examples of the webcam based laser range finder in action.