dat-ng / ar-location-based-android

This AR app generally show where things are in the real-world by indicating where the app thinks they are over the camera view when the user holds the phone up and moves it about.
MIT License
203 stars 85 forks source link

Camera preview stretched #3

Open idrisbohra opened 7 years ago

idrisbohra commented 7 years ago

camera previewing the image as stretched in both horizontal and vertical orientation. the stretched level is look like double the original object size.

ShantiRanjanDas commented 6 years ago

I also have the same issue, Have you find any solution(@idrisbohra). @dat-ng please give an idea atleast on this.

makisp commented 6 years ago

I don't know if this helps you but i remember i had a runtime error with previewSize having the wrong values. What i did to fix it was to add these lines of code under surfaceChanged inside ARCamera.java:

public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
        if(camera != null) {
            this.cameraWidth = width;
            this.cameraHeight = height;

            Camera.Parameters params = camera.getParameters();
            // Quick fix for Runtime error (previewSize has wrong value)
            List<Camera.Size> sizes = params.getSupportedPreviewSizes();
            Camera.Size cs = sizes.get(0);
            params.setPreviewSize(cs.width, cs.height);
            requestLayout();

            camera.setParameters(params);
            camera.startPreview();

            generateProjectionMatrix();
        }
    }

...good luck!

ShantiRanjanDas commented 6 years ago

It won't work

makisp commented 6 years ago

If you rotate the device to landscape does it look normal?