Skip to content

gev2002/react-native-vision-camera-text-recognition

Repository files navigation

react-native-vision-camera-text-recognition

A plugin to Scanning Text,Translate using ML Kit Text Recognition and ML Kit Translation. With High Performance and many features.

๐Ÿšจ Required Modules

react-native-vision-camera = 4.5.1
react-native-worklets-core = 1.3.3

๐Ÿ’ป Installation

npm install react-native-vision-camera-text-recognition
yarn add react-native-vision-camera-text-recognition

๐Ÿ‘ทFeatures

Easy To Use.
Works Just Writing few lines of Code.
Works With React Native Vision Camera.
Works for Both Cameras.
Works Fast.
Works With Android ๐Ÿค– and IOS.๐Ÿ“ฑ
Writen With Kotlin and Swift.
Can Recognize Text From Photo. ๐Ÿ“ธ
Can translate text. ๐ŸŒ

๐Ÿ’ก Usage

๐Ÿ“š For Live Recognition Text

import React, { useState } from 'react'
import { useCameraDevice } from 'react-native-vision-camera'
import { Camera } from 'react-native-vision-camera-text-recognition';

function App (){
  const [data,setData] = useState(null)
  const device = useCameraDevice('back');
  console.log(data)
  return(
    <>
      {!!device && (
        <Camera
          style={StyleSheet.absoluteFill}
          device={device}
          isActive
          options={{
            language: 'latin'
          }}
          mode={'recognize'}
          callback={(d) => setData(d)}
        />
      )}
    </>
  )
}

export default App;

๐ŸŒ For Translate Text

import React, { useState } from 'react'
import { useCameraDevice } from 'react-native-vision-camera'
import { Camera } from 'react-native-vision-camera-text-recognition';

function App (){
  const [data,setData] = useState(null)
  const device = useCameraDevice('back');
  console.log(data)
  return(
    <>
      {!!device && (
        <Camera
          style={StyleSheet.absoluteFill}
          device={device}
          isActive
          options={{
            from: 'en',
            to: 'de'
          }}
          mode={'translate'}
          callback={(d) => setData(d)}
        />
      )}
    </>
  )
}

export default App;

Also You Can Use Like This

import React from 'react';
import { StyleSheet } from "react-native";
import {
  Camera,
  useCameraDevice,
  useFrameProcessor,
} from "react-native-vision-camera";
import { useTextRecognition } from "react-native-vision-camera-text-recognition";

function App() {
  const device = useCameraDevice('back');
  const options = { language : 'latin' }
  const {scanText} = useTextRecognition(options)
  const frameProcessor = useFrameProcessor((frame) => {
    'worklet'
    const data = scanText(frame)
    console.log(data, 'data')
  }, [])
  return (
    <>
      {!!device && (
        <Camera
          style={StyleSheet.absoluteFill}
          device={device}
          isActive
          mode={'recognize'}
          frameProcessor={frameProcessor}
        />
      )}
    </>
  );
}
export default App;

โš™๏ธ Options

Name Type Values Default
language string latin, chinese, devanagari, japanese, korean latin
mode string recognize, translate recognize
from,to string See Below en,de

Recognize By Photo ๐Ÿ“ธ

import { PhotoRecognizer } from "react-native-vision-camera-text-recognition";

const result = await PhotoRecognizer({
    uri:assets.uri,
    orientation: "portrait"
})
console.log(result);

๐Ÿšจ Orientation available only for iOS, recommendation give it when you are using Camera.

Name Type Values Required Default Platform
uri string yes android, iOS
orientation string portrait, portraitUpsideDown, landscapeLeft, landscapeRight no portrait iOS

You can also remove unnecessary translation model

import { RemoveLanguageModel } from "react-native-vision-camera-text-recognition";

const bool = await RemoveLanguageModel("en")

Supported Languages.

<h3>Afrikaans: ๐Ÿ‡ฟ๐Ÿ‡ฆ, ๐Ÿ‡จ๐Ÿ‡ซ <---> code : "af"</h3>
<h3>Albanian: ๐Ÿ‡ฆ๐Ÿ‡ฑ <---> code : "sq"</h3>
<h3>Arabic: ๐Ÿ‡ฆ๐Ÿ‡ช, ๐Ÿ‡ธ๐Ÿ‡ฆ <---> code : "ar"</h3>
<h3>Belarusian: ๐Ÿ‡ง๐Ÿ‡พ <---> code : "be"</h3>
<h3>Bulgarian: ๐Ÿ‡ง๐Ÿ‡ฌ <---> code : "bn"</h3>
<h3>Bengali: ๐Ÿ‡ง๐Ÿ‡ฉ <---> code : "bg"</h3>
<h3>Catalan: ๐Ÿด <---> code : "ca"</h3>
<h3>Czech: ๐Ÿ‡จ๐Ÿ‡ฟ <---> code : "cs"</h3>
<h3>Welsh: ๐Ÿด๓ ง๓ ข๓ ท๓ ฌ๓ ณ๓ ฟ <---> code : "cy"</h3>
<h3>Danish: ๐Ÿ‡ฉ๐Ÿ‡ฐ <---> code : "da"</h3>
<h3>German: ๐Ÿ‡ฉ๐Ÿ‡ช <---> code : "de"</h3>
<h3>Greek: ๐Ÿ‡ฌ๐Ÿ‡ท <---> code : "el"</h3>
<h3>English: ๐Ÿ‡ฌ๐Ÿ‡ง, ๐Ÿ‡บ๐Ÿ‡ธ <---> code : "en"</h3>
<h3>Esperanto: ๐ŸŒ <---> code : "eo"</h3>
<h3>Spanish: ๐Ÿ‡ช๐Ÿ‡ธ <---> code : "es"</h3>
<h3>Estonian: ๐Ÿ‡ช๐Ÿ‡ช <---> code : "et"</h3>
<h3>Persian: ๐Ÿ‡ฎ๐Ÿ‡ท <---> code : "fa"</h3>
<h3>Finnish: ๐Ÿ‡ซ๐Ÿ‡ฎ <---> code : "fi"</h3>
<h3>French: ๐Ÿ‡ซ๐Ÿ‡ท <---> code : "fr"</h3>
<h3>Irish: ๐Ÿ‡ฎ๐Ÿ‡ช <---> code : "ga"</h3>
<h3>Galician: ๐Ÿด <---> code : "gl"</h3>
<h3>Gujarati: ๐Ÿด <---> code : "gu"</h3>
<h3>Hebrew: ๐Ÿ‡ฎ๐Ÿ‡ฑ <---> code : "he"</h3>
<h3>Hindi: ๐Ÿ‡ฎ๐Ÿ‡ณ <---> code : "hi"</h3>
<h3>Croatian: ๐Ÿ‡ญ๐Ÿ‡ท <---> code : "hr"</h3>
<h3>Haitian: ๐Ÿ‡ญ๐Ÿ‡น <---> code : "ht"</h3>
<h3>Hungarian: ๐Ÿ‡ญ๐Ÿ‡บ <---> code : "hu"</h3>
<h3>Indonesian: ๐Ÿ‡ฎ๐Ÿ‡ฉ <---> code : "id"</h3>
<h3>Icelandic: ๐Ÿ‡ฎ๐Ÿ‡ธ <---> code : "is"</h3>
<h3>Italian: ๐Ÿ‡ฎ๐Ÿ‡น <---> code : "it"</h3>
<h3>Japanese: ๐Ÿ‡ฏ๐Ÿ‡ต <---> code : "ja"</h3>
<h3>Georgian: ๐Ÿ‡ฌ๐Ÿ‡ช <---> code : "ka"</h3>
<h3>Kannada: ๐Ÿ‡จ๐Ÿ‡ฆ <---> code : "kn"</h3>
<h3>Korean: ๐Ÿ‡ฐ๐Ÿ‡ท, ๐Ÿ‡ฐ๐Ÿ‡ต <---> code : "ko"</h3>
<h3>Lithuanian: ๐Ÿ‡ฑ๐Ÿ‡น <---> code : "lt"</h3>
<h3>Latvian: ๐Ÿ‡ฑ๐Ÿ‡ป <---> code : "lv"</h3>
<h3>Macedonian: ๐Ÿ‡ฒ๐Ÿ‡ฐ <---> code : "mk"</h3>
<h3>Marathi: ๐Ÿ‡ฎ๐Ÿ‡ณ <---> code : "mr"</h3>
<h3>Malay: ๐Ÿ‡ฒ๐Ÿ‡พ <---> code : "ms"</h3>
<h3>Maltese: ๐Ÿ‡ฒ๐Ÿ‡น <---> code : "mt"</h3>
<h3>Dutch: ๐Ÿ‡ณ๐Ÿ‡ฑ <---> code : "nl"</h3>
<h3>Norwegian: ๐Ÿ‡ณ๐Ÿ‡ด <---> code : "no"</h3>
<h3>Polish: ๐Ÿ‡ต๐Ÿ‡ฑ <---> code : "pl"</h3>
<h3>Portuguese: ๐Ÿ‡ต๐Ÿ‡น <---> code : "pt"</h3>
<h3>Romanian: ๐Ÿ‡ท๐Ÿ‡ด <---> code : "ro"</h3>
<h3>Russian: ๐Ÿ‡ท๐Ÿ‡บ <---> code : "ru"</h3>
<h3>Slovak: ๐Ÿ‡ธ๐Ÿ‡ฐ <---> code : "sk"</h3>
<h3>Slovenian: ๐Ÿ‡ธ๐Ÿ‡ฎ <---> code : "sl"</h3>
<h3>Swedish: ๐Ÿ‡ธ๐Ÿ‡ช <---> code : "sv"</h3>
<h3>Swahili: ๐Ÿ‡ฐ๐Ÿ‡ช <---> code : "sw"</h3>
<h3>Tamil: ๐Ÿ‡ฑ๐Ÿ‡ฐ <---> code : "ta"</h3>
<h3>Telugu: ๐Ÿ‡ฎ๐Ÿ‡ณ <---> code : "te"</h3>
<h3>Thai: ๐Ÿ‡น๐Ÿ‡ญ <---> code : "th"</h3>
<h3>Tagalog: ๐Ÿ‡ต๐Ÿ‡ญ <---> code : "tl"</h3>
<h3>Turkish: ๐Ÿ‡น๐Ÿ‡ท <---> code : "tr"</h3>
<h3>Ukrainian: ๐Ÿ‡บ๐Ÿ‡ฆ <---> code : "uk"</h3>
<h3>Urdu: ๐Ÿ‡ต๐Ÿ‡ฐ <---> code : "ur"</h3>
<h3>Vietnamese: ๐Ÿ‡ป๐Ÿ‡ณ <---> code : "vi"</h3>
<h3>Chinese: ๐Ÿ‡จ๐Ÿ‡ณ <---> code : "zh"</h3>