iink SDK on Device

Answered

MyScript iink will stop on waitForBundle

Hi

when I use Android studio 3.6.1, gradle 3.6.1, and I use iink batch to convert text, it will stuck on waitForIdle, please see my following code:

( this function is the same as before, and it work well before, when I change to new Android studio and gradle, it failed. )

please check the log waitForIdle, it will show "before waitForIdle" and never show me "after waitForIdle"

I have a try:


 

DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
    Engine engine = BenmiNoteApp.getEngine();
    Renderer mRenderer = engine.createRenderer(displayMetrics.xdpi, displayMetrics.ydpi, null);
    Editor mEditor = engine.createEditor(mRenderer);
    Map<String, Typeface> typefaceMap = new HashMap<>();
    mEditor.setFontMetricsProvider(new FontMetricsProvider(displayMetrics, typefaceMap));
    ContentPackage mPackage;
    try {
      mPackage = engine.createPackage("text.iink");
    } catch (IOException e) {
      e.printStackTrace();
      return "";
    }
    ContentPart mPart = mPackage.createPart("Text");
    if (note.getRotation() % 180 == 0) {
      mEditor.setViewSize(Config.NOTE_CANVAS_WIDTH, Config.NOTE_CANVAS_HEIGHT);
    } else {
      mEditor.setViewSize(Config.NOTE_CANVAS_HEIGHT, Config.NOTE_CANVAS_WIDTH);
    }
    mEditor.setPart(mPart);

ArrayList<PointerEvent> events = new ArrayList<PointerEvent>();

// Stroke 1
    events.add(new PointerEvent().down(184.f, 124.f));
    events.add(new PointerEvent().move(184.f, 125.f));
    events.add(new PointerEvent().move(184.f, 128.f));
    events.add(new PointerEvent().move(184.f, 133.f));
    events.add(new PointerEvent().move(184.f, 152.f));
    events.add(new PointerEvent().move(184.f, 158.f));
    events.add(new PointerEvent().move(184.f, 163.f));
    events.add(new PointerEvent().move(183.f, 167.f));
    events.add(new PointerEvent().move(183.f, 174.f));
    events.add(new PointerEvent().move(183.f, 183.f));
    events.add(new PointerEvent().up(183.f, 184.f));

// Stroke 2
    events.add(new PointerEvent().down(150.f, 126.f));
    events.add(new PointerEvent().move(151.f, 126.f));
    events.add(new PointerEvent().move(152.f, 126.f));
    events.add(new PointerEvent().move(158.f, 126.f));
    events.add(new PointerEvent().move(166.f, 126.f));
    events.add(new PointerEvent().move(184.f, 126.f));
    events.add(new PointerEvent().move(190.f, 128.f));
    events.add(new PointerEvent().move(196.f, 128.f));
    events.add(new PointerEvent().move(200.f, 128.f));
    events.add(new PointerEvent().move(207.f, 128.f));
    events.add(new PointerEvent().move(208.f, 128.f));
    events.add(new PointerEvent().up(209.f, 128.f));

// Feed the editor
    mEditor.pointerEvents(events.toArray(new PointerEvent[0]), false);

    Log.d(TAG, "before waitForIdle");
    mEditor.waitForIdle();
    Log.d(TAG, "after waitForIdle");


    String output = "";
    try {
      output = mEditor.export_(mEditor.getRootBlock(), MimeType.TEXT);
    } catch (Exception e) {
      e.printStackTrace();
    }
    mPart.close();
    mEditor.clear();
    mRenderer.close();
    mEditor.close();
    mPackage.close();
    return output;

 



Best Answer

Dear Herman,


thank you for your question.


Currently, we have an Android batch sample that runs out of the box. Can you please try to run it? https://github.com/MyScript/interactive-ink-additional-examples-android/blob/master/java/samples/batch-mode/src/main/java/com/myscript/iink/samples/batchmode/MainActivity.java


Indeed, at first sight, I do not see anything wrong in your code. When you say "it never show me "after waitForIdle"", do you mean the reocgnition still runs? Indeed, it has to be remembered that the recognition is a very demanding process, and can take a lot of time. The lower the hardware, the slower recognition will be? Did you try adding only few strokes? Did you wait long enough?


Best regards,


Olivier

1 Comment

Answer

Dear Herman,


thank you for your question.


Currently, we have an Android batch sample that runs out of the box. Can you please try to run it? https://github.com/MyScript/interactive-ink-additional-examples-android/blob/master/java/samples/batch-mode/src/main/java/com/myscript/iink/samples/batchmode/MainActivity.java


Indeed, at first sight, I do not see anything wrong in your code. When you say "it never show me "after waitForIdle"", do you mean the reocgnition still runs? Indeed, it has to be remembered that the recognition is a very demanding process, and can take a lot of time. The lower the hardware, the slower recognition will be? Did you try adding only few strokes? Did you wait long enough?


Best regards,


Olivier