Skip to content

Commit

Permalink
TooN-2 updates to four point pose.
Browse files Browse the repository at this point in the history
  • Loading branch information
edrosten committed Aug 25, 2009
1 parent 82e53e6 commit c6fe3b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions src/fourpointpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ static inline bool computeDistances( const double xx, const double x, const doub
double beta = std::asin(sqrt(distance) / x);
double diff = fabs(alpha) - fabs(beta);
if( diff > angularError ){
TooN::Zero(roots);
roots = TooN::Zeros;
return false;
}
det = 0;
} else {
det = sqrt(det);
}
roots = (TooN::make_Vector, -p*0.5 + det, -p*0.5 - det);
roots = TooN::makeVector( -p*0.5 + det, -p*0.5 - det);
return true;
}

Expand Down Expand Up @@ -103,8 +103,8 @@ static bool fourPointSolver ( const std::vector<TooN::Vector<3> > & points, std:
distances[count] = diff * diff;
angles[count] = 2* myPixels[i] * myPixels[j];
}

TooN::Zero(A);
A = TooN::Zeros;
A.slice<0,0,1,5>() = getACoeffs(angles[0], angles[1], angles[3], distances[0], distances[1], distances[3]).as_row();
A.slice<1,0,1,5>() = getACoeffs(angles[0], angles[2], angles[4], distances[0], distances[2], distances[4]).as_row();
A.slice<2,0,1,5>() = getACoeffs(angles[1], angles[2], angles[5], distances[1], distances[2], distances[5]).as_row();
Expand Down Expand Up @@ -144,14 +144,14 @@ static bool fourPointSolver ( const std::vector<TooN::Vector<3> > & points, std:

bool valid = true;
double x = sqrt( xx );
length[0] = (TooN::make_Vector, x, -x); // possible distances to point 0
length[0] = TooN::makeVector( x, -x); // possible distances to point 0
valid &= computeDistances( xx, x, angles[0], distances[0], angularError, length[1]);
valid &= computeDistances( xx, x, angles[1], distances[1], angularError, length[2]);
valid &= computeDistances( xx, x, angles[2], distances[2], angularError, length[3]);
return valid;
}

TooN::SE3 fourPointPose( const std::vector<TooN::Vector<3> > & points, const std::vector<TooN::Vector<3> > & pixels, bool & valid, const double angularError ){
TooN::SE3<> fourPointPose( const std::vector<TooN::Vector<3> > & points, const std::vector<TooN::Vector<3> > & pixels, bool & valid, const double angularError ){
double orientationTest = ((points[1] - points[0]) ^ (points[2] - points[0])) * (points[3] - points[0]);

// normalising scales for angle computation in next loop
Expand All @@ -164,7 +164,7 @@ TooN::SE3 fourPointPose( const std::vector<TooN::Vector<3> > & points, const std
TooN::Vector<6> distances;
valid = fourPointSolver( points, myPixels, distances, length, angularError);
if( !valid )
return TooN::SE3();
return TooN::SE3<>();

// figure out the right lengths
// brute force through all combinations, with some optimizations to stop early, if a better hypothesis exists
Expand Down Expand Up @@ -195,7 +195,7 @@ TooN::SE3 fourPointPose( const std::vector<TooN::Vector<3> > & points, const std
}
if(minIndex == -1){
valid = false;
return TooN::SE3();
return TooN::SE3<>();
}

// pixel directions extended to the right distance
Expand All @@ -209,7 +209,7 @@ TooN::SE3 fourPointPose( const std::vector<TooN::Vector<3> > & points, const std
}

// just a copy of the above code with modifications to the case search
TooN::SE3 fourPointPoseFromCamera( const std::vector<TooN::Vector<3> > & points, const std::vector<TooN::Vector<3> > & pixels, bool & valid, const double angularError ){
TooN::SE3<> fourPointPoseFromCamera( const std::vector<TooN::Vector<3> > & points, const std::vector<TooN::Vector<3> > & pixels, bool & valid, const double angularError ){
// normalising scales for angle computation in next loop
std::vector<TooN::Vector<3> > myPixels(4);
for(unsigned int i = 0; i < 4; i++)
Expand All @@ -220,7 +220,7 @@ TooN::SE3 fourPointPoseFromCamera( const std::vector<TooN::Vector<3> > & points,
TooN::Vector<6> distances;
valid = fourPointSolver( points, myPixels, distances, length, angularError);
if( !valid )
return TooN::SE3();
return TooN::SE3<>();

// figure out the right lengths
// brute force through all combinations, with some optimizations to stop early, if a better hypothesis exists
Expand Down Expand Up @@ -248,7 +248,7 @@ TooN::SE3 fourPointPoseFromCamera( const std::vector<TooN::Vector<3> > & points,
}
if(minIndex == -1){
valid = false;
return TooN::SE3();
return TooN::SE3<>();
}

// pixel directions extended to the right distance
Expand Down
6 changes: 3 additions & 3 deletions tag/fourpointpose.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace tag {
/// corresponds to 90 deg VOW over 640 pixels.
/// @return SE3 describing the camera pose
/// @ingroup fourpointpose
TooN::SE3 fourPointPose( const std::vector<TooN::Vector<3> > & points, const std::vector<TooN::Vector<3> > & pixels, bool & valid, const double angularError = 0.14 );
TooN::SE3<> fourPointPose( const std::vector<TooN::Vector<3> > & points, const std::vector<TooN::Vector<3> > & pixels, bool & valid, const double angularError = 0.14 );

/// A special case of the general @ref fourPointPose function which assumes that points are
/// in front of a given camera plane but now may also lie in the same plane (but not all on one line).
Expand All @@ -43,7 +43,7 @@ TooN::SE3 fourPointPose( const std::vector<TooN::Vector<3> > & points, const std
/// corresponds to 90 deg VOW over 640 pixels.
/// @return SE3 describing the camera pose
/// @ingroup fourpointpose
TooN::SE3 fourPointPoseFromCamera( const std::vector<TooN::Vector<3> > & points, const std::vector<TooN::Vector<3> > & pixels, bool & valid, const double angularError = 0.14 );
TooN::SE3<> fourPointPoseFromCamera( const std::vector<TooN::Vector<3> > & points, const std::vector<TooN::Vector<3> > & pixels, bool & valid, const double angularError = 0.14 );

/// A RANSAC estimator using the @ref fourPointPose function. The
/// Correspondence datatype must provide a member position for the 3D point and
Expand All @@ -59,7 +59,7 @@ TooN::SE3 fourPointPoseFromCamera( const std::vector<TooN::Vector<3> > & points,
template <int ImagePlaneZ = 1>
struct Point4SE3Estimation {
/// SE3 describing the transformation from world to camera coordinate frame
TooN::SE3 T;
TooN::SE3<> T;
/// was the estimation valid
bool valid;
/// angular error to accept in the 4 point pose estimation
Expand Down

0 comments on commit c6fe3b9

Please sign in to comment.