Ask Your Question

bsm's profile - activity

2015-03-04 19:22:30 -0500 asked a question Android OpenCV error when converting Mat to Android bitmap

I'm writing an application that streams video from a webcam to an android device. The streaming client is written in C++ and uses imencode to compress images so they can be sent over UDP. I have a mock "receiver", also in C++, that can receive the images and display them. I'm porting the receiver to Android, and using only the opencv java sdk (I am not writing my own JNI stuff). The code that converts the received byte array into a Mat and then a bitmap is as follows -

Mat frame = Highgui.imdecode(new MatOfByte(packet.getData()), 0);
bm = Bitmap.createBitmap(frame.cols(), frame.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(frame, bm);
im.post(new Runnable() {
    @Override
    public void run() {
        im.setImageBitmap(bm);
     }
 });

The call to Util.matToBitmap gives the following error -

OpenCV Error: Assertion failed (AndroidBitmap_lockPixels(env, bitmap, &pixels) >= 0) in void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean), file /hdd2/buildbot/slaves/slave_ardbeg1/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp, line 99 03-04 19:04:46.337  15034-15148/ E/org.opencv.android.Utils﹕ nMatToBitmap catched cv::Exception: /hdd2/buildbot/slaves/slave_ardbeg1/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp:99: error: (-215) AndroidBitmap_lockPixels(env, bitmap, &pixels) >= 0 in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean) 03-04 19:04:46.452  15034-15148/E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-924

I have no idea what this means or what might be causing it. Any ideas?

2015-03-04 17:59:25 -0500 answered a question How to initialize OpenCV libs on Android?

The answer was quite simple: You must use OpenCVLoader.initDebug() before calling into any OpenCV libs.

2015-02-21 13:40:07 -0500 asked a question How to initialize OpenCV libs on Android?

I'm using android studio, and I managed to get my application to build by editing my build scripts and copying the sdk library folders into my project. Autocomplete and building works. However, I get the following runtime error:

java.lang.UnsatisfiedLinkError: Native method not found

I did some research and it appears that the libraries need to be initialized first. How do I do this?

2015-02-20 13:00:52 -0500 asked a question Native OpenCV networked application on Android?

Hello!

I have written an OpenCV server/client application that takes images from a networked camera and transmits them to a server for processing and display. I want to migrate the server to the NVidia Shield, an Android device. I've been wading through the Android OpenCV documentation and it seems there are several ways of architecting the application. I was curious if I could keep the application mostly native.That is, I want to know how to "migrate" the server/displayer while minimizing java code. The server has two threads, one that runs a socket server and reconstructs the sent BGR image, and another that displays the image.