android-camera2

How to create multiple camera2 previews in most efficient way?

偶尔善良 提交于 2020-01-25 09:00:27
问题 I am trying to create 4 streams of my camera preview on my activity. I created a TextureView which is registered to the camera2 API for the feed and then I set up a listener on the SurfaceView in order to listen to changes for the feed and update the other 3 previews (ImageViews) accordingly. You can see in my code below: private final TextureView.SurfaceTextureListener mSurfaceTextureListener = new TextureView.SurfaceTextureListener() { @Override public void onSurfaceTextureAvailable

How to increase the quality of captured image using Camera 2 API Android?

半城伤御伤魂 提交于 2020-01-24 04:36:04
问题 I am creating Android camera app using google sample. After the phone captures an image there is a difference of image quality. The camera preview has better image quality than the output image. How can I increase the quality of output image? After pinch zoom the difference of quality of preview image and output image even increases. This is my photo fragment and it's base class. 回答1: The only way you have to increase your image quality is increasing your ImageReaderSize to a biggest

camera2 captured picture - conversion from YUV_420_888 to NV21

。_饼干妹妹 提交于 2020-01-19 03:57:27
问题 Via the camera2 API we are receiving an Image object of the format YUV_420_888 . We are using then the following function for conversion to NV21 : private static byte[] YUV_420_888toNV21(Image image) { byte[] nv21; ByteBuffer yBuffer = image.getPlanes()[0].getBuffer(); ByteBuffer uBuffer = image.getPlanes()[1].getBuffer(); ByteBuffer vBuffer = image.getPlanes()[2].getBuffer(); int ySize = yBuffer.remaining(); int uSize = uBuffer.remaining(); int vSize = vBuffer.remaining(); nv21 = new byte

How to zoom the preview using Android CameraX library?

房东的猫 提交于 2020-01-14 14:35:33
问题 I hope to add a function to zoom in preview picture (Please see Image A ) for the sample code at https://github.com/android/camera/tree/master/CameraXBasic I have read the article but the following code doesn't work. How can I zoom the preview with CameraX API 1.0.0-alpha05 ? CameraFragment.kt /** Declare and bind preview, capture and analysis use cases */ private fun bindCameraUseCases() { ... // Apply declared configs to CameraX using the same lifecycle owner CameraX.bindToLifecycle(

Camera2 aspect ratio on Samsung

扶醉桌前 提交于 2020-01-13 19:52:53
问题 I'm using the Camera2 API on an S5, showing a TextureView-based preview at 720x480. With Camera1, the preview looks fine, but with Camera2 its distorted: I'm calling SurfaceTexture.setDefaultBufferSize properly, etc. This seems to work fine on non-Samsung phones. Curiously, if I modify Camera2Basic to use the front-facing camera and 720x480 it has the same distortion: Any idea what may be behind this problem? It seems reminiscent of another Samsung aspect ratio problem I've seen but I'm not

Camera2 aspect ratio on Samsung

ε祈祈猫儿з 提交于 2020-01-13 19:51:26
问题 I'm using the Camera2 API on an S5, showing a TextureView-based preview at 720x480. With Camera1, the preview looks fine, but with Camera2 its distorted: I'm calling SurfaceTexture.setDefaultBufferSize properly, etc. This seems to work fine on non-Samsung phones. Curiously, if I modify Camera2Basic to use the front-facing camera and 720x480 it has the same distortion: Any idea what may be behind this problem? It seems reminiscent of another Samsung aspect ratio problem I've seen but I'm not

How to change aspect ratio of camera2 preview?

邮差的信 提交于 2020-01-13 02:41:47
问题 I try to change the aspect ratio of the Camera2 preview but I fail :-( For cropping I have to use the SCALER_CROP_REGION but I don't get it working. I used the android-Camera2Video example from Google for my tests. In the openCamera method I added the following line: mSensorSize = characteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE); And in startPreview I added this: final int centerX = mSensorSize.width() / 2; final int centerY = mSensorSize.height() / 2; final int

How to change aspect ratio of camera2 preview?

断了今生、忘了曾经 提交于 2020-01-13 02:41:35
问题 I try to change the aspect ratio of the Camera2 preview but I fail :-( For cropping I have to use the SCALER_CROP_REGION but I don't get it working. I used the android-Camera2Video example from Google for my tests. In the openCamera method I added the following line: mSensorSize = characteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE); And in startPreview I added this: final int centerX = mSensorSize.width() / 2; final int centerY = mSensorSize.height() / 2; final int

How to set android camera2 preview and capture size?

天大地大妈咪最大 提交于 2020-01-13 01:29:07
问题 I am using a SurfaceView to show the preview I capture. I want to use width=1080,height=1920 for the preview. Where can I set the size of the preview? I googled for an answer, but they are all for camera version one. I am using the android.hardware.camera2. private void takePreview() { try { final CaptureRequest.Builder previewRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); previewRequestBuilder.addTarget(mSurfaceHolder.getSurface()); mCameraDevice

Parallel Processing with camera2 api android and opencvcamera2

半腔热情 提交于 2020-01-06 05:47:30
问题 I am developing an app where I want to process each frame from the camera and apply some Image processing algorithms on it. I am getting image feed from ImageReader inside onImageAvailable callback and passing it to my cpp code with JNI interface for further processing. This works fine until I perform heavy operations inside my cpp code, after that it starts adding delay and lag to camera preview. is it possible to process on feed images in parallel so I can achieve real-time results? I am