RedApparat / Fotoapparat

Making Camera for Android more friendly. 📸
Apache License 2.0
3.82k stars 408 forks source link

is there any feature to show live camera preview? #113

Closed developer-- closed 6 years ago

developer-- commented 7 years ago

I want to add some filters in preview, like gamma and etc

andrewcking commented 7 years ago

You should be able to do this with the .frameProcessor(myFrameProcessor) argument when creating your fotoapparat instance, or are you looking to do something else?

developer-- commented 7 years ago

do you have any example of how to process this frame? I couldn't create bitmap from this frame, tried to get bytes from frame and than converting it to bitmap, but it returns null

paprikanotfound commented 7 years ago

@developer-- The bitmap is null because the image is in NV21 format. Check this to convert the byte[] to bitmap: https://stackoverflow.com/a/32793908/4148930

sksar commented 7 years ago

This library can help, https://github.com/silvaren/easyrs

But i am unable to figure out how to process the frame. I am trying to set the frame.image[] byte array to the new processed one, but as it's final variable i cannot set the value.. How am i supposed to do it then ?

This is my code by the way,

@Override
        public void processFrame(Frame frame) {
            Bitmap outputBitmap = Nv21Image.nv21ToBitmap(rs, frame.image, frame.size.width, frame.size.height);
            Bitmap blurBitmap = Blur.blur(rs, outputBitmap, 20.0f);
            Nv21Image nv21Image = Nv21Image.bitmapToNV21(rs, blurBitmap);
            frame.image[] = nv21Image.nv21ByteArray[]; // This thing is not valid, what is the workaround ?
        }
Diolor commented 6 years ago

Editing a photo/video/surface/preview stream is another topic and nothing this library can do :) Hope you found your solution!