android-camera2

Why camera2 supported preview size width always bigger than height?

这一生的挚爱 提交于 2019-12-04 05:25:14
问题 I'm working on a project which using camera2 API. When I get the list of supported output preview size using: StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); Size[] choices = map.getOutputSizes(SurfaceTexture.class); the output size list always return values which have width>height despite the fact that screen's width When I use getResources().getDisplayMetrics() (or any similar method) to check width/height it's always return width And

Switch flash in Camera2 API

陌路散爱 提交于 2019-12-04 03:51:20
问题 My problem is when I switch between different flashmodes and then want to capture an image, my captureBuilder won't set the chosen flashmode. It only works when i close and reopen the camera. I took the https://github.com/googlesamples/android-Camera2Basic as a starting point. my method: private void captureStillPicture() { try { final Activity activity = (Activity) context; if (null == activity || null == mCameraDevice) { return; } // This is the CaptureRequest.Builder that we use to take a

Changing Flash setting of Android Camera 2 at runtime

心已入冬 提交于 2019-12-04 03:27:58
问题 Basically, what I am trying to do is change the CONTROL_AE_MODE by button click in the app. The user can use AUTO flash(ON_AUTO_FLASH), turn if ON(ON_ALWAYS_FLASH), or OFF(CONTROL_AE_MODE_OFF). In this example: https://github.com/googlesamples/android-Camera2Basic/blob/master/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java Line 818, they set the flash once: // Use the same AE and AF modes as the preview. captureBuilder.set(CaptureRequest.CONTROL_AF_MODE,

Zero-copy Camera Processing and Rendering Pipeline on Android

早过忘川 提交于 2019-12-03 13:23:46
问题 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, just the latest one that the CPU-side has finished processing). Rendering is decoupled from the camera processing and aims for 60 FPS even if the camera frames arrive at a lower rate than that. There's a related but higher-level question over at:

Get full screen preview with Android camera2

半世苍凉 提交于 2019-12-03 11:31:10
I'm building a custom camera using the new camera2 API. My code is based on the code sample provided by Google here . I can't find a way to get the camera preview in full screen. In the code sample, they use ratio optimization to adapt to all screens but it's only taking around 3/4 of the screen's height. Here is my code of AutoFitTextureView : public class AutoFitTextureView extends TextureView { private int mRatioWidth = 0; private int mRatioHeight = 0; public AutoFitTextureView(Context context) { this(context, null); } public AutoFitTextureView(Context context, AttributeSet attrs) { this

android textureview full screen preview with correct aspect ratio

好久不见. 提交于 2019-12-03 11:19:35
I have been working with the camera2 api demo from google and unfortunately the sample application is built to display the textureview preview at approximately 70% of the screen height, after looking around I was able to determine that this was being caused by the AutoFitTextureView overriding the onMeasure() method as shown below: @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int width = MeasureSpec.getSize(widthMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec); if (0 == mRatioWidth || 0

Camera2basic app, has very dark preview in Android 6.0 LGG3

。_饼干妹妹 提交于 2019-12-03 11:00:41
问题 The new API, perhaps only on LG G3, seems to have something changed. I'm using the sample code. On my nexus 4, the code runs perfectly, but on LGG3 updated to Android 6.0 it does not. Any ideas? I played with the settings, but no luck, this still works fine on Nexus 4: mPreviewRequestBuilder.set(CaptureRequest.BLACK_LEVEL_LOCK, false); mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AWB_LOCK, false); mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE

What's the difference between ActivityCompat and ContextCompat?

给你一囗甜甜゛ 提交于 2019-12-03 10:10:01
I'm trying to use the Android camera, for API 23 or above, it requires asking for permission at runtime. According to the documentation , I can accomplish that using, ActivityCompat or ContextCompat. I don't understand what are the difference between the two and their trade-offs. Thank you for time. I don't understand what are the difference between the two and their trade-offs There's no trade-off really. Not sure why they wrote so - checkSelfPermission() is a method of ContextCompat and ActivityCompat is subclass (child) of ContextCompat so you can pass either one whenever object of

Preview callback in Camera2 is significantly slower than in Camera1

半世苍凉 提交于 2019-12-03 09:29:44
It is 2017 and I am finally starting switching from Camera1 to Camera2. In Camera1 I was greatly relying on setPreviewCallbackWithBuffer() to perform a real time frame processing, however in Camera2 this works much much slower to the point where it becomes almost unusable. To compare, on Moto G3 Camera1 can easily produce 30-40 FPS while on Camera2 I couldn't get more than 10-15 FPS. Here is how I am creating ImageReader imageReader = ImageReader .newInstance( previewSize.width, // size is around 1280x720 previewSize.height, ImageFormat.YUV_420_888, // note, it is not JPEG 2 // max number of

capturing a video using camera2 and MediaRecorder

百般思念 提交于 2019-12-03 09:06:35
i try to record a video with 2 different resolutions at once. Sometimes all goes well and sometimes the app seems to get stuck in of of the stop() methods of the 2 MediaRecorders. Can someone plz look through my code, wheter i'm doing something wrong? package com.example.android.videorecording; import android.app.Activity; import android.app.AlertDialog; import android.content.Intent; import android.hardware.camera2.params.StreamConfigurationMap; import android.media.MediaCodec; import android.media.MediaRecorder; import android.os.Bundle; import android.hardware.camera2.*; import android.os