Ask Your Question
0

Dewrapping results not expected result

asked 2017-08-13 09:35:31 -0600

vickal93 gravatar image

I'm trying to iterate through end points of lines, build segments between them and finally dewarp the distortion. I should imagine, that all those "mini"-segments are small images (somthing about 70x300, but it variets.)

This what I done:

//allPoints are created in another class, but the output 
//for std::vector<std::pair<cv::Point, cv::Point>> allPoints is as follows:
//(for the first:)[139, 113][201, 310][223, 339][297, 437][323, 472][381, 465][408, 413][484, 291][505, 151]
//(for the second:)[139, 210][201, 692][223, 664][297, 550][323, 523][381, 544][408, 580][484, 699][505, 254]


for (int i = 0; i < allPoints.size() - 1; i++) {
    cv::Vec3b zero(0, 0, 0);
    cv::Mat_<cv::Vec3b> img_dst(allPoints[i].second.y - allPoints[i].first.y,
        allPoints[i+1].first.x - allPoints[i].first.x);
    std::cout << "\nSize of img_dst: " << img_dst.size() << "\n";

    const cv::Point2f src_pt[] = {
        cv::Point2f(allPoints[i].first),
        cv::Point2f(allPoints[i].second),
        cv::Point2f(allPoints[i + 1].second),
        cv::Point2f(allPoints[i + 1].first) };

    const cv::Point2f dst_pt[] = {
        cv::Point2f(allPoints[i].first),
        cv::Point2f(allPoints[i].second),
        cv::Point2f(allPoints[i + 1].second.x, allPoints[i].second.y),
        cv::Point2f(allPoints[i + 1].first.x, allPoints[i].first.y) };


    const cv::Mat homography_matrix = cv::getPerspectiveTransform(src_pt, dst_pt);

    cv::warpPerspective(matCopy, img_dst, homography_matrix, img_dst.size());

    cv::imshow("Result", img_dst);


    std::pair<vector<int>, std::string> wallNr = WallParser::wallParser(argument);

    int label = wallNr.first[i];
    std::cout << label << " ";

    Main::saveAll(img_dst, "", label);

}

So actually I'm giving the right size and also the right points, which should be dewrap. But I get instead of (created it quicklin ps - in PS it results a bigger image) () this one enter image description here. The image looks like this and all those end points are the end points of the yellow lines:

enter image description here

How can I get that wrapPrespective to dewrap right?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-08-13 23:37:52 -0600

Ziri gravatar image

How did you get src_pt coordinates ? obviously there is a problem with transformation matrix.

edit flag offensive delete link more

Comments

as I already mentioned in the code, I created them previously and get those end points

vickal93 gravatar imagevickal93 ( 2017-08-14 10:03:49 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-08-13 09:35:31 -0600

Seen: 119 times

Last updated: Aug 13 '17