Reputation: 121
I've encountered some problems using ArCode with 2D bar code inside. I'm using Android and the ArToolkit.
I've no problem recognizing "Hiro" marker or the "kanji". Sometimes, artoolkit confuses "0" bar code with "hiro", but this is not the problem, the problem is that I can't, in any way I've tried, recognize a 2D bar code.
This is my code :
if (!ARToolKit.getInstance().initialiseNative(this.getCacheDir().getAbsolutePath()) ||
!ARToolKit.getInstance().initialiseAR(640, 480, "Data/camera_para.dat", 0, false)) {
Log.e("MainActivity", "errore di inizializzazione");
return;
}
_markerID = ARToolKit.getInstance().addMarker("single_barcode;0;40");
it doesn't count if I use :
single_barcode;0;10 ... single_barcode;0;80
obiviosly with instead:
_markerID = ARToolKit.getInstance().addMarker("single;Data/patt.hiro;10");
it works.
I've tried aldo to create a file like the one for hiro ( patt.hiro) and kanji (patt.kanji). So, I've created a code.dat
1
00
40.0
1.0000 0.0000 0.0000 0.0000
0.0000 1.0000 0.0000 0.0000
0.0000 0.0000 1.0000 0.0000
for the "0" bar code.
_markerID = ARToolKit.getInstance().addMarker("single;Data/code.dat;40");
Again it doesn't count if I use :
single;Data/code.dat;10 .. single;Data/code.dat;80
but again nothing.
I can't find any valid example using this in android, or any exaustive manual...
Where I'm wrong ?
Upvotes: 1
Views: 3311
Reputation: 111
The usage of 2D Barcode for ARToolkit in Android is not available in any public documentation. However, if you refer directly to the ARWrapper source code. I found it is available through NativeInterface and ARToolkit.
Here's a working example I used in my Android App
Firstly, do something like this in your detection initialization
NativeInterface.arwSetPatternDetectionMode(NativeInterface.AR_MATRIX_CODE_DETECTION);
NativeInterface.arwSetMatrixCodeType(NativeInterface.AR_MATRIX_CODE_3x3_PARITY65);
markerID = ARToolKit.getInstance().addMarker("single_barcode;0;80");
For 2D Barcode (Matrix code) detection, you must set the pattern detection mode as AR_MATRIX_CODE_DETECTION
. For details of different matrix code type, you may refer to the official documentation. I am using the default ones provided under /artoolkit5/doc/patterns from the github repository.
The configuration string for single barcode detection is using the following format, "single_barcode;<barcode ID>;<Marker Width>"
.
The rest should be the same as using pattern marker. Just for clarification purpose, after calling ARToolKit.getInstance().convertAndDetect(frame)
which is usually in your Activity which inherited from ARActivity, you may query it's visibility using ARToolKit.getInstance().queryMarkerVisible(markerID)
as usual.
References
https://github.com/artoolkit/artoolkit5
Upvotes: 4
Reputation: 3996
As I mentioned in another question, everything into the assets folder is cached by ARToolkit and when you add new markers you need to either increase the version number of the app or to uninstall it.
You do not need to recompile the NDK to add new markers.
Also, the string formatting is very important:
The default one is:
_markerID = ARToolKit.getInstance().addMarker("single;Data/patt.hiro;10");
for your marker you are using:
_markerID = ARToolKit.getInstance().addMarker("single_barcode;0;40");
The string defining your marker should be: "single;Data/single_barcode;40"
Where (as explained in this page http://www.artoolkit.org/documentation/doku.php?id=4_Android:android_developing) the parameters mean:
And I agree that the documentation of ARToolkit needs to be improved.
Upvotes: 1
Reputation: 121
Thanks Shalafi, I've tried but nothing happen. I've found a japanese page in which they say that you have to change a parameter and recompile the entire ArToolkit in C++ in order to make it recognize 2d code. But ora 2d code or Arcode like hiro.
Has someone some more detailed instructions ?
The japanese page is this : http://sixwish.jp/ARTK4Android/Wrapper/section03/ (I've translated it with google translator )
Upvotes: 0