Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Recognized text is at wrong position #20

Open
j0na1han opened this issue Oct 6, 2024 · 6 comments
Open

[QUESTION] Recognized text is at wrong position #20

j0na1han opened this issue Oct 6, 2024 · 6 comments

Comments

@j0na1han
Copy link

j0na1han commented Oct 6, 2024

Hi,

I try to mark the text which your library recognized.

The code:
`
const frameProcessor = useSkiaFrameProcessor((frame) => {
'worklet'

    frame.render()
    const data = scanOCR(frame)

    const paint = Skia.Paint()
    paint.setColor(Skia.Color('red'))

    if (Object.keys(data).length != 0) {
        for (const block of data.result.blocks) {
            const rect = Skia.XYWHRect(block.frame.x, block.frame.y, block.frame.width, block.frame.height)
            frame.drawRect(rect, paint)
        }
    }

})
`

I added a video with the behavior. Do you have an idea why this so?

text.MP4

react-native-vision-camera: 4.5.3
@ismaelmoreiraa/vision-camera-ocr: 3.0.2-1

@ismaelsousa
Copy link
Owner

hello, it should be related to the rotation of the frame.
what is the ratio of the frame and the ratio of the camera view?

@j0na1han
Copy link
Author

j0na1han commented Oct 8, 2024

Hi,
the pixel ratio of the camera view is 3.

How can I get the ratio of the frame?

Here again a video without my special case.
https://github.com/user-attachments/assets/634aa738-3bae-4d68-b0e3-38d468b2142b

@ismaelsousa
Copy link
Owner

You can get the ratio from the frame inside the frame processor

But yeah, I need to take a look at that.
We need to convert the bounding boxes to the same ratio and scale of the camera view.

@ismaelsousa
Copy link
Owner

Wait, hmm, odd, are you using skia to draw the bounding boxes?

I never tried this. You can check the coordinates to see what is happening when you start to move the text to the middle of the screen.

@j0na1han
Copy link
Author

j0na1han commented Oct 8, 2024

Yes I do. You mean it is a problem with react-native-vision camera?

At the top right corner is 0,0. I would expect that in the bottom left corner is 1920,1080. Somehow the max value is not greater than 1000,1000.

coordinates

@ismaelsousa
Copy link
Owner

hmm, I guess in ML Kit the (0,0) is at top left

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants