Hi,
Using the CameraPreview example and doing some image processing I
found a strange slow behavior in the Emulator. I have little
experience with java and Android (C/C++ background) so I do not know
if it is a true issue of the emulator or some strange memory/thread
handling that I am not aware.

When the application starts after the emulator starts, the application
is very slow (228 ms per frame).
If I press the "Back" button and then press the application icon, The
applications is about 4 times faster (64ms per frame).

This fast framerate will continue to work and will not go back to the
slow behavior.
I tried launching the emulator from Eclipse and stand alone. Also in
Windows and OSX and the behavior is always the same and happens every
time.

To recreate the slow behavior I just added a couple of lines (intense
CPU usage) to the CameraPreview sample provided by the SDK.The
modified run() part is:

        @Override
                public void run() {
            // We first open the CameraDevice and configure it.
            CameraDevice camera = CameraDevice.open();
            if (camera != null) {
                CameraDevice.CaptureParams param = new
CameraDevice.CaptureParams();
                    param.type = 1; // preview
                    param.srcWidth      = 1280;
                    param.srcHeight     = 960;
                    param.leftPixel     = 0;
                    param.topPixel      = 0;
                    param.outputWidth   = 320;
                    param.outputHeight  = 240;
                    param.dataFormat    = 2; // RGB_565
                camera.setCaptureParams(param);
            }

            // This is our main acquisition thread's loop, we go until
            // asked to quit.
            SurfaceHolder holder = mHolder;

                //
===========================================================
                // Added to check strange behavior
                //
===========================================================
                        long timeMillis = java.lang.System.currentTimeMillis();
                        Paint paint = new Paint();
                        paint.setTextSize(20);
                        paint.setARGB(255, 255, 0, 0);


            while (!mDone) {
                // Lock the surface, this returns a Canvas that can
                // be used to render into.
                Canvas canvas = holder.lockCanvas();

                // Capture directly into the Surface
                if (camera != null) {
                    camera.capture(canvas);

                        //
===========================================================
                        // Added to check strange behavior
                        //
===========================================================
                    int b=3;
                    for(int i=0; i<100000; i++)
                        b=b+1;

                                long timeNew = 
java.lang.System.currentTimeMillis();
                                canvas.drawText("ms=" + (timeNew - timeMillis), 
10, 20,
paint);
                                timeMillis = timeNew;
                }

                // And finally unlock and post the surface.
                holder.unlockCanvasAndPost(canvas);
            }

            // Make sure to release the CameraDevice
            if (camera != null)
                camera.close();
        }
Can someone test it and see if the results are the same? Any ideas?
Thanks
Franco
--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to