Storm2012
Storm2012

Reputation: 579

warpPerspective

I tried to get the inverse perspective to get a frame captured in real-time to the camera plane using the following code:

Mat dst;
    dst=dst.zeros(frame.cols,frame.rows,frame.type());  

    if(Found){

     Mat mmat;
     mmat.create(3,3,CV_32FC1);
     mmat=getPerspectiveTransform(templPoints,imgPoints);
     cout<< mmat<<endl<<endl;
     warpPerspective(frame,dst,Homo,dst.size(),INTER_LINEAR );
     imshow("out",dst);
    }

the problem is that the dst image is totally black , what's wrong with my code?

enter image description here

Upvotes: 1

Views: 1046

Answers (2)

thomas_haximus
thomas_haximus

Reputation: 1531

The image you are seeing is usually the result of sending the source points into getPerspectiveTransform in the wrong order. This means that the points are crossing each other and triangular shapes will appear. Check the order of the points and make sure they match the order of the destination points.

Upvotes: 3

Francesco Callari
Francesco Callari

Reputation: 11825

You need to provide some more details. Why are you calling both findHomography and getPerspectiveTransform? Since you are calling both, I assume that both templPoints and imgPoints are of size 4, in which case the call to findHomography is redundant (and RANSAC does nothing at all for you).

Have you looked (e.g. using matlab or octave, or by hand) at the values of mmat * templPoints? They should be equal to imgPoints, and all inside the [0, dst.width] x [0, dst.height]

Upvotes: 1

Related Questions