Static Initialization on OpenCV Android
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.
10-12 09:44:19.513: E/WindowManager(676): Activity org.opencv.samples.fd.FdActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41284ed8 that was originally added here
10-12 09:44:19.513: E/WindowManager(676): android.view.WindowLeaked: Activity org.opencv.samples.fd.FdActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41284ed8 that was originally added here
10-12 09:44:19.513: E/WindowManager(676): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:374)
10-12 09:44:19.513: E/WindowManager(676): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:292)
10-12 09:44:19.513: E/WindowManager(676): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)
10-12 09:44:19.513: E/WindowManager(676): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
10-12 09:44:19.513: E/WindowManager(676): at android.view.Window$LocalWindowManager.addView(Window.java:547)
10-12 09:44:19.513: E/WindowManager(676): at android.app.Dialog.show(Dialog.java:277)
10-12 09:44:19.513: E/WindowManager(676): at org.opencv.samples.fd.FdActivity$1.onManagerConnected(FdActivity.java:59)
10-12 09:44:19.513: E/WindowManager(676): at org.opencv.samples.fd.FdActivity.onCreate(FdActivity.java:170)
10-12 09:44:19.513: E/WindowManager(676): at android.app.Activity.performCreate(Activity.java:5008)
10-12 09:44:19.513: E/WindowManager(676): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
10-12 09:44:19.513: E/WindowManager(676): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
10-12 09:44:19.513: E/WindowManager(676): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
10-12 09:44:19.513: E/WindowManager(676): at android.app.ActivityThread.access$600(ActivityThread.java:130)
10-12 09:44:19.513: E/WindowManager(676): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
10-12 09:44:19.513: E/WindowManager(676): at android.os.Handler.dispatchMessage(Handler.java:99)
10-12 09:44:19.513: E/WindowManager(676): at android.os.Looper.loop(Looper.java:137)
10-12 09:44:19.513: E/WindowManager(676): at android.app.ActivityThread.main(ActivityThread.java:4745)
10-12 09:44:19.513: E/WindowManager(676): at java.lang.reflect.Method.invokeNative(Native Method)
10-12 09:44:19.513: E/WindowManager(676): at java.lang.reflect.Method.invoke(Method.java:511)
10-12 09:44:19.513: E/WindowManager(676): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-12 09:44:19.513: E/WindowManager(676): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-12 09:44:19.513: E/WindowManager(676): at dalvik.system.NativeStart.main(Native Method)