Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Opencv with android ndk showing runtime error

Hi , i am just trying to start opencv in android ndk environment , i just use some opencv sample program in native environment , like giving in sample of opencv lib native-activity , when i run that program i am getting the following error's

04-07 10:39:01.239: E/AndroidRuntime(6645): FATAL EXCEPTION: main
04-07 10:39:01.239: E/AndroidRuntime(6645): java.lang.ExceptionInInitializerError
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.Class.newInstanceImpl(Native Method)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.Class.newInstance(Class.java:1409)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.os.Looper.loop(Looper.java:130)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread.main(ActivityThread.java:3687)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.reflect.Method.invokeNative(Native Method)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.reflect.Method.invoke(Method.java:507)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at dalvik.system.NativeStart.main(Native Method)
04-07 10:39:01.239: E/AndroidRuntime(6645): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load first-opencvjni: findLibrary returned null
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.Runtime.loadLibrary(Runtime.java:429)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.System.loadLibrary(System.java:554)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at my.project.MyFirstOpenCVJNI.MyFirstOpenCVJNI.<clinit>(MyFirstOpenCVJNI.java:27)
04-07 10:39:01.239: E/AndroidRuntime(6645):     ... 15 more
04-07 10:43:49.589: W/dalvikvm(6740): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lmy/project/MyFirstOpenCVJNI/MyFirstOpenCVJNI;
04-07 10:43:49.589: W/dalvikvm(6740): Class init failed in newInstance call (Lmy/project/MyFirstOpenCVJNI/MyFirstOpenCVJNI;)
04-07 10:43:49.589: W/dalvikvm(6740): threadid=1: thread exiting with uncaught exception (group=0x40018578)
04-07 10:43:49.589: E/AndroidRuntime(6740): FATAL EXCEPTION: main
04-07 10:43:49.589: E/AndroidRuntime(6740): java.lang.ExceptionInInitializerError
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.Class.newInstanceImpl(Native Method)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.Class.newInstance(Class.java:1409)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.os.Looper.loop(Looper.java:130)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread.main(ActivityThread.java:3687)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.reflect.Method.invokeNative(Native Method)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.reflect.Method.invoke(Method.java:507)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at dalvik.system.NativeStart.main(Native Method)
04-07 10:43:49.589: E/AndroidRuntime(6740): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load first-opencvjni: findLibrary returned null
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.Runtime.loadLibrary(Runtime.java:429)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.System.loadLibrary(System.java:554)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at my.project.MyFirstOpenCVJNI.MyFirstOpenCVJNI.<clinit>(MyFirstOpenCVJNI.java:27)
04-07 10:43:49.589: E/AndroidRuntime(6740):     ... 15 more

Opencv with android ndk showing runtime error

Hi , i am just trying to start opencv in android ndk environment , i just use some opencv sample program in native environment , like giving in sample of opencv lib native-activity , when i run that program i am getting the following error's

04-07 10:39:01.239: E/AndroidRuntime(6645): FATAL EXCEPTION: main
04-07 10:39:01.239: E/AndroidRuntime(6645): java.lang.ExceptionInInitializerError
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.Class.newInstanceImpl(Native Method)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.Class.newInstance(Class.java:1409)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.os.Looper.loop(Looper.java:130)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread.main(ActivityThread.java:3687)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.reflect.Method.invokeNative(Native Method)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.reflect.Method.invoke(Method.java:507)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at dalvik.system.NativeStart.main(Native Method)
04-07 10:39:01.239: E/AndroidRuntime(6645): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load first-opencvjni: findLibrary returned null
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.Runtime.loadLibrary(Runtime.java:429)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.System.loadLibrary(System.java:554)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at my.project.MyFirstOpenCVJNI.MyFirstOpenCVJNI.<clinit>(MyFirstOpenCVJNI.java:27)
04-07 10:39:01.239: E/AndroidRuntime(6645):     ... 15 more
04-07 10:43:49.589: W/dalvikvm(6740): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lmy/project/MyFirstOpenCVJNI/MyFirstOpenCVJNI;
04-07 10:43:49.589: W/dalvikvm(6740): Class init failed in newInstance call (Lmy/project/MyFirstOpenCVJNI/MyFirstOpenCVJNI;)
04-07 10:43:49.589: W/dalvikvm(6740): threadid=1: thread exiting with uncaught exception (group=0x40018578)
04-07 10:43:49.589: E/AndroidRuntime(6740): FATAL EXCEPTION: main
04-07 10:43:49.589: E/AndroidRuntime(6740): java.lang.ExceptionInInitializerError
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.Class.newInstanceImpl(Native Method)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.Class.newInstance(Class.java:1409)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.os.Looper.loop(Looper.java:130)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread.main(ActivityThread.java:3687)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.reflect.Method.invokeNative(Native Method)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.reflect.Method.invoke(Method.java:507)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at dalvik.system.NativeStart.main(Native Method)
04-07 10:43:49.589: E/AndroidRuntime(6740): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load first-opencvjni: findLibrary returned null
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.Runtime.loadLibrary(Runtime.java:429)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.System.loadLibrary(System.java:554)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at my.project.MyFirstOpenCVJNI.MyFirstOpenCVJNI.<clinit>(MyFirstOpenCVJNI.java:27)
04-07 10:43:49.589: E/AndroidRuntime(6740):     ... 15 more

when i build the ndk in cmd it show me the following result with ndk-build

Install        : libfirst-opencvjni.so => libs/armeabi-v7a/libfirst-opencvjni.so

Opencv with android ndk showing runtime errorMaking empty ellipse using opencv

Hi I want to create the hollow ellipse in OpenCv C++ with the black corners as in the frmae below , i am just trying work with the vignette here but there is brightness problem in center, i want to start opencv in android ndk environment hollow or empty from center , how can i just use some opencv sample program in native environment make it like this , like giving in sample of opencv lib native-activity , when which way i run that program i am getting the following error'sneed to follow

04-07 10:39:01.239: E/AndroidRuntime(6645): FATAL EXCEPTION: main
04-07 10:39:01.239: E/AndroidRuntime(6645): java.lang.ExceptionInInitializerError
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.Class.newInstanceImpl(Native Method)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.Class.newInstance(Class.java:1409)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.os.Looper.loop(Looper.java:130)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at android.app.ActivityThread.main(ActivityThread.java:3687)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.reflect.Method.invokeNative(Native Method)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.reflect.Method.invoke(Method.java:507)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at dalvik.system.NativeStart.main(Native Method)
04-07 10:39:01.239: E/AndroidRuntime(6645): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load first-opencvjni: findLibrary returned null
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.Runtime.loadLibrary(Runtime.java:429)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at java.lang.System.loadLibrary(System.java:554)
04-07 10:39:01.239: E/AndroidRuntime(6645):     at my.project.MyFirstOpenCVJNI.MyFirstOpenCVJNI.<clinit>(MyFirstOpenCVJNI.java:27)
04-07 10:39:01.239: E/AndroidRuntime(6645):     ... 15 more
04-07 10:43:49.589: W/dalvikvm(6740): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lmy/project/MyFirstOpenCVJNI/MyFirstOpenCVJNI;
04-07 10:43:49.589: W/dalvikvm(6740): Class init failed in newInstance call (Lmy/project/MyFirstOpenCVJNI/MyFirstOpenCVJNI;)
04-07 10:43:49.589: W/dalvikvm(6740): threadid=1: thread exiting with uncaught exception (group=0x40018578)
04-07 10:43:49.589: E/AndroidRuntime(6740): FATAL EXCEPTION: main
04-07 10:43:49.589: E/AndroidRuntime(6740): java.lang.ExceptionInInitializerError
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.Class.newInstanceImpl(Native Method)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.Class.newInstance(Class.java:1409)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.os.Looper.loop(Looper.java:130)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at android.app.ActivityThread.main(ActivityThread.java:3687)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.reflect.Method.invokeNative(Native Method)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.reflect.Method.invoke(Method.java:507)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at dalvik.system.NativeStart.main(Native Method)
04-07 10:43:49.589: E/AndroidRuntime(6740): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load first-opencvjni: findLibrary returned null
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.Runtime.loadLibrary(Runtime.java:429)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at java.lang.System.loadLibrary(System.java:554)
04-07 10:43:49.589: E/AndroidRuntime(6740):     at my.project.MyFirstOpenCVJNI.MyFirstOpenCVJNI.<clinit>(MyFirstOpenCVJNI.java:27)
04-07 10:43:49.589: E/AndroidRuntime(6740):     ... 15 more

enter image description here

I make the same frame as .png in PS so when i build blend it with other image in my program it convert the ndk in cmd it show me the following result with ndk-buildabove image into

Install        : libfirst-opencvjni.so => libs/armeabi-v7a/libfirst-opencvjni.so

enter image description here

Making empty ellipse using opencv

I want to create the hollow ellipse in OpenCv C++ with the black corners as in the frmae below , i work with the vignette here but there is brightness problem in center, i want to hollow or empty from center , how can i make it like this , which way i need to follow

enter image description here

I make the same frame as .png in PS so when i blend it with other image in my program it convert the above image into

enter image description here

Making empty ellipse using opencvImage shape changes when displaying

I want am trying to create the hollow ellipse display this image as i have this image in OpenCv C++ with the black corners as in the frmae below , i work with the vignette here but there is brightness problem in center, i want to hollow or empty from center , how can i make it like this , which way i need to followmy directory

enter image description here

I make the same frame as .png in PS so when but i blend displaying it with other this code

Mat img=imread("D:\\vig.png");
imshow("image",img);
waitKey();
imwrite("D:\\img.jpg",img);

The same image in my program it convert the above image intodisplayed as follows

enter image description here

What's going wrong with it ?

How to extract the value of image using LUT

Lets suppose the sample program like below

int q = 256/bins;
int res = 5;
Mat_<uchar> pal(1,256); // make a lookup table for intensities
for ( int c=0; c<256; c++ )
     pal(c) = saturate_cast<uchar>((((c/q) * q) * bins)/(bins-1));
LUT(img,pal,res);

This program change the shape of the image using LUT , but its very simple and clear , but anyhow what if I want to know the values of resultant image ? like so if I want to do it anything with LUT with interface like line and when I move the line it changes the shape of image , so when I move the line like below

enter image description here

Now this line changes the shape of the image and the program at the back of this image is using LUT approach , How I can save the value of that shape of Image shape , so that next time I can enter that value directly without moving the line and it changes when displaying

I am trying to display this image as i have this image in my directory

enter image description here

but i displaying it with this code

Mat img=imread("D:\\vig.png");
imshow("image",img);
waitKey();
imwrite("D:\\img.jpg",img);

The same image displayed as follows

enter image description here

What's going wrong with it ?the image shape.

You can see the curve related example here