| 
									
										
										
										
											2014-10-01 17:25:49 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @file expressions.h | 
					
						
							|  |  |  |  * @brief Common expressions for solving geometry/slam/sfm problems | 
					
						
							|  |  |  |  * @date Oct 1, 2014 | 
					
						
							|  |  |  |  * @author Frank Dellaert | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <gtsam_unstable/nonlinear/Expression.h>
 | 
					
						
							|  |  |  | #include <gtsam/geometry/Cal3_S2.h>
 | 
					
						
							|  |  |  | #include <gtsam/geometry/PinholeCamera.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-03 02:20:00 +08:00
										 |  |  | // Generics
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<class T> | 
					
						
							|  |  |  | Expression<T> between(const Expression<T>& t1, const Expression<T>& t2) { | 
					
						
							|  |  |  |   return Expression<T>(t1, &T::between, t2); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // 2D Geometry
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 17:25:49 +08:00
										 |  |  | typedef Expression<Point2> Point2_; | 
					
						
							| 
									
										
										
										
											2014-10-03 02:20:00 +08:00
										 |  |  | typedef Expression<Rot2> Rot2_; | 
					
						
							|  |  |  | typedef Expression<Pose2> Pose2_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Point2_ transform_to(const Pose2_& x, const Point2_& p) { | 
					
						
							|  |  |  |   return Point2_(x, &Pose2::transform_to, p); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // 3D Geometry
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 17:25:49 +08:00
										 |  |  | typedef Expression<Point3> Point3_; | 
					
						
							|  |  |  | typedef Expression<Rot3> Rot3_; | 
					
						
							|  |  |  | typedef Expression<Pose3> Pose3_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Point3_ transform_to(const Pose3_& x, const Point3_& p) { | 
					
						
							|  |  |  |   return Point3_(x, &Pose3::transform_to, p); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-03 02:20:00 +08:00
										 |  |  | // Projection
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef Expression<Cal3_S2> Cal3_S2_; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-01 17:25:49 +08:00
										 |  |  | Point2_ project(const Point3_& p_cam) { | 
					
						
							|  |  |  |   return Point2_(PinholeCamera<Cal3_S2>::project_to_camera, p_cam); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<class CAL> | 
					
						
							|  |  |  | Point2_ uncalibrate(const Expression<CAL>& K, const Point2_& xy_hat) { | 
					
						
							|  |  |  |   return Point2_(K, &CAL::uncalibrate, xy_hat); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // \namespace gtsam
 | 
					
						
							|  |  |  | 
 |