Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unable to convert mat to bitmap

hi, i am not able to convert mat to bitmap in the below code. can any one tell me what wrong i am doing here.

here is the code :-

    Mat rgb = new Mat (); 
    Mat rgb32f = new Mat();
    Mat gry = new Mat ();   
    Mat imfilter = new Mat (height, width, CvType.CV_32F, new Scalar(4));
    Mat res = new Mat();
    Bitmap bmp = t1.copy(Bitmap.Config.ARGB_8888, true);

    Utils.bitmapToMat(bmp, rgb);
    rgb.convertTo(rgb32f, CvType.CV_32F);

    Mat mu = new Mat();     
    Size ksize = new Size(5,5);
    Imgproc.blur(rgb32f, mu,ksize);

    Mat mu2 = new Mat();
    Imgproc.blur(rgb32f.mul(rgb32f), mu2, ksize);

    Mat sigma = new Mat();
    Core.sqrt(mu2, sigma);

    Core.normalize(sigma, gry, 0.0, 1.0, Core.NORM_MINMAX);

    Bitmap scale = Bitmap.createBitmap(gry.cols(), gry.rows(), Bitmap.Config.ARGB_8888);


    Utils.matToBitmap(gry, scale);

thanks....

Unable to convert mat to bitmap

hi, i am not able to convert mat to bitmap in the below code. can any one tell me what wrong i am doing here.

here is the code :-

    Mat rgb = new Mat (); 
    Mat rgb32f = new Mat();
    Mat gry = new Mat ();   
    Mat imfilter = new Mat (height, width, CvType.CV_32F, new Scalar(4));
    Mat res = new Mat();
    Bitmap bmp = t1.copy(Bitmap.Config.ARGB_8888, true);

    Utils.bitmapToMat(bmp, rgb);
    rgb.convertTo(rgb32f, CvType.CV_32F);

    Mat mu = new Mat();     
    Size ksize = new Size(5,5);
    Imgproc.blur(rgb32f, mu,ksize);

    Mat mu2 = new Mat();
    Imgproc.blur(rgb32f.mul(rgb32f), mu2, ksize);

    Mat sigma = new Mat();
    Core.sqrt(mu2, sigma);

    Core.normalize(sigma, gry, 0.0, 1.0, Core.NORM_MINMAX);

    Bitmap scale = Bitmap.createBitmap(gry.cols(), gry.rows(), Bitmap.Config.ARGB_8888);


    Utils.matToBitmap(gry, scale);

Error comes in the last line Utils.matToBitmap() function. thanks....

Unable to convert mat to bitmap

hi, i am not able to convert mat to bitmap in the below code. can any one tell me what wrong i am doing here.

here is the code :-

    Mat rgb = new Mat (); 
    Mat rgb32f = new Mat();
    Mat gry = new Mat ();   
    Mat imfilter = new Mat (height, width, CvType.CV_32F, new Scalar(4));
    Mat res = new Mat();
    Bitmap bmp = t1.copy(Bitmap.Config.ARGB_8888, true);

    Utils.bitmapToMat(bmp, rgb);
    rgb.convertTo(rgb32f, CvType.CV_32F);

    Mat mu = new Mat();     
    Size ksize = new Size(5,5);
    Imgproc.blur(rgb32f, mu,ksize);

    Mat mu2 = new Mat();
    Imgproc.blur(rgb32f.mul(rgb32f), mu2, ksize);

    Mat sigma = new Mat();
    Core.sqrt(mu2, sigma);

    Core.normalize(sigma, gry, 0.0, 1.0, Core.NORM_MINMAX);

    Bitmap scale = Bitmap.createBitmap(gry.cols(), gry.rows(), Bitmap.Config.ARGB_8888);


    Utils.matToBitmap(gry, scale);

Error comes in the last line Utils.matToBitmap() function. thanks....function.

here is logcat :-

10-30 21:23:27.999: E/cv::error()(8900): OpenCV Error: Assertion failed (src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols) in void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean), file /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp, line 97

10-30 21:23:28.009: E/org.opencv.android.Utils(8900): nMatToBitmap catched cv::Exception: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp:97: error: (-215) src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean)

10-30 21:23:28.009: W/dalvikvm(8900): threadid=1: thread exiting with uncaught exception (group=0x41bb3798)

10-30 21:23:28.009: E/AndroidRuntime(8900): FATAL EXCEPTION: main

10-30 21:23:28.009: E/AndroidRuntime(8900): CvException [org.opencv.core.CvException: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp:97: error: (-215) src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean)

Unable to convert mat to bitmap

hi, i am not able to convert mat to bitmap in the below code. can any one tell me what wrong i am doing here.

here is the code :-

    Mat rgb = new Mat (); 
    Mat rgb32f = new Mat();
    Mat gry = new Mat ();   
    Mat imfilter = new Mat (height, width, CvType.CV_32F, new Scalar(4));
    Mat res = new Mat();
    Bitmap bmp = t1.copy(Bitmap.Config.ARGB_8888, true);

    Utils.bitmapToMat(bmp, rgb);
    rgb.convertTo(rgb32f, CvType.CV_32F);

    Mat mu = new Mat();     
    Size ksize = new Size(5,5);
    Imgproc.blur(rgb32f, mu,ksize);

    Mat mu2 = new Mat();
    Imgproc.blur(rgb32f.mul(rgb32f), mu2, ksize);

    Mat sigma = new Mat();
    Core.sqrt(mu2, sigma);

    Core.normalize(sigma, gry, 0.0, 1.0, Core.NORM_MINMAX);

    Bitmap scale = Bitmap.createBitmap(gry.cols(), gry.rows(), Bitmap.Config.ARGB_8888);


    Utils.matToBitmap(gry, scale);

Error comes in the last line Utils.matToBitmap() function.

here is logcat :-

10-30 21:23:27.999: E/cv::error()(8900): OpenCV Error: Assertion failed (src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols) in void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean), file /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp, line 97

10-30 21:23:28.009: E/org.opencv.android.Utils(8900): nMatToBitmap catched cv::Exception: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp:97: error: (-215) src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean)

10-30 21:23:28.009: W/dalvikvm(8900): threadid=1: thread exiting with uncaught exception (group=0x41bb3798)

10-30 21:23:28.009: E/AndroidRuntime(8900): FATAL EXCEPTION: main

10-30 21:23:28.009: E/AndroidRuntime(8900): CvException [org.opencv.core.CvException: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp:97: error: (-215) src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean)