artoolkitx / artoolkit5

ARToolKit v5.x
Other
108 stars 28 forks source link

How to Dynamically Load Markers in Android Samples? #130

Closed ThorstenBux closed 6 years ago

ThorstenBux commented 6 years ago

Issue by AnkitAndroaid Wednesday Dec 20, 2017 at 07:37 GMT Originally opened as https://github.com/artoolkit/artoolkit5/issues/370


As it takes time to load multiple markers when it is collectively stored inside the asset folder. And till that time it shows a black screen while loading. But I want to achieve a state in my App that it should not take more than 2-3 seconds to initialise the camera and start interaction with the marker. Is there any way to dynamic load the markers in Android Sample. Or is there any other alternate which I Can Apply to reduce the camera initialisation time?

ThorstenBux commented 6 years ago

Comment by deedoc Wednesday Dec 20, 2017 at 08:20 GMT


In my configuration i'm using ARToolkit just for recognition: i'm creating all the surface's needed by myself, opening camera by myself, caching markers by myself, etc etc. This is how i add markers to ARToolkit:

ARToolKit.getInstance().initialiseNative(context.getCacheDir().getAbsolutePath());
for(MarkerRenderer mr : markerRenderers){
    int markerId = ARToolKit.getInstance().addMarker(mr.getMarkerConfig());
    if(markerId < 0){
        throw new RuntimeException(String.format("Can't add marker for path %s", mr.getMarkerConfig()));
    } else {
        mr.setMarkerId(markerId);

        /** SAM: reduce jitter. default ARW_MARKER_OPTION_FILTERED is false, ARW_MARKER_OPTION_FILTER_CUTOFF_FREQ is 15 **/
        ARToolKit.getInstance().setMarkerOptionBool(markerId, NativeInterface.ARW_MARKER_OPTION_FILTERED, true);
        ARToolKit.getInstance().setMarkerOptionFloat(markerId, NativeInterface.ARW_MARKER_OPTION_FILTER_CUTOFF_FREQ, 10.0f);
    }
}

And in particular case i have 12 markers (with size of .fset3 file 24kb-62kb) On my nexus 5 this code takes 139ms

Note that my markers allready cached Note that ARToolkit can not recognize it instantly after adding - all ARToolkit's initialization stuff goes into separate thread which does not blocks my UI

ThorstenBux commented 6 years ago

Thanks for the feedback @deedoc.