title: OpenCV Error: Bad argument <Unknown array type> in unknown function, file ..\..\..\modules\core\src\matrix.cpp, line 697
body: <p>I'm currently trying to rectify stereo cameras to create a disparity map.  Unfortunately, I'm having trouble getting past the stereo rectification step because I keep receiving the error </p>
  
  <blockquote>
    <p>"OpenCV Error: Bad argument  in unknown function, file ..\..\..\modules\core\src\matrix.cpp, line 697."</p>
  </blockquote>
  
  <p>The process is complicated by the fact that I'm not the one one who calibrated the cameras, nor do I have access to the cameras used to record the videos.  I was given all of the calibration parameters (intrinsics, distortion coefficients, rotation matrix, and translation vector).  As you can see, I've tried to turn these directly into CvMats and use them that way, but I get an error when I try to actually use them.</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>CvMat li, lm, ri, rm, r, t, Rl, Rr, Pl, Pr;    
  
  double init_li[3][3] = 
      {   {477.984984743, 0, 316.17458671}, 
      {0, 476.861945645, 253.45073026}, 
      {0, 0 ,1}   };
  double init_lm[5] = {-0.117798518453, 0.147554949385, -0.0549082041898, 0, 0};
  double init_ri[3][3] = 
      {{478.640315323, 0, 299.957994781}, 
      {0, 477.898896505, 251.665771947}, 
      {0, 0, 1}};
  double init_rm[5] = {-0.10884732532, 0.12118405303, -0.0322073237741, 0, 0};
  double init_r[3][3] = 
      {{0.999973709051976, 0.00129700728791757, -0.00713435189275776},
      {-0.00132096594266573, 0.999993501087837, -0.00335452397041856}, 
      {0.00712995468519435, 0.00336386001267643, 0.99996892361313}};
  double init_t[3] = {-0.0830973040641153, -0.00062704210860633, 1.4287643345188e-005};
  
  cvInitMatHeader(&amp;li, 3, 3, CV_64FC1, init_li);
  cvInitMatHeader(&amp;lm, 5, 1, CV_64FC1, init_lm);
  cvInitMatHeader(&amp;ri, 3, 3, CV_64FC1, init_ri);
  cvInitMatHeader(&amp;rm, 5, 1, CV_64FC1, init_rm);
  cvInitMatHeader(&amp;r, 3, 3, CV_64FC1, init_r);
  cvInitMatHeader(&amp;t, 3, 1, CV_64FC1, init_t);
  cvInitMatHeader(&amp;Rl, 3,3, CV_64FC1);
  cvInitMatHeader(&amp;Rr, 3,3, CV_64FC1);
  cvInitMatHeader(&amp;Pl, 3,4, CV_64FC1);
  cvInitMatHeader(&amp;Pr, 3,4, CV_64FC1);
  
  //frame is a cv::MAT holding the first frame of the video.
  CvSize imageSize = frame.size();
  imageSize.width /= 2;
  
  //IT BREAKS HERE
  cvStereoRectify(&amp;li, &amp;ri, &amp;lm, &amp;rm, imageSize, &amp;r, &amp;t, &amp;Rl, &amp;Rr, &amp;Pl, &amp;Pr);
  </code></pre>