Tuesday, October 6, 2009

Week 2 Day 2

Today was one of the most interesting day of all my programming days.


For first, I have managed to code up a C++ application that displays what the video camera see.


Next, simply just 2 lines of codes were added to include a "press c to capture" function. For these 2 features, I realise there wasn`t much coding that needs to be done. All the methods to do up these features were provided by OpenCV libraries, and all I need to do was to code up the while loop (to loop the capturing of image), and some variables.


As according to tradition, I captured an image of my SIP-team mate, victor, doing coding, which I believe would be the first few photos in this pictureless blog so far.









After lunch, we moved on to the last tasks which was to create a circle enclosing the area which is the brightest. I spent about an hour googling on contours and some RGB stuffs, only to find out that all that were irrelevant, and only one method, cvMinMaxLoc was needed. This method does not return objects, but it takes in memory address of 5 things, the converted single-channel (or colour) image, min(darkest) value, max(brightest) value, min(darkest) location and max(brightest) location (or spot), and write data to the variables at this memory address.

Thereafter, we used cvCircle to draw a small red circle with its centre point at the "max(brightest) location". The program worked out fine, and when we shine a laser light on a dark surface, it just feel great to see that the application is able to circle out the laser pointer's lightspot on the dark surface.

Next, we then moved on to removing the red circle when the laser pointer is not shining. First, we identified the brightness of the laser pointer's light spot on the wall, and was surprised it was the max value (255). After setting up an "if" statement to only draw the circle when the brightest spot is 255, the red circle now disappears whenever the laser pointer is not shinning, and reappears upon the laser pointer begin shone on the wall.

No comments:

Post a Comment