Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image processing with Android Camera

I want to use the onPreviewFrame to post-process the image before displaying it to the user (i.e. apply a color tint, sepia, etc). As I understand, the byte[] data returned to the callback is encoded in YUV420sp. Have people been decoding this to RGB in Java or using NDK (native code)? Does anyone have an example of a function that decodes this to RGB and how the RGB values are used afterwards?

Thanks.

like image 415
kevin Avatar asked Dec 07 '10 03:12

kevin


People also ask

What is image processing in Android?

Android allows you to manipulate images by adding different kinds of effects on the images. You can easily apply image processing techniques to add certain kinds of effects on images. The effects could be brightness,darkness, grayscale conversion e.t.c. Android provides Bitmap class to handle images.

What camera is used for image processing?

the RGB camera is the best if considering the three evaluation metrics: data quality, speed, and cost. For specific tasks, stereo images can be used which requires the image depth. So, a stereo camera is needed.

What is camera subsystem?

Camera Subsystem in Android The camera subsystem includes the implementation of fundamental image processing algorithms that converts RAW Bayer output from the camera sensor to a full-fledged image that can be consumed by applications and users.

What is the best way to learn image processing on Android?

OpenCV Android is preferred due to the ease of use on an Android platform, although there maybe limitations. Here are some references that might help: 1.The best way to learn Image Processing on an Android platform is via implementation. Try running and understanding the existing OpenCV4Android Samples on Android Studio/Eclipse.

What is the camera subsystem in Android?

The camera subsystem includes the implementation of fundamental image processing algorithms that converts RAW Bayer output from the camera sensor to a full-fledged image that can be consumed by applications and users. In another article, I have attempted to explain — Android camera hardware architecture.

What happens if camerax receives a new image before processing?

If CameraX receives a new image before the application finishes processing, the new image is saved to the same buffer, overwriting the previous image. Note that ImageAnalysis.Builder.setImageQueueDepth () has no effect in this scenario, and the buffer contents are always overwritten.

Why is my camera device being blocked while camerax is processing?

The blocking occurs across the entire camera device scope: if the camera device has multiple bound use cases, those uses cases will all be blocked while CameraX is processing these images. For example, when both preview and image analysis are bound to a Camera device, then preview would also be blocked while CameraX is processing the images.


2 Answers

I found a sample application that translates the YUV420 into RGB and displays (sort of) real time histograms over the preview image.

http://www.stanford.edu/class/ee368/Android/index.html

like image 194
anelson Avatar answered Oct 13 '22 02:10

anelson


This helps?

Parameters params = mCamera.getParameters();

param.setPreviewFormat(ImageFormat.RGB_565);

mCamera.setParameters(param);

First check if rgb is supported

http://developer.android.com/reference/android/hardware/Camera.Parameters.html#getPreviewFormat%28%29

and then set preview format to rgb

http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setPreviewFormat%28int%29

like image 43
bmkay Avatar answered Oct 13 '22 02:10

bmkay