title: transforming perspective view to a top view
body: <p>I am using a combination of Opencv and python to turn the perspective view of this image to a birds-eye view (top view) </p>
  
  <p><a href="https://i.stack.imgur.com/ysl7u.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ysl7u.jpg" alt="enter image description here"></a></p>
  
  <p>to remove the perspective view I wrote this code</p>
  
  <pre><code>Image1 = cv2.imread('/path to image/im.jpg')
  
  cv2.circle(Image1,(867,652),5,(0,0,255),-1)
  cv2.circle(Image1,(1020,580),5,(0,0,255),-1)
  cv2.circle(Image1,(1206,666),5,(0,0,255),-1)
  cv2.circle(Image1,(1057,757),5,(0,0,255),-1)
  
  
  
  
  
  pts1=np.float32([[867,652],[1020,580],[1206,666],[1057,757]])
  pts2=np.float32([[448,609],[580,607],[582,724],[445,730]])
  
  matrix=cv2.getPerspectiveTransform(pts1,pts2)
  
  
  result=cv2.warpPerspective(Image1,matrix,(1920,1080))
  
  cv2.imshow('frame',Image1)
  cv2.imshow('result',result)
  
  path = 'path'
  cv2.imwrite(os.path.join(path , 'Dots.jpg'), Image1)
  cv2.imwrite(os.path.join(path , 'TransImage.jpg'), result)
  
  cv2.waitKey(0)
  </code></pre>
  
  <p><strong>I feel the points that choose for pts2 are not that corrects and does not give me a nice top view. Can anyone find the correct transformation? I want the width of the white lane to be constant along the image.</strong></p>