Added a LibGDX packr conf and makefile. Assorted comments and cleanup.

This commit is contained in:
2015-10-19 11:27:50 -04:30
parent 01d81884da
commit 72c3db01bf
7 changed files with 108 additions and 31 deletions

View File

@@ -14,20 +14,54 @@ import com.badlogic.gdx.math.Vector3;
import ve.ucv.ciens.icaro.ardemo.ImageProcessor;
import ve.ucv.ciens.icaro.ardemo.ProjectConstants;
/**
* This class implements the glue methods needed to use the OpenCV native methods. All
* image processing is done through this class.
*
* @author Miguel Angel Astor Romero.
*/
public class CVProcessor implements ImageProcessor {
private static final String TAG = "NXTAR_ANDROID_MAIN";
private static final String CLASS_NAME = CVProcessor.class.getSimpleName();
/**
* Indicates if the external native libraries were loaded successfully.
*/
private static boolean ocvOn = false;
/*
* These two matrices represent the camera parameters calculated during camera calibration.
* Both parameters are needed to render the virtual objects correctly.
*/
private Mat cameraMatrix;
private Mat distortionCoeffs;
/*
* These objects are used to capture data from the video files.
*/
private VideoCapture markerCap;
private VideoCapture calibCap;
/**
* Indicates if the camera calibration procedure completed sucessfully.
*/
private boolean cameraCalibrated;
/*
* This block is executed when this class is loaded by the Java VM. It attempts to load
* the external native libraries.
*/
static{
try{
System.loadLibrary("opencv_java248");
System.loadLibrary("evi_10");
ocvOn = true;
}catch(UnsatisfiedLinkError e){
e.printStackTrace();
ocvOn = false;
}
}
private native void getMarkerCodesAndLocations(
long inMat,
long outMat,
@@ -51,17 +85,6 @@ public class CVProcessor implements ImageProcessor {
float[] calibrationPoints
);
static{
try{
System.loadLibrary("opencv_java248");
System.loadLibrary("evi_10");
ocvOn = true;
}catch(UnsatisfiedLinkError e){
e.printStackTrace();
ocvOn = false;
}
}
public static boolean isOcvOn() {
return ocvOn;
}
@@ -71,8 +94,8 @@ public class CVProcessor implements ImageProcessor {
cameraMatrix = new Mat();
distortionCoeffs = new Mat();
markerCap = new VideoCapture(arg[0]);
calibCap = new VideoCapture(arg[1]);
markerCap = new VideoCapture(arg[1]);
calibCap = new VideoCapture(arg[2]);
}
@Override

View File

@@ -1,10 +1,17 @@
package ve.ucv.ciens.icaro.ardemo.desktop;
import ve.ucv.ciens.icaro.ardemo.EviDemo;
import ve.ucv.ciens.icaro.ardemo.ProjectConstants;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
/**
* This is the main class of the applicaton. It is in charge of creating the {@link CVProcessor} instance
* used throught the rest of the application and launching the {@link EviDemo} class.
*
* @author Miguel Angel Astor Romero.
*/
public class DesktopLauncher{
private static final String TAG = "NXTAR_ANDROID_MAIN";
private static final String CLASS_NAME = DesktopLauncher.class.getSimpleName();
@@ -14,14 +21,14 @@ public class DesktopLauncher{
throw new RuntimeException(TAG + " : " + CLASS_NAME + ": OpenCV failed to load.");
}
if(arg.length != 2) {
System.err.println("Usage: EVI07 <markers video file> <calibration video file>");
if(arg.length != 3) {
System.err.println("Usage: " + arg[0] + " <markers video file> <calibration video file>");
System.exit(1);
}
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.width = 640;
config.height = 360;
config.width = ProjectConstants.W;
config.height = ProjectConstants.H;
new LwjglApplication(new EviDemo(new CVProcessor(arg)), config);
}