2

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

Community
  • 1
  • 1
Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300
  • Are you trying to alter the preview and have it appear on the screen altered. In other words intercept the frame on its way to be shown? – ChiefTwoPencils Apr 15 '15 at 09:07
  • Yes I want to alter the Preview of Camera and also want to save that alter frame when CaptureImage button clicks. – Zar E Ahmer Apr 15 '15 at 10:13
  • See *[Apply custom filters to camera output](https://stackoverflow.com/a/8372731/192373)* or *[How to add real time filtering effects in camera 2 API in Android](https://stackoverflow.com/a/34862846/192373)*. Even though the latter speaks about the **camera2** API, the same approach is applicable to the old *deprecated* Camera API, too. The advantage of this approach is that all processing is done by the camera itself, and is very efficient. The drawback is that the set of possible effects and their exact result may change from one device to the other. – Alex Cohn Jun 25 '20 at 08:39

0 Answers0