Last active
October 10, 2021 13:37
-
-
Save DanishAmjad12/89d0d801aaeede090b0e3f925489c440 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun download() { | |
var modelIdentifier: DigitalInkRecognitionModelIdentifier? = null | |
try { | |
modelIdentifier = | |
DigitalInkRecognitionModelIdentifier.fromLanguageTag("zxx-Zsym-x-autodraw") | |
} catch (e: MlKitException) { | |
// language tag failed to parse, handle error. | |
} | |
model = | |
DigitalInkRecognitionModel.builder(modelIdentifier!!).build() | |
val remoteModelManager = RemoteModelManager.getInstance() | |
remoteModelManager.download(model, DownloadConditions.Builder().build()) | |
.addOnSuccessListener { | |
Log.i("StrokeManager", "Model downloaded") | |
} | |
.addOnFailureListener { e: Exception -> | |
Log.e("StrokeManager", "Error while downloading a model: $e") | |
} | |
val recognizer: DigitalInkRecognizer = | |
DigitalInkRecognition.getClient( | |
DigitalInkRecognizerOptions.builder(model).build() | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment