tony-xlh / vision-camera-dynamsoft-document-normalizer

A React Native Vision Camera frame processor plugin for Dynamsoft Document Normalizer
MIT License
45 stars 2 forks source link

Detection results points rotated on iOS #8

Closed frenberg closed 2 months ago

frenberg commented 2 months ago

Hi!

Was just updating to the latest version and have run into an issue on iOS.

it looks like the coordinates for the results are (not?) rotated, tested this on iphone 12 and 15 pro and ios 17.5 and 18 beta. Works good like before on android.

IMG_0065

xulihang commented 2 months ago

The recent Vision Camera version added support for orientation: https://github.com/mrousavy/react-native-vision-camera/pull/2932#issuecomment-2154196434

I have to rotate the camera frame to match the preview. It is tested using vision camera v4.3.2.

frenberg commented 2 months ago

Thanks for the quick response.

Appologies, I thought I posted my versions but yeah I'm running vision-camera v4.3.2 too.

I can't see where you rotate the camera frame in the example app? Can you please send a link or what am I missing 🙈

xulihang commented 2 months ago

Well, it is done in the plugin's native code. You'd better lock the orientation and try again.

https://github.com/tony-xlh/vision-camera-dynamsoft-document-normalizer/blob/b80154bfd17329d9a9e88143a44899352a6352f7/ios/DetectionFrameProcessorPlugin.swift#L40-L49

frenberg commented 2 months ago

Aha, so it is handled in the native code and I should not have to change the frameprocessor or style?

xulihang commented 2 months ago

Yes. You need to change the js code since the frame width and frame height for iOS are different now.

frenberg commented 2 months ago

you mean this? https://github.com/tony-xlh/vision-camera-dynamsoft-document-normalizer/blob/main/example/src/components/Scanner.tsx#L50-L72

frenberg commented 2 months ago

before it was "if Platform.Android" but now it checks frame width and frameheight instead...

xulihang commented 2 months ago

Right. My previous version checks the platform. Now we have to deal with the orientation problem for both platforms.

frenberg commented 2 months ago

I did notice this and I have made the same change I think 🤔 But if this works I must have messed up something 🙈

xulihang commented 2 months ago

You can skip the calculation of frame width and frame height first since we've set a fixed resolution: 1920x1080. Then the frame width should be 1080 and the frame height should be 1920.

frenberg commented 2 months ago

okey... this is working for me

        } else if frame.orientation == UIImage.Orientation.up {
            degree = 90.0;