8 #ifndef TURI_ONE_SHOT_MAPPING_FUNCTION_H_ 9 #define TURI_ONE_SHOT_MAPPING_FUNCTION_H_ 12 #include <Eigen/Dense> 20 #include <boost/gil/gil_all.hpp> 26 template <
typename T,
typename F>
27 boost::gil::point2<F> operator*(
const boost::gil::point2<T>& p,
28 const Eigen::Matrix<F, 3, 3>& m) {
29 float denominator = m(2, 0) * p.x + m(2, 1) * p.y + m(2, 2);
30 if (denominator == 0) {
32 return boost::gil::point2<F>(0, 0);
34 return boost::gil::point2<F>(
35 (m(0, 0) * p.x + m(0, 1) * p.y + m(0, 2)) / denominator,
36 (m(1, 0) * p.x + m(1, 1) * p.y + m(1, 2)) / denominator);
42 struct mapping_traits;
44 template <
typename F,
typename F2>
45 boost::gil::point2<F> transform(
const Eigen::Matrix<F, 3, 3>& mat,
46 const boost::gil::point2<F2>& src) {
51 struct mapping_traits<
Eigen::Matrix<F, 3, 3> > {
52 using result_type = boost::gil::point2<F>;
58 #endif // TURI_ONE_SHOT_MAPPING_FUNCTION_H_