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>