ROBOTC with the Mindsensors NXTCam

The Mindsensors NXTCam can be configured to track up to 8 colored objects. It connects to an NXT sensor port, and reports the coordinates of each object to the NXT, enabling fast line tracking, color recognition, and object tracking. Watch this cool video showing ROBOTC and the NXTCam: http://www.education.rec.ri.cmu.edu/downloads/lego/resources/NXTCam/NXTCam.html
Sample code for Color Recognition:
#pragma config(Sensor, S1, camera1, sensorI2CCustomFast)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*
Color Recognition - ROBOTC for the NXT
Description: The NXT displays the name of the color returned by the Mindsensors NXTCam v2
NXT Configuration:
- Mindsensors NXTCam v2 plugged into NXT Sensor Port 1
Camera Configuration:
- Color Index 0: Red
- Color Index 1: Orange
- Color Index 2: Yellow
- Color Index 3: Green
- Color Index 4: Blue
- Color Index 5: Purple
- Color Index 6: Black
- Color Index 7: Brown
Notes:
- As of October 2008, NXTCam color index must be configured through
NXTCamView, found at: http://nxtcamview.sourceforge.net/
- More information can be found at: http://mindsensors.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=78
*/
//Include NXTCam Library
#include "RAnxtCamLib.c"
//Define global variables
string colorName;
int numBlobs;
int_array blobColor;
int_array blobX1;
int_array blobTop;
int_array blobX2;
int_array blobBottom;
void printColorName();
task main ()
{
//Initialize the NXTCam
enableTracking(camera1);
wait1Msec(500);
sortBySize(camera1);
wait1Msec(500);
useObjectTracking(camera1);
wait1Msec(500);
//Recognize Colors Forever
while(true)
{
printColorName();
wait1Msec(100);
}
}
//void printColorName() - Writes the color returned from the camera to the NXT screen
void printColorName()
{
nxtDisplayString(1, "The color is:");
//Retrieves Camera Data
getCameraData(camera1, numBlobs, blobColor, blobX1, blobTop, blobX2, blobBottom);
if(numBlobs > 0) //If at least 1 "blob" or color is seen...
{
switch(blobColor) //...check the blobColor index.
{
case 0:
colorName = "RED ";
break;
case 1:
colorName = "ORANGE ";
break;
case 2:
colorName = "YELLOW ";
break;
case 3:
colorName = "GREEN ";
break;
case 4:
colorName = "BLUE ";
break;
case 5:
colorName = "PURPLE ";
break;
case 6:
colorName = "BLACK ";
break;
case 7:
colorName = "BROWN ";
break;
default:
colorName = "UNKNONWN";
break;
}
}
nxtDisplayString(3, colorName);
}
I have purchased the NXTCam v2 and have a question.
I have installed the fdchip program and the nxtcam, but i can’t get the NXTCam View to show up.
I have NXT-G brick,
what should i do?
Peter Mielke
6 Jul 10 at 2:35 pm
Hi Peter -
Mindsensors should be able to help you get the software up and running. http://www.mindsensors.com/
Jesse
6 Jul 10 at 3:21 pm