Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 1 | #include "y2019/vision/target_finder.h" |
| 2 | |
| 3 | #include "ceres/ceres.h" |
| 4 | |
| 5 | #include <math.h> |
| 6 | |
Alex Perry | b6f334d | 2019-03-23 13:10:45 -0700 | [diff] [blame] | 7 | #include "aos/util/math.h" |
| 8 | |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 9 | using ceres::CENTRAL; |
| 10 | using ceres::CostFunction; |
| 11 | using ceres::Problem; |
| 12 | using ceres::Solver; |
| 13 | using ceres::Solve; |
| 14 | |
| 15 | namespace y2019 { |
| 16 | namespace vision { |
| 17 | |
| 18 | static constexpr double kInchesToMeters = 0.0254; |
| 19 | |
| 20 | using namespace aos::vision; |
| 21 | using aos::vision::Vector; |
| 22 | |
| 23 | Target Target::MakeTemplate() { |
| 24 | Target out; |
| 25 | // This is how off-vertical the tape is. |
| 26 | const double theta = 14.5 * M_PI / 180.0; |
| 27 | |
| 28 | const double tape_offset = 4 * kInchesToMeters; |
| 29 | const double tape_width = 2 * kInchesToMeters; |
| 30 | const double tape_length = 5.5 * kInchesToMeters; |
| 31 | |
| 32 | const double s = sin(theta); |
| 33 | const double c = cos(theta); |
| 34 | out.right.top = Vector<2>(tape_offset, 0.0); |
| 35 | out.right.inside = Vector<2>(tape_offset + tape_width * c, tape_width * s); |
| 36 | out.right.bottom = Vector<2>(tape_offset + tape_width * c + tape_length * s, |
| 37 | tape_width * s - tape_length * c); |
| 38 | out.right.outside = |
| 39 | Vector<2>(tape_offset + tape_length * s, -tape_length * c); |
| 40 | |
| 41 | out.right.is_right = true; |
| 42 | out.left.top = Vector<2>(-out.right.top.x(), out.right.top.y()); |
| 43 | out.left.inside = Vector<2>(-out.right.inside.x(), out.right.inside.y()); |
| 44 | out.left.bottom = Vector<2>(-out.right.bottom.x(), out.right.bottom.y()); |
| 45 | out.left.outside = Vector<2>(-out.right.outside.x(), out.right.outside.y()); |
| 46 | return out; |
| 47 | } |
| 48 | |
Austin Schuh | 2894e90 | 2019-03-03 21:12:46 -0800 | [diff] [blame] | 49 | std::array<Vector<2>, 8> Target::ToPointList() const { |
Austin Schuh | e6cfbe3 | 2019-03-10 18:05:57 -0700 | [diff] [blame] | 50 | // Note, the even points are fit with the line solver in the 4 point solution |
| 51 | // while the odds are fit with the point matcher. |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 52 | return std::array<Vector<2>, 8>{{right.top, right.outside, right.inside, |
| 53 | right.bottom, left.top, left.outside, |
| 54 | left.inside, left.bottom}}; |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 55 | } |
| 56 | |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 57 | Target Project(const Target &target, const IntrinsicParams &intrinsics, |
| 58 | const ExtrinsicParams &extrinsics) { |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 59 | Target new_targ; |
| 60 | new_targ.right.is_right = true; |
Austin Schuh | 4d6e9bd | 2019-03-08 19:54:17 -0800 | [diff] [blame] | 61 | new_targ.right.top = Project(target.right.top, intrinsics, extrinsics); |
| 62 | new_targ.right.inside = Project(target.right.inside, intrinsics, extrinsics); |
| 63 | new_targ.right.bottom = Project(target.right.bottom, intrinsics, extrinsics); |
| 64 | new_targ.right.outside = |
| 65 | Project(target.right.outside, intrinsics, extrinsics); |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 66 | |
Austin Schuh | 4d6e9bd | 2019-03-08 19:54:17 -0800 | [diff] [blame] | 67 | new_targ.left.top = Project(target.left.top, intrinsics, extrinsics); |
| 68 | new_targ.left.inside = Project(target.left.inside, intrinsics, extrinsics); |
| 69 | new_targ.left.bottom = Project(target.left.bottom, intrinsics, extrinsics); |
| 70 | new_targ.left.outside = Project(target.left.outside, intrinsics, extrinsics); |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 71 | |
| 72 | return new_targ; |
| 73 | } |
| 74 | |
| 75 | // Used at runtime on a single image given camera parameters. |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 76 | struct PointCostFunctor { |
| 77 | PointCostFunctor(Vector<2> result, Vector<2> template_pt, |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 78 | IntrinsicParams intrinsics) |
| 79 | : result(result), template_pt(template_pt), intrinsics(intrinsics) {} |
| 80 | |
Alex Perry | 3d0abf2 | 2019-04-06 19:52:24 -0700 | [diff] [blame^] | 81 | template <typename T> |
| 82 | bool operator()(const T *const x, T *residual) const { |
| 83 | const auto extrinsics = TemplatedExtrinsicParams<T>::get(x); |
| 84 | ::Eigen::Matrix<T, 2, 1> pt = |
| 85 | Project<T>(ToEigenMatrix<T>(template_pt), intrinsics, extrinsics); |
| 86 | residual[0] = result.x() - pt(0, 0); |
| 87 | residual[1] = result.y() - pt(0, 1); |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 88 | return true; |
| 89 | } |
| 90 | |
| 91 | Vector<2> result; |
| 92 | Vector<2> template_pt; |
| 93 | IntrinsicParams intrinsics; |
| 94 | }; |
| 95 | |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 96 | // Find the distance from a lower target point to the 'vertical' line it should |
| 97 | // be on. |
| 98 | struct LineCostFunctor { |
| 99 | LineCostFunctor(Vector<2> result, Segment<2> template_seg, |
| 100 | IntrinsicParams intrinsics) |
| 101 | : result(result), template_seg(template_seg), intrinsics(intrinsics) {} |
| 102 | |
Alex Perry | 3d0abf2 | 2019-04-06 19:52:24 -0700 | [diff] [blame^] | 103 | template <typename T> |
| 104 | bool operator()(const T *const x, T *residual) const { |
| 105 | const auto extrinsics = TemplatedExtrinsicParams<T>::get(x); |
| 106 | const ::Eigen::Matrix<T, 2, 1> p1 = |
| 107 | Project<T>(ToEigenMatrix<T>(template_seg.A()), intrinsics, extrinsics); |
| 108 | const ::Eigen::Matrix<T, 2, 1> p2 = |
| 109 | Project<T>(ToEigenMatrix<T>(template_seg.B()), intrinsics, extrinsics); |
| 110 | // Distance from line(P1, P2) to point result |
| 111 | T dx = p2.x() - p1.x(); |
| 112 | T dy = p2.y() - p1.y(); |
| 113 | T denom = (p2-p1).norm(); |
| 114 | residual[0] = ceres::abs(dy * result.x() - dx * result.y() + |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 115 | p2.x() * p1.y() - p2.y() * p1.x()) / |
| 116 | denom; |
| 117 | return true; |
| 118 | } |
| 119 | |
| 120 | Vector<2> result; |
| 121 | Segment<2> template_seg; |
| 122 | IntrinsicParams intrinsics; |
| 123 | }; |
| 124 | |
Austin Schuh | e6cfbe3 | 2019-03-10 18:05:57 -0700 | [diff] [blame] | 125 | // Find the distance that the bottom point is outside the target and penalize |
| 126 | // that linearly. |
| 127 | class BottomPointCostFunctor { |
| 128 | public: |
| 129 | BottomPointCostFunctor(::Eigen::Vector2f bottom_point, |
| 130 | Segment<2> template_seg, IntrinsicParams intrinsics) |
| 131 | : bottom_point_(bottom_point.x(), bottom_point.y()), |
| 132 | template_seg_(template_seg), |
| 133 | intrinsics_(intrinsics) {} |
| 134 | |
Alex Perry | 3d0abf2 | 2019-04-06 19:52:24 -0700 | [diff] [blame^] | 135 | template <typename T> |
| 136 | bool operator()(const T *const x, T *residual) const { |
| 137 | const auto extrinsics = TemplatedExtrinsicParams<T>::get(x); |
| 138 | const ::Eigen::Matrix<T, 2, 1> p1 = Project<T>( |
| 139 | ToEigenMatrix<T>(template_seg_.A()), intrinsics_, extrinsics); |
| 140 | const ::Eigen::Matrix<T, 2, 1> p2 = Project<T>( |
| 141 | ToEigenMatrix<T>(template_seg_.B()), intrinsics_, extrinsics); |
Austin Schuh | e6cfbe3 | 2019-03-10 18:05:57 -0700 | [diff] [blame] | 142 | |
| 143 | // Construct a vector pointed perpendicular to the line. This vector is |
| 144 | // pointed down out the bottom of the target. |
Alex Perry | 3d0abf2 | 2019-04-06 19:52:24 -0700 | [diff] [blame^] | 145 | ::Eigen::Matrix<T, 2, 1> down_axis; |
| 146 | down_axis << -(p1.y() - p2.y()), p1.x() - p2.x(); |
Austin Schuh | e6cfbe3 | 2019-03-10 18:05:57 -0700 | [diff] [blame] | 147 | down_axis.normalize(); |
| 148 | |
| 149 | // Positive means out. |
Alex Perry | 3d0abf2 | 2019-04-06 19:52:24 -0700 | [diff] [blame^] | 150 | const T component = |
| 151 | down_axis.transpose() * (bottom_point_ - p1); |
Austin Schuh | e6cfbe3 | 2019-03-10 18:05:57 -0700 | [diff] [blame] | 152 | |
Alex Perry | 3d0abf2 | 2019-04-06 19:52:24 -0700 | [diff] [blame^] | 153 | if (component > T(0)) { |
Austin Schuh | e6cfbe3 | 2019-03-10 18:05:57 -0700 | [diff] [blame] | 154 | residual[0] = component * 1.0; |
| 155 | } else { |
Alex Perry | 3d0abf2 | 2019-04-06 19:52:24 -0700 | [diff] [blame^] | 156 | residual[0] = T(0); |
Austin Schuh | e6cfbe3 | 2019-03-10 18:05:57 -0700 | [diff] [blame] | 157 | } |
| 158 | return true; |
| 159 | } |
| 160 | |
| 161 | private: |
| 162 | ::Eigen::Vector2d bottom_point_; |
| 163 | Segment<2> template_seg_; |
| 164 | |
| 165 | IntrinsicParams intrinsics_; |
| 166 | }; |
| 167 | |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 168 | IntermediateResult TargetFinder::ProcessTargetToResult(const Target &target, |
| 169 | bool verbose) { |
| 170 | // Memory for the ceres solver. |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 171 | double params_8point[ExtrinsicParams::kNumParams]; |
| 172 | default_extrinsics_.set(¶ms_8point[0]); |
| 173 | double params_4point[ExtrinsicParams::kNumParams]; |
| 174 | default_extrinsics_.set(¶ms_4point[0]); |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 175 | |
Brian Silverman | 6323677 | 2019-03-23 22:02:44 -0700 | [diff] [blame] | 176 | Problem::Options problem_options; |
| 177 | problem_options.context = ceres_context_.get(); |
| 178 | Problem problem_8point(problem_options); |
| 179 | Problem problem_4point(problem_options); |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 180 | |
Austin Schuh | 2894e90 | 2019-03-03 21:12:46 -0800 | [diff] [blame] | 181 | ::std::array<aos::vision::Vector<2>, 8> target_value = target.ToPointList(); |
| 182 | ::std::array<aos::vision::Vector<2>, 8> template_value = |
| 183 | target_template_.ToPointList(); |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 184 | |
| 185 | for (size_t i = 0; i < 8; ++i) { |
Austin Schuh | 2894e90 | 2019-03-03 21:12:46 -0800 | [diff] [blame] | 186 | aos::vision::Vector<2> a = template_value[i]; |
| 187 | aos::vision::Vector<2> b = target_value[i]; |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 188 | |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 189 | if (i % 2 == 1) { |
| 190 | aos::vision::Vector<2> a2 = template_value[i-1]; |
| 191 | aos::vision::Segment<2> line = Segment<2>(a, a2); |
| 192 | |
| 193 | problem_4point.AddResidualBlock( |
Alex Perry | 3d0abf2 | 2019-04-06 19:52:24 -0700 | [diff] [blame^] | 194 | new ceres::AutoDiffCostFunction<LineCostFunctor, 1, 4>( |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 195 | new LineCostFunctor(b, line, intrinsics_)), |
Austin Schuh | e6cfbe3 | 2019-03-10 18:05:57 -0700 | [diff] [blame] | 196 | NULL, ¶ms_4point[0]); |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 197 | } else { |
| 198 | problem_4point.AddResidualBlock( |
Alex Perry | 3d0abf2 | 2019-04-06 19:52:24 -0700 | [diff] [blame^] | 199 | new ceres::AutoDiffCostFunction<PointCostFunctor, 2, 4>( |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 200 | new PointCostFunctor(b, a, intrinsics_)), |
Austin Schuh | e6cfbe3 | 2019-03-10 18:05:57 -0700 | [diff] [blame] | 201 | NULL, ¶ms_4point[0]); |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | problem_8point.AddResidualBlock( |
Alex Perry | 3d0abf2 | 2019-04-06 19:52:24 -0700 | [diff] [blame^] | 205 | new ceres::AutoDiffCostFunction<PointCostFunctor, 2, 4>( |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 206 | new PointCostFunctor(b, a, intrinsics_)), |
Austin Schuh | e6cfbe3 | 2019-03-10 18:05:57 -0700 | [diff] [blame] | 207 | NULL, ¶ms_8point[0]); |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 208 | } |
| 209 | |
Austin Schuh | bb2ac92 | 2019-03-11 01:09:57 -0700 | [diff] [blame] | 210 | Solver::Options options; |
| 211 | options.minimizer_progress_to_stdout = false; |
| 212 | Solver::Summary summary_8point; |
| 213 | Solve(options, &problem_8point, &summary_8point); |
| 214 | |
| 215 | |
| 216 | // So, let's sneak up on it. Start by warm-starting it with where we got on the 8 point solution. |
| 217 | ExtrinsicParams::get(¶ms_8point[0]).set(¶ms_4point[0]); |
| 218 | // Then solve without the bottom constraint. |
| 219 | Solver::Summary summary_4point1; |
| 220 | Solve(options, &problem_4point, &summary_4point1); |
| 221 | |
Austin Schuh | e6cfbe3 | 2019-03-10 18:05:57 -0700 | [diff] [blame] | 222 | // Now, add a large cost for the bottom point being below the bottom line. |
| 223 | problem_4point.AddResidualBlock( |
Alex Perry | 3d0abf2 | 2019-04-06 19:52:24 -0700 | [diff] [blame^] | 224 | new ceres::AutoDiffCostFunction<BottomPointCostFunctor, 1, 4>( |
Austin Schuh | e6cfbe3 | 2019-03-10 18:05:57 -0700 | [diff] [blame] | 225 | new BottomPointCostFunctor(target.left.bottom_point, |
| 226 | Segment<2>(target_template_.left.outside, |
| 227 | target_template_.left.bottom), |
| 228 | intrinsics_)), |
| 229 | NULL, ¶ms_4point[0]); |
| 230 | // Make sure to point the segment the other way so when we do a -pi/2 rotation |
| 231 | // on the line, it points down in target space. |
| 232 | problem_4point.AddResidualBlock( |
Alex Perry | 3d0abf2 | 2019-04-06 19:52:24 -0700 | [diff] [blame^] | 233 | new ceres::AutoDiffCostFunction<BottomPointCostFunctor, 1, 4>( |
Austin Schuh | e6cfbe3 | 2019-03-10 18:05:57 -0700 | [diff] [blame] | 234 | new BottomPointCostFunctor(target.right.bottom_point, |
| 235 | Segment<2>(target_template_.right.bottom, |
| 236 | target_template_.right.outside), |
| 237 | intrinsics_)), |
| 238 | NULL, ¶ms_4point[0]); |
| 239 | |
Austin Schuh | bb2ac92 | 2019-03-11 01:09:57 -0700 | [diff] [blame] | 240 | // And then re-solve. |
| 241 | Solver::Summary summary_4point2; |
| 242 | Solve(options, &problem_4point, &summary_4point2); |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 243 | |
| 244 | IntermediateResult IR; |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 245 | IR.extrinsics = ExtrinsicParams::get(¶ms_8point[0]); |
| 246 | IR.solver_error = summary_8point.final_cost; |
| 247 | IR.backup_extrinsics = ExtrinsicParams::get(¶ms_4point[0]); |
Austin Schuh | bb2ac92 | 2019-03-11 01:09:57 -0700 | [diff] [blame] | 248 | IR.backup_solver_error = summary_4point2.final_cost; |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 249 | |
Alex Perry | b6f334d | 2019-03-23 13:10:45 -0700 | [diff] [blame] | 250 | // Normalize all angles to (-M_PI, M_PI] |
| 251 | IR.extrinsics.r1 = ::aos::math::NormalizeAngle(IR.extrinsics.r1); |
| 252 | IR.extrinsics.r2 = ::aos::math::NormalizeAngle(IR.extrinsics.r2); |
Austin Schuh | 4563988 | 2019-03-24 19:20:42 -0700 | [diff] [blame] | 253 | IR.backup_extrinsics.r1 = |
| 254 | ::aos::math::NormalizeAngle(IR.backup_extrinsics.r1); |
| 255 | IR.backup_extrinsics.r2 = |
| 256 | ::aos::math::NormalizeAngle(IR.backup_extrinsics.r2); |
| 257 | |
| 258 | // Ok, let's look at how perpendicular the corners are. |
| 259 | // Vector from the outside to inside along the top on the left. |
| 260 | const ::Eigen::Vector2d top_left_vector = |
| 261 | (target.left.top.GetData() - target.left.inside.GetData()) |
| 262 | .transpose() |
| 263 | .normalized(); |
| 264 | // Vector up the outside of the left target. |
| 265 | const ::Eigen::Vector2d outer_left_vector = |
| 266 | (target.left.top.GetData() - target.left.outside.GetData()) |
| 267 | .transpose() |
| 268 | .normalized(); |
| 269 | // Vector up the inside of the left target. |
| 270 | const ::Eigen::Vector2d inner_left_vector = |
| 271 | (target.left.inside.GetData() - target.left.bottom.GetData()) |
| 272 | .transpose() |
| 273 | .normalized(); |
| 274 | |
| 275 | // Vector from the outside to inside along the top on the right. |
| 276 | const ::Eigen::Vector2d top_right_vector = |
| 277 | (target.right.top.GetData() - target.right.inside.GetData()) |
| 278 | .transpose() |
| 279 | .normalized(); |
| 280 | // Vector up the outside of the right target. |
| 281 | const ::Eigen::Vector2d outer_right_vector = |
| 282 | (target.right.top.GetData() - target.right.outside.GetData()) |
| 283 | .transpose() |
| 284 | .normalized(); |
| 285 | // Vector up the inside of the right target. |
| 286 | const ::Eigen::Vector2d inner_right_vector = |
| 287 | (target.right.inside.GetData() - target.right.bottom.GetData()) |
| 288 | .transpose() |
| 289 | .normalized(); |
| 290 | |
| 291 | // Now dot the vectors and use that to compute angles. |
| 292 | // Left side, outside corner. |
| 293 | const double left_outer_corner_dot = |
| 294 | (outer_left_vector.transpose() * top_left_vector)(0); |
| 295 | // Left side, inside corner. |
| 296 | const double left_inner_corner_dot = |
| 297 | (inner_left_vector.transpose() * top_left_vector)(0); |
| 298 | // Right side, outside corner. |
| 299 | const double right_outer_corner_dot = |
| 300 | (outer_right_vector.transpose() * top_right_vector)(0); |
| 301 | // Right side, inside corner. |
| 302 | const double right_inner_corner_dot = |
| 303 | (inner_right_vector.transpose() * top_right_vector)(0); |
| 304 | |
| 305 | constexpr double kCornerThreshold = 0.35; |
| 306 | if (::std::abs(left_outer_corner_dot) < kCornerThreshold && |
| 307 | ::std::abs(left_inner_corner_dot) < kCornerThreshold && |
| 308 | ::std::abs(right_outer_corner_dot) < kCornerThreshold && |
| 309 | ::std::abs(right_inner_corner_dot) < kCornerThreshold) { |
| 310 | IR.good_corners = true; |
| 311 | } else { |
| 312 | IR.good_corners = false; |
| 313 | } |
Alex Perry | b6f334d | 2019-03-23 13:10:45 -0700 | [diff] [blame] | 314 | |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 315 | if (verbose) { |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 316 | std::cout << "rup = " << intrinsics_.mount_angle * 180 / M_PI << ";\n"; |
| 317 | std::cout << "fl = " << intrinsics_.focal_length << ";\n"; |
| 318 | std::cout << "8 points:\n"; |
| 319 | std::cout << summary_8point.BriefReport() << "\n"; |
| 320 | std::cout << "error = " << summary_8point.final_cost << ";\n"; |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 321 | std::cout << "y = " << IR.extrinsics.y / kInchesToMeters << ";\n"; |
| 322 | std::cout << "z = " << IR.extrinsics.z / kInchesToMeters << ";\n"; |
| 323 | std::cout << "r1 = " << IR.extrinsics.r1 * 180 / M_PI << ";\n"; |
| 324 | std::cout << "r2 = " << IR.extrinsics.r2 * 180 / M_PI << ";\n"; |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 325 | std::cout << "4 points:\n"; |
Austin Schuh | bb2ac92 | 2019-03-11 01:09:57 -0700 | [diff] [blame] | 326 | std::cout << summary_4point1.BriefReport() << "\n"; |
| 327 | std::cout << "error = " << summary_4point1.final_cost << ";\n\n"; |
| 328 | std::cout << "4 points:\n"; |
| 329 | std::cout << summary_4point2.BriefReport() << "\n"; |
| 330 | std::cout << "error = " << summary_4point2.final_cost << ";\n\n"; |
Alex Perry | bac3d3f | 2019-03-10 14:26:51 -0700 | [diff] [blame] | 331 | std::cout << "y = " << IR.backup_extrinsics.y / kInchesToMeters << ";\n"; |
| 332 | std::cout << "z = " << IR.backup_extrinsics.z / kInchesToMeters << ";\n"; |
| 333 | std::cout << "r1 = " << IR.backup_extrinsics.r1 * 180 / M_PI << ";\n"; |
| 334 | std::cout << "r2 = " << IR.backup_extrinsics.r2 * 180 / M_PI << ";\n"; |
Austin Schuh | 4563988 | 2019-03-24 19:20:42 -0700 | [diff] [blame] | 335 | |
| 336 | |
| 337 | printf("left upper outer corner angle: %f, top (%f, %f), outer (%f, %f)\n", |
| 338 | (outer_left_vector.transpose() * top_left_vector)(0), |
| 339 | top_left_vector(0, 0), top_left_vector(1, 0), |
| 340 | outer_left_vector(0, 0), outer_left_vector(1, 0)); |
| 341 | printf("left upper inner corner angle: %f\n", |
| 342 | (inner_left_vector.transpose() * top_left_vector)(0)); |
| 343 | |
| 344 | printf("right upper outer corner angle: %f, top (%f, %f), outer (%f, %f)\n", |
| 345 | (outer_right_vector.transpose() * top_right_vector)(0), |
| 346 | top_right_vector(0, 0), top_right_vector(1, 0), |
| 347 | outer_right_vector(0, 0), outer_right_vector(1, 0)); |
| 348 | printf("right upper inner corner angle: %f\n", |
| 349 | (inner_right_vector.transpose() * top_right_vector)(0)); |
Parker Schuh | 2a1447c | 2019-02-17 00:25:29 -0800 | [diff] [blame] | 350 | } |
| 351 | return IR; |
| 352 | } |
| 353 | |
| 354 | } // namespace vision |
| 355 | } // namespace y2019 |