Software Development Kit

InkStrokes Box for text & candidates (without UI edit control)

Hello

I'm trying to use your API without your UI controls, 

sending my InkStrokes through Editor.PointerEvents() 
with the returned text & candidates, I need to know the InkStrokes "Box" coordinates. 

Tried several <export.jiix.XXXX> parameters 
Couldn't get <render.debug.draw-text-boxes> to work
Also scanned through your support forum, and didn't find. 

Could you help with the cleanest way to get the InkStrokes Box, or provide a code snippet in C# 

Thanks in advance, Clement


Dear Clement,


Thank you for contacting us.


Currently, when exporting as JIIX, for each word candidate, you will normally be returned with the bounding box (the export.jiix.bounding-box configuration is set by default):

   "candidates": [ "Welcome", "welcome", "Welcomes", "welcomes" ],
"bounding-box": {
"x": 64.18338,
"y": 36.888428,
"width": 86.581161,
"height": 21.643131
   },


In the same way, you will be returned with the x and y points of each stroke:

"items": [ {
"timestamp": "1970-01-01 20:39:38.363000",
"X": [ 65.298935, 65.18338,...],
"Y": [ 45.39901, 44.936787,...],
"F": [ 1.6078443e8, 1.6078443e8,...],
"T": [ 0, 0, ...],
"type": "stroke",
"id": "0000000001003900ff00"
}, {
"timestamp": "1970-01-01 20:39:38.363000",
"X": [ 86.675125, 86.444298,...],
"Y": [ 54.180714, 54.411827,...],
"F": [ 1.6078443e8, 1.6078443e8,...],
"T": [ 0, 0,...],
"type": "stroke",
"id": "0000010001003900ff00"
}, {
"timestamp": "1970-01-01 20:39:38.363000",
"X": [ 107.12715, 106.4341,...],
"Y": [ 50.945423, 50.252087,...],
"F": [ 1.6078443e8, 1.6078443e8,...],
"T": [ 0, 0,...],
"type": "stroke",
"id": "0000020001005700ff00"
} ]
  },...


Please note these coordinates are in mms, not in pixel.


Let uw know if this helps.


Best regards,


Olivier

Merci Olivier, for fast reply, I'll try, thanks

Hi Olivier,

In fact I'm using my own InkCanvas and sending the ink strokes (multi-words) with MyScript Editor.PointerEvents(), then Editor.Convert(). 
MyScript then returns the converted text(label) and candidates, with text boxes (export.jiix.bounding-box)... 
But to process my InkCanvas (C#) I need to know which original ink strokes are concerned in the conversion for every word (or character). 

Warm thanks in advance, Clement

Hi Clément,


Thank you for your update.


If you want to retrieve the matching between strokes and recognized content, you should use the Export_ method with a JIIX format rather than the convert method.


To make sure that you export the final recognition result, you have to call the WiatForIdle() method before calling the Export_() method.  


This way you will have both the word candidates and the strokes in the export JIIX file. For further details, please check this section

If you want to  have information at character level too, then you should set the  export.jiix.text.chars property to true ( see JIIX configuration)


Let us know if this helps.


Best regards,


Gwenaëlle



Merci Gwenaëlle,

I don't get it quite, could you show a C# snippet on the leanest way to "JIIX Export_()" ink strokes from my InkCanvas, WaitForIdle(), "convert" ink,
and retrieve the label (& candidates) with their corresponding ink strokes. 

Summer thanks, Clement

Hi Clément,


In a previous post, you indicated that you were sending your ink strokes through Editor.PointerEvents(), so if
we assume that events is a List<PointerEvent> that contains your strokes, your code could look like:

// you feed your editor with the events corresponding to your strokes, this will trigger the recognition
editor.PointerEvents(events.ToArray(), false);

// wait for the end of recognition
editor.WaitForIdle();

// Export recognition result as JIIX format
// 1st argument is the block to export "null" means we use default value i.e. root block
// 2nd argument is MIME Type
// 3rd argument is the configuration: here we use default one so we set "null"

String jiix = editor.Export_(null, MimeType.JIIX, null);

The JIIX string will contain the JIIX tree that Olivier described in his previous post.

For instance if I handwrite "Welcome" , this tree might contain following word information:


"words": [ {
"label": "Welcome",
"candidates": [ "Welcome", "welcome", "Welcomes", "welcomes", "Wellcome" ],
"bounding-box": {
"x": 11.315153,
"y": 18.266289,
"width": 21.858465,
"height": 5.9126835
},
"items": [ {
"timestamp": "2019-07-08 08:33:16.714000",
     "X": [ ...

    ],
    "Y": [ , ...

    ],
     "F": [ 0, ...

    0 ],
"T": [ 0, ... ],
"type": "stroke",
"id": "000000000100b301ff00"
}, {
"timestamp": "2019-07-08 08:33:16.719000",
"X":

[ ...

    ],
    "Y": [ , ...

    ],
     "F": [ 0, ...

    0 ],
    "T": [ 0, ... ],

"type": "stroke",
"id": "0000020001008304ff00"
} ]
},


The items block in the word block contains the list fo the strokes that correspond to the word.

So if you want to have the match between strokes and word, you have to scan the JIIX tree.


I hope this helps.


Regards,


Gwenaëlle



Thanks Gwenaëlle,

For your swift explanation on how to use editor.Export_(). Works fine.

Warm regards, Clement

Login or Signup to post a comment