|
|
@ -22,7 +22,7 @@ def draw(flow):
|
|
|
|
f[...,0] = 0 #np.minimum(v*10, 255)
|
|
|
|
f[...,0] = 0 #np.minimum(v*10, 255)
|
|
|
|
|
|
|
|
|
|
|
|
f[...,1] = 0
|
|
|
|
f[...,1] = 0
|
|
|
|
f[...,2] = 255- np.minimum(v**2, 255) #ang*(180/np.pi/2)
|
|
|
|
f[...,2] = 255- np.minimum(v**3, 255) #ang*(180/np.pi/2)
|
|
|
|
bgr = cv2.cvtColor(f, cv2.COLOR_HSV2BGR)
|
|
|
|
bgr = cv2.cvtColor(f, cv2.COLOR_HSV2BGR)
|
|
|
|
|
|
|
|
|
|
|
|
return bgr
|
|
|
|
return bgr
|
|
|
@ -35,7 +35,7 @@ p.add_argument("--height", type=int, default=480, help="pre-detect resize height
|
|
|
|
p.add_argument("--fourcc", default="XVID", help="MJPG,mp4v,XVID")
|
|
|
|
p.add_argument("--fourcc", default="XVID", help="MJPG,mp4v,XVID")
|
|
|
|
p.add_argument("--framerate", type=float, default=25, help="output frame rate")
|
|
|
|
p.add_argument("--framerate", type=float, default=25, help="output frame rate")
|
|
|
|
p.add_argument("--show", default=False, action="store_true")
|
|
|
|
p.add_argument("--show", default=False, action="store_true")
|
|
|
|
p.add_argument("--time", type=float, default=None)
|
|
|
|
p.add_argument("--frames", type=int, default=100)
|
|
|
|
args = p.parse_args()
|
|
|
|
args = p.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
fourcc = None
|
|
|
|
fourcc = None
|
|
|
@ -59,9 +59,8 @@ while True:
|
|
|
|
if prevgray.shape == (args.height, args.width):
|
|
|
|
if prevgray.shape == (args.height, args.width):
|
|
|
|
break
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
count = 0
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if args.time != None:
|
|
|
|
|
|
|
|
start = time.time()
|
|
|
|
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
ret, frame = cam.read()
|
|
|
|
ret, frame = cam.read()
|
|
|
|
|
|
|
|
|
|
|
@ -72,18 +71,19 @@ try:
|
|
|
|
|
|
|
|
|
|
|
|
if out != None:
|
|
|
|
if out != None:
|
|
|
|
out.write(frame)
|
|
|
|
out.write(frame)
|
|
|
|
|
|
|
|
count += 1
|
|
|
|
if args.show:
|
|
|
|
if args.show:
|
|
|
|
cv2.imshow('display', frame)
|
|
|
|
cv2.imshow('display', frame)
|
|
|
|
if cv2.waitKey(5) & 0xFF == ord('q'):
|
|
|
|
if cv2.waitKey(5) & 0xFF == ord('q'):
|
|
|
|
break
|
|
|
|
break
|
|
|
|
if args.time != None:
|
|
|
|
if args.frames != None:
|
|
|
|
elapsed = time.time() - start
|
|
|
|
if (count >= args.frames):
|
|
|
|
if (elapsed >= args.time):
|
|
|
|
|
|
|
|
break
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
print ("\nCleaning up...")
|
|
|
|
print ("\nCleaning up... Wrote", count, "frames")
|
|
|
|
if out:
|
|
|
|
if out:
|
|
|
|
out.release()
|
|
|
|
out.release()
|
|
|
|
if args.show:
|
|
|
|
if args.show:
|
|
|
|