Support for various different Cameras.
The commercial cameras I am aware of, and whose data sheet I have read, largely work in the same basic manner but have various 'camera specific' options. The cameras I have looked at are Blackfin, AVRcam and CMUcam. Let me know if you are aware of others that are in general use.
For example: they are all driven via a UART (normally at 115,200 baud) and have a concept of a colour bin or colour map. One such entry contains a minimum and maximum colour - ie a colour range. Once these have been sent to the camera then it can then provide 'blob' detection - returning a list of screen rectangles whose contents match these ranges of colours. So if my application wants to hunt for a 'red ball', a 'green ball' and a 'blue ball' then I can initialise three colour banks: one for each coloured ball. I can then receive a list of screen rectangles where these colours can be seen.
Why bother - why not just do the calculations in WebbotLib? Well even at a small camera resolution of say 176 by 144 then it can take 4 seconds to transmit a single image from the camera even at 115,200 baud. So requesting an image frame dump from the camera should only be done either as a last resort or if you are working from a PC say and you want to see a picture of what the camera can see. Obviously transmitting the information about a rectangle (ie top/left and bottom/right corners) is very quick and is independent of the size of the rectangle.
So that covers the basics of what the cameras support. So what about all the other stuff?
This is where it tends to get specific from one camera to the next. For example: some cameras will also provide some of the following:-
- Return the colour of a pixel at X,Y
- Return the average colour for the whole screen
- Return the number of pixels in a user-specified rectangle which match a given colour bin
- Change the camera resolution
- Change between RGB and YUV colours - most cameras only work in one colour space (see color.h in this manual - it has routines to allow you to convert from one to the other).
So as a library designer my goal is to provide you with a consistent programming interface that can be used regardless of the actual camera you are using. In the same way as my servo drivers don't change depending on the Make/Model of servo you've got plugged in - then it would also be good if you could swap one camera for another. As with all devices then you can add as many cameras as you need.
I have come up with an initial programming interface and the AVRcam is the first guinea pig for it because a) it is new to WebbotLib and b) I have someone to test it for me! The Blackfin camera is already supported directly and I will only move it to this new interface once the interface has been proved.
The other reason for having a standard programming interface is try to encourage camera suppliers to support the WebbotLib interface. As the adoption of WebbotLib increases then hopefully this will further encourage suppliers to become compliant. If you are a supplier then contact me via http://webbot.org.uk
Most cameras allow you to re-program their software and so you 'could' write your own WebbotLib functions for a given camera - but this is beyond the scope of the average person and unless you are willing to publish, support and maintain your code then it doesn't benefit the community.
In the meantime: I have tried to keep the supported calls to a minimum. Why? With some of the non-basic calls then some cameras support it directly whereas others dont and so I have to spend ages downloading a screen image and do the calculations myself. So for each camera I have commented which functions will 'run slow'.