[Java] how to handle PS3Eye camera! CLEyeMulticamTest doesn’t work!
Posted: 26 April 2010 06:20 AM   [ Ignore ]
New Member
Rank
Total Posts:  3
Joined  2010-04-23

Hi, sorry for my bad English, I hope you can hunderstand me… smile

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 zoomValzoomDelta;
    
float rotateValrotateDelta;

    @
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(animatesetupAnimation();
    
}

    
@Override
    
public void draw(){
      
// Loops through available cameras and updates
      
for(int i 0numCamsi++)
      
{
        
// ---------------------   (image destination, wait timeout)
        
myCameras[i].getCameraFrame(myImages[i].pixels, (i==0) ? 1000 0);
        
myImages[i].updatePixels();
        
image(myImages[i]cameraWidth*i0);
      
}
      
// 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 0numCamsi++)
  
{
    
// 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(iCLCamera.CLEYE_COLOR_PROCESSEDCLCamera.CLEYE_VGAcameraRate);
    
// Starts camera captures
    
myCameras[i].startCamera();
    
myImages[i] createImage(cameraWidthcameraHeightRGB);
  
}
  
// resize the output window
  
size(cameraWidth*numCamscameraHeight);
  
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?

Profile
 
 
Posted: 27 April 2010 01:18 AM   [ Ignore ]   [ # 1 ]
New Member
Rank
Total Posts:  3
Joined  2010-04-23

I solved!

This is the code!

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 zoomValzoomDelta;
    
float rotateValrotateDelta;

    @
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(animatesetupAnimation();
    
}

    
@Override
    
public void draw(){
      
// Loops through available cameras and updates
      
for(int i 0numCamsi++)
      
{
        
// ---------------------   (image destination, wait timeout)
        
myCameras[i].getCameraFrame(myImages[i].pixels, (i==0) ? 1000 0);
        
myImages[i].updatePixels();
        
image(myImages[i]cameraWidth*i0);
      
}
      
// Updates the animation
      
if(animate)updateAnimation();
    
}

boolean setupCameras
(){
  System
.out.println("Getting number of cameras");

  
System.out.println(this);
  
// 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 0numCamsi++)
  
{
    
// Prints Unique Identifier per camera
    
System.out.println("Camera " + (i+1) + " UUID " CLCamera.cameraUUID(i));
    
// New camera instance per camera
    
System.out.println(this);

    
myCameras[i] = new CLCamera(this);
    
// ----------------------(i, CLEYE_GRAYSCALE/COLOR, CLEYE_QVGA/VGA, Framerate)
    
myCameras[i].createCamera(iCLCamera.CLEYE_COLOR_PROCESSEDCLCamera.CLEYE_VGAcameraRate);
    
// Starts camera captures
    
myCameras[i].startCamera();
    
myImages[i] createImage(cameraWidthcameraHeightRGB);
  
}
  
// resize the output window
  
size(cameraWidth*numCamscameraHeight);
  
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;
}

   
  
public static void main(String args[]{
    PApplet
.main(new String[] { "--present""MyProcessingSketch" });
  
}

Profile
 
 
Posted: 27 April 2010 06:19 PM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  585
Joined  2009-09-17

You beat me to it smile

Thanks for posting the working code

AlexP

Profile
 
 
Posted: 06 May 2010 04:22 AM   [ Ignore ]   [ # 3 ]
New Member
Rank
Total Posts:  3
Joined  2010-04-23

Hi, I’m back… smile

I’ve a new question!

How do I close the Applet?

I try to explain better my problem: I’ve to handle the applet from another class. I start it calling the main method of CLEyeMulticamTest class. Now I have to close it and come back to the first process that called the ps3camera applet, how can I do?

Profile
 
 
Posted: 08 May 2011 06:54 PM   [ Ignore ]   [ # 4 ]
New Member
Rank
Total Posts:  1
Joined  2011-05-08

I like to use ps3eye camera in my java projection. It seems that you
resolved this. I am a new java programmer. Would you like to share your java
projection with me? So I can run it derectly.Thank you!

Profile
 
 
 
 


RSS 2.0     Atom Feed