1

How can I do fisheyes correction in Python without knowing the contours? I use OpenCV, is it any function I can use? I found sample code for correction.

pts1 = np.float32([[56,65],[368,52],[28,387],[389,390]])
pts2 = np.float32([[0,0],[300,0],[0,300],[300,300]])
M = cv2.getPerspectiveTransform(pts1,pts2)

But in actual, I don't know the contours and size. The picture is capturing a receipt. Receipt in the middle part can be left or right.

Do I need to detect the contours of the receipt before doing fisheyes correction? And How? I use OpenCV to detect, but cannot give me a image back.

img = cv2.drawContours(img, contours, -1, (0,255,0), 3)

Thanks, Robin

Robin Qu
  • 11
  • 3
  • 2
    can you assume that there are any lines in the image that are straight in real life? – Micka Mar 19 '15 at 05:49
  • possible duplicate of [correcting fisheye distortion programmatically](http://stackoverflow.com/questions/2477774/correcting-fisheye-distortion-programmatically) – rayryeng Mar 19 '15 at 06:03
  • Standard fisheye correction is to determine points that are collinear in the image then use these to compute the distortion function to rectify the image. I've also marked a link as a duplicate so you can take a look. – rayryeng Mar 19 '15 at 06:03
  • @rayryeng I saw that one, but that answer sets the parameter it needs. # ./undistort 0_0000.jpg 1367.451167 1367.451167 0 0 -0.246065 0.193617 -0.002004 -0.002056 DO you mind to show me which part for detecting the edge (fx fy cx cy k1 k2 p1 p2)? Thanks. – Robin Qu Mar 20 '15 at 11:16

0 Answers0