Ask Your Question
2

Static Initialization Problem

asked 2012-09-26 12:28:38 -0600

Droidkie gravatar image

updated 2012-11-03 09:34:37 -0600

Kirill Kornyakov gravatar image

i'm trying to run OpenCV Tutorial 1 - Add OpenCV with static initialization using dev_with_OCV_on_Android.html#application-development-with-static-initialization (i don't want a separate OpenCV Manager application installed) but i get an "OpenCV error: Cannot load info library for OpenCV." i did the following things:

  1. added a libs folder with armeabi, armeabi-v7a, and x86 folders inside of it (from OpenCV-2.4.2-android-sdk/sdk/native/libs/>
  2. added the static{if (!OpenCVLoader.initDebug())} code just below private Sample1View mView;
  3. removed the if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack)) code

what seems to be the problem?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
5

answered 2012-09-27 08:18:25 -0600

Andrey Pavlenko gravatar image

updated 2012-09-28 10:18:46 -0600

When you've removed

if (!OpenCVLoader.initAsync(...

code block then nobody calls

mOpenCVCallBack.onManagerConnected()

that creates View class and opens Camera. Add the call

mOpenCVCallBack.onManagerConnected(LoaderCallbackInterface.SUCCESS);

to the OnCreate() methods as a quick dirty fix.

BTW, the "OpenCV error: Cannot load info library for OpenCV" message doesn't indicate an error, look at the further log lines to see that "OpenCV libs init was ok!"

Here is complete diff:

--- OpenCV-2.4.2-android-sdk\samples\tutorial-1-addopencv\src\org\opencv\samples\tutorial1\Sample1Java.java
+++ OpenCV-2.4.2-android-sdk\samples\tutorial-1-addopencv\src\org\opencv\samples\tutorial1\Sample1Java.java.modified
@@ -21,6 +21,11 @@
     private MenuItem            mItemPreviewCanny;
     private Sample1View         mView;

+static {
+    if (!OpenCVLoader.initDebug()) {
+   //TBD!!!
+    }
+}
     private BaseLoaderCallback  mOpenCVCallBack = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
@@ -91,10 +96,11 @@
         requestWindowFeature(Window.FEATURE_NO_TITLE);

         Log.i(TAG, "Trying to load OpenCV library");
-        if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack))
+        /*if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack))
         {
            Log.e(TAG, "Cannot connect to OpenCV Manager");
-        }
+        }*/
+   mOpenCVCallBack.onManagerConnected(LoaderCallbackInterface.SUCCESS);
     }

     @Override
edit flag offensive delete link more

Comments

i did what you posted but it still doesn't work. here is the log: <pre>Trying to get library list OpenCV error: Cannot load info library for OpenCV Library list: "" First attempt to load libs Trying to init OpenCV libs Trying to load library opencv_java Trying to load lib /data/data/org.opencv.samples.tutorial1/lib/libopencv_java.so Shared lib '/data/data/org.opencv.samples.tutorial1/lib/libopencv_java.so' already loaded in same CL OpenCV libs init was ok! First attempt to load libs is OK </pre>

Droidkie gravatar imageDroidkie ( 2012-09-27 09:13:14 -0600 )edit
1

The lines: <pre> OpenCV libs init was ok!First attempt to load libs is OK </pre> mean that OpenCV library is loaded OK, so the problem is in app code. I tried what is described and tutorial-1 app started OK on my side. Could you specify the HW & SW of your device?

Andrey Pavlenko gravatar imageAndrey Pavlenko ( 2012-09-27 09:27:09 -0600 )edit

i don't know where i went wrong. using Samsung Galaxy Mini 2 that has Android OS, v2.3.6 (Gingerbread). if it's ok with you, may i have a copy of your project so that i can check what i'm doing wrong? [email protected]

Droidkie gravatar imageDroidkie ( 2012-09-27 09:35:02 -0600 )edit
1

I've added the complete diff to my answer. All that you need in addition to the provided changes is to copy the libs folder from OpenCV-2.4.2-android-sdk/sdk/native folder to your project folder.

Andrey Pavlenko gravatar imageAndrey Pavlenko ( 2012-09-28 10:21:06 -0600 )edit

i still get a black screen. when i press Preview RGA, Preview GRAY or Canny, i get "The application has stopped unexpectedly. Please try again."

Droidkie gravatar imageDroidkie ( 2012-09-29 20:16:16 -0600 )edit

I have the same problem. At this point...I just feel stupid. I did everything exactly like in the tutorial...I've read all the related questions in the forum and I'm still getting a black screen. I'm using OpenCV4Android 2.4.3 & Android Version 4.1.2. I'm also using an OpenCV4Android example without JNI....so it's not that difficult...actually. But I just can't figure it out -.- ...

jjbluesky gravatar imagejjbluesky ( 2013-02-28 15:14:12 -0600 )edit

Try the 2.4.4 version that will to be released today - it can solve your problem.

Andrey Pavlenko gravatar imageAndrey Pavlenko ( 2013-03-01 07:48:34 -0600 )edit

True story. It finally works. I'm happy :)

jjbluesky gravatar imagejjbluesky ( 2013-03-01 09:54:50 -0600 )edit

Question Tools

Stats

Asked: 2012-09-26 12:28:38 -0600

Seen: 9,004 times

Last updated: Sep 28 '12