0.4.0 • Published 8 months ago

react-native-ml-text-overlay v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

react-native-ml-text-overlay

Overlay layer for OCR / Vision results, complete with depth rendering, loading icons and touch actions for blocks. Resizable (within limits)

Used internally at Wail

How it works

Installation

yarn add react-native-ml-text-overlay

Usage

import MlTextOverlay from 'react-native-ml-text-overlay';

<MlTextOverlay
  limit={0}
  imageSource={image}
  padding={20}
  ocrResults={ocrResults}
  itemsDone={itemsDone}
/>;

Props

NameTypeRequireddefaultcomment
blockIcon(x: { done: boolean, error:boolean }) => ReactChildno-
blockPaddingnumberno20Padding around each overlay block
blockStyleViewStyle (RN)no-
depth1 | 2 | 3no1decide the depth (granularity of the overlay), 1 is bigger blocks,3 is smaller (each letter), note: if over 100 blocks gets rendered animations turn off
doneStyleViewStyle (RN)no-style appending on blockStyle if index is contained in itemsDone
errorStyleViewStyle (RN)no-style appending on blockStyle if index is contained in itemsError
hideDonebooleannofalsehide block if index is contained in itemsDone
imageSourceImageStyle (RN)yes-{uri:imguri} or imported image
imageStyleImageRequireSource | ImageURISourceyes-
itemsDonenumber[]no-array of indexes for items somehow marked as done example 1,2,3
itemsErrornumber[]no-array of indexes for items somehow marked as erroneous example 1,2,3
limitnumberno-set a render limit of blocks
ocrResultsMLTextOverlay[]yes-the JSON object containing all coordinate data for rendering
onPress(x: { block: GoogleMLText | Element | Line; index: number }) => voidno-on press Item, return type includes index and the block data
paddingnumberno0padding around the root render

Sources

Any source is fine as long as it follows the interface for MLTextOverlay (see source)

primarly use for Google ML Kit text and RN implementations like react-native-mlkit-ocr

to convert other sources like google cloud vision ensure the format adheres to

bounding: {
  height: number
  left: number
  top: number
  width: number
}

use the converter

TODO

  • implement parser for Google ml kit
  • implement parser for Google Cloud ML
  • implement block / paragraph parser for Cloud ML
  • implement parser for AWS Rekognition
  • implement parser for Azure Computer Vision

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

0.4.0

8 months ago

0.3.0

2 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago