added a safe projection method to Calibrated and SimpleCamera. added a positiveDepth property to ARToolkitMeasurement so that the visibility can be checked

release/4.3a0
Kai Ni 2009-09-13 16:09:54 +00:00
parent 571c0da8d1
commit 100b9b2eec
2 changed files with 30 additions and 3 deletions

View File

@ -8,6 +8,8 @@
#include "SimpleCamera.h"
#include "CalibratedCamera.h"
using namespace std;
namespace gtsam {
/* ************************************************************************* */
@ -24,10 +26,16 @@ namespace gtsam {
SimpleCamera::~SimpleCamera() {
}
Point2 SimpleCamera::project(const Point3 & P) const {
Point2 intrinsic = calibrated_.project(P);
pair<Point2, bool> SimpleCamera::projectSafe(const Point3& P) const {
Point3 cameraPoint = transform_to(calibrated_.pose(), P);
Point2 intrinsic = project_to_camera(cameraPoint);
Point2 projection = uncalibrate(K_, intrinsic);
return projection;
return pair<Point2, bool>(projection, cameraPoint.z() > 0);
}
Point2 SimpleCamera::project(const Point3 & P) const {
pair<Point2, bool> projected = projectSafe(P);
return projected.first;
}
SimpleCamera SimpleCamera::level(const Cal3_S2& K, const Pose2& pose2, double height) {
@ -38,6 +46,10 @@ namespace gtsam {
// measurement functions and derivatives
/* ************************************************************************* */
pair<Point2, bool> projectSafe(const SimpleCamera& camera, const Point3& point) {
return camera.projectSafe(point);
}
Point2 project(const SimpleCamera& camera, const Point3& point) {
return camera.project(point);
}

View File

@ -37,6 +37,15 @@ namespace gtsam {
return K_;
}
/**
* project a 3d point to the camera and also check the depth
*/
std::pair<Point2,bool> projectSafe(const Point3& P) const;
/**
* project a 3d point to the camera
*/
Point2 project(const Point3& P) const;
/**
@ -59,6 +68,12 @@ namespace gtsam {
// measurement functions and derivatives
/* ************************************************************************* */
/**
* This function receives the camera pose and the landmark location and
returns the location the point is supposed to appear in the image as well as the sign of the depth
*/
std::pair<Point2, bool> projectSafe(const SimpleCamera& camera, const Point3& point);
/**
* This function receives the camera pose and the landmark location and
returns the location the point is supposed to appear in the image