Perspective change of vector

asked 2013-08-13 05:41:24 -0500

engine gravatar image

updated 2013-08-13 05:49:41 -0500

Hi!

say I have a source image than I transform to a dst image using getPerspectiveTransform and cv::warpPerspective. after that I have special vector of points in my source image, and I want to get or rather draw them in my dst image , I thought it'll obvious, but I don't this done , to better explain the problem I have a sample with a chessboard:

.................................
transformationMatrix= cv::getPerspectiveTransform(src_Point, quad_pts);
            cv::warpPerspective(src, dst, transformationMatrix, dst.size()/,CV_INTER_LINEAR,cv::BORDER_ISOLATED);

this work fine so Now I've changed the perspective of my src frame. to transform my Points and theen put them in the dst I wrote this small function

std::vector<cv::Point2f> warpStuff(std::vector<cv::Point2f> inputVector , cv::Mat transformationMatrix){
    cv::Matx33f warp = transformationMatrix;
    cv::Point3f homogenous;
    std::vector<cv::Point2f> result;

    for (int k  =0;  k < inputVector.size()-1; k++ ){
        homogenous = warp* inputVector[k];
        result.push_back(cv::Point2f(homogenous.x,homogenous.y));
    }

    return result;
}

when try to draw the result vector in dst I don't get the points in their position ?

here's my source image

the source

and after the transformation, when draw result here' a what I get :

the dst

I think the problem is that cv::warpPerspective is using in addition to the transformation matrix the size of the dst image, I tried to debugg the stuff but I really didn't understand what does it do with this size so I can add this to my function !

any suggestion ?

edit retag flag offensive close merge delete

Comments

1

Just a remark on the use of tags, there is already a wide list of tags available, without the hashtags, that people can use to filter out the topics. Adding hashtags creates double tags without any use, so in the feature, please remove hashtags from your questions tags.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-13 05:51:10 -0500 )edit