nazirmohd2006 / javacv

Automatically exported from code.google.com/p/javacv
0 stars 0 forks source link

ArtoolkitPlus #296

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm trying to use Artoolkitplus from within your JavaCV project but the 
detection does not seem to be 100% correct.

First I initialize the tracker like this:
tracker = new ARToolKitPlus.MultiTracker(640, 480);                              
tracker.setPixelFormat(ARToolKitPlus.PIXEL_FORMAT_RGB);
tracker.setBorderWidth(0.125f);
tracker.activateAutoThreshold(true);
tracker.setUndistortionMode(ARToolKitPlus.UNDIST_NONE);
tracker.setPoseEstimator(ARToolKitPlus.POSE_ESTIMATOR_RPP);
tracker.setPoseEstimator(ARToolKitPlus.POSE_ESTIMATOR_ORIGINAL);
tracker.setMarkerMode(ARToolKitPlus.MARKER_ID_SIMPLE);
tracker.setImageProcessingMode(ARToolKitPlus.IMAGE_FULL_RES);
tracker.setUseDetectLite(false);
tracker.init(art/LogitechPro4000.dat,art/markerboard_480499.cfg,1.0f,1000.0f,nul
l);

Then I feed the tracker with images from my webcam:
tracker.calc(image.imageData());
double[] transfo=new double[16];
if(tracker.getNumDetectedMarkers()>0)
         for (int i = 0; i < 12; i++) {
             transfo[i] = (double) config.trans().get(i);
         }
         for (int i = 0; i < 3; i++) {
             transfo[12 + i] = 0;
         }
transfo[15] = 0;
transfo=Inverse.row2Column(transfo); 
transfo[13]=-transfo[13]; 
transfo[12]=-transfo[12]; 

As seen in the last row I have to adjust the detection matrix to get a valid 
OpenGL matrix. 

I also have an opengl environment (using jogl). When I want to initialize the 
projection matrix using the projection matrix from the tracker 
(tracker.getProjectionMatrix()) I noticed I also have to adopt the retrieved 
projection matrix to get some output in my opengl environment.

double[] mView=new double[16];
for (int i = 0; i < 16; i++) {
 mView[i] = (double) tracker.getProjectionMatrix().get(i);
            }
mView[5]=-mView[5];
mView[8]=-mView[8];
mView[9]=-mView[9];
mView[10]=-mView[10];
mView[11]=-mView[11];

After all this I render a square on top of the marker (using jogl) but it seems 
like the detection is not 100% correct. And with that I mean that my opengl 
object is not on top of my marker. I assume it is caused by an incorrect 
projection matrix.

I am using JavaCv-0.3 on windows 7 (I saw there were no changes to the 
artoolkitplus part in the latest update to javacv-0.4)

Am I doing something wrong or is this a bug?

Thanks in advance,
Pieter

Original issue reported on code.google.com by PieterBo...@gmail.com on 30 Mar 2013 at 9:38

GoogleCodeExporter commented 8 years ago
BTW, when I use the sample picture (markerboard_480-499.jpg)
I recieve the following detection matrix from the tracker:
[0.99139616886684, -0.12489926499563347, 0.0391638859116917, 
-14.323429937834153, -0.05549449486718083, -0.6720376010253218, 
-0.7384347119736228, -18.724884025436914, 0.11854955670769068, 
0.7299079643432325, -0.6731867246111801, 301.2116529853281, 0.0, 0.0, 0.0, 0.0]

Original comment by PieterBo...@gmail.com on 30 Mar 2013 at 10:06

GoogleCodeExporter commented 8 years ago
Unless you have a Logitech Pro 4000 as camera that's probably not going to 
work. You need to calibrate for your camera.

If you're only after the 2D correspondences in image space, we don't need to do 
any sort of calibration or transformation. Just do as I did in this file:
http://code.google.com/p/javacv/source/browse/src/main/java/com/googlecode/javac
v/MarkerDetector.java

Please ask your questions on the mailing list next time if possible, thank you!

Original comment by samuel.a...@gmail.com on 31 Mar 2013 at 11:54