summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2014-08-27 00:47:47 +0200
committerFlorian Jung <flo@windfisch.org>2014-08-27 00:47:47 +0200
commit3e064160794a7835c77a376e257d832261371c24 (patch)
treeeed5418678f677e14a54d1b9e0947a6e5b6789f8
parent3923d212b7555a11705708685b4b8684c8bad112 (diff)
warp
-rw-r--r--cam42.pngbin0 -> 1158719 bytes
-rw-r--r--warp.py49
2 files changed, 49 insertions, 0 deletions
diff --git a/cam42.png b/cam42.png
new file mode 100644
index 0000000..d427b50
--- /dev/null
+++ b/cam42.png
Binary files differ
diff --git a/warp.py b/warp.py
new file mode 100644
index 0000000..2272a37
--- /dev/null
+++ b/warp.py
@@ -0,0 +1,49 @@
+import math
+import cv2
+import numpy
+
+xlist=[]
+ylist=[]
+
+xres=1280
+yres=720
+
+#constant = 1./math.sqrt((xres/2)**2 + (yres/2)**2)
+constant = 1./(xres/2.)*30./42.
+
+for y in xrange(0,yres):
+ xtmp=[]
+ ytmp=[]
+
+ yy=(y-yres/2.)/yres*720
+ for x in xrange(0,xres):
+ xx=(x-xres/2.)/xres*1280
+
+ dist = math.sqrt(xx**2 + yy**2)
+
+ if (dist != 0):
+ xtmp=xtmp+[ 1280/2+ xx/dist/constant*math.atan(constant*dist) ]
+ ytmp=ytmp+[ 720/2 + yy/dist/constant*math.atan(constant*dist) ]
+ else:
+ xtmp=xtmp+[0+1280/2]
+ ytmp=ytmp+[0+720/2]
+
+ xlist=xlist+[xtmp]
+ ylist=ylist+[ytmp]
+
+ if y % 10 == 0:
+ print y
+
+xmap=numpy.array(xlist).astype('float32')
+ymap=numpy.array(ylist).astype('float32')
+
+img=cv2.imread("../cam42.png")
+img2=cv2.remap(img, xmap, ymap, cv2.INTER_CUBIC)
+
+cv2.imshow("orig", img)
+cv2.imshow("remap", img2)
+
+print img2.shape
+
+while cv2.waitKey(50) & 256 != ord("q"):
+ pass