Preview Data in camera is yuv420sp style data. But the data delivered in datacallback is jpeg data. How to convert yuv420sp data to jpeg data before datacallback?
It is very difficult to convert in JAVA layer. So what else method you have?
No need to convert. The Camera.PictureCallBack returns a JPEG.
See "http://developer.android.com/reference/android/hardware/Camera.html#takePicture(android.hardware.Camera.ShutterCallback, android.hardware.Camera.PictureCallback, android.hardware.Camera.PictureCallback, android.hardware.Camera.PictureCallback)"
Related
I am using CameraX to obtain frames from the camera for further analysis. The callback returns ImageProxy object that contains 3 planes of YUV_420_888 image. Now, I want to pass this image to 3rd party library for further processing. The function there accepts one dimensional byte array with "raw image data" - as documentation says. I don't understand how can I convert those 3 arrays (Y, U, V) into one byte array.
I have tried to convert it into Bitmap and then to byte array but the library returns that input is invalid. I have also tried to take only one channel from YUV and pass it to the library and it worked but the results were poor because (as I am guessing) one channel didn't carry enough information for the algorithms.
How can I merge Y, U and V channels into one byte array?
I'm just started with Tango and Unity, and need to find a way to get raw RGB or YUV data from the device camera in order to pass it further for processing. This processing requires me to provide either ARGB array or three Y,U,V buffers. How shall I approach this?
I need something similar to OnTangoImageAvailableEventHandler callback - however, it gives me an array of bytes which is a YUV image and I have no way of getting individual Y,U or V planes, neither strides for each plane.
YUV byte array can be transformed to RGB using function mentioned here:
Confusion on YUV NV21 conversion to RGB.
Using that function you can get R, G and B values.
I am doing android native development using libjpeg9. The image data I get from android camera is compressed in jpeg format. Then the data is transferred to native c++ function as an unsigned char* array. As required by function jpeg_mem_src JPP((j_decompress_ptr cinfo,unsigned char * inbuffer,unsigned long insize)) of libjpeg9, the size of the array which is the 'inbuffer' parameter should be provided.
As far as I know, sizeof function cannot be used to get the size of the array because it is only a pointer. We also do not want to change the interface of our c++ function to transfer the size of the array.
So I want to get the size of the array from the header of jpeg. Does anyone know the position of the header where I can get the size of this jpeg image array size?
Any help will be appreciated!
Does anyone know the position of the header where I can get the size of this jpeg image array size?
There isn't one.
Any help will be appreciated!
Change the interface of your c++ function to transfer the size of the array.
i'm trying to get data from onPreviewFrame(byte[] data, Camera camera)
and convert it to BASE64,
Base64.encodeToString(data, Base64.DEFAULT)
the result given is not convertible to an image
(using some sites like http://codebeautify.org/base64-to-image-converter)
note that data is a signed byte array that contain some negative values (values between -128 to 127), i think it should be array of unsigned byte, no?
can you help me please, how to get a BASE64 from onPreviewFrame?
thanks,
I have bitmap in RGB565 format I want to convert it to YUV420/NV21
I found this here
How to convert RGB565 to YUV420SP faster on android?
but it does not have respective JNI call written there to be used in android code any clean java code for same if some one know ?