How to detect when an image needs perspective transform?
This could be a possible approach:

Take a reference picture (which does not require a perspective transform).
Define four points of interest- (x1,y1) (x2,y2) (x3,y3) (x4,y4) in your reference image. Consider these points as your destination points.
Now in every other image that you want to check if a perspective transform is necessary, you will detect the same points of interest in those images. Lets call them source points.
Next you have to check if the source points match your destination points. Also you will have to check if the dimensions(width & height) match.
If neither of the two matches(the points or the dimension), there's a need for perspective transform.
I have a set of images in which I need to detect which of them needs a perspective transform. The images might be plain documents or photos taken with phone cameras with perspective and I need to perform perspective transform on those. How can I detect which need perspective transform in opencv?
I can do perspective transform, however, I'm not capable of detecting when an image needs to suffer a perspective transform.