Question

I am developing an android application in which I can do high level image processing and I used custom camera preview to capture images, but when I check logcat after launching the application, I found this message from Choreographer Skipped 440 frames! The application may be doing too much work on its main thread.

My log is as bellow

05-07 10:04:11.480: I/CameraPreview(28340): Orientation Changed
05-07 10:04:11.990: I/Choreographer(28340): Skipped 145 frames!  The application    may be doing too much work on its main thread.
05-07 10:04:15.620: I/Choreographer(28340): Skipped 212 frames!  The application      may be doing too much work on its main thread.
05-07 10:04:20.590: I/CameraPreview(28340): +++++++++++++++++++++++++++++++++++++++
05-07 10:04:20.590: I/CameraPreview(28340): starting recognition process
05-07 10:04:22.490: I/FaceDetector(28340): Number of faces found: 1
05-07 10:04:22.490: I/Value X(28340): 273
05-07 10:04:22.500: I/Value Y(28340): 106
05-07 10:04:22.500: I/Bitmap Width :(28340): 640
05-07 10:04:22.510: I/Bitmap Height :(28340): 480
05-07 10:04:22.520: I/CameraPreview(28340): Bitmap Size : 205 : 201
05-07 10:04:22.520: I/Face Recognition(28340):        ===========================================
05-07 10:04:22.520: I/Face Recognition(28340): recognizeFace (single face)
05-07 10:04:22.550: I/CameraPreview(28340): Previwe Stoped Face Detected....
05-07 10:04:22.550: I/CameraPreview(28340): Stopping preview in SurfaceDestroyed().
05-07 10:04:22.720: I/CameraPreview(28340): Total Recognition process took:       2.127638333
05-07 10:04:22.720: I/Choreographer(28340): Skipped 440 frames!  The application may    be doing too much work on its main thread.
  • I used custom camera preview in onFramePreview() method to frequently capture buffer images and if it contains a "Human Face" then send it for processing.
  • When the image processing part is executed, it's frame is skipped by Choreographer and im not getting expected result.
  • I used OpenCV for the image processing

Please help me to solve this stuff. I searched many times in StackOverflow but not getting a proper answer.

Thanks

Was it helpful?

Solution

Use more threading, Run intensive processes on the background thread, either AsyncTask or use this.

    public Runnable NameOfRunnable = new Runnable()
    {
        @Override
        public void run()
        {
            while (true)
            {
            // TODO add code to refresh in background
                try
                {

                    Thread.sleep(1000);// sleeps 1 second
                    //Do Your process here.
                } catch (InterruptedException e){
            // TODO Auto-generated catch block
            e.printStackTrace();
            }
        }

    }
};

then call

    NameOfRunnable.start();

or

    NameOfRunnable.run();

depends on what you want to do with it, either ui or just back ground info, plus callbacks will help do what you need to do

OTHER TIPS

Is the image processing part being done on the main thread ? If yes then try to do all heavy processing in another thread and after processing is done pass it back to the Main thread. A better alternative would be to use AyncTask and perform the image processing in the doInBackground() method.

Refer to the following tutorial : tutorial

Its like u r doing lot of processing in main thread.You should use a separate thread or asynctask for doing processing or buffering of images and after that can update ui . If using asychtask do background operation in doinBackground() and update ui in onPostExecute and If u use thread then for updating ui u need to call runOnUithread to update the UI

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top