c++ - WrapPerspective doesn't dewrap corectly -
after procedure std::vector<std::pair<cv::point, cv::point>> tempendpoints
, i'll following first
, second
parameter:
first: [139, 113][201, 310][223, 339][297, 437][323, 472][381, 465][408, 413][484, 291][505, 151] second: [139, 210][201, 692][223, 664][297, 550][323, 523][381, 544][408, 580][484, 699][505, 254]
now i'm stuck @ wrapperspective
. each of "corner" points creats small image, has individual size (it earlier created textureimage
). stored , fine. want dewrap "small images" inside points, mentioned before.
for (int = 0; < tempendpoints.size() - 1; i++) { //do stuff... cv::vec3b zero(0, 0, 0); cv::mat_<cv::vec3b> dewrapped(textureimage.rows, textureimage.cols, zero); cv::point2f srcpts[] = { point2f(tempendpoints[i].first), point2f(tempendpoints[i + 1].first), point2f(tempendpoints[i + 1].second), point2f(tempendpoints[i].second) }; std::cout << "srcpoints: " << tempendpoints[i].first << ", " << tempendpoints[i + 1].first << ", " << tempendpoints[i + 1].second << ", " << tempendpoints[i].second << "\n"; const cv::point2f dstpts[] = { cv::point2f(tempendpoints[i].first), cv::point2f(tempendpoints[i + 1].first.x, tempendpoints[i].first.y), cv::point2f(tempendpoints[i + 1].second.x, tempendpoints[i].second.y), cv::point2f(tempendpoints[i].second)}; std::cout << "dstpoints: " << tempendpoints[i].first << ", " << tempendpoints[i + 1].first.x << "-" << tempendpoints[i].first.y << ", " << tempendpoints[i + 1].second.x << "-" << tempendpoints[i].second.y << ", " << tempendpoints[i].second << "\n"; cv::mat homography_matrix = cv::getperspectivetransform(srcpts, dstpts); cv::warpperspective(textureimage, dewrapped, homography_matrix, textureimage.size()); cv::imshow("dewrap", dewrapped);
followed this blog , nothing seems happen - well, black image. order of points in srcpts
, dstpts
is:
1---2 | | 4---3
looking @ this question, tried order, results in black image. there's order in blog, mentioned before. doing wrong in code?
[edit:] output srcpt
, dstpt
is:
srcpts: [20, 54], [123, 83], [123, 188], [20, 65] dstpts: [20, 54], [123, 54], [123, 65], [20, 65] srcpts: [123, 83], [181, 362], [181, 718], [123, 188] dstpts: [123, 83], [181, 83], [181, 188], [123, 188] srcpts: [181, 362], [278, 412], [278, 569], [181, 718] dstpts: [181, 362], [278, 362], [278, 718], [181, 718] srcpts: [278, 412], [290, 428], [290, 557], [278, 569] dstpts: [278, 412], [290, 412], [290, 569], [278, 569] srcpts: [290, 428], [321, 469], [321, 525], [290, 557] dstpts: [290, 428], [321, 428], [321, 557], [290, 557] srcpts: [321, 469], [373, 476], [373, 534], [321, 525] dstpts: [321, 469], [373, 469], [373, 525], [321, 525] srcpts: [373, 476], [387, 447], [387, 552], [373, 534] dstpts: [373, 476], [387, 476], [387, 534], [373, 534] srcpts: [387, 447], [407, 415], [407, 579], [387, 552] dstpts: [387, 447], [407, 447], [407, 552], [387, 552] srcpts: [407, 415], [421, 392], [421, 597], [407, 579] dstpts: [407, 415], [421, 415], [421, 579], [407, 579] srcpts: [421, 392], [531, 90], [531, 212], [421, 597] dstpts: [421, 392], [531, 392], [531, 597], [421, 597]
Comments
Post a Comment