android-camera2

android camera2 api - onImageAvailable is not invoked after session.capture

让人想犯罪 __ 提交于 2020-08-19 08:48:08
问题 I am trying to use camera api2 to capture images. The code worked fine on MOTO g4, but when I test the code on NEXUS 6, the onImageAvailable is not invoked after session.capture, and no image has been saved. Really frustrated, greatly appreciated if someone could help! Thanks so much. ImageReader reader = ImageReader.newInstance(width, height, ImageFormat.JPEG, 1); List<Surface> outputSurfaces = new ArrayList<Surface>(2); outputSurfaces.add(reader.getSurface()); outputSurfaces.add(new Surface

How to zoom camera using android camera2 API

夙愿已清 提交于 2020-07-08 01:55:29
问题 I m using Camera2 Api for my app. I have a zoom in out function. I am able to zoom in and zoom out using pinch gesture. But how do I implement the same using a seekbar. 回答1: The code to zoom: int mProgress; { minZoom = getMinZoom(); maxZoom = getMaxZoom() - 1; final int zoomStep = 1; seekBarCardZoom.setMax(Math.round(maxZoom - minZoom)); seekBarCardZoom.setOnSeekBarChangeListener( new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) {

Android Camera 2: ImageReader's Images Have no Stride Values

為{幸葍}努か 提交于 2020-06-29 04:44:40
问题 I've been trying to route the images from the camera to an ImageReader so that I can manipulate the images directly using the Camera2 API. When I have the capture session stream to a SurfaceView, the stream works just fine. When I then set the capture session stream to my ImageReader, I notice that the images are somehow invalid. In my ImageReader's OnImageAvailable callback function, I pull the next available Image and try to read it. This is where I have the problem. The Image isn't null

preview stretches in camera2 apis

◇◆丶佛笑我妖孽 提交于 2020-06-24 20:51:52
问题 Following are the screenshots when using texture view in camera2 apis.In full screen the preview stretches,but it works when using lower resolution(second image). How to use this preview in full screen without stretching it. 回答1: Below answer assumes you are in portrait mode only. Your question is How to use the preview in full-screen without stretching it Let's break it down to 2 things: You want the preview to fill the screen The preview cannot be distorted First you need to know that this

preview stretches in camera2 apis

二次信任 提交于 2020-06-24 20:51:27
问题 Following are the screenshots when using texture view in camera2 apis.In full screen the preview stretches,but it works when using lower resolution(second image). How to use this preview in full screen without stretching it. 回答1: Below answer assumes you are in portrait mode only. Your question is How to use the preview in full-screen without stretching it Let's break it down to 2 things: You want the preview to fill the screen The preview cannot be distorted First you need to know that this

How to pass input configuration to camera 2 android

一世执手 提交于 2020-06-13 09:27:06
问题 I am developing an android camera application, and I wanted to pass in the capture size to configure the camera before taking a picture. This is my code: try { mCaptureRequestBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); mCaptureRequestBuilder.addTarget(previewSurface); InputConfiguration inputConfiguration = new InputConfiguration(1920, 1080, ImageFormat.JPEG); //error here. cameraDevice.createReprocessableCaptureSession(inputConfiguration, Arrays.asList

Turning on/off flash with Android camera2 API not working

折月煮酒 提交于 2020-06-10 05:19:58
问题 I'm creating an Android app with a custom camera and I'm switching to the new camera2 API. I have a button allowing to turn ON and OFF the flash when the back camera is on (without stopping the camera, like any classic camera app). When I tap the flash icon, nothing happens and this is what the logcat returns: D/ViewRootImpl: ViewPostImeInputStage processPointer 0 D/ViewRootImpl: ViewPostImeInputStage processPointer 1 I don't know why it's not working. Here is the code: I have a

CameraX equivalent of Camera2's CaptureRequest

十年热恋 提交于 2020-06-02 04:34:49
问题 I want to use ImageAnalysis with CameraX, but adjust some Camera settings such as auto-focus or auto-white balance, exposure and frame duration. Here's an example of the settings I need and how I set them with Camera2: captureRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_OFF) captureRequestBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CameraMetadata.CONTROL_AWB_MODE_OFF) captureRequestBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, FRAME_DURATION_NS)

Overlapping GLSurfaceView on SurfaceView and vice versa

浪子不回头ぞ 提交于 2020-06-01 05:31:05
问题 ExoPlayer - SurfaceView Camera2 + MediaCodec - GLSurfaceView I am using the above view groups for playing video and camera recording. UI-1: Exo-Surf at the center and Cam-GLS in the top right corner. UI-2: Cam-GLS at the center and Exo-Surf in the top right corner. To achieve this I am using setZOrderOnTop to set z-index, as both are inside RelativeLayout. (exoPlayerView.videoSurfaceView as? SurfaceView)?.setZOrderOnTop(true/false) It seems working fine on Samsung S9+ with API 29 - Android 10

Camera2 API Make Preview Fill Entire View

坚强是说给别人听的谎言 提交于 2020-05-27 10:36:32
问题 I am using the Camera2Basic example from Google Samples (https://github.com/googlesamples/android-Camera2Basic) to display a camera preview inside a fragment. This fragment contains a RelativeLayout and a custom AutoFitTextureView. The latter can be found on the link above. I have adjusted the layout to center the preview and remove control buttons: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match