You need to use affine transformations, here is tutorial . In your situation, you need to choose some size of the car plate, for example 20x100 . Your destinations will have 3 corners without turning a rectangle of the selected size, and the starting points will be 3 corners of the car plate based. I hope this is clear, if it is not, let me know - I will give an example.
* \\ EDIT:
Ok, I made some examples. Here is the code:
cv::Mat img = cv::imread("D:\\temp\\car_plate.jpg"); cv::Point2f a1(25, 18), b1(279, 27), c1(279, 79), a2(0, 0), b2(img.size().width, 0), c2(img.size().width, img.size().height); //cv::Point2f a1(0, 16), b1(303, 28), c1(303, 81), a2(0, 0), b2(img.size().width, 0), c2(img.size().width, img.size().height); cv::Point2f src[] = {a1, b1, c1}; cv::Point2f dst[] = {a2, b2, c2}; cv::Mat warpMat = cv::getAffineTransform(src, dst); cv::warpAffine(img, img, warpMat, img.size()); cv::imshow("result", img); cv::waitKey(-1); return 0;
And the results:


If you use the code without any changes, you will get the first result, if you comment on the second line and uncomment the third line, you will get the second result (I think you wanted). To get the second result, you just need to find the points where the upper and lower lines intersect the border of the image. I noted this here:

So basically you need to use red glasses. To calculate their positions, you just need to find where the blue lines (which, if I understand what you already have) cross the border of the image.