Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AspectRatio.RATIO_16_9 displays an aspect ratio 1:1 #91

Closed
ludovicroland opened this issue Oct 25, 2019 · 1 comment
Closed

AspectRatio.RATIO_16_9 displays an aspect ratio 1:1 #91

ludovicroland opened this issue Oct 25, 2019 · 1 comment
Assignees

Comments

@ludovicroland
Copy link

I am currently playing with new cameraX library from Android Jetpack. I use the latest available version : 1.0.0-alpha06

In the CameraXBasic sample (https://github.com/android/camera-samples/tree/master/CameraXBasic), after updated the cameraX library version from 1.0.0-alpha05 to 1.0.0-alpha06, I am trying to display a 16:9 ratio preview instead of the fullscreen one.

In order to do that, I have updated the fragment_camera.xml layout in order to "force" the ratio aspect of the TextureView :

<androidx.constraintlayout.widget.ConstraintLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:id="@+id/camera_container"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@android:color/black"
  >
    <TextureView
      android:id="@+id/view_finder"
      android:layout_width="0dp"
      android:layout_height="0dp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintDimensionRatio="16:9"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      />
</androidx.constraintlayout.widget.ConstraintLayout>

The preview looks good :

enter image description here

Now, I have updated the code into the CameraFragment class in order to use the new AspectRatio enum.

So now, the camera preview config looks like :

val viewFinderConfig = PreviewConfig.Builder().apply {
  setLensFacing(lensFacing)
  // We request aspect ratio but no resolution to let CameraX optimize our use cases
  setTargetAspectRatio(AspectRatio.RATIO_16_9)
  // Set initial target rotation, we will have to call this again if rotation changes
  // during the lifecycle of this use case
  setTargetRotation(viewFinder.display.rotation)
}.build()

Unfortunately, the result looks like a 1:1 ratio and not a 16:9 one :

enter image description here

if I use AspectRatio.RATIO_4_3 value instead of the AspectRatio.RATIO_16_9 the result looks good :

enter image description here

Is it an issue with the library or an issue with my implementation using the AspectRatio.RATIO_16_9 value ?

I can reproduce the issue at least on a:

  • Google Pixel 2 on Android 10
  • LG NExus 5 on Android 6.0.1

Probably links with the issue #87 .

Thank you in advance for your help!

@owahltinez
Copy link
Contributor

Hi @ludovicroland thanks for reporting this. Unfortunately, we can't really help with issues related to the library here -- this repo is dedicated exclusively to the sample. I would recommend filing an issue in the AOSP issue tracker or starting a thread in the developer forums

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants