title: OpenCV Error: Assertion failed (s >= 0) in void cv::setSize(cv::Mat&, int, int const*, const size_t*, bool)
body: <p>I am new to opencv library. I am trying to stitch the images using openCv, while running it's giving exception "Assertion failed (s >= 0) in void cv::setSize". Please help me. Here is my code..</p>
  
  <pre><code>JNIEXPORT void JNICALL Java_com_example_imagejoiner_MyJoiner_stitchImages(
          JNIEnv* env, jobject javaThis, jobjectArray jfilePaths,
          jstring jfinalImagePath) {
  
  vector&lt;Mat&gt; imgs;
  imgs.clear();
  
  Mat imgMat;
  
  bool try_use_gpu = false;
  
  const int imageCount = env-&gt;GetArrayLength(jfilePaths);
  
  for (int i = 0; i &lt; imageCount; i++) {
  
      jstring filePath = (jstring) env-&gt;GetObjectArrayElement(jfilePaths, i);
  
      const char *rawString = env-&gt;GetStringUTFChars(filePath, 0);
  
      LOGV("RESULT = %s", rawString);
  
      imgMat = imread(rawString);
  
      if (!imgMat.empty()) {
          LOGV("Mat added.....");
          LOGV("RESULT = %d", i);
          imgs.push_back(imgMat);
      }
  
  }
  
  imgMat.release();
  
  const char *finalImagePath = env-&gt;GetStringUTFChars(jfinalImagePath, 0);
  
  LOGV("RESULT = %s", finalImagePath);
  
  Mat pano;
  
  Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
  Stitcher::Status status = stitcher.stitch(imgs, pano);
  
  imgs.clear();
  
  LOGV("RESULT = %s", "done mat.....");
  
  imwrite(finalImagePath, pano);
  
  LOGV("RESULT = %s", "done writing.....");
  
  pano.release();
  }
  </code></pre>