From 28f80ffc4458a02be4d3de2549e4769cc12e1801 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Mon, 25 Aug 2014 19:07:50 +0200 Subject: panorama schlecht --- test.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'test.py') diff --git a/test.py b/test.py index 2f703e7..3e33792 100644 --- a/test.py +++ b/test.py @@ -11,6 +11,9 @@ feature_params = dict( maxCorners = 100, blockSize = 7 ) scale_factor=0.5 +scr_width=1600 +scr_height=900 + # Parameters for lucas kanade optical flow lk_params = dict( winSize = (15,15), @@ -21,13 +24,17 @@ lk_params = dict( winSize = (15,15), ret,oldframe=cap.read() oldgray=cv2.cvtColor(oldframe,cv2.COLOR_BGR2GRAY) +height, width, bpp = oldframe.shape + +mask = numpy.ones((height,width, 1), numpy.uint8) * 255 +screencontent = numpy.zeros((scr_height, scr_width,3), numpy.uint8) + total_angle=0. total_x=0 total_y=0 while(cap.isOpened()): ret, frame = cap.read() - height, width, bpp = frame.shape gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) @@ -68,7 +75,6 @@ while(cap.isOpened()): print angle/3.141592654*180,'deg\t',stretch,"%\t", shift_x,'\t',shift_y - frame2=frame.copy() mat2=cv2.getRotationMatrix2D((width/2,height/2), total_angle/3.141593654*180, scale_factor) mat2[0,2] = mat2[0,2]+total_x*scale_factor mat2[1,2] = mat2[1,2]+total_y*scale_factor @@ -76,10 +82,17 @@ while(cap.isOpened()): # mat2=numpy.array([[cos(total_angle), sin(total_angle), total_x], [-sin(total_angle),cos(total_angle),total_y]]) - frame2= cv2.warpAffine(frame2, mat2, (width,height) ) + frame2= cv2.warpAffine(frame, mat2, (scr_width,scr_height) ) + mask2 = cv2.warpAffine(mask, mat2, (scr_width,scr_height) ) + + #screencontent = frame2 + screencontent = cv2.bitwise_and(screencontent,screencontent, mask=cv2.bitwise_not(mask2)) + screencontent = cv2.add(screencontent, frame2) + #screencontent = frame2 + #screencontent = mask2 cv2.imshow('frame', frame) - cv2.imshow('frame2', frame2) + cv2.imshow('screencontent', screencontent) oldframe=frame oldgray=gray -- cgit v1.2.3