Text

Answered

Empty string returned from "editor.export_(editor.getRootBlock(), MimeType.TEXT);"

I am clueless on why there is no result returned from the editor, please help to take a look, thank you!!


  

    private Editor setConfig(){
        Engine engine = iInk.getEngine();

        // Configure the engine to disable guides (recommended)
        Configuration conf = engine.getConfiguration();
        conf.setBoolean("text.guides.enable", false);
        conf.setStringArray("configuration-manager.search-path", new String[] { "C:/Users/ChenJing/Desktop/CS/FYP/FYP_Dec19_v/recognition-assets" });
        conf.setString("lang", "zh_CN");

        // Create a renderer with a null render target
        int dpiX = this.getHeight();
        int dpiY = this.getWidth();
        Renderer renderer = engine.createRenderer(dpiX, dpiY, null);

        // Create the editor
        Editor editor = engine.createEditor(renderer);

        // The editor requires a font metrics provider and a view size *before* calling setPart()
        DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        Map<String, Typeface> typefaceMap = new HashMap<>();
        editor.setFontMetricsProvider(new FontMetricsProvider(displayMetrics, typefaceMap));
        editor.setViewSize(dpiX, dpiY);

//        // Create a temporary package and part for the editor to work with
        ContentPackage contentPackage = null;
        try
        {
            contentPackage = engine.createPackage("text.iink");
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }

        ContentPart part = contentPackage.createPart("Text");
        editor.setPart(part);

        return editor;
    }


    public void recognise() throws IOException {
        Editor editor = setConfig();
        editor.pointerEvents(events.toArray(new PointerEvent[0]), false);
        editor.waitForIdle();

        //export
        String result = editor.export_(editor.getRootBlock(), MimeType.TEXT);
        System.out.println(result);
        System.out.println("i am at this step");
        editor.clear();
    }

 

 


Best Answer

Dear Jing,


Currently, the "configuration-manager.search-path" shall be the path of your conf directory inside of your application. In our Android getStarted it is defined as follows:

String confDir = "zip://" + getPackageCodePath() + "!/assets/conf";


=>The easier is that you deploy the zh_CN assets exactly the way we proceed with the en_US assets in the getStarted directory.


2: When creating the renderer, the resolution you provide shall be the one of your input device. Let's say you write with a pen whose resolution is 100 DPI and your device has a resolution of 300 DPI, you shall then set 100 DPI for the renderer resolution.

Regarding the setViewSize, you shall set the width and height of the page in which you write.


Best regards,


Olivier


Dear Jing,


thank you for the update.


Feel free to contact us if you have any other question.


Best regards,


Olivier

Hey Olivier,


thank you so much! it works perfectly now!

Answer

Dear Jing,


Currently, the "configuration-manager.search-path" shall be the path of your conf directory inside of your application. In our Android getStarted it is defined as follows:

String confDir = "zip://" + getPackageCodePath() + "!/assets/conf";


=>The easier is that you deploy the zh_CN assets exactly the way we proceed with the en_US assets in the getStarted directory.


2: When creating the renderer, the resolution you provide shall be the one of your input device. Let's say you write with a pen whose resolution is 100 DPI and your device has a resolution of 300 DPI, you shall then set 100 DPI for the renderer resolution.

Regarding the setViewSize, you shall set the width and height of the page in which you write.


Best regards,


Olivier

Hey Olivier,


Thank you for checking for me! :) I have two more questions:

  1. I have implemented the listener and found out that the error is "CONFIGURATION_BUNDLE_NOT_FOUND: error: no such configuration bundle zh_CN". I am wondering how to properly deploy the assets. Currently, I have the files put in the same folder as my project (FYP_Dec19_v), shown in ss below, and my configuration is set to point to the "conf" folder. Am I doing it correctly?


  1.         conf.setStringArray("configuration-manager.search-path", new String[] { "C:/Users/ChenJing/Desktop/CS/FYP/FYP_Dec19_v/recognition-assets/conf" });
    
    image
  2. Secondly, i would like to confirm, both the resolution and view size in         

    "Renderer renderer = engine.createRenderer(dpiX, dpiY, null); "

    and

    "editor.setViewSize(dpiX, dpiY); "

    refer to the dimension of the view(identified by the black box) that i am capturing the handwriting am i right?   image


thank you so much for your time!

Dear Jing Chen,


currently, I am a bit puzzled as I could have a recognized text:


Based on this, the issue rather looks on your project side: Did you properly deployed the assets? Did you set the proper resolution? Did you set the proper view sisze? https://developer.myscript.com/docs/interactive-ink/1.3/android/fundamentals/error-management/#recognition-quality-is-poor


If this doesn't help, please provide your project, so that we can investigate further.


Best regards,


Olivier

0 = {PointerEvent@5537} "PointerEvent(DOWN, x=414.98657 y=61.95703 t=-1 f=0.0 pointerType=PEN id=-1)"

1 = {PointerEvent@5538} "PointerEvent(MOVE, x=423.33444 y=78.37097 t=-1 f=0.0 pointerType=PEN id=-1)"

2 = {PointerEvent@5539} "PointerEvent(MOVE, x=499.95483 y=214.94531 t=-1 f=0.0 pointerType=PEN id=-1)"

3 = {PointerEvent@5540} "PointerEvent(UP, x=499.95483 y=214.94531 t=-1 f=0.0 pointerType=PEN id=-1)"

4 = {PointerEvent@5541} "PointerEvent(DOWN, x=223.98926 y=246.9375 t=-1 f=0.0 pointerType=PEN id=-1)"

5 = {PointerEvent@5542} "PointerEvent(MOVE, x=241.65826 y=246.9375 t=-1 f=0.0 pointerType=PEN id=-1)"

6 = {PointerEvent@5543} "PointerEvent(MOVE, x=284.40005 y=249.92578 t=-1 f=0.0 pointerType=PEN id=-1)"

7 = {PointerEvent@5544} "PointerEvent(MOVE, x=534.45807 y=225.96094 t=-1 f=0.0 pointerType=PEN id=-1)"

8 = {PointerEvent@5545} "PointerEvent(MOVE, x=614.32117 y=223.96875 t=-1 f=0.0 pointerType=PEN id=-1)"

9 = {PointerEvent@5546} "PointerEvent(MOVE, x=843.96075 y=208.96875 t=-1 f=0.0 pointerType=PEN id=-1)"

10 = {PointerEvent@5547} "PointerEvent(MOVE, x=848.9575 y=208.96875 t=-1 f=0.0 pointerType=PEN id=-1)"

11 = {PointerEvent@5548} "PointerEvent(UP, x=848.9575 y=208.96875 t=-1 f=0.0 pointerType=PEN id=-1)"

12 = {PointerEvent@5549} "PointerEvent(DOWN, x=232.98706 y=249.92578 t=-1 f=0.0 pointerType=PEN id=-1)"

13 = {PointerEvent@5550} "PointerEvent(MOVE, x=241.98486 y=272.4417 t=-1 f=0.0 pointerType=PEN id=-1)"

14 = {PointerEvent@5551} "PointerEvent(MOVE, x=264.99023 y=456.47205 t=-1 f=0.0 pointerType=PEN id=-1)"

15 = {PointerEvent@5552} "PointerEvent(MOVE, x=270.98877 y=578.3561 t=-1 f=0.0 pointerType=PEN id=-1)"

16 = {PointerEvent@5553} "PointerEvent(MOVE, x=273.98804 y=756.6334 t=-1 f=0.0 pointerType=PEN id=-1)"

17 = {PointerEvent@5554} "PointerEvent(MOVE, x=250.98267 y=920.7013 t=-1 f=0.0 pointerType=PEN id=-1)"

18 = {PointerEvent@5555} "PointerEvent(MOVE, x=241.98486 y=947.89453 t=-1 f=0.0 pointerType=PEN id=-1)"

19 = {PointerEvent@5556} "PointerEvent(MOVE, x=241.98486 y=950.9414 t=-1 f=0.0 pointerType=PEN id=-1)"

20 = {PointerEvent@5557} "PointerEvent(MOVE, x=235.98633 y=970.9219 t=-1 f=0.0 pointerType=PEN id=-1)"

21 = {PointerEvent@5558} "PointerEvent(MOVE, x=232.98706 y=976.89844 t=-1 f=0.0 pointerType=PEN id=-1)"

22 = {PointerEvent@5559} "PointerEvent(MOVE, x=226.98853 y=970.9219 t=-1 f=0.0 pointerType=PEN id=-1)"

23 = {PointerEvent@5560} "PointerEvent(UP, x=226.98853 y=970.9219 t=-1 f=0.0 pointerType=PEN id=-1)"

Dear Denny,


currently, in a text file, please provide all the events, so that we can see what the ink looks like and reproduce.


Best regards,


Olivier

Hey Oliver,


Attached is the ss of the pointer events, when i run the app on an emulator


image


Dear Jing,


thank you for contacting us and your question.


At first sight, I do not see anything wrong in your code. I would tend to think the "no result" is due to your ink.


Is it possible to have your events array, so that we have a look at it?


Best regards,


Olivier

I am sending the pointer events in a batch, and the events will be collected when "onTouchEvent" is triggered.

  • Support
  • Forums
  • Text
  • Empty string returned from "editor.export_(editor.getRootBlock(), MimeType.TEXT);"