Peter and Jeff,

Thanks for each of your fantastic help, I am very close to achieving a
filtered preview display as required for my project - Modification of
the Android Camera Display from onPreviewFrame.

Here is my current stumbling block:
I can't seem to make coexist: SurfaceHolder for the camera & ImageView
for the filtered Bitmap to display.

One must assign the Camera preview display into a SurfaceHolder in
order to get preview callbacks:
        mCamera.setPreviewDisplay(surfaceHolder);
The SurfaceHolder's Surface must be a child of the current View in
order to receive surfaceCreated, surfaceChanged, and surfaceDestroyed
callbacks.
I have been using an ImageView object to display the Bitmap into which
I am writing my decoded preview data via an int[] array.

Therefore, both the SurfaceView and the ImageView seem to have to be
children of the same ViewGroup, which is currently displayed.
However, as soon as I add the ImageView to the ViewGroup via:
        linearLayout.addView(imageView);  or
        absoluteLayout.addView(imageView); etc.
My Activity stops receiving Camera preview callbacks onPreviewFrame
().  LogCat indicates an AndroidRuntime "ERROR: thread attach failed"
error.  I am not sure if this is related.

I have tried setting the Surface to the same size as the Camera
preview size setting in the surfaceChanged callback:
        Camera.Parameters parameters = mCamera.getParameters();
        final Size preSz = parameters.getPreviewSize();
        mHolder.setFixedSize(preSz.width, preSz.height);

I tried to create and manage the Surface (needed by Camera preview)
outside of the SurfaceHolder callbacks using the Activity's onResume
and onPause methods.  I did this so that I would not have to put the
SurfaceView into the active display hierarchy (i.e. remove as child of
current View) so that it would not conflict with the ImageView as
above.  Unfortunately, this causes a Camera exception "app passed NULL
surface" - directly after my call to:
        surfaceView = new SurfaceView(this);
        mHolder = surfaceView.getHolder();
        // mHolder.addCallback(this);


Do you know why I can't make the Camera's Surface and an ImageView
Bitmap simultaneous members of the same active ViewGroup?

Thanks again.  Your generous responses help me more than you might
realize.

 - Regards, David Manpearl

On Nov 25, 12:47 am, blindfold <[EMAIL PROTECTED]> wrote:
> How come I recognize so many of these findings? ;-)
>
> > 4. I believe that processing breaks down whenever I spend too much
> > time in the onPreviewFrame function.
>
> That's what I observed too: so do the heavy duty image processing
> outside onPreviewFrame(), with supplementary frame skipping and
> subsampling as needed. Then there is no problem quitting the app
> either.
>
> > I'd incurr an extra copy of the YUV_422 byte[] buffer from
> > onCameraFrame into the Thread prior to processing.
>
> Yes, you need to take care of the limited data[] lifetime in
> onPreviewFrame().
>
> > Between this and skipping frames that overlap the frame-processing thread,
> > this might drastically reduce the filter/display speed.
>
> I doubt that the buffer copying matters (especially when using
> arraycopy) as compared to the time lost in decoding the preview image
> (pixel-by-pixel) for lack of an Android API with a native decoding
> method for the preview format(s).
>
> > I've looked at various offsets within each expected set of 6 bytes for each 
> > 2 pixels.
>
> For the Y (luminance) part just use the first block in data[]: the
> colors are not interleaved with Y; Y is in one block of bytes with
> offset zero in data[], with one byte per pixel. So decoding Y is easy,
> and identical for emulator and G1 (except for the stride due to
> preview image size differences: default 176x144 vs 480x320).
>
> Regards
--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to