-2

I want to make a camera app. For the beginning I created a sample app.I had looked in github a lot and I cant find a good solutution but I want a camera like snapchat's camera preview .Can anyone give me a solution how can I start?

In my sample apps I can take a picture but the preview from the picture is not good.The picture should appear in full screen in my device like snapchat.

EDIT: I just want to learn the way how can I do this correctly. However I check out the library which is described on the comment. My app its base on like it's described in android-vision library.

Olcay Sönmez
  • 602
  • 1
  • 7
  • 16
  • I used the library from that https://github.com/googlesamples/android-vision and it include the cameraPreview . Actually, it works fine for me. There is in barcode-reader folder and in that folder you will see the "cameraSource and cameraPreviewSource" class. I highly recommend to use that and if you want you can customize it too. Please look it and read carefully the command line @iMDroid – Olcay Sönmez Jun 20 '18 at 07:11
  • Hi, the android- vision library helped a lot. I literally look carefully and make some changes like it's described in that library. Thank you again for your help. – Olcay Sönmez Oct 23 '18 at 12:26

1 Answers1

1

I had to make a custom camera plug for cordova and this helped me a lot: https://github.com/performanceactive/phonegap-custom-camera-plugin/tree/master/platforms/android/src/com/performanceactive/plugins/camera

Check CustomCameraActivity and CustomCameraPreview, they show you how to customize a camera, control the preview size, aspect ratio and surface change.

Check this function in CustomCameraPreview.java:

  private Size optimimalPreviewSize(int targetWidth, int targetHeight) {
        List<Size> sizes = camera.getParameters().getSupportedPreviewSizes();
        float targetAspectRatio = (float) targetWidth / targetHeight;
        List<Size> sizesWithMatchingAspectRatios = filterByAspectRatio(targetAspectRatio, sizes);
        if (sizesWithMatchingAspectRatios.size() > 0) {
            return optimalSizeForHeight(sizesWithMatchingAspectRatios, targetHeight);
        }
        return optimalSizeForHeight(sizes, targetHeight);
    }

Hope this helps you

Fabio Venturi Pastor
  • 2,519
  • 3
  • 19
  • 32