Want to found perspective

asked 2019-04-30 08:51:44 -0600

dev4all12358 gravatar image

Hello, I want to undistord the image just using perspective transformation. Here is the image I use.

image description

Here is the code I use:

Mat input, output;
  input = cv::imread("1_1gVwxOmy8aEZr6duMTmHuA.png");

  std::vector<Point2f> image_points;
  image_points.push_back(Point2f(434, 291));
  image_points.push_back(Point2f(476, 278));
  image_points.push_back(Point2f(527, 257));
  image_points.push_back(Point2f(592, 240));
  image_points.push_back(Point2f(656, 225));
  image_points.push_back(Point2f(730, 218));
  image_points.push_back(Point2f(808, 215));
  image_points.push_back(Point2f(884, 222));
  image_points.push_back(Point2f(954, 229));
  image_points.push_back(Point2f(421, 343));
  image_points.push_back(Point2f(462, 326));
  image_points.push_back(Point2f(514, 310));
  image_points.push_back(Point2f(575, 291));
  image_points.push_back(Point2f(647, 282));
  image_points.push_back(Point2f(727, 271));
  image_points.push_back(Point2f(811, 269));
  image_points.push_back(Point2f(893, 278));
  image_points.push_back(Point2f(965, 282));
  image_points.push_back(Point2f(404, 400));
  image_points.push_back(Point2f(445, 387));
  image_points.push_back(Point2f(498, 373));
  image_points.push_back(Point2f(565, 360));
  image_points.push_back(Point2f(641, 345));
  image_points.push_back(Point2f(725, 342));
  image_points.push_back(Point2f(813, 337));
  image_points.push_back(Point2f(900, 341));
  image_points.push_back(Point2f(977, 349));
  image_points.push_back(Point2f(394, 467));
  image_points.push_back(Point2f(436, 454));
  image_points.push_back(Point2f(490, 447));
  image_points.push_back(Point2f(556, 436));
  image_points.push_back(Point2f(634, 429));
  image_points.push_back(Point2f(722, 423));
  image_points.push_back(Point2f(817, 420));
  image_points.push_back(Point2f(905, 424));
  image_points.push_back(Point2f(987, 428));
  image_points.push_back(Point2f(390, 533));
  image_points.push_back(Point2f(432, 530));
  image_points.push_back(Point2f(483, 523));
  image_points.push_back(Point2f(550, 522));
  image_points.push_back(Point2f(629, 516));
  image_points.push_back(Point2f(721, 513));
  image_points.push_back(Point2f(819, 515));
  image_points.push_back(Point2f(909, 512));
  image_points.push_back(Point2f(991, 513));
  image_points.push_back(Point2f(394, 602));
  image_points.push_back(Point2f(433, 607));
  image_points.push_back(Point2f(487, 606));
  image_points.push_back(Point2f(552, 609));
  image_points.push_back(Point2f(633, 608));
  image_points.push_back(Point2f(724, 610));
  image_points.push_back(Point2f(818, 605));
  image_points.push_back(Point2f(909, 604));
  image_points.push_back(Point2f(992, 600));

  std::vector<Point2f> output_points;
  output_points.push_back(Point2f(0, 0));
  output_points.push_back(Point2f(0, 10));
  output_points.push_back(Point2f(0, 20));
  output_points.push_back(Point2f(0, 30));
  output_points.push_back(Point2f(0, 40));
  output_points.push_back(Point2f(0, 50));
  output_points.push_back(Point2f(0, 60));
  output_points.push_back(Point2f(0, 70));
  output_points.push_back(Point2f(0, 80));
  output_points.push_back(Point2f(10, 0));
  output_points.push_back(Point2f(10, 10));
  output_points.push_back(Point2f(10, 20));
  output_points.push_back(Point2f(10, 30));
  output_points.push_back(Point2f(10, 40));
  output_points.push_back(Point2f(10, 50));
  output_points.push_back(Point2f(10, 60));
  output_points.push_back(Point2f(10, 70));
  output_points.push_back(Point2f(10, 80));
  output_points.push_back(Point2f(20, 0));
  output_points.push_back(Point2f(20, 10));
  output_points.push_back(Point2f(20, 20));
  output_points.push_back(Point2f(20, 30));
  output_points.push_back(Point2f(20, 40));
  output_points.push_back(Point2f(20, 50));
  output_points.push_back(Point2f(20, 60));
  output_points.push_back(Point2f(20, 70));
  output_points.push_back(Point2f(20, 80));
  output_points.push_back(Point2f(30, 0));
  output_points.push_back(Point2f(30, 10));
  output_points.push_back(Point2f(30, 20));
  output_points.push_back(Point2f(30, 30));
  output_points.push_back(Point2f(30, 40));
  output_points.push_back(Point2f(30, 50));
  output_points.push_back(Point2f(30, 60));
  output_points.push_back(Point2f(30, 70));
  output_points.push_back(Point2f(30, 80));
  output_points.push_back(Point2f(40, 0));
  output_points.push_back(Point2f(40, 10));
  output_points.push_back(Point2f ...
(more)
edit retag flag offensive close merge delete