title: OpenCV Error: Assertion failed (src.dims == 2 && info.height == (uint32_t)
body: <p>I am trying to write a simple app using OpenCV for android to load an image, process it and display that image in an ImageView. I've searched around the OpenCV forums and people suggests that the below code is a typical way of achieving this operation. </p>
  
  <pre><code>public class mainactivity extends Activity {
  
  private Mat destination, source;
  
  static {
      OpenCVLoader.initDebug();
  }
  
  private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
      @Override
      public void onManagerConnected(int status) {
          if (status == LoaderCallbackInterface.SUCCESS ) {
  
              threshold();
          } else {
              super.onManagerConnected(status);
          }
      }
  };
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
  }
  
  @Override
  public void onResume() {;
      super.onResume();
      OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_9,this, mLoaderCallback);
   }
  
  public void threshold(){
  
      try {
          source = Highgui.imread(getAssets().open("10007.bmp").toString());
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      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()));
  
      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(640, 480, Config.ARGB_8888);
      Utils.matToBitmap(source, bmp);
      ImageView image= (ImageView) findViewById(R.id.imageView1);
      image.setImageBitmap(bmp);
  
  }
  }
  </code></pre>
  
  <p>Unfortunately this set of codes throws me the following set of errors( I included the Log messages):</p>
  
  <pre><code>01-07 13:59:49.934: W/source type(31303): 0
  01-07 13:59:49.934: W/source rows(31303): 0
  01-07 13:59:49.934: W/source columns(31303): 0
  01-07 13:59:49.934: W/source width(31303): 0
  01-07 13:59:49.935: W/source height(31303): 0
  01-07 13:59:49.935: W/source size(31303): 0x0
  01-07 13:59:49.937: W/destination type(31303): 0
  01-07 13:59:49.937: W/destination rows(31303): 0
  01-07 13:59:49.937: W/destination columns(31303): 0
  01-07 13:59:49.937: W/destination width(31303): 0
  01-07 13:59:49.937: W/destination height(31303): 0
  01-07 13:59:49.944: E/cv::error()(31303): OpenCV Error: Assertion failed (src.dims == 2 &amp;&amp; info.height == (uint32_t)src.rows &amp;&amp; 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
  01-07 13:59:49.944: E/org.opencv.android.Utils(31303): 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 &amp;&amp; info.height == (uint32_t)src.rows &amp;&amp; info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean)
  01-07 13:59:49.945: D/AndroidRuntime(31303): Shutting down VM
  01-07 13:59:49.946: E/AndroidRuntime(31303): FATAL EXCEPTION: main
  01-07 13:59:49.946: E/AndroidRuntime(31303): Process: com.example.test1, PID: 31303
  01-07 13:59:49.946: E/AndroidRuntime(31303): 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 &amp;&amp; info.height == (uint32_t)src.rows &amp;&amp; info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean)
  01-07 13:59:49.946: E/AndroidRuntime(31303): ]
  </code></pre>
  
  <p>Ok, what I understand from this set of errors after reading other similar post is that my destination bitmap has a different dimension as compared with the Mat src. Therefore I included Log messages to observe the rows and columns dimensions and it all reflects zeros. I've posted this question on OpenCV forums but have yet to receive any help. Can anyone help pls.</p>