android-camera2

Android camera2 Lens intrinsic calibration

青春壹個敷衍的年華 提交于 2019-12-20 03:56:11
问题 I downloaded an Android camera2 demo, it ran well. Now I want to get the intrinsic matrix of the camera by querying the CameraCharacteristics. My code is private void setUpCameraOutputs(int width, int height) { Activity activity = getActivity(); CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE); try { for (String cameraId : manager.getCameraIdList()) { CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); float[] intrinsic

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

≯℡__Kan透↙ 提交于 2019-12-18 11:33:08
问题 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

How to convert & rotate raw NV21 array image (android.media.Image) from front cam portrait mode in onImageAvailable (android Camera2)?

左心房为你撑大大i 提交于 2019-12-18 03:46:48
问题 Note: All info in my post only goes for Samsung Galaxy S7 device. I do not know how emulators and other devices behave. In onImageAvailable I convert continuously each image to a NV21 byte array and forward it to an API expecting raw NV21 format. This is how I initialize the image reader and receive the images: private void openCamera() { ... mImageReader = ImageReader.newInstance(WIDTH, HEIGHT, ImageFormat.YUV_420_888, 1); // only 1 for best performance mImageReader

Camera2 API Set Custom White Balance & Temperature Color

三世轮回 提交于 2019-12-17 19:11:52
问题 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 [Red,Green,Blue] from the White Balance Value between 100 and 100.000. I attached this method to a Seekbar and its working fine, my problem appear when I try to focus something white, then it becomes pink. Any kind of light looks like a pink torch in the

Android Turn on/off Camera Flash Programmatically with Camera2

一笑奈何 提交于 2019-12-17 18:55:32
问题 I am making a simple application that acts as a flashlight. I need to be able to turn on and off the flash from a button in the application with the Camera2 API, as I get errors with the old camera API. I would like to use a "torch" flashlight, where the camera doesn't have to open in order for the flash to turn on. I know it's possible, as lots of phones have a flash on/off in the quick settings menu, but I can't find any code or tutorials about how to do this. Code: Camera cam = Camera.open

How to use Android's camera or camera2 API to support old and new API versions without deprecation notes?

随声附和 提交于 2019-12-17 03:50:26
问题 The new camera2 API confuses me. I want to develop an app (for Android APIs 10 - 21) which uses the device's camera. As stated here, I should use the "Camera" API. However, when I try to add the "Camera" API (android.hardware.Camera) to the manifest's user features, it is marked as deprecated. On the other hand, I cannot change it to the "camera2" API (android.hardware.camera2) since it is only compatible with Android API 21+ (Android 5 - Lollipop) - Would have linked it too, but I can only

Camera2 api error failed to create capture session

筅森魡賤 提交于 2019-12-13 18:24:37
问题 I am trying to implement the Camera2 api in my android application. When I click the take picture button, the image gets freezes in the preview and error message comes as "Failed to create capture session; configuration failed". The application has minimum api as 21 and I have set the permissions as below: <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android

Camera2 MediaRecorder changes Frame Rate on Galaxy S9

拜拜、爱过 提交于 2019-12-13 17:31:00
问题 I am not able to get a constant framerate with the camera2 API using MediaRecorder on the Galaxy S9 front camera. Essentially I am using the example Project from https://github.com/googlesamples/android-Camera2Video but stripped it down to find the error. I removed the mTextureView and use only the mediaRecorder surface. Here are the relevant code snippets: @Override protected void setUpMediaRecorder() throws IOException { final Activity activity = getActivity(); if (null == activity) {

How to configure the capture size in Camera 2 API

☆樱花仙子☆ 提交于 2019-12-13 16:52:22
问题 I'm making an android camera application. My doubt is how do I pass the supported resolutions as parameters to the camera. So, first I'm getting all the supported resolution sizes: Size[] sizes = configurationMap.getOutputSizes(ImageFormat.YUV_420_888); Log.d("test","size:"+sizes.length); for(Size size : sizes){ Log.d("test", "width: " + size.getWidth() + " height" + size.getHeight()); } Then I'm configuring the input with one of these sizes. InputConfiguration inputConfiguration = new

How to get the distance from an object to android device using camera2 API

冷暖自知 提交于 2019-12-13 16:25:09
问题 I want to get the distance from an object to android device using android camera2 API. In CaptureCallback , I get the value by result.get(CaptureResult.LENS_FOCUS_DISTANCE) and check LENS_STATE, CONTROL_AF_MODE, CONTROL_AF_STATE at the same time. They are "STATIONARY", CONTINUOUS_PICTURE and PASSIVE_FOCUSED . I think the focus distance should be valid and the distance from an object to android device should be 1/focus_distance . But in fact the calculated value is totally different from the