net.sourceforge.jartoolkit.core
Class JARToolKit

java.lang.Object
  extended bynet.sourceforge.jartoolkit.core.JARToolKit

public class JARToolKit
extends java.lang.Object

JARToolKit: Java binding to the AR Toolkit Class encapsulate the AR-Toolkit. This class is a Java-Wrapper for the C AR-Toolkit. Not all funktions of the original AR-Toolkit are implemented, only these one, I need to get AR runnig under Java. You're welcome to do the rest :-) .

Version:
2.0
Author:
Jörg Stöcklein (ozone_abandon at sourceforge.net)

Field Summary
static java.lang.String version
          The Version of JARToolKit.
 
Method Summary
 int activatePattern(int pat_no)
          Activate the given pattern.
 int arMultiDeactivate(int multiMarkerID)
          Deactivates a multipattern.
 int arMultiFreeConfig(int multiMarkerID)
          Free a multipattern.
static JARToolKit create()
          Create a JARToolKit instance.
 int deactivatePattern(int pat_no)
          Deactivate the given pattern.
 int[] detectMarker(int[] dataPtr, int thresh)
          Try to detect pattern in an image.
 int[] detectMarker(long dataPtr, int thresh)
          Try to detect pattern in an image.
 int[] detectMarkerLite(int[] dataPtr, int thresh)
          Try to detect pattern in an image, alternative methode.
 int[] detectMarkerLite(long dataPtr, int thresh)
          Try to detect pattern in an image, alternative methode.
 int freePattern(int patt_no)
          Free the given pattern.
 double[] getCamTransMatrix()
          Return the camera transformation matrix.
 void getCamTransMatrix(double[] matrix)
          Fills the camera transformation matrix to the given doublearray.
 double[] getCamTransMatrixJava3D()
          Return the camera transformation matrix for Java3D.
 void getCamTransMatrixJava3D(double[] matrix)
          Return the camera transformation matrix for Java3D.
 void getCamTransMatrixJava3D(double[] matrix, double corrx, double corry)
          Fills the camera transformation matrix to the given doublearray for Java3D.
 double[] getCamTransMatrixJava3D(double corrx, double corry)
          Fills the camera transformation matrix to the given doublearray for Java3D.
 boolean getTransMatrix(double[] matrix, int patternID, int patternWidth, float patternCenterX, float patternCenterY)
          Fills the transformation matrix of a detected pattern to the given doublearray.
 double[] getTransMatrix(int patternID, int patternWidth, float patternCenterX, float patternCenterY)
          Return the transformation matrix of a detected pattern.
 boolean getTransMatrixCont(double[] matrix, int patternID, int patternWidth, float patternCenterX, float patternCenterY, double[] prev_conv)
          Return the transformation matrix of a detected pattern.
 double[] getTransMatrixCont(int patternID, int patternWidth, float patternCenterX, float patternCenterY, double[] prev_conv)
          Return the transformation matrix of a detected pattern.
 boolean getTransMatrixContJava3D(double[] matrix, int patternID, int patternWidth, float patternCenterX, float patternCenterY, double[] prev_conv)
          Return the transformation matrix of a detected pattern.
 double[] getTransMatrixContJava3D(int patternID, int patternWidth, float patternCenterX, float patternCenterY, double[] prev_conv)
          Return the transformation matrix of a detected pattern.
 boolean getTransMatrixJava3D(double[] matrix, int patternID, int patternWidth, float patternCenterX, float patternCenterY)
          Fills the transformation matrix of a detected pattern to the given doublearray.
 double[] getTransMatrixJava3D(int patternID, int patternWidth, float patternCenterX, float patternCenterY)
          Return the transformation matrix of a detected pattern.
 int initCparam()
          Initialize the camara-parameter.
 int loadPattern(java.lang.String filename)
          Load a pattern to the toolkit.
 boolean multiGetTransMat(double[] matrix, int multiMarkerID, int markerNumber)
          Recieve a specific transform-matrix from the multipattern.
 double[] multiGetTransMat(int multiMarkerID, int markerNumber)
          Recieve a specific transform-matrix from the multipattern.
 boolean multiGetTransMatJava3D(double[] matrix, int multiMarkerID, int markerNumber)
          Recieve a specific transform-matrix from the multipattern.
 double[] multiGetTransMatJava3D(int multiMarkerID, int markerNumber)
          Recieve a specific transform-matrix from the multipattern.
 int multiPatternActivate(int multiMarkerID)
          Activates a multipattern.
 int multiReadConfigFile(java.lang.String filename)
          Load a multipattern configuration file.
 int paramChangeSize(int width, int height)
          Change the size of the camera-parameter to the given values.
 void paramDisplay()
          Display the current camera-parameter.
 int paramLoad(java.lang.String filename)
          Load the camera-parameter-file.
static void utilSleep(int msec)
          Wait the given milliseonds.
static double utilTimer()
          Return the current time of the timer in seconds.
static void utilTimerReset()
          Reset the internal timer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static final java.lang.String version
The Version of JARToolKit.

See Also:
Constant Field Values
Method Detail

create

public static JARToolKit create()
                         throws java.lang.InstantiationException
Create a JARToolKit instance. You can create an instance only once. If you call this static method more than once null will return.

Returns:
A instance of a JARFrameGrabber class, or null, if you called this method more than once.
Throws:
java.lang.InstantiationException

utilSleep

public static void utilSleep(int msec)
Wait the given milliseonds.

Parameters:
msec - milliseconds to wait.

utilTimer

public static double utilTimer()
Return the current time of the timer in seconds.

Returns:
time in seconds.

utilTimerReset

public static void utilTimerReset()
Reset the internal timer.


activatePattern

public int activatePattern(int pat_no)
Activate the given pattern.

Parameters:
pat_no - The patternid that should be activated.
Returns:
0, if pattern was activated, !=0 else.

arMultiDeactivate

public int arMultiDeactivate(int multiMarkerID)
Deactivates a multipattern.

Parameters:
multiMarkerID - The id of the multipattern
Returns:
0, if multipattern was deactivated, !=0 else.

arMultiFreeConfig

public int arMultiFreeConfig(int multiMarkerID)
Free a multipattern.

Parameters:
multiMarkerID - The id of the multipattern
Returns:
0, if multipattern was freed, !=0 else.

deactivatePattern

public int deactivatePattern(int pat_no)
Deactivate the given pattern.

Parameters:
pat_no - The patternid that should be deactivated.
Returns:
0, if pattern was deactivated, !=0 else.

detectMarker

public int[] detectMarker(int[] dataPtr,
                          int thresh)
Try to detect pattern in an image. Returns a list of patternids detected in the image.

Parameters:
dataPtr - Integer-array of the image searched in.
thresh - Threshhold for converting image to B/W. Must be between 0 and 255.
Returns:
List of patternids detected in the image.

detectMarker

public int[] detectMarker(long dataPtr,
                          int thresh)
Try to detect pattern in an image. Returns a list of patternids detected in the image.

Parameters:
dataPtr - Longpointer of the image searched in.
thresh - Threshhold for converting image to B/W. Must be between 0 and 255.
Returns:
List of patternids detected in the image.

detectMarkerLite

public int[] detectMarkerLite(int[] dataPtr,
                              int thresh)
Try to detect pattern in an image, alternative methode. Returns a list of patternids detected in the image.

Parameters:
dataPtr - Integer-array of the image searched in.
thresh - Threshhold for converting image to B/W. Must be between 0 and 255.
Returns:
List of patternids detected in the image.

detectMarkerLite

public int[] detectMarkerLite(long dataPtr,
                              int thresh)
Try to detect pattern in an image, alternative methode. Returns a list of patternids detected in the image.

Parameters:
dataPtr - Longpointer of the image searched in.
thresh - Threshhold for converting image to B/W. Must be between 0 and 255.
Returns:
List of patternids detected in the image.

freePattern

public int freePattern(int patt_no)
Free the given pattern.

Parameters:
patt_no - The patternid that should be freed.
Returns:
0, if pattern was freed, !=0 else.

getCamTransMatrix

public double[] getCamTransMatrix()
Return the camera transformation matrix.

Returns:
Doublearray representing a 4x4 column-major matrix. (like OpenGL matrices).

getCamTransMatrix

public void getCamTransMatrix(double[] matrix)
Fills the camera transformation matrix to the given doublearray.

Parameters:
matrix - Doublearray representing a 4x4 column-major matrix. (like OpenGL matrices).

getCamTransMatrixJava3D

public double[] getCamTransMatrixJava3D()
Return the camera transformation matrix for Java3D.

Returns:
Doublearray representing a 4x4 column-major matrix. (like OpenGL matrices).

getCamTransMatrixJava3D

public double[] getCamTransMatrixJava3D(double corrx,
                                        double corry)
Fills the camera transformation matrix to the given doublearray for Java3D.

Parameters:
corrx - Correction in x
corry - Correction in y
Returns:
Doublearray representing a 4x4 column-major matrix. (like OpenGL matrices).

getCamTransMatrixJava3D

public void getCamTransMatrixJava3D(double[] matrix)
Return the camera transformation matrix for Java3D.

Returns:
Doublearray representing a 4x4 column-major matrix. (like OpenGL matrices).

getCamTransMatrixJava3D

public void getCamTransMatrixJava3D(double[] matrix,
                                    double corrx,
                                    double corry)
Fills the camera transformation matrix to the given doublearray for Java3D.

Parameters:
matrix - Doublearray representing a 4x4 column-major matrix.
corrx - Correctionfactor for x.
corry - Correctionfactor for y. (like OpenGL matrices).

getTransMatrix

public boolean getTransMatrix(double[] matrix,
                              int patternID,
                              int patternWidth,
                              float patternCenterX,
                              float patternCenterY)
Fills the transformation matrix of a detected pattern to the given doublearray.

Parameters:
matrix - Doublearray representing a 4x4 column-major matrix.
patternID - ID of the pattern.
patternWidth - Width of the pattern.
patternCenterX - Center of the pattern, x component.
patternCenterY - Center of the pattern, y component.
Returns:
true, if the pattern was recognized, false else.

getTransMatrix

public double[] getTransMatrix(int patternID,
                               int patternWidth,
                               float patternCenterX,
                               float patternCenterY)
Return the transformation matrix of a detected pattern.

Parameters:
patternID - ID of the pattern.
patternWidth - Width of the pattern.
patternCenterX - Center of the pattern, x component.
patternCenterY - Center of the pattern, y component.
Returns:
Doublearray representing a 4x4 column-major matrix (like OpenGL matrices), if the pattern was detected, the identity-marix else.

getTransMatrixCont

public boolean getTransMatrixCont(double[] matrix,
                                  int patternID,
                                  int patternWidth,
                                  float patternCenterX,
                                  float patternCenterY,
                                  double[] prev_conv)
Return the transformation matrix of a detected pattern.

Parameters:
matrix - Doublearray representing a 4x4 column-major matrix.
patternID - ID of the pattern.
patternWidth - Width of the pattern.
patternCenterX - Center of the pattern, x component.
patternCenterY - Center of the pattern, y component.
prev_conv - detected martix of the pattern.
Returns:
true, if the pattern was recognized, false else.

getTransMatrixCont

public double[] getTransMatrixCont(int patternID,
                                   int patternWidth,
                                   float patternCenterX,
                                   float patternCenterY,
                                   double[] prev_conv)
Return the transformation matrix of a detected pattern.

Parameters:
patternID - ID of the pattern.
patternWidth - Width of the pattern.
patternCenterX - Center of the pattern, x component.
patternCenterY - Center of the pattern, y component.
prev_conv - detected martix of the pattern.
Returns:
Doublearray representing a 4x4 column-major matrix (like OpenGL matrices), if the pattern was detected, the identity-marix else.

getTransMatrixContJava3D

public boolean getTransMatrixContJava3D(double[] matrix,
                                        int patternID,
                                        int patternWidth,
                                        float patternCenterX,
                                        float patternCenterY,
                                        double[] prev_conv)
Return the transformation matrix of a detected pattern. Special method for use in Java3D.

Parameters:
matrix - Doublearray representing a 4x4 column-major matrix.
patternID - ID of the pattern.
patternWidth - Width of the pattern.
patternCenterX - Center of the pattern, x component.
patternCenterY - Center of the pattern, y component.
prev_conv - detected martix of the pattern.
Returns:
true, if the pattern was recognized, false else.

getTransMatrixContJava3D

public double[] getTransMatrixContJava3D(int patternID,
                                         int patternWidth,
                                         float patternCenterX,
                                         float patternCenterY,
                                         double[] prev_conv)
Return the transformation matrix of a detected pattern. Special method for use in Java3D.

Parameters:
patternID - ID of the pattern.
patternWidth - Width of the pattern.
patternCenterX - Center of the pattern, x component.
patternCenterY - Center of the pattern, y component.
prev_conv - detected martix of the pattern.
Returns:
Doublearray representing a 4x4 column-major matrix (like OpenGL matrices), if the pattern was detected, the identity-marix else.

getTransMatrixJava3D

public boolean getTransMatrixJava3D(double[] matrix,
                                    int patternID,
                                    int patternWidth,
                                    float patternCenterX,
                                    float patternCenterY)
Fills the transformation matrix of a detected pattern to the given doublearray. Special method for use in Java3D.

Parameters:
matrix - Doublearray representing a 4x4 column-major matrix.
patternID - ID of the pattern.
patternWidth - Width of the pattern.
patternCenterX - Center of the pattern, x component.
patternCenterY - Center of the pattern, y component.
Returns:
true, if the pattern was recognized, false else.

getTransMatrixJava3D

public double[] getTransMatrixJava3D(int patternID,
                                     int patternWidth,
                                     float patternCenterX,
                                     float patternCenterY)
Return the transformation matrix of a detected pattern. Special method for use in Java3D.

Parameters:
patternID - ID of the pattern.
patternWidth - Width of the pattern.
patternCenterX - Center of the pattern, x component.
patternCenterY - Center of the pattern, y component.
Returns:
Doublearray representing a 4x4 column-major matrix (like OpenGL matrices), if the pattern was detected, the identity-marix else.

initCparam

public int initCparam()
Initialize the camara-parameter.

Returns:
0 If no error occurs.

loadPattern

public int loadPattern(java.lang.String filename)
Load a pattern to the toolkit.

Parameters:
filename - The filename of the pattern.
Returns:
PatternID<=0 or <0, if an error occurs.

multiGetTransMat

public boolean multiGetTransMat(double[] matrix,
                                int multiMarkerID,
                                int markerNumber)
Recieve a specific transform-matrix from the multipattern.

Parameters:
matrix - Doublearray representing a 4x4 column-major matrix.
multiMarkerID - The ID of the multipattern.
markerNumber - The marker number of the multipattern, 0<=markerNumberReturns:
true, if the pattern was recognized, false else.

multiGetTransMat

public double[] multiGetTransMat(int multiMarkerID,
                                 int markerNumber)
Recieve a specific transform-matrix from the multipattern.

Parameters:
multiMarkerID - The ID of the multipattern.
markerNumber - The marker number of the multipattern, 0<=markerNumberReturns:
Doublearray representing a 4x4 column-major matrix (like OpenGL matrices), if the pattern was detected, the identity-marix else.

multiGetTransMatJava3D

public boolean multiGetTransMatJava3D(double[] matrix,
                                      int multiMarkerID,
                                      int markerNumber)
Recieve a specific transform-matrix from the multipattern. Special method for use in Java3D.

Parameters:
matrix - Doublearray representing a 4x4 column-major matrix.
multiMarkerID - The ID of the multipattern.
markerNumber - The marker number of the multipattern, 0<=markerNumberReturns:
true, if the pattern was recognized, false else.

multiGetTransMatJava3D

public double[] multiGetTransMatJava3D(int multiMarkerID,
                                       int markerNumber)
Recieve a specific transform-matrix from the multipattern. Special method for use in Java3D.

Parameters:
multiMarkerID - The ID of the multipattern.
markerNumber - The marker number of the multipattern, 0<=markerNumberReturns:
Doublearray representing a 4x4 column-major matrix (like OpenGL matrices), if the pattern was detected, the identity-marix else.

multiPatternActivate

public int multiPatternActivate(int multiMarkerID)
Activates a multipattern.

Parameters:
multiMarkerID - The id of the multipattern
Returns:
0, if multipattern was activated, !=0 else.

multiReadConfigFile

public int multiReadConfigFile(java.lang.String filename)
Load a multipattern configuration file. Returns the id of the multipattern.

Parameters:
filename - The filename of the configuration file.
Returns:
-1, if an error occurs, multiMarkerID >=0 else.

paramChangeSize

public int paramChangeSize(int width,
                           int height)
Change the size of the camera-parameter to the given values.

Parameters:
width - Width to change to.
height - Height to change to.
Returns:
0, if no error occurs, !=0 else.

paramDisplay

public void paramDisplay()
Display the current camera-parameter. The method prints the parameter to the console using the printf in C. In the next version this method should return a string you can print in Java.


paramLoad

public int paramLoad(java.lang.String filename)
Load the camera-parameter-file.

Parameters:
filename - The filename of the parameter-file.
Returns:
0, if no error occurs, !=0 else.