So, our team is trying to get the sample vision code to work using the Axis M1011 camera, and we are getting a weird exception. As we step through the code, I’m finding that the cause (or at least where the error occurs) is when “image->ThresholdHSV(threshold)” is called.
By going into ColorImage.cpp we have found that the exception occurs on line 37 when “wpi_setImaqErrorWithContext(success, “ImaqThreshold error”)” is called. The value of success is 0, which I assume means it was successful but I’m not sure.
We have not tried this process with any images loaded onto the cRio. We can see the camera by viewing it on the Dashboard and/or in a web browser. The IP is set to 10.15.51.11.
Any help or suggestions would be much appreciated.
http://i.imgur.com/ikSVZIY.png
void Autonomous(void)
{
Threshold threshold(60, 100, 90, 255, 20, 255); //HSV threshold criteria, ranges are in that order ie. Hue is 60-100
ParticleFilterCriteria2 criteria] = {
{IMAQ_MT_AREA, AREA_MINIMUM, 65535, false, false}
}; //Particle filter criteria, used to filter out small particles
AxisCamera &camera = AxisCamera::GetInstance("10.15.51.11"); //To use the Axis camera uncomment this line
while (IsAutonomous() && IsEnabled()) {
/**
* Do the image capture with the camera and apply the algorithm described above. This
* sample will either get images from the camera or from an image file stored in the top
* level directory in the flash memory on the cRIO. The file name in this case is "testImage.jpg"
*/
ColorImage *image;
//image = new RGBImage("/testImage.jpg"); // get the sample image from the cRIO flash
camera.GetImage(image); //To get the images from the camera comment the line above and uncomment this one
BinaryImage *thresholdImage = image->ThresholdHSV(threshold); // get just the green target pixels
//thresholdImage->Write("/threshold.bmp");
...
...
BinaryImage *ColorImage::ComputeThreshold(ColorMode colorMode,
int low1, int high1,
int low2, int high2,
int low3, int high3)
{
BinaryImage *result = new BinaryImage();
Range range1 = {low1, high1},
range2 = {low2, high2},
range3 = {low3, high3};
int success = imaqColorThreshold(result->GetImaqImage(), m_imaqImage, 1, colorMode, &range1, &range2, &range3);
wpi_setImaqErrorWithContext(success, "ImaqThreshold error");
return result;
}