title: OpenCV error: Assertion failed (src_total() > 0) in cv:warpPerspective, file imwarp.cpp, line 6090
body: <p>I'm trying to change viewport of 2D image with this code:</p>
  
  <pre><code>int main() {
      cv::Mat input = cv::imread("10K_F_1.jpg");
  
      std::vector&lt;cv::Point3f&gt; pointsOnPlane;
  
      pointsOnPlane.push_back(cv::Point3f(0-input.cols/2,0-input.rows/2,0));
      pointsOnPlane.push_back(cv::Point3f(input.cols-input.cols/2,0-input.rows/2,0));
      pointsOnPlane.push_back(cv::Point3f(input.cols-input.cols/2,input.rows-input.rows/2,0));
      pointsOnPlane.push_back(cv::Point3f(0-input.cols/2,input.rows-input.rows/2,0));
  
      std::vector&lt;cv::Point2f&gt; originalPointsInImage;
      originalPointsInImage.push_back(cv::Point2f(0,0));
      originalPointsInImage.push_back(cv::Point2f(input.cols,0));
      originalPointsInImage.push_back(cv::Point2f(input.cols,input.rows));
      originalPointsInImage.push_back(cv::Point2f(0,input.rows));
  
      std::cout &lt;&lt; "original pixel positions:" &lt;&lt; std::endl;
      for(unsigned int i=0; i&lt;originalPointsInImage.size(); ++i)
          std::cout &lt;&lt; originalPointsInImage[i] &lt;&lt; std::endl;
  
      cv::Mat cameraIntrinsics = cv::Mat::eye(3,3,CV_64FC1);
  
      cameraIntrinsics.at&lt;double&gt;(0,0) = 500.0;
      cameraIntrinsics.at&lt;double&gt;(1,1) = 500.0;
      cameraIntrinsics.at&lt;double&gt;(0,2) = input.cols/2.0;
      cameraIntrinsics.at&lt;double&gt;(1,2) = input.rows/2.0;
  
      std::vector&lt;double&gt; distCoefficients;
  
      cv::Mat rVec;
      cv::Mat tVec;
      cv::solvePnP(pointsOnPlane, originalPointsInImage, cameraIntrinsics, distCoefficients, rVec, tVec);
  
      // let's increase the distance a bit
      tVec = tVec*2;
      double angle = -45; // degrees
  
      cv::Mat rVec2 = getRotationMatrixAroundY(angle);
  
      std::vector&lt;cv::Point2f&gt; projectedPointsOnImage;
      cv::projectPoints(pointsOnPlane, rVec2, tVec, cameraIntrinsics, distCoefficients, projectedPointsOnImage);
  
      cv::Mat H = cv::findHomography(originalPointsInImage, projectedPointsOnImage);
  
      cv::Mat warped;
      cv::warpPerspective(input, warped, H, input.size(), 1, 0);
  
      cv::imshow("input", input);
      cv::imshow("warped", warped);
      cv::waitKey(0);
      return 0;
  }
  </code></pre>
  
  <p>when I run it, I got the error:</p>
  
  <blockquote>
    <p>OpenCV error: Assertion failed (src_total() > 0) in cv:warpPerspective, file imwarp.cpp, line 6090</p>
  </blockquote>
  
  <p>I try to found a solution but can't. I'm using OpenCV 3.0 on visual studio 2012.</p>
  
  <p>Please help me to fix this, thanks in advance.</p>