Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Perspective change of vector

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 ?

Perspective change of vector

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 ?