View Single Post
  #3   Spotlight this post!  
Unread 22-03-2009, 19:55
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Capturing Camera Images to cRIO

Not only do we have code that does this, but I took home the school laptop from the waterloo regional, so I have it on me. This is debug code that isn't critical, so forgive the lack of error checking and memory-freeing.

Code:
void SavePictures(TrackingThreshold& tGreen, TrackingThreshold& tPink)
{
  Image* cameraImage = frcCreateImage(IMAQ_IMAGE_HSL);
  GetImage(cameraImage, NULL);
  Image* thresImage = frcCreateImage(IMAQ_IMAGE_HSL);
  frcColorThreshold(thresImage,cameraImage,IMAQ_HSL,&tGreen.hue,&tGreen.saturation,&tGreen.luminance);
  frcWriteImage(thresImage,"green.jpg");
  frcColorThreshold(thresImage,cameraImage,IMAQ_HSL,&tPink.hue,&tPink.saturation, &tPink.luminance);
  frcWriteImage(thresImage,"pink.jpg");
  frcWriteImage(cameraImage,"raw.jpg");
}
This was copied by hand from our code on the laptop, so it probably has some typos. I think the only thing different is that you were not frcCreateImage-ing your image to allocate it.

If you do the thresholding stuff like we did, one note is that you should modify frcColorThreshold so that it sets the "on" color value to something other than 1 (the default in WPILib) so it is easy to see the colors in the thresholded images. We spent quite awhile debugging our thresholding, saying "why are we getting pure-black images" until we realized that they only appeared black, and actually contained data.