<<Prev 1 2 3 4 5 6 7 8 9 10 11 Next>>
Center of Gravity
There are many ways we could translate the resulting image intensities into right and left motor movements.
A simple way would be to add up all the pixel values of the left side of the image and compare the
result to the right side. Based on which is more the robot would move towards that side.
At this point, however, we will use the COG or Center of Gravity of the image to help guide our robot.
The COG of an object is the location where one could balance the object using just one finger. In image
terms it is where one would balance all the white pixels at a single spot. The COG is quick and easy to
calculate and will change based on the object's shape or position in an image.
To calculate the COG of an image add all the x,y locations of non-black pixels and divide by the number
of pixels counted. The resulting two numbers (one for x and the other for y) is the COG location.
Let's do that for a couple images and see what we get!
<<Prev 1 2 3 4 5 6 7 8 9 10 11 Next>>
|