From effe56ffd6cecdfcbb0846c1298e4a20246086f2 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Wed, 27 Aug 2014 01:47:43 +0200 Subject: hell yeah --- warp.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/warp.py b/warp.py index 57564c1..7cda232 100644 --- a/warp.py +++ b/warp.py @@ -5,26 +5,33 @@ import numpy xlist=[] ylist=[] -xres=1600 -yres=900 +xres=1600/2 +yres=900/2 #constant = 1./math.sqrt((xres/2)**2 + (yres/2)**2) -constant = 1./(1280/2.)*30./40. -print constant +constant = 30./41.5*3 +# found out experimentally +constant2= 1./(1280/2.)*math.atan(30./40) +print constant2 + +# calculated from official spec: maximum angle (i.e., over the diagonals) +# is 92 deg. -> angle over half a diagonal's length is 92/2 deg +constant2= 1./(math.sqrt((1280/2)**2+(720/2)**2))*(92/2)/180*math.pi +print constant2 for y in xrange(0,yres): xtmp=[] ytmp=[] - yy=(y-yres/2.)/yres*720 + yy=(y-yres/2.)/xres # yes, xres. for x in xrange(0,xres): - xx=(x-xres/2.)/xres*1280 + xx=(x-xres/2.)/xres dist = math.sqrt(xx**2 + yy**2) if (dist != 0): - xtmp=xtmp+[ 1280/2+ xx/dist/constant*math.atan(constant*dist*1.3) ] - ytmp=ytmp+[ 720/2 + yy/dist/constant*math.atan(constant*dist*1.3) ] + xtmp=xtmp+[ 1280/2+ xx/dist/constant2*math.atan(constant*dist) ] + ytmp=ytmp+[ 720/2 + yy/dist/constant2*math.atan(constant*dist) ] else: xtmp=xtmp+[0+1280/2] ytmp=ytmp+[0+720/2] @@ -38,7 +45,7 @@ for y in xrange(0,yres): xmap=numpy.array(xlist).astype('float32') ymap=numpy.array(ylist).astype('float32') -img=cv2.imread("../cam42.png") +img=cv2.imread("cam42.png") img2=cv2.remap(img, xmap, ymap, cv2.INTER_CUBIC) cv2.imshow("orig", img) -- cgit v1.2.1