capacitor-community / camera-preview

Capacitor plugin that allows camera interaction from HTML code
MIT License
186 stars 154 forks source link

Android - Gap between camera preview and capture base64 #27

Open albanlorillard opened 4 years ago

albanlorillard commented 4 years ago

Hello,

Actually, i've 2 issues concerning capture() function and the live camera :

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)

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

nielsvanharen commented 4 years ago

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

hodeware commented 2 years ago

Same issue here. Is there any solution?

pbowyer commented 2 years ago

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

  1. Fix your phone firmly somewhere - we don't want it to move
  2. Start CameraPreview running
  3. Take a screenshot on the phone of what you see
  4. Capture the photo in CameraPreview
  5. 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)?
yksolanki9 commented 2 years ago

Hey @pbowyer facing the same issue. Would like to know how you worked it out. Please share the approach if you dont mind. Thanks!