Comments (14)
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.
@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.
I'll investigate.
from cameraview.
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.
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.
@yaraki Do you have any update on this ?
from cameraview.
Not yet. I'm working on it.
from cameraview.
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.
Nexus 6P, Android Nougat, 1:1 aspect ratio is ignored.
getSupportedAspectRatios() returns empty set
from cameraview.
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.
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.
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.
could not achieve aspect ratio 1:1 on Nokia 6
from cameraview.
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)
- how to store a click photos in gallery
- FLASH_TORCH sticks until FLASH_OFF is used
- camera preview showing black ,Please look my code below to solve. HOT 2
- java.lang.NullPointerException@android.hardware.camera2.CameraCaptureSession.capture HOT 6
- Black preveiw for front facing camera
- Why fall back to Camera1
- rotate
- CameraView shows green color when turn the screen OFF and turn ON in Redmi note 5 only HOT 2
- NPE while setting the aspect ratio HOT 1
- How to install BurstMode in this ?
- when add android:configChanges="orientation|keyboardHidden|screenSize" toCameraActivity Screen Rotation show Black Screen HOT 1
- Caused by: java.lang.RuntimeException: Fail to connect to camera service HOT 2
- TakePicture flash problem
- Pinch to zoom with Google Android Calendar
- android.view.TextureView.onSizeChanged (TextureView.java:367)
- Exit Interface always returns 0 for Google pixel with Google camera
- OPPO R17 Redmi 8A Android 9 crash
- Demo app crashes when trying to switch camera front facing camera
- Camera
- Security Policy violation Binary Artifacts HOT 23
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cameraview.