camera-preview
camera-preview copied to clipboard
Android - Gap between camera preview and capture base64
Hello,
Actually, i've 2 issues concerning capture() function and the live camera :
- On a first android mobile (Asus x00td / Android 8.1.0) that have only one back Camera, their is a gap between the live camera preview and the base64 capture.
Example (doesn't matter of the content) At left: screenshot of my application At right: the base64 image captured (The blue area = the gap that appear only in the capture)
- On the second android mobile with 2 back camera (Samsung A70 / Android 9), the live camera preview is the first back camera, and capture function is shot with the 2nd back camera. At left: screenshot of my application At right: the base64 image captured
Here is my configuration:
CameraPreview.start({
parent: "cameraPreview",
position: "rear",
camera: "rear"
});
I've tried to add x:0, y:0 or width=window.screen.width and height=window.screen.height but that change only on the web browser.
Regards,
Alban
This is something I noticed as well, the ‘old’ camera implementation of android does not support multiple camera’s very well , there is a new camera implementation that handles multiple camera’s much better
Same issue here. Is there any solution?
Looking at the photos in the original post, I am wondering if this is the same problem as I saw on an iPhone.
On many phones the camera isn't the same aspect ratio as the screen. CameraPreview covers the phone screen with the picture, which means it often crops off the sides of the picture when in portrait mode.
When the photo is captured it's the full photo, not the bit which fitted the screen.
It took me a while to work this out, and I added some JS in my app that cropped the captured photo to the aspect ratio of the phone's screen. For me this solved the problem.
How to see if this is the problem
- Fix your phone firmly somewhere - we don't want it to move
- Start CameraPreview running
- Take a screenshot on the phone of what you see
- Capture the photo in CameraPreview
- In a graphics program, open the captured photo and screenshot. Overlay the screenshot on the captured photo, resizing it as needed. Are they the same perspective? Do they fit exactly (so the same camera & lens was used)?
Hey @pbowyer facing the same issue. Would like to know how you worked it out. Please share the approach if you dont mind. Thanks!