jonathanpalma / react-native-tesseract-ocr

Tesseract OCR wrapper for React Native
MIT License
561 stars 172 forks source link

App get crash while TesseractOcr.recognize #90

Closed UmeshBaldaniya46 closed 3 years ago

UmeshBaldaniya46 commented 3 years ago

Describe the bug Create new sample project add tesseract-ocr & image-picker. Add eng.traineddata file in to assets folder, and try to run

Getting error like Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 14659 (Thread-5), pid 14527 (.awesomeproject),

I have done google for that, They said you are update UI from BG thread. but i did not do any thing, i have just copy code from your sample project.

Dependencies (please complete the following information):

Screenshots Screenshot 2020-10-06 at 5 59 25 PM

Smartphone (please complete the following information):

Additional context I have try in other system as well but same result.

CODE `const [isLoading, setIsLoading] = useState(false); const [progress, setProgress] = useState(0); const [imgSrc, setImgSrc] = useState(null); const [text, setText] = useState('');

const onSelectImage = () => { ImagePicker.launchImageLibrary({ storageOptions: { skipBackup: true, path: 'images', }, }, async (response) => { console.log('Response == ', response);

  if (response.didCancel) {
    console.log('User cancelled image picker');
  } else if (response.error) {
    console.log('ImagePicker Error: ', response.error);
  } else if (response.customButton) {
    console.log('User tapped custom button: ', response.customButton);
  } else {
    setImgSrc({ uri: response.path });
    await recognizeTextFromImage(response.path);
  }
});

}

useEventListener('onProgressChange', (p) => { setProgress(p.percent / 100); });

const recognizeTextFromImage = async (path) => { setIsLoading(true);

try {
  const tesseractOptions = {};
  const recognizedText = await TesseractOcr.recognize(
    path,
    LANG_ENGLISH,
    tesseractOptions,
  );
  setText(recognizedText);
} catch (err) {
  console.error(err);
  setText('');
}

setIsLoading(false);
setProgress(0);

};`

` return ( <>

    <SafeAreaView>
      <ScrollView
        contentInsetAdjustmentBehavior="automatic"
        style={styles.scrollView}>
        <Header />
        {global.HermesInternal == null ? null : (
          <View style={styles.engine}>
            <Text style={styles.footer}>Engine: Hermes</Text>
          </View>
        )}
        <View style={styles.body}>
          <View style={styles.sectionContainer}>
            <Text style={styles.sectionTitle}>Step One</Text>
            <Button
              // disabled={isLoading}
              title="Pick Image"
              onPress={() => {
                onSelectImage()
              }}
            />
          </View>
          <Text>{text}</Text>
          <Image style={styles.image} source={imgSrc} />
        </View>
      </ScrollView>
    </SafeAreaView>
  </>
);`
rchowdhe commented 3 years ago

Hello everyone, is there any update regarding above issue? I am facing same issue.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.