Git Product home page Git Product logo

Comments (14)

yaraki avatar yaraki commented on April 28, 2024

Because it is not one of the supported aspect ratios. We will figure out how to deliver errors properly. For now, please make sure to use CameraView#getSupportedAspectRatios before setting an aspect ratio.

from cameraview.

ivacf avatar ivacf commented on April 28, 2024

@yaraki so if we always want our camera view to be a square but the camera doesn't support a 1:1 ratio, what's your recommended way to achieve this?

Actually, after doing some testing I think this may still be a bug. Im using this in my layout file:

<com.google.android.cameraview.CameraView
    android:id="@+id/camera"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:keepScreenOn="true"
    android:adjustViewBounds="true"
    app:autoFocus="true"
    app:aspectRatio="1:1"
    app:facing="back"
    app:flash="auto"/>

And the ratio that actually displays on Nexus 5X with Nougat is about 3:4. If I retrieve the supported ratios after the camera is opened usinggetSupportedAspectRatios(), 1:1 is one of them, so it seem like the camera actually supports it. If I then try to set it programmatically using cameraView.setAspectRatio() the camera view gets the right size but stops displaying the preview.

from cameraview.

yaraki avatar yaraki commented on April 28, 2024

I'll investigate.

from cameraview.

remq avatar remq commented on April 28, 2024

Couldn't you just put the CameraView inside a square parent? Something like this:

public class SquareRelativeLayout extends RelativeLayout {

    public SquareRelativeLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        // Or use heightMeasureSpec
        super.onMeasure(widthMeasureSpec, widthMeasureSpec);
    }
}

from cameraview.

yaraki avatar yaraki commented on April 28, 2024

That will crop the CameraView to square size, but the taken pictures will not be square.

This is a combination of 2 issues. I'm working on a fix.

  • Aspect Ratio is not working properly.
  • Nexus 5X reports 1:1 ratio as one of the supported picture format, but the preview crashes with SurfaceView.

from cameraview.

bunjix avatar bunjix commented on April 28, 2024

@yaraki Do you have any update on this ?

from cameraview.

yaraki avatar yaraki commented on April 28, 2024

Not yet. I'm working on it.

from cameraview.

yaraki avatar yaraki commented on April 28, 2024

I added aspect ratio choice in the demo app. Also, setAspectRatio now works after layout. I still need to fix the issue with 1:1 on N5x and such.

from cameraview.

vadymhimself avatar vadymhimself commented on April 28, 2024

Nexus 6P, Android Nougat, 1:1 aspect ratio is ignored.
getSupportedAspectRatios() returns empty set

from cameraview.

iftekhar-ahmed avatar iftekhar-ahmed commented on April 28, 2024

I get the same issue with nexus 5x android nougat/O. can't get a 1:1 setting it with a setAspectRatio call after layout. Is there an update to this problem?

from cameraview.

drottemberg avatar drottemberg commented on April 28, 2024

I had the same issue and basically you need to set the aspect ratio after the camera has been initialized in this function

private CameraView.Callback mCallback
            = new CameraView.Callback() {

        @Override
        public void onCameraOpened(CameraView cameraView) {
            Set s = mCameraView.getSupportedAspectRatios(); // This is just to make sure the set is not empty
            mCameraView.setAspectRatio(AspectRatio.of(1,1));
        }

from cameraview.

jgarcia3327 avatar jgarcia3327 commented on April 28, 2024

Do you guys have a fix on the issue? Have white background appearing on my Nexus 5x running Android 8 on 16:9 preview. All other phone I tested running ok. Thanks.

from cameraview.

nawinkhatiwada avatar nawinkhatiwada commented on April 28, 2024

could not achieve aspect ratio 1:1 on Nokia 6

from cameraview.

Himanshu507 avatar Himanshu507 commented on April 28, 2024

Do you guys have a fix on the issue? Have white background appearing on my Nexus 5x running Android 8 on 16:9 preview. All other phone I tested running ok. Thanks.

Hey can you help me. i'm recording the video on full screen but when i preview this video it not plays in full screen why ?

from cameraview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.