Skip to content

Instantly share code, notes, and snippets.

@LethalMaus
Created March 20, 2024 09:08
Show Gist options
  • Select an option

  • Save LethalMaus/ea955b0eaf87e8d77f2133c2a598781b to your computer and use it in GitHub Desktop.

Select an option

Save LethalMaus/ea955b0eaf87e8d77f2133c2a598781b to your computer and use it in GitHub Desktop.
text-recognition.kt
// From a media image
val image = InputImage.fromMediaImage(mediaImage, rotation)
// From a file path
val image: InputImage
try {
image = InputImage.fromFilePath(context, uri)
} catch (e: IOException) {
e.printStackTrace()
}
// From a byte buffer
val image = InputImage.fromByteBuffer(
byteBuffer,
/* image width */ 480,
/* image height */ 360,
rotationDegrees,
InputImage.IMAGE_FORMAT_NV21 // or IMAGE_FORMAT_YV12
)
// From a bitmap
val image = InputImage.fromBitmap(bitmap, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment