<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.programmingexamples.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.programmingexamples.net/w/index.php?action=history&amp;feed=atom&amp;title=OpenCV%2FWishList%2FStereo%2FstereoRectifyUncalibrated</id>
		<title>OpenCV/WishList/Stereo/stereoRectifyUncalibrated - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.programmingexamples.net/w/index.php?action=history&amp;feed=atom&amp;title=OpenCV%2FWishList%2FStereo%2FstereoRectifyUncalibrated"/>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/w/index.php?title=OpenCV/WishList/Stereo/stereoRectifyUncalibrated&amp;action=history"/>
		<updated>2026-06-15T12:47:19Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.5</generator>

	<entry>
		<id>http://www.programmingexamples.net/w/index.php?title=OpenCV/WishList/Stereo/stereoRectifyUncalibrated&amp;diff=4604&amp;oldid=prev</id>
		<title>Daviddoria: Created page with 'OpenCV Error: Assertion failed (scn + 1 == m.cols &amp;&amp; (depth == CV_32F || depth == CV_64F)) in perspectiveTransform, file /home/doriad/src/OpenCV-2.3.0/modules/core/src/matmul.cpp…'</title>
		<link rel="alternate" type="text/html" href="http://www.programmingexamples.net/w/index.php?title=OpenCV/WishList/Stereo/stereoRectifyUncalibrated&amp;diff=4604&amp;oldid=prev"/>
				<updated>2011-07-17T19:13:08Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;OpenCV Error: Assertion failed (scn + 1 == m.cols &amp;amp;&amp;amp; (depth == CV_32F || depth == CV_64F)) in perspectiveTransform, file /home/doriad/src/OpenCV-2.3.0/modules/core/src/matmul.cpp…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;OpenCV Error: Assertion failed (scn + 1 == m.cols &amp;amp;&amp;amp; (depth == CV_32F || depth == CV_64F)) in perspectiveTransform, file /home/doriad/src/OpenCV-2.3.0/modules/core/src/matmul.cpp, line 1916&lt;br /&gt;
terminate called after throwing an instance of 'cv::Exception'&lt;br /&gt;
  what():  /home/doriad/src/OpenCV-2.3.0/modules/core/src/matmul.cpp:1916: error: (-215) scn + 1 == m.cols &amp;amp;&amp;amp; (depth == CV_32F || depth == CV_64F) in function perspectiveTransform&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==stereoRectifyUncalibrated.cxx==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;opencv2/core/core.hpp&amp;quot;&lt;br /&gt;
#include &amp;quot;opencv2/imgproc/imgproc.hpp&amp;quot;&lt;br /&gt;
#include &amp;quot;opencv2/calib3d/calib3d.hpp&amp;quot;&lt;br /&gt;
#include &amp;quot;opencv2/highgui/highgui.hpp&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;fstream&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;sstream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
std::vector&amp;lt;cv::Point2f&amp;gt; ReadPoints(const std::string&amp;amp; filename);&lt;br /&gt;
&lt;br /&gt;
int main( int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
  // Verify arguments&lt;br /&gt;
  if(argc &amp;lt; 5)&lt;br /&gt;
    {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; &amp;quot;Required arguments: input1.jpg input2.jpg points1.txt points2.txt&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    return -1;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  // Parse arguments&lt;br /&gt;
  std::string image1FileName = argv[1];&lt;br /&gt;
  std::string image2FileName = argv[2];&lt;br /&gt;
  std::string points1FileName = argv[3];&lt;br /&gt;
  std::string points2FileName = argv[4];&lt;br /&gt;
&lt;br /&gt;
  // Output arguments&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;Image1: &amp;quot; &amp;lt;&amp;lt; image1FileName &amp;lt;&amp;lt; std::endl&lt;br /&gt;
            &amp;lt;&amp;lt; &amp;quot;Image2: &amp;quot; &amp;lt;&amp;lt; image2FileName &amp;lt;&amp;lt; std::endl&lt;br /&gt;
            &amp;lt;&amp;lt; &amp;quot;Points1: &amp;quot; &amp;lt;&amp;lt; points1FileName &amp;lt;&amp;lt; std::endl&lt;br /&gt;
            &amp;lt;&amp;lt; &amp;quot;Points2: &amp;quot; &amp;lt;&amp;lt; points2FileName &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  // Read images&lt;br /&gt;
  cv::Mat image1 = cv::imread(image1FileName, 1);&lt;br /&gt;
  cv::Mat image2 = cv::imread(image2FileName, 1);&lt;br /&gt;
&lt;br /&gt;
  // Read points&lt;br /&gt;
  std::vector&amp;lt;cv::Point2f&amp;gt; points1 = ReadPoints(points1FileName);&lt;br /&gt;
  std::vector&amp;lt;cv::Point2f&amp;gt; points2 = ReadPoints(points2FileName);&lt;br /&gt;
&lt;br /&gt;
  if(points1.size() != points2.size())&lt;br /&gt;
    {&lt;br /&gt;
    std::cerr &amp;lt;&amp;lt; &amp;quot;There must be the same number of points in both files (since they are correspondences!). File1 has &amp;quot; &amp;lt;&amp;lt; points1.size() &amp;lt;&amp;lt; &amp;quot; while file2 has &amp;quot; &amp;lt;&amp;lt; points2.size() &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    return -1;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  cv::Mat fundamentalMatrix = cv::findFundamentalMat(points1, points2, cv::FM_RANSAC, 3, 0.99);&lt;br /&gt;
&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;F = &amp;quot; &amp;lt;&amp;lt; fundamentalMatrix &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  cv::Mat H1, H2;&lt;br /&gt;
  cv::stereoRectifyUncalibrated(points1, points2, fundamentalMatrix, image2.size(), H1, H2);&lt;br /&gt;
&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;H1 = &amp;quot; &amp;lt;&amp;lt; H1 &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;H2 = &amp;quot; &amp;lt;&amp;lt; H2 &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  cv::Mat rectified(3,3,CV_64FC3);&lt;br /&gt;
  cv::perspectiveTransform(image2, rectified, H2);&lt;br /&gt;
&lt;br /&gt;
  cv::imwrite(&amp;quot;output.png&amp;quot;, rectified);&lt;br /&gt;
  &lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
std::vector&amp;lt;cv::Point2f&amp;gt; ReadPoints(const std::string&amp;amp; filename)&lt;br /&gt;
{&lt;br /&gt;
  // Read points&lt;br /&gt;
  std::ifstream pointsstream(filename.c_str());&lt;br /&gt;
&lt;br /&gt;
  if(pointsstream == NULL)&lt;br /&gt;
    {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Cannot open file &amp;quot; &amp;lt;&amp;lt; filename &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    exit(-1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  // Read the point from the first image&lt;br /&gt;
  std::string line;&lt;br /&gt;
  std::vector&amp;lt;cv::Point2f&amp;gt; points;&lt;br /&gt;
&lt;br /&gt;
  while(getline(pointsstream, line))&lt;br /&gt;
  {&lt;br /&gt;
    std::stringstream ss(line);&lt;br /&gt;
    float x,y;&lt;br /&gt;
    ss &amp;gt;&amp;gt; x &amp;gt;&amp;gt; y;&lt;br /&gt;
    points.push_back(cv::Point2f(x,y));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  return points;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==CMakeLists.txt==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cmake&amp;quot;&amp;gt;&lt;br /&gt;
cmake_minimum_required(VERSION 2.6)&lt;br /&gt;
&lt;br /&gt;
PROJECT(stereoRectifyUncalibrated)&lt;br /&gt;
&lt;br /&gt;
FIND_PACKAGE(OpenCV REQUIRED )&lt;br /&gt;
INCLUDE_DIRECTORIES( ${OPENCV_INCLUDE_DIR} )&lt;br /&gt;
&lt;br /&gt;
ADD_EXECUTABLE(stereoRectifyUncalibrated stereoRectifyUncalibrated.cxx)&lt;br /&gt;
TARGET_LINK_LIBRARIES(stereoRectifyUncalibrated ${OpenCV_LIBS})&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Daviddoria</name></author>	</entry>

	</feed>