I have a rectangle picture like this image :

But after that I took a photo from the camera like this :


I detected 4 corners of my rectangle by approxPolyDP.
The points that I detected are these values:
308,25
38,99
147,477
412,466
Now how can I calculate Pitch, Roll and Yaw by these 4 points?
See How to calculate perspective transform for OpenCV from rotation angles?. You would have to work backwards from that solution.
Getting the transformation matrix is the easy part using getPerspectiveTransform. Figuring out the pitch, roll, and yaw from that matrix would be solving for angles in the single rotation matrix written here: http://planning.cs.uiuc.edu/node102.html for the respective Euler angles.