I have not found any way to crop camera ppreview and then display it on the SurfaceView.
Android - Is it possible to crop camera preview?
Using OBS to crop webcam allows you to cut out irrelevant parts of the webcam video. To get a perfect cut, you have to crop from the side of the webcam screen. This is the easiest way to remove irrelevant background from the picture, and there is no better and convenient way to do this than the OBS tool.
To control the camera in your Zoom Room: Start or join a meeting. Tap the Camera Control icon. Use the icons on the Camera Control popup to zoom and pan until the camera is in the position you need.
You can do this without overlay views (which won't work in all situations).
Subclass ViewGroup, add the SurfaceView as the only child, then:
basically,
public class CroppedCameraPreview extends ViewGroup {
private SurfaceView cameraPreview;
public CroppedCameraPreview( Context context ) {
super( context );
// i'd probably create and add the SurfaceView here, but it doesn't matter
}
@Override
protected void onMeasure( int widthMeasureSpec, int heightMeasureSpec ) {
setMeasuredDimension( croppedWidth, croppedHeight );
}
@Override
protected void onLayout( boolean changed, int l, int t, int r, int b ) {
if ( cameraPreview != null ) {
cameraPreview.layout( 0, 0, actualPreviewWidth, actualPreviewHeight );
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With