StorageType in Target creation

+1 vote
asked Jun 11, 2018 by diaz1111 (320 points)
edited Jun 11, 2018 by diaz1111

Hi ,

     I am using EsyAr sdk in android and IOS . I have gone through the document for `StorageType` class but did not understand much . So here i am asking .

1. Can i load target from SD card path ? if yes the which `StorageType` should i use and where should i keep all the images ?

I am trying to load all images from a Folder which is located at `/data/data/com.myapp/Targets/`. How can i achive this in android ? When i use code below its giving me error for the URL .

private void loadFromSDcard(ImageTracker tracker, String path)
{
    ImageTarget target = new ImageTarget();
    target.setup(path, StorageType.Absolute, "");
    tracker.loadTarget(target, new FunctorOfVoidFromPointerOfTargetAndBool() {
        @Override
        public void invoke(Target target, boolean status) {
            Log.i("AREngine", String.format("load target (%b): %s (%d)", status, target.name(), target.runtimeID()));
        }
    });
}

2. Can i load target from a http server url? if yes the what is the `StorageType` for this .

Please provide proper explanation for both platforms . Thanks.  

EDIT:-  I have done it as follows .

private void loadallFromSDcard(ImageTracker tracker, File file) {
    String pre = "{\n" +
            "  \"images\": [\n";
    String post =   "  ]\n" +
            "}";
     StringBuilder builder=new StringBuilder();
    for (File file1: file.listFiles()) {
        if(builder.length()==0){
            builder.append("\""+file1.getAbsolutePath()+"\"");
        }else{
            builder.append(",\""+file1.getAbsolutePath()+"\"");
        }
    }
    String jstr=pre+builder.toString()+post;
    for (ImageTarget target : ImageTarget.setupAll(jstr, StorageType.Json)) {
        tracker.loadTarget(target, new FunctorOfVoidFromPointerOfTargetAndBool() {
            @Override
            public void invoke(Target target, boolean status) {
                Log.i("AREngine", String.format("load target (%b): %s (%d)", status, target.name(), target.runtimeID()));
            }
        });
    }
}

Its loading targets . But i think its not the right way to do it . Can you please post code of the right way to do this in android .

1 Answer

0 votes
answered Jun 11, 2018 by albert52 (31,850 points)

1)  Yes. You need to get the image from an sd card and create the ImageTargets dynamically. 

Absolute  :  The absolute path (json/image path or video path) or url (video only).

2)You mean creating ImageTarget by image(url)? This won't work, but you can display video by url

commented Jun 11, 2018 by diaz1111 (320 points)
Thx for quick answer,  I am amazed . Would you please look into edited question.
Welcome to EasyAR SDK Q&A, where you can ask questions and receive answers from other members of the community.
...