CvException error: ... in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean)
Hi All, I am trying to perform a simple image thresholding activity but it throws the above errors. I can't seem to tell why is it throwing these errors. I am using OpenCV 249 and working on Eclipse IDE. My codes are:
public class mainactivity extends Activity {
private Mat destination, source;
private Bitmap image;
static {
OpenCVLoader.initDebug();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Mat source = Highgui.imread(Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/CT Image/10006.bmp");
destination = new Mat(source.rows(), source.cols(), source.type());
Log.w("source type", String.valueOf(source.type()));
Log.w("source rows", String.valueOf(source.rows()));
Log.w("source columns", String.valueOf(source.cols()));
Log.w("source width", String.valueOf(source.width()));
Log.w("source height", String.valueOf(source.height()));
Log.w("source size", String.valueOf(source.size()));
destination = source;
Imgproc.threshold(source, destination, 127, 255, Imgproc.THRESH_TOZERO);
Log.w("destination type", String.valueOf(destination.type()));
Log.w("destination rows", String.valueOf(destination.rows()));
Log.w("destination columns", String.valueOf(destination.cols()));
Log.w("destination width", String.valueOf(destination.width()));
Log.w("destination height", String.valueOf(destination.height()));
Highgui.imwrite("ThreshZero.jpg", destination);
Bitmap bmp = Bitmap.createBitmap(1920, 1080, Config.ARGB_8888);
Utils.matToBitmap(destination, bmp);
ImageView photo = (ImageView) findViewById(R.id.imageView1);
photo.setImageBitmap(bmp);
}
}
And my logcat is:
01-04 13:42:17.210: E/AndroidRuntime(26055): Process: com.example.test1, PID: 26055
01-04 13:42:17.210: E/AndroidRuntime(26055): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.test1/com.examples.test.mainactivity}: 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)
My understanding of this logcat message is that my destination Mat and Bitmap bmp are of different 'dimensions'. I included the Log messages in my code to observe what are those 'dimensions' and these dimensions are all zeros. Anyone pls assist? In this project I am not using any jni folder.