Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying modified live camera preview

I've currently made an android app that can display a live preview of the camera, but I'm looking for a way to perform live pixel manipulation (ie, make the image grayscale, sepia-toned, etc.). As of yet I haven't found any code for someone whose done this before.

Any help would be appreciated.

like image 397
Rob Avatar asked Mar 10 '11 17:03

Rob


People also ask

What is camera preview in Android?

PreviewView — Implementation modes To display the camera feed, it uses either a SurfaceView or TextureView , provides a preview surface to the camera when it's ready, tries to keep it valid as long as the camera is using it, and when released prematurely, provides a new surface if the camera is still in use.

How do I change camera preview orientation on Android?

To force portrait orientation: set android:screenOrientation="portrait" in your AndroidManifest. xml and call camera. setDisplayOrientation(90); before calling camera.

How to access camera Android?

Tap the app drawer icon. This opens the list of apps on your Android. If you see the Camera app on the home screen, you don't have to open the app drawer. Just tap Camera or the icon that looks like a camera.

How to access camera using Android studio?

Just click on button present in the toolbar of Android Studio. Select your emulator. Now, your camera app is ready and displayed by the emulator. Now, when you click on camera in the app, your camera will start.


1 Answers

You could use the Camera.Parameters to set the appropriate effect. Read more about it here.

If you want to do the manipulation by yours then use onPreviewFrame of camera. This gives you raw byte[] of YUV format (its by default, you could set it to other formats also. Look here for setting the preview format).

Now you could able to perform any pixel manipulation you want on byte[].

Hope this helps!

like image 61
Vinod Maurya Avatar answered Oct 20 '22 15:10

Vinod Maurya