Hi, sorry for my bad English, I hope you can hunderstand me…
I’ve to develop a Java software that handle a PS3Eye camera.
I downloaded CL-Eye Platform SDK, I use the cleyemulticam.jar library in my code, but I can not use the camera from my java code.
This is my code:
//Main.java
public class Main {
public static void main(String[] args) {
CLEyeMulticamTest test = new CLEyeMulticamTest();
test.setup();
}
}
//CLEyeMulticamTest.java
import processing.core.*;
import cl.eye.*;
public class CLEyeMulticamTest extends PApplet{
// Camera Variables
int numCams;
CLCamera myCameras[] = new CLCamera[2];
PImage myImages[] = new PImage[2];
int cameraWidth = 640;
int cameraHeight = 480;
int cameraRate = 30;
// Animation Variables (not required)
boolean animate = true;
float zoomVal, zoomDelta;
float rotateVal, rotateDelta;
@Override
public void setup(){
// Library loading via native interface (JNI)
// If you see "UnsatisfiedLinkError" then target the library path otherwise leave it commented out.
// CLCamera.loadLibrary("C://PATH//TO//CL-EYE SDK FOLDER//Bin/CLEyeMulticam.dll");
// Verifies the native library loaded
if(!setupCameras()) System.exit(-1);
// Setups animated variables
if(animate) setupAnimation();
}
@Override
public void draw(){
// Loops through available cameras and updates
for(int i = 0; i < numCams; i++)
{
// --------------------- (image destination, wait timeout)
myCameras[i].getCameraFrame(myImages[i].pixels, (i==0) ? 1000 : 0);
myImages[i].updatePixels();
image(myImages[i], cameraWidth*i, 0);
}
// Updates the animation
if(animate)updateAnimation();
}
boolean setupCameras(){
System.out.println("Getting number of cameras");
// Checks available cameras
numCams = CLCamera.cameraCount();
System.out.println("Found " + numCams + " cameras");
if(numCams == 0) return false;
// create cameras and start capture
for(int i = 0; i < numCams; i++)
{
// Prints Unique Identifier per camera
System.out.println("Camera " + (i+1) + " UUID " + CLCamera.cameraUUID(i));
// New camera instance per camera
if (this == null)
System.out.println(this);
myCameras[i] = new CLCamera(this); ///***
// ----------------------(i, CLEYE_GRAYSCALE/COLOR, CLEYE_QVGA/VGA, Framerate)
myCameras[i].createCamera(i, CLCamera.CLEYE_COLOR_PROCESSED, CLCamera.CLEYE_VGA, cameraRate);
// Starts camera captures
myCameras[i].startCamera();
myImages[i] = createImage(cameraWidth, cameraHeight, RGB);
}
// resize the output window
size(cameraWidth*numCams, cameraHeight);
System.out.println("Complete Initializing Cameras");
return true;
}
void setupAnimation(){
// General Animation Variables
zoomVal = 0;
zoomDelta = (float) (TWO_PI / 75.0);
rotateVal = 0;
rotateDelta = (float) (TWO_PI / 125.0);
}
void updateAnimation(){
myCameras[0].setCameraParam(CLCamera.CLEYE_HKEYSTONE, (int)(150 * sin(rotateVal)));
myCameras[0].setCameraParam(CLCamera.CLEYE_VKEYSTONE, (int)(200 * cos(rotateVal)));
//myCameras[0].setCameraParam(Multicam.CLEYE_LENSCORRECTION1, (int)(75 * sin(rotateVal)));
if(numCams>1)
{
myCameras[1].setCameraParam(CLCamera.CLEYE_ZOOM, (int)(200 * sin(zoomVal)));
}
rotateVal += rotateDelta;
zoomVal += zoomDelta;
}
}
At this line *** I have this problem:
java.lang.NullPointerException
at processing.core.PApplet.registerNoArgs(Unknown Source)
at processing.core.PApplet.registerDispose(Unknown Source)
at cl.eye.CLCamera.
Where is the problem?
Do you have a running sample?