Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   ColorImage java method results in 'not an image' exception (http://www.chiefdelphi.com/forums/showthread.php?t=142673)

rtrahms 27-01-2016 21:24

ColorImage java method results in 'not an image' exception
 
Hi all -

Using Java (wpilibj), we have successfully instantiated an Axis Camera, get an image from it, and doing a thresholdHSV on the ColorImage object doesn't crash the roborio... but the moment we query the BinaryImage object, an NIVisionException 'not an image' is thrown. Code below:

... within our TargetFinder object....

private AxisCamera camera;
private String address;
private boolean hasTarget;

public void initCamera(String address) {
camera = new AxisCamera(address); // get an instance of the camera
}

public void findTarget() {
try {
if (camera.isFreshImage()) {
System.out.println("Got image");

// these calls are okay. image returns height and width okay
ColorImage image = camera.getImage();
System.out.println("Color image data = " + image.getHeight() + "," + image.getWidth());

// this call is okay
BinaryImage thresholdImage = image.thresholdHSV(H_LOW, H_HIGH, S_LOW, S_HIGH, V_LOW, V_HIGH);

// this call throws the 'not an image' exception on the call to getHeight()
System.out.println("Binary image data = " + thresholdImage.getHeight() + "," + thresholdImage.getWidth());

thresholdImage.free();
image.free();
}

} catch (NIVisionException ex) {
ex.printStackTrace();
}
}


All times are GMT -5. The time now is 10:18.

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