def DispalyTraceDynamic(homography): sequence = projectResources + "GroundFloorData/sunclipds.avi" sequence = cv2.VideoCapture(fn) floorPlan = cv2.imread(projectResources + "Images/ITUMap.bmp") trackingData = loadtxt(projectResources + "GroundFloorData/trackingdata.dat") trackingData = SIGBTools.toHomogenious(trackingData) m,n = trackingData.shape drawI = floorPlan.copy() running, cap = sequence.read() for p in trackingData: running, cap = sequence.read(); cv2.imshow("Sequence", cap) cv2.waitKey(1) if(running): currentPoint = matrix([p[2], p[3],1]).T hPoint = matrixmultiply(homography, currentPoint) cv2.circle(drawI,(int(hPoint[0]),int(hPoint[1])),2,(0,255,0),1) cv2.imshow("Plan", drawI) cv2.waitKey(1) #print hPoint return
def DisplayTraceSatic(homography): trackingData = loadtxt(projectResources + "GroundFloorData/trackingdata.dat") trackingData = SIGBTools.toHomogenious(trackingData) #rotationCW90 = n.matrix([[n.cos(90), n.sin(90), 0],[-n.sin(90), n.cos(90) ,0],[0,0,1]]) #homography = homography * rotationCW90 transformedPoints = list() for p in trackingData: currentPoint = n.matrix([p[2], p[3],1]).T transformedPoints.append(matrixmultiply(homography, currentPoint)) I = cv2.imread(projectResources + "Images/ITUMap.bmp") drawI = I.copy() fig = figure(1) ax1 = subplot(1,2,1) ax2 = subplot(1,2,2) ax1.imshow(I) ax2.imshow(drawI) ax1.axis('image') ax1.axis('off') fig.hold('on') for p in transformedPoints: subplot(1,2,1) plot(p[0],p[1],'rx') cv2.circle(drawI,(int(p[0]),int(p[1])),2,(0,255,0),1) ax2.cla ax2.imshow(drawI) draw() #update display: updates are usually defered show() cv2.imwrite("drawImage.jpg", drawI) return transformedPoints