Ask Your Question
0

converting bitmap to Mat ( java, android)

asked 2013-03-05 06:58:39 -0600

zippy gravatar image

updated 2013-03-06 00:11:46 -0600

Hi, i face problem in converting bitmap to Mat ( thru highgui)

i got the image by using built-in android camera API. What i need to do is capture image from camera, change that bitmap to Mat, then apply rgb2gray. Can i know what is the correct and recommended way to perform the async initialization if i were to use the highgui only?

edit ( error message):

------------------------------------------------
03-05 21:47:44.918: E/AndroidRuntime(29461): FATAL EXCEPTION: main
03-05 21:47:44.918: E/AndroidRuntime(29461): java.lang.UnsatisfiedLinkError: Native method not found: org.opencv.highgui.Highgui.imread_1:(Ljava/lang/String;)J
03-05 21:47:44.918: E/AndroidRuntime(29461):    at org.opencv.highgui.Highgui.imread_1(Native Method)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at org.opencv.highgui.Highgui.imread(Highgui.java:349)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at com.example.finalcameraapi.Main.onActivityResult(Main.java:110)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at android.app.Activity.dispatchActivityResult(Activity.java:5293)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at android.app.ActivityThread.deliverResults(ActivityThread.java:3315)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3362)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at android.app.ActivityThread.access$1100(ActivityThread.java:141)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at android.os.Looper.loop(Looper.java:137)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at android.app.ActivityThread.main(ActivityThread.java:5041)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at java.lang.reflect.Method.invokeNative(Native Method)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at java.lang.reflect.Method.invoke(Method.java:511)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-05 21:47:44.918: E/AndroidRuntime(29461):    at dalvik.system.NativeStart.main(Native Method)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-03-06 00:19:25 -0600

java.lang.UnsatisfiedLinkError: Native method not found exception for methods from OpenCV means that you try to use OpenCV before its initialization. You may use OpenCV objects and call methods from library only after onManagerConnected with status LoaderCallbackInterface.SUCCESS.

edit flag offensive delete link more

Comments

thanks for your response. Is is that i need to initialize cameraview, then only i can use highgui?

zippy gravatar imagezippy ( 2013-03-06 05:35:52 -0600 )edit
1

Do you call initAsync method to initialize OpenCV? If that, all OpenCV code will be work, when callback with successful status will return.

If you use initDebug method, then OpenCV will be ready after its call. In this case OpenCV native libs must be placed in your application package. Add "OPENCV_CAMERA_MODULES := on" and "OPENCV_INSTALL_MODULES := on" strings to Android.mk before inclusion of OpenCV.mk to do it automatically.

Alexander Smorkalov gravatar imageAlexander Smorkalov ( 2013-03-06 06:49:44 -0600 )edit

Question Tools

Stats

Asked: 2013-03-05 06:58:39 -0600

Seen: 2,478 times

Last updated: Mar 06 '13