|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: WPILIB Camera Code Crashing JVM
To provide some clarity, we can see from the stack from the JVM that we're in com.ni.vision.NIVision._Priv_ReadJPEGString in wpi's lib when the jvm crashes...
Code:
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) J 361 com.ni.vision.NIVision._Priv_ReadJPEGString_C(JJI)V (0 bytes) @ 0xb4815038 [0xb4814fe0+0x58] J 357 C1 edu.wpi.first.wpilibj.vision.AxisCamera.getImage(Lcom/ni/vision/NIVision$Image;)Z (47 bytes) @ 0xb4813b88 [0xb48138f0+0x298] J 326 C1 org.usfirst.frc3932.Robot.runCamera()V (42 bytes) @ 0xb480bac8 [0xb480ba90+0x38] J 324 C1 org.usfirst.frc3932.Robot.teleopPeriodic()V (15 bytes) @ 0xb480b3b0 [0xb480b180+0x230] j edu.wpi.first.wpilibj.IterativeRobot.startCompetition()V+240 j edu.wpi.first.wpilibj.RobotBase.main([Ljava/lang/String;)V+322 Code:
public static AxisCamera currentCamera;
.
.
.
private void runCamera(){
try {
currentCamera.getImage(image);
CameraServer.getInstance().setImage(image);
} catch (Exception e) {
System.err.println("Failed to get image from camera");
System.err.println(e.getStackTrace());
}
}
.
.
.
|
|
#2
|
|||
|
|||
|
Re: WPILIB Camera Code Crashing JVM
Looking at the source for NIVision I think the .free() will work if used in a finally block. When we tried it the first time it didn't end up in a finally block and the image was being used as a member variable.
The NIVision class is calling C libraries that allocate memory outside the JVM so the correct steps we need are (pseudo code):
Will repost when we understand better. |
|
#3
|
|||
|
|||
|
Re: WPILIB Camera Code Crashing JVM
Still crashing.
Here's the JVM version... Code:
gsmin@roboRIO-3932-FRC:/usr/local/frc/bin# /usr/local/frc/JRE/bin/java -version -XX:+PrintCommandLineFlag java version "1.8.0_06" Java(TM) SE Embedded Runtime Environment (build 1.8.0_06-b23, profile compact2, headless) Java HotSpot(TM) Embedded Client VM (build 25.6-b23, mixed mode) admin@roboRIO-3932-FRC:/usr/local/frc/bin# cd /usr/local/frc/JRE/bin admin@roboRIO-3932-FRC:/usr/local/frc/JRE/bin# ls java keytool rmid rmiregistry admin@roboRIO-3932-FRC:/usr/local/frc/JRE/bin# cd Code:
Mem: 176600K used, 75372K free, 0K shrd, 93K buff, 3067729088K cached CPU: 9% usr 12% sys 0% nic 76% idle 0% io 0% irq 0% sirq Load average: 2.22 2.15 2.30 4/290 8550 |
|
#4
|
|||
|
|||
|
Re: WPILIB Camera Code Crashing JVM
Here is our latest and cleanest code with all the logic encapsulated in a single class. This still crashes the JVM...
Code:
public class CameraConfig {
private AxisCamera camera;
private String URL;
public CameraConfig(String URL){
this.URL = URL;
this.camera = new AxisCamera(this.URL);
camera.writeExposurePriority(50);
}
public void sendImage() {
Image image = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
try {
camera.getImage(image);
CameraServer.getInstance().setImage(image);
} catch (Exception e) {
System.err.println("Failed to get image from camera");
System.err.println(e.getStackTrace());
} finally {
image.free();
}
}
public boolean exists() {
boolean flag = false;
Image image = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
try {
camera.getImage(image);
flag = true;
}
catch (Exception e){
}
finally {
image.free();
}
return flag;
}
}
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|