from jasf import jasf_cv import flowUtil import numpy as np from flowSubtraction import FlowDiffComputer if __name__ == "__main__": cam = cv2.VideoCapture( './input/inputTest-butter-from-0.5-to-10-alpha-20-lambda_c-80-chromAtn-0.avi' ) #get first frame so we set width and whigth of the flow computer ret, frame = cam.read() flowComputer = flowUtil.FlowComputer() width, height = frame.shape[1], frame.shape[0] grid = flowUtil.getGrid(0, 0, width - 5, height - 5, 10, 10) flowComputer.setGrid(grid) #initialize flowComputer with first frame(at this point, we have only one image and no flow is computer) flowComputer.apply(frame) #initialize flow diff computer diffComputer = FlowDiffComputer(flowComputer) allBlack = np.zeros((height, width), dtype=np.uint8) #find optimal size for fourrier transform rows, cols, k = frame.shape nrows = cv2.getOptimalDFTSize(rows) ncols = cv2.getOptimalDFTSize(cols) modeDemoSpectrum = False
import sys sys.path.insert(0, '../') import jasf from jasf import jasf_cv import cv2 import flowUtil cam = cv2.VideoCapture(0) ret, frame = cam.read() h, w, d = frame.shape print frame.shape half_side = 200 grid = flowUtil.getGrid(w / 2 - half_side, h / 2 - half_side, half_side * 2, half_side * 2, 5, 5) flowComputer = flowUtil.FlowComputer() flowComputer.setGrid(grid) ret, frame = cam.read() flowFilter = flowUtil.FlowFilter() flowFilter2 = flowUtil.FlowFilter_ConnectedRegions(frame.shape[:2]) jasf_cv.getInputWindow() jasf_cv.getSettingsWindow() jasf.cv.setManyTrackbars(['low', 'upper'], [10, 25], [100, 100]) jasf.cv.setManyTrackbars(['low2', 'upper2'], [150, 50000], [10000, 50000]) while cam.isOpened(): ch = cv2.waitKey(5) & 0xFFFF
if __name__ == "__main__": def help(): print 'usage: python RangePerCentFlowComputer option' print 'option maybe "regular" or "window"' quit() print 'running test mode of RangePerCentFlowComputer...' cam = cv2.VideoCapture(0) if len(sys.argv) != 2 or sys.argv[1] not in ('regular', 'window'): help() mode = sys.argv[1] unit = RangePerCentFlowComputer_regularComputer() if mode == 'regular' else RangePerCentFlowComputer_windowFlow() h,w = jasf.cv.getVideoCaptureFrameHeightWidth(cam) unit.setGrid(flowUtil.getGrid(0,0, w, h, 10, 10)) jasf_cv.getBasicWindows() ret,frame = cam.read() output = np.zeros_like(frame) jasf.cv.setManyTrackbars(['min', 'max'], [95, 100], [100,100]) def readSettings(): min,max = jasf.cv.readManyTrackbars(['min', 'max']) return min/100.0, max/100.0 while True: ch = cv2.waitKey(30) & 0xFFFF if ch == ord('q'):
else: grid = self.flowComputer.grid.astype(np.uint64) if returnIndo2Draw: return grid, grid else: return grid, np.zeros(grid.shape[0]) if __name__ == "__main__": cam = cv2.VideoCapture(0) #get first frame so we set width and whigth of the flow computer ret, frame = cam.read() flowComputer = flowUtil.FlowComputer() width, height = frame.shape[1], frame.shape[0] grid = flowUtil.getGrid(5, 5, width - 5, height - 5, 10, 10) flowComputer.setGrid(grid) #initialize flowComputer with first frame(at this point, we have only one image and no flow is computer) flowComputer.apply(frame) #initialize flow diff computer diffComputer = FlowDiffComputer(flowComputer) #initialize windows to be used jasf.cv.getManyWindows(['input', 'flowDiffMag']) allBlack = np.zeros((height, width), dtype=np.uint8) while True: #quit if 'q' is pressed ch = jasf.cv.waitKey(5)
print 'usage: python RangePerCentFlowComputer option' print 'option maybe "regular" or "window"' quit() print 'running test mode of RangePerCentFlowComputer...' cam = cv2.VideoCapture(0) if len(sys.argv) != 2 or sys.argv[1] not in ('regular', 'window'): help() mode = sys.argv[1] unit = RangePerCentFlowComputer_regularComputer( ) if mode == 'regular' else RangePerCentFlowComputer_windowFlow() h, w = jasf.cv.getVideoCaptureFrameHeightWidth(cam) unit.setGrid(flowUtil.getGrid(0, 0, w, h, 10, 10)) jasf_cv.getBasicWindows() ret, frame = cam.read() output = np.zeros_like(frame) jasf.cv.setManyTrackbars(['min', 'max'], [95, 100], [100, 100]) def readSettings(): min, max = jasf.cv.readManyTrackbars(['min', 'max']) return min / 100.0, max / 100.0 while True: ch = cv2.waitKey(30) & 0xFFFF if ch == ord('q'):
# debug cv2.imshow('average2', average2) return good_old, good_new else: self.addToAverage(img) return np.empty((0,0), dtype = np.uint8), np.empty((0,0), dtype = np.uint8) if __name__ == "__main__": print 'running test mode of WindowFlowComputer...' cam = cv2.VideoCapture(0) unit = WindowFlowComputer() h,w = jasf.cv.getVideoCaptureFrameHeightWidth(cam) unit.setGrid(flowUtil.getGrid(w/2,h/2, 100, 100, 10, 10)) jasf.cv.getManyWindows(['input', 'output', 'average1', 'average2']) ret,frame = cam.read() output = np.zeros_like(frame) while True: ch = cv2.waitKey(30) & 0xFFFF if ch == ord('q'): break ret, frame = cam.read() frame = jasf_cv.convertBGR2Gray(frame) old, new = unit.apply(frame) if old.size != 0:
return good_old, good_new else: self.addToAverage(img) return np.empty((0, 0), dtype=np.uint8), np.empty((0, 0), dtype=np.uint8) if __name__ == "__main__": print 'running test mode of WindowFlowComputer...' cam = cv2.VideoCapture(0) unit = WindowFlowComputer() h, w = jasf.cv.getVideoCaptureFrameHeightWidth(cam) unit.setGrid(flowUtil.getGrid(w / 2, h / 2, 100, 100, 10, 10)) jasf.cv.getManyWindows(['input', 'output', 'average1', 'average2']) ret, frame = cam.read() output = np.zeros_like(frame) while True: ch = cv2.waitKey(30) & 0xFFFF if ch == ord('q'): break ret, frame = cam.read() frame = jasf_cv.convertBGR2Gray(frame) old, new = unit.apply(frame) if old.size != 0:
from jasf import jasf_cv import flowUtil import numpy as np from flowSubtraction import FlowDiffComputer if __name__ == "__main__": cam = cv2.VideoCapture('./input/inputTest-butter-from-0.5-to-10-alpha-20-lambda_c-80-chromAtn-0.avi') #get first frame so we set width and whigth of the flow computer ret, frame = cam.read() flowComputer = flowUtil.FlowComputer() width, height = frame.shape[1], frame.shape[0] grid = flowUtil.getGrid(0,0, width-5, height-5, 10,10) flowComputer.setGrid(grid) #initialize flowComputer with first frame(at this point, we have only one image and no flow is computer) flowComputer.apply(frame) #initialize flow diff computer diffComputer = FlowDiffComputer(flowComputer) allBlack = np.zeros((height, width), dtype=np.uint8) #find optimal size for fourrier transform rows,cols,k = frame.shape nrows = cv2.getOptimalDFTSize(rows) ncols = cv2.getOptimalDFTSize(cols)
import sys sys.path.insert(0, '../') import jasf from jasf import jasf_cv import cv2 import flowUtil cam = cv2.VideoCapture(0) ret, frame = cam.read() h,w,d = frame.shape print frame.shape half_side = 200 grid = flowUtil.getGrid(w/2-half_side, h/2 - half_side, half_side*2, half_side*2, 5, 5) flowComputer = flowUtil.FlowComputer() flowComputer.setGrid(grid) ret, frame = cam.read() flowFilter = flowUtil.FlowFilter() flowFilter2 = flowUtil.FlowFilter_ConnectedRegions(frame.shape[:2]) jasf_cv.getInputWindow() jasf_cv.getSettingsWindow() jasf.cv.setManyTrackbars(['low', 'upper'], [10, 25], [100, 100]) jasf.cv.setManyTrackbars(['low2', 'upper2'], [150, 50000], [10000, 50000]) while cam.isOpened(): ch = cv2.waitKey(5) & 0xFFFF