OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Mon, 13 May 2019 03:16:05 -0500Why homgraphy matrix doesn't work for any point in the image?http://answers.opencv.org/question/212857/why-homgraphy-matrix-doesnt-work-for-any-point-in-the-image/ I'm trying to find homography between the following two images.
<br/>
If I calculate homography based on only corresponding points on the ground then the transformation works well only for the points on the ground.
If I calculate homography based on only corresponding points on the heads then the transformation works well only for the points on the head level.
How do I get homography that will work for any point on the image? Is it even possible ?
**The code for homography calculation:**
vector<pair<Point, Point> > homographyPoints;
vector<cv::Point2f> plane1Points;
vector<cv::Point2f> plane2Points;
for (auto& p : homographyPoints)
{
plane1Points.push_back(p.first);
plane2Points.push_back(p.second);
}
homography = findHomography(plane1Points, plane2Points, CV_RANSAC);
**The code for using the homography:**
vector<cv::Point2f> srcPoints, dstPoints;
srcPoints.push_back(selectedPoint);
cv::perspectiveTransform(srcPoints, dstPoints, params->homography);
Mon, 13 May 2019 01:17:12 -0500http://answers.opencv.org/question/212857/why-homgraphy-matrix-doesnt-work-for-any-point-in-the-image/Comment by Eduardo for <p>I'm trying to find homography between the following two images.
<br>
If I calculate homography based on only corresponding points on the ground then the transformation works well only for the points on the ground.
If I calculate homography based on only corresponding points on the heads then the transformation works well only for the points on the head level.</p>
<p>How do I get homography that will work for any point on the image? Is it even possible ?</p>
<p><strong>The code for homography calculation:</strong></p>
<pre><code>vector<pair<Point, Point> > homographyPoints;
vector<cv::Point2f> plane1Points;
vector<cv::Point2f> plane2Points;
for (auto& p : homographyPoints)
{
plane1Points.push_back(p.first);
plane2Points.push_back(p.second);
}
homography = findHomography(plane1Points, plane2Points, CV_RANSAC);
</code></pre>
<p><strong>The code for using the homography:</strong></p>
<pre><code>vector<cv::Point2f> srcPoints, dstPoints;
srcPoints.push_back(selectedPoint);
cv::perspectiveTransform(srcPoints, dstPoints, params->homography);
</code></pre>
http://answers.opencv.org/question/212857/why-homgraphy-matrix-doesnt-work-for-any-point-in-the-image/?comment=212863#post-id-212863Homography transformation holds only for the same planar objects or pure camera rotational motion. You should look at a [computer vision course](http://www.cse.psu.edu/~rtc12/CSE486/lecture16.pdf).
[Here](http://szeliski.org/Book/drafts/SzeliskiBook_20100903_draft.pdf) an introduction on computer vision.Mon, 13 May 2019 03:16:05 -0500http://answers.opencv.org/question/212857/why-homgraphy-matrix-doesnt-work-for-any-point-in-the-image/?comment=212863#post-id-212863Comment by berak for <p>I'm trying to find homography between the following two images.
<br>
If I calculate homography based on only corresponding points on the ground then the transformation works well only for the points on the ground.
If I calculate homography based on only corresponding points on the heads then the transformation works well only for the points on the head level.</p>
<p>How do I get homography that will work for any point on the image? Is it even possible ?</p>
<p><strong>The code for homography calculation:</strong></p>
<pre><code>vector<pair<Point, Point> > homographyPoints;
vector<cv::Point2f> plane1Points;
vector<cv::Point2f> plane2Points;
for (auto& p : homographyPoints)
{
plane1Points.push_back(p.first);
plane2Points.push_back(p.second);
}
homography = findHomography(plane1Points, plane2Points, CV_RANSAC);
</code></pre>
<p><strong>The code for using the homography:</strong></p>
<pre><code>vector<cv::Point2f> srcPoints, dstPoints;
srcPoints.push_back(selectedPoint);
cv::perspectiveTransform(srcPoints, dstPoints, params->homography);
</code></pre>
http://answers.opencv.org/question/212857/why-homgraphy-matrix-doesnt-work-for-any-point-in-the-image/?comment=212858#post-id-212858> based on only corresponding points on the heads
the *what* ?Mon, 13 May 2019 01:52:37 -0500http://answers.opencv.org/question/212857/why-homgraphy-matrix-doesnt-work-for-any-point-in-the-image/?comment=212858#post-id-212858