NXTCam is a real-time image processing engine. Think of
it as a vision sub-system with on-board processor and a
protocol interface that is accessible through a standard
NXT sensor port. This interface provides high-level,
post-processed information of the image NXTCam sees.
The processed information contains the bounding box
coordinates of the objects of interest in view of NXTCam,
in line tracking mode, this information contains
coordinates of line segments.
NXTCam does not send the image itself to NXT, however connecting NXTCam to a
PC with USB cable, and using a Viewer and Configuration software, you can see the
image on the PC.
NXTCam-v4 is compatible with NXTCam-v3 software and libraries.
NXTCam Specs
•Track up to 8 different colorful objects at 30 frames/second
•Configure the NXTCam using USB interface on Windows XP, Windows Vista.
•Supports two tracking modes: Object tracking and Line tracking.
•Provide real-time tracked object statistics (number of objects, color of
objects, bounding box coordinates or line coordinates) through a standard
NXT sensor port.
•Tracked image resolution of 88 x 144 pixels at 30 frames/second
•Perform full-resolution (176 x 144) pixels color image dumps to PC via USB
port.
•Maximum power consumption (42 mA at 4.7 V)
•Uses NXT compatible I2C protocol for communications.
•Supports Auto Detecting Parallel Architecture (ADPA) for NXT sensor bus.
This means that NXTCam can coexist with LEGO or third party digital
sensor on the same NXT port. ADPA support enables user to employ several
sensors on the same port without the need of external sensor multiplexer,
reducing the overall size without compromising the functionality.
What you will need before using NXTCam
Connector Cables
mindsensors.com 1/14
For runtime operations (on the robot, in autonomous mode), the NXTCam connects
to NXT on a sensor port using a standard connector cable that comes with NXT (the
one with jacks similar to phone jacks).
For offline operations (for programming and configurations), NXTCam connects to
PC using mini-USB cable. (This is in addition to the cable
you would use to connect NXT to your PC). Adjacent
picture shows the mini-USB connector you would need on
your USB cable, this connector is commonly used for
digital cameras. If you need to acquire a cable separately, it should be a ‘5 wire’
cable.
USB Driver installation
In order for NXTCam to work properly, you will need to install USB drivers for your
operating system. Currently support exists for:
Windows XP (i386 and AMD processors)
Windows Vista (i386 and AMD processors)
Mac OS X v10.4.10 (PowerPC G4)
Download the drivers and installation instructions from following location:
To see the picture that’s in the field of view of NXTCam, capture that picture for
analysis and configure the Colormaps for onboard processing, you will need to install
and use Viewer and Configuration software on your PC.
Download Viewer and Configuration software for your operating system from
following location:
For MS-Windows XP/Vista:http://nxtcamview.sourceforge.net/ (developed by Paul
Tingey)
NXTCam may be connected to any of the sensor ports of NXT using standard NXT
connector cable. In your program, select the appropriate port number to which
NXTCam is connected.
WARNING
Do not connect the NXTCam to any motor port, as the voltage applied by the motor
port may damage the electronics of NXTCam.
During offline operations, such as programming and configuration, NXTCam must be
connected to PC (using USB cable) as well as NXT (using standard NXT connector
cable) while NXT is powered ON.
During runtime (or autonomous) operations on NXT, the USB connection to PC must
be removed.
NOTE: While NXTCam is connected to NXT as well as PC, the PC communication
takes priority over any other communication.
In other words, while NXTCam is connected to PC as well as NXT, if you run a
program on NXT, it will not be able to talk to NXTCam.
Mounting NXTCam on your contraption
The holes on the NXTCam enclosure are designed for tight fit of
Technic pins (or axles) with ‘’ cross section. The holes however
are not designed for repeated insertions/removals of these pins.
mindsensors.com 3/14
To mount NXTCam v2 on your contraption we suggest that you use two dark gray
‘Technic Axle 3 with Stud’ as shown.
Insert axles from the front (lens side) of the NXTCam and secure with a bushing on
the back or mount it on your contraption directly.
Alternately, you may use blue ‘Technic Axle Pin with Friction’, as shown.
While disassembling contraption, leave the axles and/or pins on NXTCam.
LED on NXTCam
The LED on NXTCam blinks initially when NXTCam is booting up
(when power is connected through USB port or NXT Sensor port).
During the normal operation the LED may blink occasionally.
Configuring NXTCam Colormaps using NXTCamView
What’s a Colormap?
The objects of interest are recognized by NXTCam by matching the stored color
values with the captured image. To do that, color values of the objects of interest
need to be stored in NXTCam’s memory. These color values are known as Colormaps.
NXTCam can store up to 8 Colormaps and provide processed information of the
objects matching those Colormaps.
Default Object Colormap
The NXTCam is shipped with a default Colormap to track a light source (white light).
Download a test program or write a test program, and try tracking a light source.
Objects of interest
Below are screen dumps of NXTCamView software, showing objects of interests and
their tracking information.
mindsensors.com 4/14
The top left window in the picture below shows the field of view of NXTCam.
The objects of interest from this view are the red and blue pens. In the object
tracking mode, the bounding box coordinates are returned, as shown:
mindsensors.com 5/14
In line tracking mode, beginning point and end point coordinates of a line
representing the object are returned. In the following picture, the bounding
boxes are drawn for the line coordinates received from NXTcam:
To pick Colormap values of your objects of interest and to store them on NXTCam
using the NXTCamView software, please follow these steps:
1.Download, install and start NXTCamView on your PC.
2. Ensure the two NXTCam drivers (USB-to-Serial and NXTCam) have been
installed on your PC.
3. Ensure the NXTCam is plugged into one of your PCs USB ports.
4. In NXTCamView, setup communications to the NXTCam via Tools\Options.
Often only the COMPort needs to be set.
5. Connect to your NXTCam.
6. Capture an image (or two) to check the focus and lighting conditions.
7. Select some colors to track by clicking on the image you captured. Colors are
shown as ranges of red, green and blue (min/max values of each). You can
add or remove colors from a range by holding down the "CTRL" key or
"SHIFT-CTRL" keys while clicking.
8. Upload the color ranges into the NXTCam.
9. Test your colors in the Tracking window to see what object blobs are
returned.
10. Disconnect NXTCamView from your NXTCam.
mindsensors.com 6/14
Also watch a demo video ‘Capture and Select’ at following URL:
Object Colors in Line Tracking Vs Object Tracking Modes
In the object tracking mode, you can track objects comprising of 8 distinct colors.
While selecting colors, avoid any overlap between colors of different objects.
In line tracking mode, only the first color from the Colormap is used, and it is
recommended to limit the number of colors to one.
Lighting conditions
The NXTCam is designed to operate under white fluorescent light. If you notice
reddish image color, which tends to happen when your environment has lot of
ambient Infrared light, try to find the source of Infrared light and reduce it by
replacing it with fluorescent light.
For advanced operations it is possible to change color gain, brightness and contrast
of NXTCam by manipulating the I2C register values.
Focus
As a factory default, NXTCam lens is set for optimal focus between 2 and 4 feet.
The lens is screwed in it’s holder and it is designed to be tight to prevent accidental
rotation and loss of focus. To refocus the lens, gently turn the lens from the holder,
capture images and see if the new focus is satisfactory. Do not apply excessive
force, as it may damage the lens. For better grip while turning lens, you may wrap a
rubber-band around the exposed threads of the lens. To check the focus, you can
use Viewer software and perform a 'capture' to see the new focus results.
Updating your Colormap
Human eye (and brain) is conditioned to adapt to ambient light conditions and see.
Whereas based on ambient light, the colors of objects appear different to a camera
CCD. In other words, a blue ball in your laboratory lighting conditions will appear to
be a different shade of blue in Gymnasium lighting. Considering this aspect, ensure
to update your NXTCam Colormap based on your final lighting conditions.
Selecting Colors of your Target Object for Colormap
Due to angle of light and shadows cast on the object, to
NXTCam, the object appears to be a mix of dark and
light shades. In choosing color for your colormap, try to
select the lighter shade of your object’s colors. If with
lighter shades you have trouble tracking darker shades,
then select complete range of colors.
mindsensors.com 7/14
Changing the I2C Address
The factory default I2C address of NXTCam is 0x02.
This address can be changed. To set an address different from default address,
send sequence of following commands on the command register:
0xA0, 0xAA, 0xA5, <new I2C address>
Note: Send these commands with no break/read operation in between. This new
address is effective immediately. Please note down your new address for future
reference.
Alternately, you can download device scan and address change programs from
following URLs, and change them to suit your needs:
To ensure USB drivers are installed properly, follow these steps:
1.Ensure to install the USB drivers as mentioned in this document.
2. Connect the NXTcam using a USB cable to your computer.
3. From Start menu -> Right click on Computer, select 'Properties', select
'Hardware' tab, and select the 'Device Manager'.
4. Expand the 'Universal Serial Bus Controller' entry.
5. You should see 'NXTCam' listed.
6. In the same Device Manager, Expand ‘Ports (COM & LPT) entry.
7. You should see a COM port listed for NXTCam (this is the COM port you
should use for your viewer software configuration).
To ensure actual USB communication, follow these steps:
Install TeraTerm from following URL:
http://ttssh2.sourceforge.jp/
mindsensors.com 8/14
Select NXTCam port from the list provided.
Setup Baud Rate as shown:
1.In the main terminal window, just press
<enter>
You should get a response from NXTCam
as ‘NCK’
2. In the same window, type:
GV<enter>
You should get a response from NXTCam
as ‘NXTcam V n.n’ (where n.n is your NXTcam version number)
Alternately, you can use Hyperterminal (on Windows XP)
3. Connect the NXTcam using a USB cable to your computer.
4. Run Hyperterminal: Start -> All Programs -> Accessories -> Communication ->
Hyper Terminal
5. Give a name for the configuration, say ‘mynxtcam’.
6. In the next dialog box specify:
Connect Using: <NXTCam COM Port> (the port you noted from Ports (Com
and LPT) entry in Device Manager)
7. Click OK.
8. In next window Specify:
Bits per second: 115200
Data bits: 8
Parity: None
Stop bits: 1
Flow Control: None
9. Click OK.
10. In the main terminal window, just press <enter>
You should get a response from NXTCam as ‘NCK’
11. In the same window, type:
GV<enter>
You should get a response from NXTCam as ‘NXTcam V n.n’ (where n.n is
your NXTcam version number)
Troubleshooting ‘Time-out’ error
While using NXTCam-v4 on PC (with NXTCamView), if you get ‘Search Error: The
operation has timed out’, NXTCam-v4 AVR firmware may be corrupted.
mindsensors.com 9/14
As a feature of NXTCam-v4, the firmware is designed to be re-writable, but
sometimes due to unknown reason it writes itself and corrupts.
In this case, the firmware needs be re-written by following procedure in section
'How to change Firmware of AVR Mega 8 processor' of 'Advanced Programming
Guide'.
Troubleshooting NXTCam communication with your NXT
Ensure to install NXT-G blocks for NXTCam as mentioned above in the document.
1.Connect your NXT to your PC using it’s standard USB cable.
2. Connect your NXTCam to NXT Port 1 using standard NXT sensor cable.
3. Run NXT-G software on your computer.
4. Power on the NXT.
5. Start a New Program (say Untitled-1), and from Advanced Block Palette,
drag and drop the NXTCam block in it.
6. Click on the block, and examine the bottom left corner of NXT-G window
(where block control
panel is located).
7. You should see
NXTCam version
number shown in the
bottom left corner,
as shown in the
adjacent picture.
8. If the NXTCam is not connected correctly to your NXT, this status will
indicate ‘No Device’. If that happens, ensure the port and Address in your
program match to what’s on NXTCam.
Reference Information
Open Source Software and Hardware
NXTCam is based on AVRcam, and is Open Source using GNU license. We encourage
you to improve the source code and features and inform us the changes for inclusion
in future releases. Visit following URL for Advanced Programming Resources and
related docs.
Following table lists the register definitions and setup commands:
CommandsAction
mindsensors.com 10/14
ASCII Hex
A0x41Sort tracked objects by size
B0x42Select Object tracking mode
C0x43Write to image sensor Registers
Use CAUTION when using command C since this can
stop NXTCam from working properly. In case this
happens, please power off your NXTCam and power
it on again.
D0x44Disable Tracking
E0x45Enable Tracking
G0x47Get the Color map from NXTCam Engine
H0x48Read data from the image sensor Registers
I0x49Illumination on (Future)
L0x4CSelect Line tracking mode
N0x4ESet ADPA mode ON (setting stored in NVRAM)
O0x4FSet ADPA mode Off (default) (setting stored in
NVRAM)
P0x50Ping NXTCam Engine
R0x52Reset NXTCam Engine
S0x53Send the color map to NXTCam Engine
T0x54Illumination Off
U0x55Sort tracked objects by color
V0x56Get NXTCam Engine firmware version No,
Read resulting string at 0x42 (12 bytes).
X0x58Do not Sort tracked objects
While programming in NXC, you can use the API function NXTCam_SendCommand ()
to send the command to NXTCam. While using NXT-G block, most of the essential
commands are enumerated in ‘Operation’.
Colormap Reference
More information about Colormap Structure and how they are constructed is
available in document: NXTCam-v3-Colormap-Reference.pdf at following URL: