How do I use warpPerspective correctly?

. The blue positions are from paint. Output is the output from the code.

I have attached the image I am talking about. I want to get the perspective transformation so I can get the card in its canonical form. It does not work and I get a bad output.

This is my code. The points I got from point and they are correct (checked with the function circle() )

void main(){
cv::Mat begin = cv::imread("\cards.jpg");
cv::Mat output;
cv::Point2f Poly2[4] = {


cv::Point2f Points[4] = {
			  cv::Point2f(0,600),       //The picture I want to transform to. 


for (int i = 0; i < 4; i++) {
	cv::circle(begin, cv::Point2d(Poly2[i].x, Poly2[i].y), 2, cv::Scalar(244, 233, 44), 3, 8, 0);

cv::Mat Matrix = cv::getPerspectiveTransform( Points,Poly2);

cv::warpPerspective(begin, output, Matrix, cv::Size(300, 600));

cv::imshow("begin", begin);
cv::imshow("Output", output);

I hope you guys can help me.

your Points are in the wrong order. if Poly2 is clockwise, starting from tl, the Points have to be so, too.

(you have to swap the last 2 points)

It seems that you switched the parameters of getPerspectiveTransform. Try with:

cv::Mat Matrix = cv::getPerspectiveTransform( Poly2,Points); // (source,destination)