ismaelsousa / vision-camera-ocr

VisionCamera Frame Processor Plugin to detect text in real time using MLKit Text Detector (OCR)
MIT License
27 stars 32 forks source link

[QUESTION]: text in wrong direction #13

Open Valentin-Rault opened 5 months ago

Valentin-Rault commented 5 months ago

After upgrading to latest version of react native, react native vision camera and this library, the frame is now in a wrong orientation. The frame orientation is set to portrait but is actually in landscape-right. This results in needing to orientate the text to the right in order to be able to scan. A quick fix I tried is to set visionImage.orientation = .right instead of .up, now the text is scanned properly when held upright in front of the camera.

I realise that this issue is also coming from react native vision camera but shouldn't this library be able to handle different frame orientation?

Version: react native: 0.74.2 react native vision camera: 4.3.2 vision camera ocr: 3.0.1

ismaelsousa commented 5 months ago

yeah, I saw that vision now supports the orientation. But I didn't have time to play around with it and see the changes in there. if you have a time, could you implement a proposal and create a PR for it? @Valentin-Rault

Valentin-Rault commented 5 months ago

I will definitely take a look at it and play with it a bit

Valentin-Rault commented 4 months ago

Little update here, as of react native vision camera v.4.4.0 the frame is back to the correct orientation of landscape-right. I am still having some issues with scanning though. Do you have the possibility to test @ismaelsousa? So I can see if it is an issue from the rest of my code. In the meantime I am starting to look into a way to support the orientation to not have this issue again in the future

ismaelsousa commented 4 months ago

hmmm, maybe your error is around this, isn’t ?

image

Because if you are trying to draw it and it's appearing in a mess way the frame can give you the rotation but the output of ML kit is rotated to that format. Try to update the native side with this properties and let me know the result :)

link to docs: https://developer.android.com/reference/androidx/camera/core/ImageAnalysis.Builder#setOutputImageRotationEnabled(boolean)

Valentin-Rault commented 4 months ago

@ismaelsousa I have made a PR with a proposal to rectify this behaviour for ios

alamothe commented 4 months ago

Hello, the author of react-native-vision-camera has described how to fix the issue here: https://github.com/mrousavy/react-native-vision-camera/issues/3051

It seems to be one line of code.

Can you please fix this ASAP?

alamothe commented 4 months ago

https://github.com/ismaelsousa/vision-camera-ocr/pull/16