Software Development Kit

Answered

Myscript and Wacom Bamboo Slate Integration

How can I convert Ink Document object returned by Bamboo slate to .iink format for OCR detection?

Platform -Android


Best Answer

Dear Bobby,


Thank you for your update.


Here are my comments:

- What is your part type?

- Do you process one or several strokes?


According to the comment in your code "//Stokes from Wacom SDK", I guess you want to process several strokes


If you are processing several strokes, setting only the starting point to DOWN and the end point to UP  is not enough, as a stroke is defined from the moment the pen touches the screen until the pen is lifted again.

So you should have a starting point (DOWN) and end point (UP) per stroke.


Please refer to this section of the documentation for an example.



Best regards,


Gwenaëlle




Dear Bobby,


thank you for contacting us and your question.


First, you should use the WACOM SDK to get the strokes from your wacom Bamboo slate: https://developer-docs.wacom.com/.

Please note for any question related to Wacom (SDK, device), you shall contact them, as we have no experience with it.


Once you have the strokes, you can then provide these to our iink SDK, using the "batch mode": 

-https://developer.myscript.com/docs/interactive-ink/1.3/android/advanced/off-screen-usage/

-https://developer.myscript.com/docs/interactive-ink/1.3/android/fundamentals/editing/#series-of-events


Also, please find a batch-mode sample available on github: https://github.com/MyScript/interactive-ink-additional-examples-android/tree/master/java/samples/batch-mode

Once you are able to get the strokes by yourself, using the latter, you should be able to add these the iink.


Best regards,


Olivier

I tried above mentioned approach but MyScript is not recognising anything. I am getting rawpoints (x,y, time in milliseconds and pressure) but No EventType from WACOM sdk. I kept the starting point as DOWN and last point as UP and rest all as MOVE but that is not working.



//Stokes from Wacom SDK
for (RawPoint rawPoint : inkStroke.getRawPoints()) {
PointerEvent pointerEvent = new PointerEvent();
pointerEvent.pointerType = PointerType.PEN;
pointerEvent.pointerId = 1;
pointerEvent.eventType = PointerEventType.MOVE;


// Transform the x and y coordinates of the stroke from mm to px
// This is needed to be adaptive for each device
pointerEvent.x = (rawPoint.x/ 25.4f) * displayMetrics.xdpi;
pointerEvent.y = (rawPoint.y / 25.4f) * displayMetrics.ydpi;

pointerEvent.t = rawPoint.timestampInMillis;
pointerEvent.f = rawPoint.pressure;

pointerEvents.add(pointerEvent);
}
// Configure recognition
Configuration conf = engine.getConfiguration();
String confDir = "zip://" + getPackageCodePath() + "!/assets/conf";

conf.setStringArray("configuration-manager.search-path", new String[]{confDir});
conf.setString("content-package.temp-folder", getFilesDir().getPath() + File.separator + "tmp");
conf.setString("lang", language);

// Configure the engine to disable guides (recommended)
conf.setBoolean("text.guides.enable", false);

// Create a renderer with a null render target
displayMetrics = getResources().getDisplayMetrics();
Renderer renderer = engine.createRenderer(displayMetrics.xdpi, displayMetrics.ydpi, null);

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

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

try {
// Create a new package
contentPackage = engine.createPackage(packageName);

// Create a new part
contentPart = contentPackage.createPart(partType);
} catch (Exception e) {
}

// Associate editor with the new part
editor.setPart(contentPart);

// Feed the editor
PointerEvent[] arr = new PointerEvent[pointerEvents.size()];
arr = pointerEvents.toArray(arr);
editor.pointerEvents(arr, false);

// Export the result of the recognition into a file
export();
void export() {
MimeType mimeType = MimeType.TEXT;

File directory = new File(filePath.getAbsolutePath() + "/Navia Image/");
directory.mkdirs();

File file = new File(directory, "/"+exportFileName + mimeType.getFileExtensions());
editor.waitForIdle();

try {
editor.export_(null, file.getAbsolutePath(), mimeType, null);
String s= editor.export_(null,mimeType);

Log.i("output",s);
} catch (Exception e) {
e.printStackTrace();
}

editor.setPart(null);
contentPart.close();
contentPackage.close();

try {
engine.deletePackage(packageName);
} catch (IOException e) {
e.printStackTrace();
}
}

@Override
protected void onDestroy() {
engine = null;

super.onDestroy();

}
Answer

Dear Bobby,


Thank you for your update.


Here are my comments:

- What is your part type?

- Do you process one or several strokes?


According to the comment in your code "//Stokes from Wacom SDK", I guess you want to process several strokes


If you are processing several strokes, setting only the starting point to DOWN and the end point to UP  is not enough, as a stroke is defined from the moment the pen touches the screen until the pen is lifted again.

So you should have a starting point (DOWN) and end point (UP) per stroke.


Please refer to this section of the documentation for an example.



Best regards,


Gwenaëlle



Thank you so much. Your suggestions worked for me