Vision processing - Not an image error

Hello,
We’ve had a problem while trying to do some basic vision processing, when we try to get an image then threshold that image, every method we do on the result fails(things we’ve tried: write,getHeight, getWidth, convexHull, particleFilter) and the error we receive:

Unhandled exception: VisionException [com.ni.vision.VisionException: imaqError: -1074396120: Not an image.]

The camera seems to be fine(we can see the image on the dashboard, and when we write the image we get after using getImage() it’s valid) so we’re kinda stuck and don’t know what to do.
We’d love to get some help to solve this :slight_smile:

Here is an example of some code we ran:

package org.usfirst.frc.team2231.robot;

import com.ni.vision.NIVision.Image;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.image.BinaryImage;
import edu.wpi.first.wpilibj.image.ColorImage;
import edu.wpi.first.wpilibj.image.NIVisionException;
import edu.wpi.first.wpilibj.vision.AxisCamera;

public class Robot extends SampleRobot {
int session;
Image frame;
ColorImage image;
BinaryImage thresholdImage;
AxisCamera camera;

public void robotInit() {

    // open the camera at the IP address assigned. This is the IP address that the camera
    // can be accessed through the web interface.
    camera = new AxisCamera("10.22.31.11");
}

public void operatorControl() {

    while (isOperatorControl() && isEnabled()) {
        try {
  		image = camera.getImage();
  		thresholdImage = image.thresholdHSL(0, 255, 0, 255, 0, 255);
  		thresholdImage.write("/tmp/threshold.jpg");
  		image.free();
          thresholdImage.free();thresholdImage.
  		
  	} catch (NIVisionException e) {
  		// TODO Auto-generated catch block
  		e.printStackTrace();
  	}
        

        /** robot code here! **/
        Timer.delay(0.005);		// wait for a motor update time
    }
}

public void test() {
}

}

And the error:

ERROR Unhandled exception: VisionException [com.ni.vision.VisionException: imaqError: -1074396120: Not an image.] at [com.ni.vision.NIVision._imaqWriteFile(Native Method), com.ni.vision.NIVision.imaqWriteFile(NIVision.java:20506), edu.wpi.first.wpilibj.image.BinaryImage.write(BinaryImage.java:111), org.usfirst.frc.team2231.robot.Robot.operatorControl(Robot.java:54), edu.wpi.first.wpilibj.SampleRobot.startCompetition(SampleRobot.java:148), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:234)]

Have you looked at the 2015 vision examples? They have working examples of thresholding.

I looked at the examples and they worked :slight_smile:
Thanks for the help,
But I was just wondering: the examples use the “com.ni.vision.NIVision”
and in the last years we’ve used “edu.wpi.first.wpilibj.image” - are they not supported anymore?