How to make square crop in new video capture

402 views
Skip to first unread message
Assigned to trevor...@google.com by eri...@google.com

Hossein Kheirollahpour

unread,
Dec 27, 2021, 10:04:12 AM12/27/21
to Android CameraX Discussion Group
Hello Group
How we can make an video output center square in the new video lib(androidx.camera:camera-video:1.1.0-alpha12)?
In the previous VideoCapture(androidx.camera:camera-core:1.1.0-alpha08), we can set target resolution but in the new one cant be able to do this.
Since the new version gets quality, can we do the same config?
Screenshot from 2021-12-27 18-33-29.png
Using VideoCapture in new library(alpha12):
val qualitySelector = QualitySelector.from(Quality.SD)
val recorder = Recorder.Builder()
.setQualitySelector(qualitySelector)
.build()
val videoCapture = VideoCapture.withOutput(recorder)


Using VideoCapture in old library(alpha8):
val videoCapture = VideoCapture.Builder()
      setTargetResolution(
Size(deviceWidth, deviceWidth))
      .setTargetName("VideoCapture")
      .build()

Trevor McGuire

unread,
Jan 4, 2022, 7:50:46 PM1/4/22
to Android CameraX Discussion Group, softwar...@gmail.com
Hello,

This is Trevor from the CameraX team. Unfortunately the new video APIs don't yet support this. However, we are working on this feature. The legacy restricted VideoCapture class could not guarantee a square aspect ratio on all devices, though many devices may have supported it. We want to make sure this feature will work on all devices, so it will take a bit more time as we work through performance and compatibility issues. Please stay tuned.

Hossein Kheirollahpour

unread,
Jan 5, 2022, 7:24:11 AM1/5/22
to Android CameraX Discussion Group, trevor...@google.com, Hossein Kheirollahpour
Thanks a lot.
We are waiting for this attractive feature.
Best Regards.

Daxesh Nagar

unread,
Dec 26, 2022, 11:50:28 PM12/26/22
to Android CameraX Discussion Group, Hossein Kheirollahpour, trevor...@google.com
Any update on this feature?

Leo Huang

unread,
Dec 27, 2022, 1:25:26 AM12/27/22
to Android CameraX Discussion Group, daxe...@wazirx.com, Hossein Kheirollahpour, Trevor McGuire
Hi,
CameraX Video support WYSIWYG feature since 1.3.0-alpha01 via ViewPort API.
Arbitrary aspect ratio can be set in the ViewPort.Builder()

ex:
ViewPort viewPort = new ViewPort.Builder(new Rational(1, 1), mViewFinder.getDisplay().getRotation())
        .setScaleType(ViewPort.FILL_CENTER)
        .build();
UseCaseGroup useCaseGroup = new UseCaseGroup.Builder()
        .setViewPort(viewPort)
        .addUseCase(preview)
        .addUseCase(videoCapture)
        .build();
mCamera = mCameraProvider.bindToLifecycle(this, mCameraSelector, useCaseGroup);

daxe...@wazirx.com 在 2022年12月27日 星期二中午12:50:28 [UTC+8] 的信中寫道:
Reply all
Reply to author
Forward
0 new messages