Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

convert cv::Mat (C++, native Code) to Bitmap (Android, Java)

Dear OpenCV Users,

I have the following C++ native code which I use to get an image from my (native) camera:

string Java_com_example_hellojni_HelloJni_getImageNative(JNIEnv* env, jobject thiz) {
   // first camera available
   cv::VideoCapture capture(CV_CAP_ANDROID + 0);
   // set captuer properties
   capture.set(CV_CAP_PROP_FRAME_WIDTH, 640);
   capture.set(CV_CAP_PROP_FRAME_HEIGHT, 480);

   // check if capture is opened
   if( !capture.isOpened()) return env->NewStringUTF("Capture not opened!");

   //  grab frame
   cv::Mat frame;
  capture >> frame;

// how to return the image as Bitmap to Android??
}

How would I return a Bitmap to Android Code in Java via JNI?

All the best, Stephan