Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Vision processing - Not an image error (http://www.chiefdelphi.com/forums/showthread.php?t=133757)

sretter 31-01-2015 11:40

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:
Quote:

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 :)

Here is an example of some code we ran:
Quote:

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:

Quote:

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(Bina ryImage.java:111), org.usfirst.frc.team2231.robot.Robot.operatorContr ol(Robot.java:54), edu.wpi.first.wpilibj.SampleRobot.startCompetition (SampleRobot.java:148), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:234)]

Joe Ross 31-01-2015 12:00

Re: Vision processing - Not an image error
 
Have you looked at the 2015 vision examples? They have working examples of thresholding.

sretter 31-01-2015 13:14

Re: Vision processing - Not an image error
 
I looked at the examples and they worked :)
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?


All times are GMT -5. The time now is 22:30.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi