android-camera2

Camera2 ImageReader freezes repeating capture request

China☆狼群 提交于 2019-11-30 08:27:24
问题 I'm trying to capture image data from the camera using the camera2 API. I've mostly used code taken from the android Capture2RAW example. Only a few images come through (i.e. calls to onImageAvailable) before stopping completely. I've tried capturing using the RAW_SENSOR and JPEG formats at different sizes with the same results. What am I doing wrong? this.mImageReader = ImageReader.newInstance(width, height, ImageFormat.RAW_SENSOR, /*maxImages*/ 1); Surface surface = this.mImageReader

Android Camera2 increase brightness

我与影子孤独终老i 提交于 2019-11-30 07:55:11
问题 I am using android camera2 in my application to take continuous images, Here when I use camera2 getting image preview brightness very dark compare to original camera. I seen this but there is no similar requirement in that answer. I tried to set brightness in camera2 as suggested here: Note that this control will only be effective if android.control.aeMode != OFF. This control will take effect even when android.control.aeLock == true. captureRequestBuilder = cameraDevice.createCaptureRequest

Android convert ImageReader Image to YCbCr_420_SP (NV21) byte array using render script?

走远了吗. 提交于 2019-11-30 06:36:17
I am currently working with Javacv which makes use of the public void onPreviewFrame(byte[] data, Camera camera) camera function. Since camera is deprecated, I have been looking into camera2 and MediaProjection . Both of these libraries make use of the ImageReader class . Currently I instantiate such an ImageReader with the following code: ImageReader.newInstance(DISPLAY_WIDTH, DISPLAY_HEIGHT, PixelFormat.RGBA_8888, 2); And attach an OnImageAvailableListener like this: private final ImageReader.OnImageAvailableListener mOnImageAvailableListener = new ImageReader.OnImageAvailableListener() {

How to programmatically take Photos while recording Video using Camera2 API in Android

扶醉桌前 提交于 2019-11-30 04:01:00
I want to capture image while recording video using camera2 API. Two separate demos are available. 1. To capture image and 2. To record video I tried to combine them into one app. But confused in many things. Like CameraDevice is single which representation of a single camera connected to an Android device. Different template needed in request. For image : mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); and for video mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_RECORD); In createCaptureSession method surface of ImageReader is needed and for video MediaRecorder is

ImageReader makes Camera lag

此生再无相见时 提交于 2019-11-29 22:27:03
问题 I'm facing a problem where I am using a ImageReader in addition to have a SurfaceView which is used to show the output of the camera. I have added the SurfaceView itself and the surface for the ImageReader like this (and added the ImageReader listeners in order to receive events on new images): preview.addTarget(_surfaces.get(1)); //ImageReader surface preview.addTarget(_surfaces.get(0)); //SurfaceView of the layout However, if I remove the ImageReader the application is working fine (no

Android Camera2 API switch back - front cameras

醉酒当歌 提交于 2019-11-29 18:51:09
问题 I'm creating a custom camera capturing videos with the new camera2 API. My code is strongly inspired from the code provided by Google here. My camera preview has a button to switch from back to front camera and then from front to back camera. The "camera preview" activity is launched with the back camera by default. For some reason, when I click on the "switch/swap camera" button for the first time , it brings be to the front camera as it should, BUT everytime I click again, the switch/swap

Full screen preview camera2Basic Example Project

拜拜、爱过 提交于 2019-11-29 17:13:12
I'm trying to modify Google's camera2Basic example code. I removed the <FrameLayout/> containing the "Picture" and "Info" button in an attempt to make the <TextureView/> full screen. However, the preview does not fill the entire screen, there remains a black bar below it. I believe this has something to do with the AutoFitTextureView that it ships with but since they haven't provided any documentation on how it works I am unable to make modifications to it. I noticed this exact same issue before on my Galaxy Note 5 and I believe it had to do with the way they set the aspect ratio - there are

How to use android camera2 api to record 60 fps video with fixed exposure time

懵懂的女人 提交于 2019-11-29 16:00:59
I want to implement a app to record 60 fps with fixed exposure time. As device I have the Google Pixel. Since its native camera app can do 60 fps and it has hardware level LEVEL_3, I thought this won't be a problem but I can't get it working. With getSupportedPreviewFpsRange() (from camera api) I get ranges [15, 15], [24, 24], [7, 30], [30, 30] and with getHighSpeedVideoFpsRangesFor (from camera2 api) I get ranges [30, 120], [120, 120], [30, 240], [240, 240], [240, 240] . When I set [60, 60] to CONTROL_AE_TARGET_FPS_RANGE I get error "Fps range [60, 60] in the request is not a supported high

Camera2 video recording without preview on Android: mp4 output file not fully playable

天涯浪子 提交于 2019-11-29 13:59:48
问题 I am trying to record video from the back camera (the one that faces the face) on my Samsung Galaxy S6 (which supports 1920x1080 at about 30 fps). I do not want to have to use any surface for previewing if I do not have to as this is to just happen in the background. I seem to have it working, but the output files are not playable in a way that actually is correct. On my Windows 10 PC, Windows Media Player will show the first frame and then play the audio, VLC will not show any of the frames.

Face detection & draw circle using Android Camera2 API

不羁岁月 提交于 2019-11-29 12:04:08
问题 Currently I am trying to convert Camera2.Face to actual view's rect in order to draw circle over the face detected by the Camera2 API. I am able to get number of faces and its data into Callback by below code: private CameraCaptureSession.CaptureCallback mCaptureCallback = new CameraCaptureSession.CaptureCallback() { private void process(CaptureResult result) { Integer mode = result.get(CaptureResult.STATISTICS_FACE_DETECT_MODE); Face [] faces = result.get(CaptureResult.STATISTICS_FACES); if