Post date: Apr 09, 2014 6:55:53 PM
The webcam has arrived! I decided to hook it up and check out what I can do in terms of image processing in MATLAB. Eventually we want to port it into OpenCV, but for prototyping, MATLAB will do. So far, I was able to get the camera connected to MATLAB and take an image. I tried some processing techniques MATLAB had built in and came out with some nifty results.
The tutorial I have referenced is linked here.
Above is the captured image taken from the webcam into MATLAB. For this image, I am shining my cellphone flashlight into the camera to recreate light from a pinhole. Ideally, we would want this to be video so the process is continuous and adapts over time. However, I decided to just work with an image to determine which algorithms will be the best for our final implementation. The image above is actually a RGB image (not black and white) so we need to convert that into a bitmapped format.
Some things to note about the above image. Because the light is directly parallel to the camera lens, lens flares are apparent (which WILL be an issue further down the line). I think the best way to combat this is to tone down the brightness, but as we will see later, this should still be able to find the center of the figure. Another suggestion that may help would be including a polarizing filter to cut back on the light leaks, but more research will have to be done on that later.
The image above shows the same image after bitmap and section removal processing. Essentially, MATLAB finds the areas that are designated as "light" and removes sections with an area less than 10000px^2. From that, we have our main LED light in bitmap form, ready to process.
Â
With the image in bitmap form, we can finally apply processing to the image to determine its roundness and centerpoint. The number to the left of the shape indicates its roundness, with a value of 1 being completely circular. As we can see here, MATLAB does not recognize this as a very round figure. This is largely due to the noisy fringes at the edges that contribute to it not being round. However, the centroid of the area can still be found and is shown with the circle in the center. Although it appears that the centroid is off slightly, this is a good start on an algorithm that determines the centerlines and positions of a direct light.
Justin