How to get MarkerId in Artoolkitplus in android

2019-05-06 16:58发布

问题:

I am using ARToolkitPlusBenchmark to scan AR Tag Marker. I can easily detect all 4096 BCH marker.But my problem is i can't getting idea how to detect each BCH marker id?

I have found code from here ARToolkitPlusBenchmark

I have tried to detect marker in Markerinfo.java

class DetectMarkerWorker extends Thread {
private byte[] curFrame;
public DetectMarkerWorker() {
 setPriority(MAX_PRIORITY);
 start();
}
@Override
public synchronized void run() {
  try {
wait();
 } catch (InterruptedException e) {
 }
 while (true) {
  if(!CurrentConfig.ONLY_CAMERA_PREVIEW){
 long tick = System.currentTimeMillis();
 if (CurrentConfig.USE_ARTOOLKITPLUS) {

  timeNativeMarkerDetection = artoolkitPlus_detectmarkers(curFrame, transMatMonitor);      
  nativeMarkerDetectionHistory.add(timeNativeMarkerDetection);
  if(nativeMarkerDetectionHistory.size()>20){
   nativeMarkerDetectionHistory.remove(0);
  }
  for(int i = 0;i<nativeMarkerDetectionHistory.size();i++){
   sumNativeMarkerDetection += nativeMarkerDetectionHistory.elementAt(i);
  }
  avgNativeMarkerDetection = sumNativeMarkerDetection/nativeMarkerDetectionHistory.size();
  sumNativeMarkerDetection = 0;
 } else {
  artoolkit_detectmarkers(curFrame, transMatMonitor);
 }
 timeJavaMarkerDetection = System.currentTimeMillis() - tick;
 javaMarkerDetectionHistory.add(timeJavaMarkerDetection);
 if(javaMarkerDetectionHistory.size()>20){
  javaMarkerDetectionHistory.remove(0);
 }
 for(int i = 0;i<javaMarkerDetectionHistory.size();i++){
  sumJavaMarkerDetection += javaMarkerDetectionHistory.elementAt(i);
 }
 avgJavaMarkerDetection = sumJavaMarkerDetection/javaMarkerDetectionHistory.size();
 sumJavaMarkerDetection = 0;
}  
DebugFps.updateFPS();
try {
 wait();
  } catch (InterruptedException e) {
  }
 }
}

iOS In iOS i am using VRToolkit to find id of each Marker.This app uses ARToolKit plus to detect markers on the video frames.

I can scan all 4096 BCH marker as well as thin based Marker after setting corresponding property to YES and getting each Marker Id.

In Android i am facing problem.

Please let me know if need more information to understand this problem. I will be much thankful for any short of help or guidance.

回答1:

Any reason why you're using ARToolkitPlusBenchmark to achieve this? Have you tried looking at http://code.google.com/p/andar/

Andar also uses ARToolkit and if you see ARObject class - it can give you id for the marker belonging to this object.