Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   How to initialize ColorImage object (http://www.chiefdelphi.com/forums/showthread.php?t=154312)

grady404 26-01-2017 22:28

How to initialize ColorImage object
 
So for whatever reason I can't figure out for the life of me how to initialize a ColorImage object. I have the following code inside of my robot class:

Code:

static USBCamera camera = new USBCamera("cam0");
static HSLImage snapshot = // what do I put here?

public void teleopInit() {
    camera.openCamera();
    camera.setExposureAuto();
    camera.startCapture();
}

public void teleopPeriodic() {
    camera.getImage(snapshot.image);
    CameraServer.getInstance().setImage(snapshot.image);
}

Problem is I just can't figure out what line of code I'm supposed to put to initialize the HSLImage object (or RGBImage, or any other type of ColorImage). I've tried the constructor, new HSLImage(), which takes a String for the file path. First of all, there shouldn't be a file path since it's receiving data from the camera directly, and second of all when I do pass in a string I receive an NIVisionException. What do I do? Any help would be greatly appreciated.

jmcculloch 27-01-2017 17:45

Re: How to initialize ColorImage object
 
It looks like you are using the old (2016) version of the usb camera and camera server, which is in the NI vision library. You should instead use the new CameraServer and UsbCamera (not USBCamera) class, which are in the cscore and wpilibj libraries. This link should help you get started, and for more complex vision processing, see this link.


All times are GMT -5. The time now is 09:45.

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