Michaelvilleneuve / react-native-document-scanner

Document scanner, features live border detection, perspective correction, image filters and more ! 📲📸
MIT License
838 stars 289 forks source link

Camera preview seem `stretch` #44

Open phuhk opened 5 years ago

phuhk commented 5 years ago

Hi there, anyone notice about Camera preview? My app currently support switch between 2 mode standar Camera and this scan document camera. And I notice preview aspect ratio of this scan document camera seem stretch smaller size than standar camera.

mmamoyco commented 5 years ago

+1

igor90007 commented 4 years ago

+1

humphreyja commented 4 years ago

The preview aspect ratio is a problem caused by Android having a preset list of available camera preview sizes. This means that you need to adjust the height and or width of the camera preview to match the aspect ratio (not just full screen). If you set flex: 1 on the scanner component, it will distort the preview. You will need to correct the aspect ratio by setting the width and height.

I noticed a lot of issues with this package which is why I completely rebuilt this package (both Android and iOS to fix this issue. I changed the API for this package to include a callback that gives you the aspect ratio percentages so you can address this issue. If you want a plug and play scanner, just look at the full example I give for this package, it shows how I handle this situation. Here's the link to it. It's react-native-rectangle-scanner on NPM.

https://github.com/HarvestProfit/react-native-rectangle-scanner