How can I add thermal effect to YUV image

1.4k views Asked by At

After googling a lot. I find a way to change Preview of a single frame. Correct me if i am wrong.

camera.setPreviewCallback(new PreviewCallback() 

callBack let you get the frame of a Camera in byte. Now you can save it or modify it.

First of all i only want to add thermal or night effect to these byte. How can i add these color(Effects) to YUV Image or byte[] data.

camera.setPreviewCallback(new PreviewCallback() {
                    @Override
                    public void onPreviewFrame(byte[] data, Camera camera) {
                        // TODO Auto-generated method stub
                        Camera.Parameters parameters = camera.getParameters();
                        Size size = parameters.getPreviewSize();
                        YuvImage image = new YuvImage(data, ImageFormat.NV21,
                                size.width, size.height, null);
                        /*Rect rectangle = new Rect();
                        rectangle.bottom = size.height;
                        rectangle.top = 0;
                        rectangle.left = 0;
                        rectangle.right = size.width;
                        ByteArrayOutputStream out2 = new ByteArrayOutputStream();
                        image.compressToJpeg(rectangle, 100, out2);
                        DataInputStream in = new DataInputStream();
                        in.write(out2.toByteArray());*/

                        }
                    }

                });

How to apply filter/effect to YUVImage or byte[] .

And for taking a picture i should use android.hardware.Camera.PictureCallback or setOneShotPreviewCallback()

Edit

I think i find some useful links which help to filter bitmap image.

setPixel Explanation

getPixel and setPixel not working Properly

0

There are 0 answers