On 07/04/2011 06:43 PM, Qianqian Fang wrote:
hi

I am new to android sdk. I need to write a program to process the
camera image frames. I found "setPreviewCallbackWithBuffer()"  from
the sdk documentation, but did not figure out how to get it to work.

Here is my code skeleton:

     public void onResume() {
        super.onResume();
        camera=Camera.open();
         ...
        param.setPreviewSize(preview_size.width,preview_size.height);
        camera.setParameters(param);
        camera.addCallbackBuffer(new byte[bufSize]);
        camera.setPreviewCallbackWithBuffer(bufPreviewCallback);
        camera.startPreview();
     }
     PreviewCallback bufPreviewCallback = new PreviewCallback() {
        public void onPreviewFrame(byte[] data, Camera camera) {
             TextView tv = (TextView)findViewById(R.id.txReading);
             tv.setText("frame done");
         }
     };

I was hoping that the bufPreviewCallback() function gets triggered
every time a frame is available, activated right after the
startPreview() call. However, when I started the program, my txReading
textview never got updated.

using logcat, I figured out why the callback wasn't triggered:
My bufSize was 0 because of pixelinfo.bitsPerPixel wasn't
initialized.

Now I have another problem: the bufPreviewCallback
function was only called once. Is it expected? I appended
camera.startPreview() inside bufPreviewCallback, but
the log message still only print once. How can I call
a function at a rate matching the preview frame
update speed (24Hz?)

thanks

Qianqian




Can anyone tell me if this is the right way to work with
setPreviewCallbackWithBuffer? do I need to call startPreview() inside
bufPreviewCallback, like the case for takePicture?

thanks

Qianqian


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

Reply via email to