Any way to get rid of the rendering? While playing with the "GetStartedSwift" project, I figured out how to initiate the engine and how to create the IINKEditor. But it seems the editor needs an IINKRenderer as well as an FontMetricsProvider (both seems very rendering specific). My app uses an own approach on rendering. So I like to provide only the data points. Any ideas?
Best regards
Chris
Best Answer
T
Thomas PENIN
said
almost 2 years ago
Hi Chris,
The Interactive Ink SDK API requires an IINKRenderer and a FontMetricsProvider to be provided to the editor. The dpi information provided by the renderer, for instance, is important to get a sense of the scale of what was written and will impact the quality of the recognition; the font metrics provider is required in case typeset data needs to be layouted at some point (certain cases of import or export). However, you do not need to display anything: the IINKRenderer asks for a render target: you can provide your own object implementing IINKIRenderTarget with methods that do nothing.
The Interactive Ink SDK API requires an IINKRenderer and a FontMetricsProvider to be provided to the editor. The dpi information provided by the renderer, for instance, is important to get a sense of the scale of what was written and will impact the quality of the recognition; the font metrics provider is required in case typeset data needs to be layouted at some point (certain cases of import or export). However, you do not need to display anything: the IINKRenderer asks for a render target: you can provide your own object implementing IINKIRenderTarget with methods that do nothing.
Best regards,
Thomas
m
myscriptdev@hotactionstudios.com
said
over 1 year ago
Hi Thomas,
I'm having the same use-case - I just want to put some strokes in and get a word out. My current implementation looks like this follows but I always get "" (empty string) in return:
FontMetricsProvider, minimal implementation, I don't want to render anything:
public class FontMetricsProvider: NSObject, IINKIFontMetricsProvider {
public func getCharacterBoundingBoxes(_ text: IINKText!, spans: [IINKTextSpan]!) -> [NSValue]! {
return []
}
public func getFontSizePx(_ style: IINKStyle!) -> Float {
return style.fontSize
}
}
My custom engine initializer (I wrapped the static lib in a dynamic framework because I need it in multiple other frameworks):
extension IINKEngine {
public convenience init?(certificateData: Data = Data(bytes: myCertificate.bytes, count: myCertificate.length), configurationPath: String = "/recognition-assets/conf") {
self.init(certificate: certificateData)
// Configure the iink runtime environment
let configurationPath = Bundle(for: IINKEngine.self).bundlePath.appending(configurationPath)
do {
try configuration.setStringArray("configuration-manager.search-path", value: [configurationPath]) // Tells the engine where to load the recognition assets from.
} catch {
print("Should not happen, please check your resources assets : " + error.localizedDescription)
return nil
}
// Set the temporary directory
do {
try configuration.setString("content-package.temp-folder", value: NSTemporaryDirectory().appending("/HandwritingRecognitionAssets"))
} catch {
print("Failed to set temporary folder: " + error.localizedDescription)
return nil
}
}
}
However, when processStrokes() gets called, it always prints "" (the empty string). I think I'm missing something but I don't know what.
Is my current understanding correct?
A "package" is a sorted collection of parts (acc. to the docs), i.e. assuming one uses documents it would be the whole document.
A "part" is whatever the user writes in one piece, e.g. a word or a complete sentence.
A "block" is some sub-thingy of a part, maybe a letter, maybe a number, maybe a part of a word (or a letter?), I usually don't care about this.
===
In the example code above a create a package for everything the engine should recognize (because I don't want the engine to have the context of the anything else), just feed some strokes and get a word (or list of candidates) out. I don't get any errors logged so I assume my setup is correct (it would log a message if it didn't have any recognition-assets (I use analyzer, en_US, math and shape), right?). I find it really hard to debug this because I don't see how I can get the points of an editor (to see if I fed them correctly into it), etc.
Any help is very much appreciated, thank you!
T
Thomas PENIN
said
over 1 year ago
Hi,
If you keep your proposed analogy "package" = "document", then you have "part" = "page", a page being of a given type (some text, a diagram, some math, etc.). A block would be a semantic subdivision of a page, for instance a paragraph.
I see two potential issues with the code:
I am under the impression that you send the events to the editor before you attach the part to it. You should do the other way round. The part "gathers" the data iink will work on.
As recognition may take some time to complete, you need to call waitForIdle on the editor object before attempting to export.
To get configuration error, you should implement the onError method of IINKEditorDelegate. It will raise an error whether you attempt to use an invalid configuration.
I hope this will help,
Best regards,
Thomas
2 people like this
m
myscriptdev@hotactionstudios.com
said
over 1 year ago
Hi Thomas,
Thank you very much for your explanation and your pointers! After I adjusted the code according to your remarks it works perfectly fine! :)
Chris Trotzky
Hi folks!
Any way to get rid of the rendering? While playing with the "GetStartedSwift" project, I figured out how to initiate the engine and how to create the IINKEditor. But it seems the editor needs an IINKRenderer as well as an FontMetricsProvider (both seems very rendering specific). My app uses an own approach on rendering. So I like to provide only the data points. Any ideas?
Best regards
Chris
Hi Chris,
The Interactive Ink SDK API requires an IINKRenderer and a FontMetricsProvider to be provided to the editor. The dpi information provided by the renderer, for instance, is important to get a sense of the scale of what was written and will impact the quality of the recognition; the font metrics provider is required in case typeset data needs to be layouted at some point (certain cases of import or export). However, you do not need to display anything: the IINKRenderer asks for a render target: you can provide your own object implementing IINKIRenderTarget with methods that do nothing.
Best regards,
Thomas
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstThomas PENIN
Hi Chris,
The Interactive Ink SDK API requires an IINKRenderer and a FontMetricsProvider to be provided to the editor. The dpi information provided by the renderer, for instance, is important to get a sense of the scale of what was written and will impact the quality of the recognition; the font metrics provider is required in case typeset data needs to be layouted at some point (certain cases of import or export). However, you do not need to display anything: the IINKRenderer asks for a render target: you can provide your own object implementing IINKIRenderTarget with methods that do nothing.
Best regards,
Thomas
myscriptdev@hotactionstudios.com
Hi Thomas,
I'm having the same use-case - I just want to put some strokes in and get a word out. My current implementation looks like this follows but I always get "" (empty string) in return:
FontMetricsProvider, minimal implementation, I don't want to render anything:
My custom engine initializer (I wrapped the static lib in a dynamic framework because I need it in multiple other frameworks):
This is the meat:
However, when processStrokes() gets called, it always prints "" (the empty string). I think I'm missing something but I don't know what.
Is my current understanding correct?
A "package" is a sorted collection of parts (acc. to the docs), i.e. assuming one uses documents it would be the whole document.
A "part" is whatever the user writes in one piece, e.g. a word or a complete sentence.
A "block" is some sub-thingy of a part, maybe a letter, maybe a number, maybe a part of a word (or a letter?), I usually don't care about this.
===
In the example code above a create a package for everything the engine should recognize (because I don't want the engine to have the context of the anything else), just feed some strokes and get a word (or list of candidates) out. I don't get any errors logged so I assume my setup is correct (it would log a message if it didn't have any recognition-assets (I use analyzer, en_US, math and shape), right?). I find it really hard to debug this because I don't see how I can get the points of an editor (to see if I fed them correctly into it), etc.
Any help is very much appreciated, thank you!
Thomas PENIN
Hi,
If you keep your proposed analogy "package" = "document", then you have "part" = "page", a page being of a given type (some text, a diagram, some math, etc.). A block would be a semantic subdivision of a page, for instance a paragraph.
I see two potential issues with the code:
2 people like this
myscriptdev@hotactionstudios.com
Hi Thomas,
Thank you very much for your explanation and your pointers! After I adjusted the code according to your remarks it works perfectly fine! :)