Go to Post I'd be more worried about getting struck by lightning right after winning the lottery. :p - evulish [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 30-01-2012, 11:27
ksanger's Avatar
ksanger ksanger is offline
Registered User
FRC #0211 (MaK)
 
Join Date: Mar 2010
Rookie Year: 2010
Location: Rochester NY
Posts: 62
ksanger is on a distinguished road
Standalone Java Image Application

We are trying to build a standalone Java Image application that would read the camera, process the image, and post data to the Smart Dashboard. For debugging we would like to read in one of the sample images. However our code crashes using the RGBimage("filename.jpg") with a class not found exception.

We haven't found any examples of standalone java applications. Only ones that use the cRIO. Can anyone help?


Here's our simple program.

package javaimagesample;

import edu.wpi.first.wpilibj.image.ColorImage;
import edu.wpi.first.wpilibj.image.NIVisionException;
import edu.wpi.first.wpilibj.image.NIVision;
import edu.wpi.first.wpilibj.image.RGBImage;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
*
* @author l241870
*/
public class JavaImageSample {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
ColorImage image; // next 2 lines read image from flash on cRIO
try {
image = new RGBImage("/10ft2.jpg");
} catch (NIVisionException ex) {
logger.getLogger(JavaImageSample.class.getName()). log(Level.SEVERE, null, ex);
}
}
}

Here is the debugger output showing we error on the line
image = new RGBImage("/10ft2.jpg");
We have also tried defining the complete path to the image too.


debug:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/cldc/jna/TaskExecutor
at edu.wpi.first.wpilibj.image.NIVision.<clinit>(NIVi sion.java:29)
at edu.wpi.first.wpilibj.image.Image.<init>(Image.jav a:24)
at edu.wpi.first.wpilibj.image.ColorImage.<init>(Colo rImage.java:16)
at edu.wpi.first.wpilibj.image.RGBImage.<init>(RGBIma ge.java:32)
at javaimagesample.JavaImageSample.main(JavaImageSamp le.java:27)
Caused by: java.lang.ClassNotFoundException: com.sun.cldc.jna.TaskExecutor
at java.net.URLClassLoader$1.run(URLClassLoader.java: 366)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:4 23)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 56)
... 5 more
Java Result: 1
BUILD SUCCESSFUL (total time: 18 seconds)
Reply With Quote
  #2   Spotlight this post!  
Unread 30-01-2012, 15:39
Chiller Chiller is offline
Registered User
AKA: Connor Christie
FRC #4095 (RoXI Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Wisconsin
Posts: 118
Chiller is on a distinguished road
Re: Standalone Java Image Application

Quote:
Originally Posted by ksanger View Post
We are trying to build a standalone Java Image application that would read the camera, process the image, and post data to the Smart Dashboard. For debugging we would like to read in one of the sample images. However our code crashes using the RGBimage("filename.jpg") with a class not found exception.

We haven't found any examples of standalone java applications. Only ones that use the cRIO. Can anyone help?


Here's our simple program.

package javaimagesample;

import edu.wpi.first.wpilibj.image.ColorImage;
import edu.wpi.first.wpilibj.image.NIVisionException;
import edu.wpi.first.wpilibj.image.NIVision;
import edu.wpi.first.wpilibj.image.RGBImage;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
*
* @author l241870
*/
public class JavaImageSample {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
ColorImage image; // next 2 lines read image from flash on cRIO
try {
image = new RGBImage("/10ft2.jpg");
} catch (NIVisionException ex) {
logger.getLogger(JavaImageSample.class.getName()). log(Level.SEVERE, null, ex);
}
}
}

Here is the debugger output showing we error on the line
image = new RGBImage("/10ft2.jpg");
We have also tried defining the complete path to the image too.


debug:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/cldc/jna/TaskExecutor
at edu.wpi.first.wpilibj.image.NIVision.<clinit>(NIVi sion.java:29)
at edu.wpi.first.wpilibj.image.Image.<init>(Image.jav a:24)
at edu.wpi.first.wpilibj.image.ColorImage.<init>(Colo rImage.java:16)
at edu.wpi.first.wpilibj.image.RGBImage.<init>(RGBIma ge.java:32)
at javaimagesample.JavaImageSample.main(JavaImageSamp le.java:27)
Caused by: java.lang.ClassNotFoundException: com.sun.cldc.jna.TaskExecutor
at java.net.URLClassLoader$1.run(URLClassLoader.java: 366)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:4 23)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 56)
... 5 more
Java Result: 1
BUILD SUCCESSFUL (total time: 18 seconds)
This is usually a java version error, try and see if you are compiling in Java 7, if so then try and make it compile in Java 6.
Reply With Quote
  #3   Spotlight this post!  
Unread 30-01-2012, 16:02
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 992
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Standalone Java Image Application

You can't just take WPIlibJ programs set up to run under the SquawkVM on the cRIO and run them under a regular VM on Windows. You would need a SquawkVM for Windows and significant rewriting of the code to support this. To do image processing on a PC check out the Smart Dashboard vision extension.
Reply With Quote
  #4   Spotlight this post!  
Unread 30-01-2012, 21:32
ksanger's Avatar
ksanger ksanger is offline
Registered User
FRC #0211 (MaK)
 
Join Date: Mar 2010
Rookie Year: 2010
Location: Rochester NY
Posts: 62
ksanger is on a distinguished road
Re: Standalone Java Image Application

Thanks for the answer. I'll install the SmartDashboard and OpenCV as per WPILibCookbook and try that.

http://www.wbrobotics.com/attachment...ibCookbook.pdf

Note I did try the program using Netbeans 6.9.1 and that fails too. It makes sense that the libraries are written for the Alpha on the cRIO. So much for JAVA portability.
Reply With Quote
  #5   Spotlight this post!  
Unread 30-01-2012, 22:21
ksanger's Avatar
ksanger ksanger is offline
Registered User
FRC #0211 (MaK)
 
Join Date: Mar 2010
Rookie Year: 2010
Location: Rochester NY
Posts: 62
ksanger is on a distinguished road
Re: Standalone Java Image Application

I've downloaded the SmartDashboard installer with OpenCV, then tried the example code based on:
http://www.wbrobotics.com/attachment...ibCookbook.pdf
page 74.

First I added the jar file to the libraries which are installed at C:\Program Files\SmartDashboard\extensions\WPICameraExtension .jar

I assume that's the library needed?

My program looks like:


import edu.wpi.first.smartdashboard.camera.WPICameraExten sion;

public class BasicCameraExtension extends WPICameraExtension {
@Override
public WPIImage processImage(WPIColorImage rawImage) {
return super.processImage(rawImage);
}
}

There are errors
On the @Override statement I get "method does not override or implement a method from a supertype".

On WPIImage I get cannot find symbol.

On WPIColorImage I also get cannot find symbol.

It looks to me like I'm not pointing to the correct libraries again.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 00:40.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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