3

Hi I am using OpenCV face-detection sample(OpenCV 2.4.2). I have changed the face-detection sample to OpenCV static initialization. I changed the below code in my FdActivity.java file. But I am not able to open native camera. when I call the "openCamera()" method it shows "Fatal error: can't open camera!" alert box. what seems to be the problem?

@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);
        }
    }

logcat:

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.
1
  • 1
    @Astor: I have added the logcat output with my question. Commented Oct 15, 2012 at 3:50

1 Answer 1

8

Finally I fixed the issue. The problem is the OpenCV native libs are not copied into the project lib folder, when I did ndk build. So I have copied the corresponding OpenCV native libs from "/sdk/native/libs/" to my project "/libs/" manually. Now It works fine.

Sign up to request clarification or add additional context in comments.

1 Comment

See docs.opencv.org/doc/tutorials/introduction/… -- there are makefile settings that copy them automatically, if you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.