Hello,
I've been working on creating a program that will output the Camera
Preview with various user-chosen filters (SnapPhoto has this
functionality) and I've run into some problems.

I have the following set up.
- Camera preview set to a SurfaceView (I had to set PUSH_BUFFERS or
the program fails).
- Have another SurfaceView lieing over the Camera preview SurfaceView
(in a FrameLayout)
- Registered a camera callback for the preview data

My problem is that the output is extremely choppy and the program
quickly becomes unresponsive. I've set up a thread to do the
processing, but this doesn't seem to help. I've implemented the
decoding (into rgb_8888) algorithm (courtesy of dmanpearl
http://groups.google.com/group/android-developers/msg/d3b29d3ddc8abf9b
) Is there anything I'm doing blatantly wrong or something I could fix
to make this program run at a decent speed? Sorry if the code has poor
style, I'm sort of an Android beginner and, for that matter, Java
beginner.

This code is inside the second SurfaceView, lieing over the Camera
preview SurfaceView

public void onPreviewFrame(byte[] data, Camera camera) {
                if(hasSurface) {
                                System.arraycopy(data, 0, _data, 0, 
data.length);
                                outputThread = new HandleOutput();
                                outputThread.start();
                }
        }

where HandleOutput() extends Thread, and _data is a global array.

and this is inside the Thread

public void run() {
                        while(!done) {
                                canvas = mHolder.lockCanvas();
                                PixelManip.decodeYUV(rgb, _data, width, 
height); //courtesy of
dmanpearl (link above)
                                PixelManip.applyFilter(filterID, _data, rgb);
                                bitmap.setPixels(rgb, 0, width, 0, 0, width, 
height);
                                canvas.drawBitmap(bitmap, 0, 0, paint);
                                mHolder.unlockCanvasAndPost(canvas);
                                done = true;
                        }
                }

Thanks,
Greg

P.S. Let me know if I should post any more code.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to