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

	<entry>
		<id>http://programmingexamples.net/w/index.php?title=OpenCV/WishList/StereoRectifyUncalibrated&amp;diff=4689&amp;oldid=prev</id>
		<title>Daviddoria: Created page with '==StereoRectifyUncalibrated.cxx== &lt;source lang=&quot;cpp&quot;&gt; #include &quot;opencv2/calib3d/calib3d.hpp&quot; #include &quot;opencv2/imgproc/imgproc.hpp&quot; #include &quot;opencv2/core/core.hpp&quot; #include &quot;ope…'</title>
		<link rel="alternate" type="text/html" href="http://programmingexamples.net/w/index.php?title=OpenCV/WishList/StereoRectifyUncalibrated&amp;diff=4689&amp;oldid=prev"/>
				<updated>2011-07-23T13:42:19Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;==StereoRectifyUncalibrated.cxx== &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; #include &amp;quot;opencv2/calib3d/calib3d.hpp&amp;quot; #include &amp;quot;opencv2/imgproc/imgproc.hpp&amp;quot; #include &amp;quot;opencv2/core/core.hpp&amp;quot; #include &amp;quot;ope…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==StereoRectifyUncalibrated.cxx==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;opencv2/calib3d/calib3d.hpp&amp;quot;&lt;br /&gt;
#include &amp;quot;opencv2/imgproc/imgproc.hpp&amp;quot;&lt;br /&gt;
#include &amp;quot;opencv2/core/core.hpp&amp;quot;&lt;br /&gt;
#include &amp;quot;opencv2/highgui/highgui.hpp&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;fstream&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&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;
&lt;br /&gt;
  //cv::Mat F = cv::findFundamentalMat(points1, points2, cv::FM_RANSAC, 3, 0.99);&lt;br /&gt;
  cv::Mat F = cv::findFundamentalMat(points1, points2, CV_FM_8POINT);&lt;br /&gt;
  &lt;br /&gt;
  cv::Mat H1(4,4, image1.type());&lt;br /&gt;
  cv::Mat H2(4,4, image1.type());&lt;br /&gt;
  cv::stereoRectifyUncalibrated(points1, points2, F, image1.size(), H1, H2);&lt;br /&gt;
  &lt;br /&gt;
  cv::Mat rectified1(image1.size(), image1.type());&lt;br /&gt;
  cv::warpPerspective(image1, rectified1, H1, image1.size());&lt;br /&gt;
  cv::imwrite(&amp;quot;rectified1.png&amp;quot;, rectified1);&lt;br /&gt;
  &lt;br /&gt;
  cv::Mat rectified2(image2.size(), image2.type());&lt;br /&gt;
  cv::warpPerspective(image2, rectified2, H2, image2.size());&lt;br /&gt;
  cv::imwrite(&amp;quot;rectified2.png&amp;quot;, rectified2);&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_core opencv_highgui&lt;br /&gt;
opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect&lt;br /&gt;
          opencv_features2d opencv_calib3d opencv_legacy opencv_contrib&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Daviddoria</name></author>	</entry>

	</feed>