Questions tagged [android-camera2]

The android.hardware.camera2 package provides an interface to fully control many apsects of camera device, e.g. CameraDevice, CaptureRequest-CaptureResult flow, Surfaces, ProcessingImages, setting camera parameters, setting request parameters and so on. It replaces the deprecated Camera class.

From Android Documentation

This package models a camera device as a pipeline, which takes in input requests for capturing a single frame, captures the single image per the request, and then outputs one capture result metadata packet, plus a set of output image buffers for the request. The requests are processed in-order, and multiple requests can be in flight at once. Since the camera device is a pipeline with multiple stages, having multiple requests in flight is required to maintain full framerate on most Android devices. To enumerate, query, and open available camera devices, obtain a CameraManager instance.

Individual CameraDevices provide a set of static property information that describes the hardware device and the available settings and output parameters for the device. This information is provided through the CameraCharacteristics object, and is available through getCameraCharacteristics(String).

1641 questions
12
votes
3 answers

Android Camera2 API YUV_420_888 to JPEG

I'm getting preview frames using OnImageAvailableListener: @Override public void onImageAvailable(ImageReader reader) { Image image = null; try { image = reader.acquireLatestImage(); Image.Plane[] planes = image.getPlanes(); …
Volodymyr Kulyk
  • 6,455
  • 3
  • 36
  • 63
12
votes
4 answers

android camera2 handle zoom

I'm new in Android Camera2 API. I just move my all project to the new Camera2 API. I have used the Camera2Basic example as a starting point. I'm now trying handle zoom by adding this: public boolean onTouchEvent(MotionEvent event) { try { …
Eli Elezra
  • 525
  • 2
  • 4
  • 18
12
votes
3 answers

Nexus 5x reverse landscape sensor fix in a android camera preview app

I am kind of newbie in Android development, so my apologies in advance if my question is trivial. In one part of my app I need a live preview of my rear camera, so I created a custom class which extends SurfaceView and implement…
12
votes
1 answer

How to get continuously frame data from Camera2 API for streaming purpose?

We are working on real time video streaming using Lib streaming library. Lib streaming library supports old Camera api, all is working fine but we required to integrate Camera2 api to Lib streaming library. Some of functionality like video preview…
SAM
  • 121
  • 4
11
votes
2 answers

Recording video using MediaCodec with Camera2 API

I am trying to use MediaCodec to record raw frames from ImageReader in onImageAvailable callback but unable to write a working code. Most of the examples are using Camera 1 API or MediaRecorder. My aim is to capture individual frames process it and…
HimalayanCoder
  • 9,630
  • 6
  • 59
  • 60
11
votes
1 answer

Camera 2 API Video Recording - Auto flash not working

I have implemented a custom camera that records a video using camera2 API. There is an option to set flash to "On", "off", and "Auto". Setting flash to "Auto" is not working while other options are working fine. Here is the code : private void…
iMDroid
  • 2,108
  • 1
  • 16
  • 29
11
votes
6 answers

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

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…
Khushbu Shah
  • 1,603
  • 3
  • 27
  • 45
10
votes
2 answers

Camera2 Pass Images from ImageReader to MediaRecorder

I'm trying to create a Camera2 CameraCaptureSession that is capable of four outputs: On-screen preview (SurfaceView, up to 1080p) Photo capture (ImageReader, up to 8k photos) Video Capture (MediaRecorder/MediaCodec, up to 4k videos) Frame…
10
votes
1 answer

Is it possible to combine Preview, ImageAnalysis, and VideoCapture with CameraX?

Is it possible to bind Preview, ImageAnalysis, and VideoCapture at the same time? Combined in pairs, all possible combinations (ie. Preview+ImageAnalysis, Preview+VideoCapture, and ImageAnalysis+VideoCapture) work perfectly fine but binding all…
Georgios
  • 4,764
  • 35
  • 48
10
votes
2 answers

On Android - how to capture image/video from the wide angle camera?

How to capture images or videos from the camera2 api wide angle camera? or the telescopic camera? I know how to handle camera capture for front & back camera. I just can't understand how to open the camera and choose the wide/telescopic camera? I…
kfir
  • 635
  • 8
  • 27
10
votes
2 answers

Getting android camera2 preview frames without lagging the screen preview

In the original (now deprecated) camera API, we used to be able to get preview frames in the Camera.PreviewCallback and be able to process it (taking possibly very long) and release the buffer to be able to receive another frame, without lagging the…
silvaren
  • 730
  • 6
  • 14
10
votes
1 answer

Zero-copy Camera Processing and Rendering Pipeline on Android

I need to do a CPU-side read-only process on live camera data (from just the Y plane) followed by rendering it on the GPU. Frames shouldn't be rendered until processing completes (so I don't always want to render the latest frame from the camera,…
tangobravo
  • 898
  • 10
  • 24
10
votes
2 answers

Camera2 API Set Custom White Balance & Temperature Color

I'm trying to set a custom value for the White Balance & temperature color in my camera app. I'm using camera2 API and I'm trying different ways to set this value. I found a method from a excel file to get the right RGB Temperature matrix…
Francisco Durdin Garcia
  • 12,540
  • 9
  • 53
  • 95
10
votes
1 answer

Set brightness/contrast in video capture using Android Camera2

I made a video capture app with Camera2 API by following this guide, Is there a provision to change brightness/contrast/exposure settings of the video programatically? I'm trying to capture some low-lit video footage, and I wish to increase the…
Caife
  • 415
  • 1
  • 5
  • 16
9
votes
0 answers

CameraX is using the wide angle camera

I've set up the CameraX to use the the back facing camera requireLensFacing(CameraSelector.LENS_FACING_BACK), but testing on a phone with multiple cameras, it uses the wide angle one. How can I let it use the regular camera…
xatok
  • 905
  • 5
  • 20