toon-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Toon-members] tag tag/five_point.h src/five_point.cpp


From: Edward Rosten
Subject: [Toon-members] tag tag/five_point.h src/five_point.cpp
Date: Mon, 11 May 2009 17:32:32 +0000

CVSROOT:        /cvsroot/toon
Module name:    tag
Changes by:     Edward Rosten <edrosten>        09/05/11 17:32:32

Modified files:
        tag            : five_point.h 
        src            : five_point.cpp 

Log message:
        Reprojection error for the essential matrix.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/tag/tag/five_point.h?cvsroot=toon&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/tag/src/five_point.cpp?cvsroot=toon&r1=1.15&r2=1.16

Patches:
Index: tag/five_point.h
===================================================================
RCS file: /cvsroot/toon/tag/tag/five_point.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- tag/five_point.h    28 Apr 2009 10:40:10 -0000      1.5
+++ tag/five_point.h    11 May 2009 17:32:31 -0000      1.6
@@ -35,6 +35,17 @@
 /// @ingroup essentialgroup
 TooN::SE3<> optimize_epipolar(const std::vector<std::pair<TooN::Vector<3>, 
TooN::Vector<3> > > & points, const TooN::SE3<> & initial);
 
+/// Given an essential matrix \e E and two points \e p and \e q, this
+/// functions computes the reprojection errors given by the squared distance 
from 
+/// \e p to the line defined by \f$ E\vec{q} \f$ and the squared distance from 
+/// \e q to the line defined by \f$ E\vec{p} \f$. If \e E is not an essential 
matrix
+/// then the errors will not be sensible.
+///
+///@param E \e E
+///@param p \e p
+///@param q \e q
+///@returns the reprojection errors
+std::pair<double, double> essential_reprojection_errors_squared(const 
TooN::Matrix<3>& E, const TooN::Vector<3>&p, const TooN::Vector<3>& q);
 }
 
 #endif // TAG_FIVE_POINT

Index: src/five_point.cpp
===================================================================
RCS file: /cvsroot/toon/tag/src/five_point.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- src/five_point.cpp  30 Apr 2009 17:52:20 -0000      1.15
+++ src/five_point.cpp  11 May 2009 17:32:31 -0000      1.16
@@ -327,4 +327,46 @@
        return SE3<>(Rt, Rn * X);
 }
 
+
+namespace {
+double sq(double x)
+{
+       return x*x;
+}
+}
+// Define a line l = [a b c] so that [x y 1] . [a b c] = 0
+//
+// The line equation can be written as:
+//
+// y = -ax/b -c/b
+//
+// And written in vector form:
+//
+// [ x ]   [0   ]              [ b ]
+// [ y ] = [-c/b]  + x (1/b) * [ -a]
+//
+//The line normal therefore is v = [a b]
+//
+// r is the vector from [x0 y0] to any point on the line. The perpendicular 
diatance to the
+// line is |r . v| / |v|
+//
+// d = | (x - x0)*a + (y-y0) * b | / sqrt(a^2 + b^2)
+//
+// Rearranging and using ax + yb = -c:
+//
+// d = |ax0 + by0 + c| / sqrt(a*a + b*b)
+double point_line_distance_squared(Vector<3> point, const Vector<3>& line)
+{      
+       //Normalize the point to [x0, y0, 1]
+       point.slice<0,2>() /= point[2];
+
+       return sq(point * line) / (sq(line[0]) + sq(line[1]));
+}
+
+
+pair<double, double> essential_reprojection_errors_squared(const Matrix<3>& E, 
const Vector<3>& p, const Vector<3>& q)
+{
+       return make_pair(point_line_distance_squared(p, E*q), 
point_line_distance_squared(q, E.T()*p));
+}
+
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]