I got a Mindsensors NXTCam2 for my birthday last year but hadn’t had much time to play with it yet. That is, until today.
The NXTCam2 detects objects by matching them to one of 8 user-programmable colour ranges. The objects and their colour can then be retrieved via a few trivial I2C commands.
You would think that this would mean that a ball shaped object would appear ball shaped on the camera when dangled in front of it. You would be wrong. Objects are rarely uniformly coloured and a patch of reflected light might make the object appear very differently to the camera, resulting in something resembling the picture to the right.
This can make processing processing the information quite hard and daunting if all you really want is to know whether there’s a red ball in front of your robot. I thought it would be nice if there was some way to combine all the shapes that were overlapping or touching into something that was was contiguous and square. One type of software that does a lot of checking whether two objects are touching is game software. After a little Googe’ing I came across this great tutorial that explains collision detection very nicely: Collision Detection and Response.
After a little fiddling and programming, I turned the above jumble of boxes into just two big squares. This makes dealing with the shapes a lot simpler. It gives a much more accurate representation of what’s in front of the camera than the original, assuming you’re not trying to detect pringles with your NXTCam2, that is.
The program below is a modified version of cam_display written by Gordon Wyeth. I’ve also included the nxtcamlib file with the program.
File: cam_display_mk2.zip
Hi,
I have a cmucam3, is the nxtcam based on the same model?
Is it possible to program the nxtcam in the same way as the cmucam?
The CMUCam has a lot more functionality in it than the NXTCam. I don’t know if they’re based on the same model or not, but the CMUCam does not natively support the I2C protocol. You can chat to it via an RS485 bus though. Perhaps it is possible to use the NXT’s RS485 bus for that. I haven’t got one, so there is no way for me to try it.
The NXTCam is only capable of recognising up to 8 coloured blobs of up to 8 different colours. It doesn’t do object recognition like the CMUCam can.
In many ways the CMUCam is vastly superior to the NXTCam, unfortunately, I can’t make it work with my NXT. At least not without some additional home made hardware.
Regards,
Xander
Hi, Xander
I think it would be possible to use the CMUCam with NXT with a serialBT adapter. I use one serialBT to communicate my Bioloid with other devices.
Although I am interested in a camera for the NXT, I still want to wait until it can recognize shpes, display the RBG data from individual pixels, and the preset colors can be set by the NXT. Care to work on another project involving the NXTCamV2?
-NNG
NNG,
I am not sure the ATmega in the NXTCamv2 could handle the kind of image processing you are intending to do. You simply couldn’t transfer the amount of data through the 9600 baud I2C connection that would be required for the RGB info of all the pixels. The NXT is also limited to transferring 16 bytes per I2C transaction. What you’re looking for is something like the CMUcam3 with an uplink to a host PC running RoboRealm.
As for setting the preset colours from the NXT, it *is* possible afaik, but not very easy. The PC program is just a lot more convenient.
Regards,
Xander