Hi i need that when i put something like a ball in front of my webcam a square is putten around that ball and keep following it if i moved the ball i currently have no idea on how i can do this so any help whould be appreciated thank you all

Easiest way I can think of would be to crank the contrast up internally, then go by color on this high contrast image to look for edges (of a ball, in this case). For just a rectangle this can be a relatively fast calculation:

-Find the leftmost pixel of color that you are looking for (red ball perhaps)
-Scan to the right (not necessarily pixel by pixel, an approximation algorithm can improve efficiency here) until there is no longer that color
-Find the top most point of that color, scan down till you find the bottom most point like you did scanning to the right
-You now have the boundary for your shape in the image
-Note that the higher the contrast, the easier the edge detection will be. This high contrast image, however, should be stored internally and the coordinates of the boundaries sent off to render the rectangle to the actual image.

People make millions off of software like this so don't expect it to be easy. This type of technology can get A LOT more sophisticated - so much so that operating systems like windows start to become a bad platform for development due to insufficient clock speeds. This is why things such as Microsoft Kinect use embedded systems for these calculations.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.