3

您好我正在使用 OpenCV 人脸检测示例(OpenCV 2.4.2)。我已将人脸检测示例更改为 OpenCV 静态初始化。我在我的 FdActivity.java 文件中更改了以下代码。但我无法打开本机相机。当我调用“openCamera()”方法时,它显示“致命错误:无法打开相机!” 警报框。似乎是什么问题?

@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.initDebug()) {
            Log.e(TAG, "Cannot connect to OpenCV Manager");
        } else {
            mOpenCVCallBack.onManagerConnected(LoaderCallbackInterface.SUCCESS);
        }
    }

日志猫:

10-12 09:44:01.604: I/Sample::Activity(676): Instantiated new class org.opencv.samples.fd.FdActivity
10-12 09:44:01.654: I/Sample::Activity(676): onCreate
10-12 09:44:01.704: I/Sample::Activity(676): Trying to load OpenCV library
10-12 09:44:01.704: D/OpenCV/StaticHelper(676): Trying to get library list
10-12 09:44:01.895: E/OpenCV/StaticHelper(676): OpenCV error: Cannot load info library for OpenCV
10-12 09:44:01.895: D/OpenCV/StaticHelper(676): Library list: ""
10-12 09:44:01.895: D/OpenCV/StaticHelper(676): First attempt to load libs
10-12 09:44:01.895: D/OpenCV/StaticHelper(676): Trying to init OpenCV libs
10-12 09:44:01.895: D/OpenCV/StaticHelper(676): Trying to load library opencv_java
10-12 09:44:01.895: D/dalvikvm(676): Trying to load lib /data/data/com.face.conf/lib/libopencv_java.so 0x411e3cc0
10-12 09:44:02.134: D/dalvikvm(676): Added shared lib /data/data/com.face.conf/lib/libopencv_java.so 0x411e3cc0
10-12 09:44:02.164: D/OpenCV/StaticHelper(676): OpenCV libs init was ok!
10-12 09:44:02.164: D/OpenCV/StaticHelper(676): First attempt to load libs is OK
10-12 09:44:02.164: I/Sample::Activity(676): OpenCV loaded successfully
10-12 09:44:02.164: I/Sample::Activity(676): OpenCV loaded successfully
10-12 09:44:02.174: D/dalvikvm(676): Trying to load lib /data/data/com.face.conf/lib/libdetection_based_tracker.so 0x411e3cc0
10-12 09:44:02.185: D/dalvikvm(676): Added shared lib /data/data/com.face.conf/lib/libdetection_based_tracker.so 0x411e3cc0
10-12 09:44:02.185: D/dalvikvm(676): No JNI_OnLoad found in /data/data/com.face.conf/lib/libdetection_based_tracker.so 0x411e3cc0, skipping init
10-12 09:44:02.394: I/Sample::SurfaceView(676): Instantiated new class org.opencv.samples.fd.FdView
10-12 09:44:02.654: I/Sample::FdView(676): Loaded cascade classifier from /data/data/com.face.conf/app_cascade/lbpcascade_frontalface.xml
10-12 09:44:02.654: D/dalvikvm(676): Trying to load lib /data/data/com.face.conf/lib/libdetection_based_tracker.so 0x411e3cc0
10-12 09:44:02.654: D/dalvikvm(676): Shared lib '/data/data/com.face.conf/lib/libdetection_based_tracker.so' already loaded in same CL 0x411e3cc0
10-12 09:44:02.924: I/Sample::SurfaceView(676): openCamera
10-12 09:44:02.924: I/Sample::SurfaceView(676): releaseCamera
10-12 09:44:02.934: D/CAMERA_ACTIVITY(676): Library name: libopencv_java.so
10-12 09:44:02.934: D/CAMERA_ACTIVITY(676): Library base address: 0x4ac0c000
10-12 09:44:02.984: D/CAMERA_ACTIVITY(676): Libraries folder found: /data/data/com.face.conf/lib/
10-12 09:44:02.984: D/CAMERA_ACTIVITY(676): CameraWrapperConnector::connectToLib: folderPath=/data/data/com.face.conf/lib/
10-12 09:44:02.984: E/CAMERA_ACTIVITY(676): CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library
10-12 09:44:02.984: E/CV_CAP(676): Native_camera returned opening error: 4
10-12 09:44:02.984: E/Sample::SurfaceView(676): Failed to open native camera
10-12 09:44:03.234: D/dalvikvm(676): GC_CONCURRENT freed 210K, 4% free 8461K/8775K, paused 33ms+33ms, total 149ms
10-12 09:44:03.564: I/Sample::Activity(676): onResume
10-12 09:44:03.584: I/Sample::SurfaceView(676): openCamera
10-12 09:44:03.584: I/Sample::SurfaceView(676): releaseCamera
10-12 09:44:03.584: D/CAMERA_ACTIVITY(676): Library name: libopencv_java.so
10-12 09:44:03.584: D/CAMERA_ACTIVITY(676): Library base address: 0x4ac0c000
10-12 09:44:03.634: D/CAMERA_ACTIVITY(676): Libraries folder found: /data/data/com.face.conf/lib/
10-12 09:44:03.634: D/CAMERA_ACTIVITY(676): CameraWrapperConnector::connectToLib: folderPath=/data/data/com.face.conf/lib/
10-12 09:44:03.634: E/CAMERA_ACTIVITY(676): CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library
10-12 09:44:03.634: E/CV_CAP(676): Native_camera returned opening error: 4
10-12 09:44:03.634: E/Sample::SurfaceView(676): Failed to open native camera
10-12 09:44:04.254: I/Choreographer(676): Skipped 185 frames!  The application may be doing too much work on its main thread.
10-12 09:44:04.924: I/Sample::SurfaceView(676): surfaceCreated
10-12 09:44:04.945: I/Sample::SurfaceView(676): surfaceChanged
10-12 09:44:04.945: I/Sample::SurfaceView(676): Starting processing thread
10-12 09:44:04.964: I/Sample::SurfaceView(676): setupCamera(800, 442)
10-12 09:44:05.054: I/Sample::SurfaceView(676): Finishing processing thread
10-12 09:44:05.054: E/OBJECT_DETECTOR(676): SimpleHighguiDemoCore::stop is called but the SimpleHighguiDemoCore pthread is not active
10-12 09:44:05.194: I/Choreographer(676): Skipped 231 frames!  The application may be doing too much work on its main thread.
10-12 09:44:05.245: D/gralloc_goldfish(676): Emulator without GPU emulation detected.
10-12 09:44:05.944: I/Choreographer(676): Skipped 40 frames!  The application may be doing too much work on its main thread.
10-12 09:44:06.814: I/Choreographer(676): Skipped 69 frames!  The application may be doing too much work on its main thread.
10-12 09:44:12.354: I/Sample::Activity(676): onPause
10-12 09:44:12.414: I/Sample::SurfaceView(676): releaseCamera
10-12 09:44:14.084: D/dalvikvm(676): GC_CONCURRENT freed 146K, 3% free 8713K/8967K, paused 31ms+26ms, total 156ms
10-12 09:44:14.923: I/Choreographer(676): Skipped 495 frames!  The application may be doing too much work on its main thread.
10-12 09:44:15.083: I/Sample::SurfaceView(676): surfaceDestroyed
10-12 09:44:15.083: I/Sample::SurfaceView(676): releaseCamera
10-12 09:44:16.253: I/Choreographer(676): Skipped 230 frames!  The application may be doing too much work on its main thread.
10-12 09:44:17.313: I/Choreographer(676): Skipped 211 frames!  The application may be doing too much work on its main thread.
10-12 09:44:18.873: I/Choreographer(676): Skipped 85 frames!  The application may be doing too much work on its main thread.
4

1 回答 1

8

最后我解决了这个问题。问题是当我进行 ndk 构建时,OpenCV 本机库没有复制到项目库文件夹中。所以我已经手动将相应的 OpenCV 原生库从“/sdk/native/libs/”复制到我的项目“/libs/”中。现在它工作正常。

于 2012-10-17T10:50:28.207 回答