Ask Your Question
3

Static Initialization on OpenCV Android

asked 2012-10-09 04:58:13 -0600

karthi gravatar image

updated 2012-11-03 09:33:50 -0600

Kirill Kornyakov gravatar image

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 ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2012-10-15 03:26:39 -0600

It looks like you forgot to put native camera libraries to libs folder in your project. Add OPENCV_CAMERA_MODULES:=on and OPENCV_INSTALL_MODULES:=on to your Android.mk file. See tutorial for more details.

edit flag offensive delete link more

Comments

I already added "OPENCV_CAMERA_MODULES:=on and OPENCV_INSTALL_MODULES:=on" in my Android.mk. But I didn't add the libraries into my lib folder. After adding the libs the native camera opened. thanks a lot.

karthi gravatar imagekarthi ( 2012-10-17 02:17:45 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2012-10-09 04:58:13 -0600

Seen: 7,457 times

Last updated: Oct 15 '12