Research Log of Web Science Students

Computer Science is not simply programming

Java3D Multiple Marker Porting Issues.

leave a comment »

Date: September 12, 2009

I finished porting  the multiple markers on Java 3D. What I did was, I copied the J3d Marker files and created a new J3d Marker Files.

So I changed the code from

private NyARSingleDetectMarker _nya;

to

private NyARDetectMarker _nya;

as stated in the JOGL implementation for Multiple Marker Detection. And I set the NyARCode from a single variable to an array on every method.

public GLAREMarkerBehaviorHolder(J3dNyARParam i_cparam, float i_rate, NyARCode[] i_arcode,double[] i_marker_width, int i_markers) throws NyARException{

...

}

Since all the detection and 3D stuff will happen on the Behavior class, specifically on the processStimulus() method, I copied some of the code from JOGL and placed it on the processStimulus method. It turned out like this:

public void processStimulus(Enumeration arg0) {
int found_markers;
final NyARTransMatResult src = this.trans_mat_result;
try {
if (raster.hasData()){
found_markers = related_nya.detectMarkerLite(raster,100);
synchronized(raster){
for(int i=0; i< found_markers; i++){
Transform3D t3d = null;
if (back_ground != null){
raster.renewImageComponent2D();
back_ground.setImage(raster.getImageComponent2D());
}
if (related_nya.getARCodeIndex(i) != 0){
continue;
}
Matrix4d matrix = new Matrix4d(
-src.m00, -src.m10, src.m20, 0,
-src.m01, -src.m11, src.m21, 0,
-src.m02, -src.m12, src.m22, 0,
-src.m03,-src.m13, src.m23, 1);
matrix.transpose();
t3d = new Transform3D(matrix);
if (trgroup != null) {
trgroup.setTransform(t3d);
}
if(listener != null){
listener.onUpdate(i, t3d);
}
}
}
}
Thread.sleep(1);
wakeupOn(wakeup);
} catch (Exception e) {
e.printStackTrace();
}
}

public void processStimulus(Enumeration arg0) {

int found_markers;

final NyARTransMatResult src = this.trans_mat_result;

try {

if (raster.hasData()){

found_markers = related_nya.detectMarkerLite(raster,100);

synchronized(raster){

for(int i=0; i< found_markers; i++){

Transform3D t3d = null;

if (back_ground != null){

raster.renewImageComponent2D();

back_ground.setImage(raster.getImageComponent2D());

}

if (related_nya.getARCodeIndex(i) != 0){

continue;

}

Matrix4d matrix = new Matrix4d(

-src.m00, -src.m10, src.m20, 0,

-src.m01, -src.m11, src.m21, 0,

-src.m02, -src.m12, src.m22, 0,

-src.m03,-src.m13, src.m23, 1);

matrix.transpose();

t3d = new Transform3D(matrix);

if (trgroup != null) {

trgroup.setTransform(t3d);

}

if(listener != null){

listener.onUpdate(i, t3d);

}

}

}

}

Thread.sleep(1);

wakeupOn(wakeup);

} catch (Exception e) {

e.printStackTrace();

}

}

Fortunately, the source code debugged with no errors but it never showed anything after I tried running it. I will be reading on J3d books a bit more since I think the problem lies with how I implemented it from the Locale to its Nodes.

Advertisements

Written by rururu

September 12, 2009 at 11:37 am

Posted in Augmented Reality

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: