应用程序在致命信号11(SIGSEGV)处于0x00000020(代码= 1)之后崩溃 - Android

时间:2012-12-18 13:48:05

标签: android opencv video-capture

我在一个Android应用程序中工作。在我的应用程序中,我使用opencv本机相机捕获图像。当我打开相机捕捉图像时,应用程序崩溃了。显示“致命信号11(SIGSEGV)在0x00000020(代码= 1)”的日志文件。我不知道它为什么会崩溃。谁能告诉我可能出现什么问题?此代码在模拟器中工作。但是当我在设备中使用时,它崩溃了。我使用opencv人脸检测样本。代码段如下,

  /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        Log.i(TAG, "onCreate");
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        Log.i(TAG, "Trying to load OpenCV library");
        if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack))
        {
            Log.e(TAG, "Cannot connect to OpenCV Manager");
        }
    }


private BaseLoaderCallback  mOpenCVCallBack = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS:
                {
                    Log.i(TAG, "OpenCV loaded successfully");

                    // Load native libs after OpenCV initialization
                    System.loadLibrary("detection_based_tracker");

                    // Create and set View
                    mView = new FdView(mAppContext);
                    mView.setDetectorType(mDetectorType);
                    mView.setMinFaceSize(0.2f);
                    setContentView(mView);
                    // Check native OpenCV camera
                    if( !mView.openCamera() ) {
                        AlertDialog ad = new AlertDialog.Builder(mAppContext).create();
                        ad.setCancelable(false); // This blocks the 'BACK' button
                        ad.setMessage("Fatal error: can't open camera!");
                        ad.setButton("OK", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            finish();
                            }
                        });
                        ad.show();
                    }
                } break;
                default:
                {
                    super.onManagerConnected(status);
                } break;
            }
        }
    };
   public FdView(Context context) {
        super(context);

        try {
            InputStream is = context.getResources().openRawResource(R.raw.lbpcascade_frontalface);
            File cascadeDir = context.getDir("cascade", Context.MODE_PRIVATE);
            mCascadeFile = new File(cascadeDir, "lbpcascade_frontalface.xml");
            FileOutputStream os = new FileOutputStream(mCascadeFile);

            byte[] buffer = new byte[4096];
            int bytesRead;
            while ((bytesRead = is.read(buffer)) != -1) {
                os.write(buffer, 0, bytesRead);
            }
            is.close();
            os.close();

            mJavaDetector = new CascadeClassifier(mCascadeFile.getAbsolutePath());
            if (mJavaDetector.empty()) {
                Log.e(TAG, "Failed to load cascade classifier");
                mJavaDetector = null;
            } else
                Log.i(TAG, "Loaded cascade classifier from " + mCascadeFile.getAbsolutePath());

            mNativeDetector = new DetectionBasedTracker(mCascadeFile.getAbsolutePath(), 0);

            cascadeDir.delete();

        } catch (IOException e) {
            e.printStackTrace();
            Log.e(TAG, "Failed to load cascade. Exception thrown: " + e);
        }
    }
    @Override
protected Bitmap processFrame(VideoCapture capture) {
    capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
    capture.retrieve(mGray, Highgui.CV_CAP_ANDROID_GREY_FRAME);

    if (mAbsoluteFaceSize == 0)
    {
        int height = mGray.rows();
        if (Math.round(height * mRelativeFaceSize) > 0);
        {
            mAbsoluteFaceSize = Math.round(height * mRelativeFaceSize);
        }
        mNativeDetector.setMinFaceSize(mAbsoluteFaceSize);
    }

    MatOfRect faces = new MatOfRect();

    if (mDetectorType == JAVA_DETECTOR)
    {
        if (mJavaDetector != null)
            mJavaDetector.detectMultiScale(mGray, faces, 1.1, 2, 2 // TODO: objdetect.CV_HAAR_SCALE_IMAGE
                    , new Size(mAbsoluteFaceSize, mAbsoluteFaceSize), new Size());
    }
    else if (mDetectorType == NATIVE_DETECTOR)
    {
        if (mNativeDetector != null)
            mNativeDetector.detect(mGray, faces);
    }
    else
    {
        Log.e(TAG, "Detection method is not selected!");
    }

    Rect[] facesArray = faces.toArray();
    for (int i = 0; i < facesArray.length; i++)
        Core.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3);

    Bitmap bmp = Bitmap.createBitmap(mRgba.cols(), mRgba.rows(), Bitmap.Config.ARGB_8888);

    try {
        Utils.matToBitmap(mRgba, bmp);
    } catch(Exception e) {
        Log.e(TAG, "Utils.matToBitmap() throws an exception: " + e.getMessage());
        bmp.recycle();
        bmp = null;
    }

    return bmp;
}

日志如下。

I/dalvikvm-heap(  688): Grow heap (frag case) to 7.827MB for 1228816-byte allocation
D/dalvikvm(  688): GC_CONCURRENT freed <1K, 12% free 7852K/8839K, paused 2ms+2ms
D/dalvikvm(  688): GC_FOR_ALLOC freed 1200K, 25% free 6652K/8839K, paused 24ms
I/dalvikvm-heap(  688): Grow heap (frag case) to 7.827MB for 1228816-byte allocation
F/libc    (  688): Fatal signal 11 (SIGSEGV) at 0x00000020 (code=1)
I/DEBUG   (   83): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (   83): Build fingerprint: 'softwinners/crane_q7/crane-q7:4.0.3/IML74K/20120709:eng/test-keys'
I/DEBUG   (   83): pid: 688, tid: 690  >>> com.user.mailconf <<<
I/DEBUG   (   83): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000020
I/DEBUG   (   83):  r0 00000000  r1 000106e0  r2 000106e0  r3 40a091e8
I/DEBUG   (   83):  r4 50a090f8  r5 408d3c58  r6 00000000  r7 000106e0
I/DEBUG   (   83):  r8 50a09000  r9 000106e0  10 50a09100  fp 4085f394
I/DEBUG   (   83):  ip 0000001f  sp 100ffdd0  lr 4084efc4  pc 4085efac  cpsr 80000010
I/DEBUG   (   83):  d0  0000000000000000  d1  0000000000000000
I/DEBUG   (   83):  d2  0000000000000000  d3  0000000000000000
I/DEBUG   (   83):  d4  0000000000000000  d5  0000000000000000
I/DEBUG   (   83):  d6  0000000000000000  d7  0000000000000000
I/DEBUG   (   83):  d8  0000000000000000  d9  0000000000000000
I/DEBUG   (   83):  d10 0000000000000000  d11 0000000000000000
I/DEBUG   (   83):  d12 0000000000000000  d13 0000000000000000
I/DEBUG   (   83):  d14 0000000000000000  d15 0000000000000000
I/DEBUG   (   83):  d16 0000000000000000  d17 991f1f1f991f1f1f
I/DEBUG   (   83):  d18 0707070703030303  d19 0000000000000000
I/DEBUG   (   83):  d20 0100010001000100  d21 0100010001000100
I/DEBUG   (   83):  d22 0000000000000000  d23 0000000000000000
I/DEBUG   (   83):  d24 0000000000000000  d25 0000000000000000
I/DEBUG   (   83):  d26 0067006700670067  d27 0067006700670067
I/DEBUG   (   83):  d28 0067006700670067  d29 0067006700670067
I/DEBUG   (   83):  d30 00308000002b4000  d31 003b40000035c000
I/DEBUG   (   83):  scr 80000012
I/DEBUG   (   83): 
I/DEBUG   (   83):          #00  pc 00042fac  /system/lib/libdvm.so
I/DEBUG   (   83):          #01  pc 00032fc0  /system/lib/libdvm.so (_Z21dvmHeapBitmapScanWalkP10HeapBitmapPFvP6ObjectPvS3_ES3_)
I/DEBUG   (   83):          #02  pc 000433c4  /system/lib/libdvm.so (_Z24dvmHeapScanMarkedObjectsv)
I/DEBUG   (   83):          #03  pc 00033694  /system/lib/libdvm.so (_Z25dvmCollectGarbageInternalPK6GcSpec)
I/DEBUG   (   83):          #04  pc 0007ba40  /system/lib/libdvm.so
I/DEBUG   (   83):          #05  pc 0005f656  /system/lib/libdvm.so
I/DEBUG   (   83):          #06  pc 00012be4  /system/lib/libc.so (__thread_entry)
I/DEBUG   (   83):          #07  pc 00012738  /system/lib/libc.so (pthread_create)
I/DEBUG   (   83): 
I/DEBUG   (   83): code around pc:
I/DEBUG   (   83): 4085ef8c e1a04000 e59f01e0 e1a07001 e79f5000  .@.......p...P..
I/DEBUG   (   83): 4085ef9c e5940000 e59530b0 e1500003 0a00003a  .....0....P.:...
I/DEBUG   (   83): 4085efac e590c020 e31c0101 0a000011 ebfffeb9   ...............
I/DEBUG   (   83): 4085efbc e5940000 e5903020 e3130202 08bd81f0  .... 0..........
I/DEBUG   (   83): 4085efcc e594e008 e2846010 e35e0000 08bd81f0  .....`....^.....
I/DEBUG   (   83): 
I/DEBUG   (   83): code around lr:
I/DEBUG   (   83): 4084efa4 e0888404 e16fcf16 e58d3004 e1a0100a  ......o..0......
I/DEBUG   (   83): 4084efb4 e1a02009 e1c66c33 e088018c e12fff3b  . ..3l......;./.
I/DEBUG   (   83): 4084efc4 e3560000 e59d3004 1afffff5 e5971010  ..V..0..........
I/DEBUG   (   83): 4084efd4 e597800c e068e001 e1a0142e e2844001  ......h......@..
I/DEBUG   (   83): 4084efe4 e2855c01 e1510004 2affffe7 e28dd00c  .\....Q....*....
I/DEBUG   (   83): 
I/DEBUG   (   83): stack:
I/DEBUG   (   83):     100ffd90  00000000  
I/DEBUG   (   83):     100ffd94  408cef90  /system/lib/libdvm.so
I/DEBUG   (   83):     100ffd98  000106e0  [heap]
I/DEBUG   (   83):     100ffd9c  40fdc538  /dev/ashmem/dalvik-heap (deleted)
I/DEBUG   (   83):     100ffda0  000106e0  [heap]
I/DEBUG   (   83):     100ffda4  41165c10  /dev/ashmem/dalvik-heap (deleted)
I/DEBUG   (   83):     100ffda8  00000000  
I/DEBUG   (   83):     100ffdac  80000000  
I/DEBUG   (   83):     100ffdb0  40a0a0b8  /dev/ashmem/dalvik-heap (deleted)
I/DEBUG   (   83):     100ffdb4  4085ef28  /system/lib/libdvm.so
I/DEBUG   (   83):     100ffdb8  41165bf0  /dev/ashmem/dalvik-heap (deleted)
I/DEBUG   (   83):     100ffdbc  408d3c58  /system/lib/libdvm.so
I/DEBUG   (   83):     100ffdc0  4116c158  /dev/ashmem/dalvik-heap (deleted)
I/DEBUG   (   83):     100ffdc4  408d3c58  /system/lib/libdvm.so
I/DEBUG   (   83):     100ffdc8  df0027ad  
I/DEBUG   (   83):     100ffdcc  00000000  
I/DEBUG   (   83): #00 100ffdd0  00100000  [heap]
I/DEBUG   (   83):     100ffdd4  10000100  
I/DEBUG   (   83):     100ffdd8  00000000  
I/DEBUG   (   83):     100ffddc  0001079c  [heap]
I/DEBUG   (   83):     100ffde0  50a09000  
I/DEBUG   (   83):     100ffde4  4084efc4  /system/lib/libdvm.so
I/DEBUG   (   83): #01 100ffde8  408d3c58  /system/lib/libdvm.so
I/DEBUG   (   83):     100ffdec  80000000  
I/DEBUG   (   83):     100ffdf0  ffffffff  
I/DEBUG   (   83):     100ffdf4  000106c8  [heap]
I/DEBUG   (   83):     100ffdf8  000106e0  [heap]
I/DEBUG   (   83):     100ffdfc  408cef90  /system/lib/libdvm.so
I/DEBUG   (   83):     100ffe00  fffffe4c  
I/DEBUG   (   83):     100ffe04  7fffffff  
I/DEBUG   (   83):     100ffe08  00000000  
I/DEBUG   (   83):     100ffe0c  0008b5db  [heap]
I/DEBUG   (   83):     100ffe10  408d3c58  /system/lib/libdvm.so
I/DEBUG   (   83):     100ffe14  4085f3c8  /system/lib/libdvm.so
I/DEBUG   (  992): debuggerd: Jul  9 2012 16:58:08
I/ActivityManager(  144): Process com.user.mailconf (pid 688) has died.
W/ActivityManager(  144): Force removing ActivityRecord{412fd3f8 com.user.mailconf/org.opencv.samples.fd.FdActivity}: app died, no saved state
D/V4L2CameraDevice(   87): stopDevice
D/CallbackNotifier(   87): storeMetaDataInBuffers, false
I/WindowManager(  144): WIN DEATH: Window{41274608 com.user.mailconf/org.opencv.samples.fd.FdActivity paused=false}
W/WindowManager(  144): Force-removing child win Window{4133c958 SurfaceView paused=false} from container Window{41274608 com.user.mailconf/org.opencv.samples.fd.FdActivity paused=false}
D/Zygote  (   85): Process 688 terminated by signal (11)
I/WindowManager(  144): MediaPlayer.is not PlayingVideo
W/WindowManager(  144): Failed looking up window
W/WindowManager(  144): java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@4119ca18 does not exist
W/WindowManager(  144):     at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:7156)
W/WindowManager(  144):     at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:7147)
W/WindowManager(  144):     at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1529)
W/WindowManager(  144):     at android.os.BinderProxy.sendDeathNotice(Binder.java:417)
W/WindowManager(  144):     at dalvik.system.NativeStart.run(Native Method)
I/WindowManager(  144): WIN DEATH: null
V/TabletStatusBar(  210): setLightsOn(true)
D/V4L2CameraDevice(   87): cedarx_hardware_exit ok
W/CameraService(   87): native_window_api_disconnect failed: Broken pipe (-32), api: 6
I/CameraService(   87): Destroying camera 0
D/CallbackNotifier(   87): storeMetaDataInBuffers, false
W/AudioFlinger(   87): session id 7 not found for pid 87
W/AudioFlinger(   87): session id 8 not found for pid 87
D/dalvikvm(  337): GC_FOR_ALLOC freed 162K, 35% free 7073K/10823K, paused 26ms
W/InputManagerService(  144): Got RemoteException sending setActive(false) notification to pid 688 uid 10038
D/dalvikvm(  337): GC_FOR_ALLOC freed 267K, 35% free 7128K/10823K, paused 24ms
I/WindowManager(  144): MediaPlayer.is not PlayingVideo
I/wpa_supplicant(  455): [CTRL_IFACE]SIGNAL_POLL
D/dalvikvm(  337): GC_CONCURRENT freed <1K, 31% free 7536K/10823K, paused 3ms+5ms
D/dalvikvm(  337): GC_FOR_ALLOC freed 654K, 33% free 7322K/10823K, paused 26ms
I/dalvikvm-heap(  337): Grow heap (frag case) to 8.533MB for 1286224-byte allocation
D/dalvikvm(  337): GC_FOR_ALLOC freed 2K, 21% free 8575K/10823K, paused 24ms
D/dalvikvm(  337): GC_CONCURRENT freed 60K, 18% free 8964K/10823K, paused 2ms+4ms
D/dalvikvm(  337): GC_CONCURRENT freed 2240K, 28% free 7843K/10823K, paused 2ms+3ms
I/WindowManager(  144): MediaPlayer.is not PlayingVideo
I/WindowManager(  144): MediaPlayer.is not PlayingVideo
I/wpa_supplicant(  455): [CTRL_IFACE]SIGNAL_POLL
I/ActivityManager(  144): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.user.mailconf/.activity.Accounts} from pid 337
D/ViewRootImpl(  144): pckname = com.user.mailconf
D/dalvikvm(  993): Late-enabling CheckJNI
I/ActivityManager(  144): Start proc com.user.mailconf for activity com.user.mailconf/.activity.Accounts: pid=993 uid=10038 gids={3003, 1015, 1006}
I/dalvikvm(  993): Turning on JNI app bug workarounds for target SDK version 8...
D/OpenGLRenderer(  337): Flushing caches (mode 1)
D/dalvikvm(   85): GC_EXPLICIT freed 37K, 7% free 5611K/6019K, paused 3ms+37ms
D/OpenGLRenderer(  337): Flushing caches (mode 0)
D/dalvikvm(   85): GC_EXPLICIT freed <1K, 7% free 5611K/6019K, paused 3ms+10ms
D/dalvikvm(   85): GC_EXPLICIT freed <1K, 7% free 5611K/6019K, paused 7ms+4ms
I/ActivityThread(  993): Pub com.user.mailconf.messageprovider: com.user.mailconf.provider.MessageProvider
I/HubMail (  993): Loading preferences from DB into Storage
D/dalvikvm(  993): GC_CONCURRENT freed 169K, 6% free 5929K/6279K, paused 2ms+9ms
I/HubMail (  993): Preferences load took 45ms
I/wpa_supplicant(  455): [CTRL_IFACE]SIGNAL_POLL

0 个答案:

没有答案