How can I add thermal effect to YUV image

柔情痞子 提交于 2019-11-26 23:33:45

问题


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

来源:https://stackoverflow.com/questions/29645950/how-can-i-add-thermal-effect-to-yuv-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!