comparison scripts/undistort-video.py @ 1249:2aa56b101041

added mask functionality for dltrack
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 15 Feb 2024 14:09:52 -0500
parents b684135d817f
children
comparison
equal deleted inserted replaced
1248:c4c50678c856 1249:2aa56b101041
37 capture = cv2.VideoCapture(args.videoFilename) 37 capture = cv2.VideoCapture(args.videoFilename)
38 width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH)) 38 width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH))
39 height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT)) 39 height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
40 [map1, map2], newCameraMatrix = cvutils.computeUndistortMaps(width, height, args.undistortedImageMultiplication, intrinsicCameraMatrix, args.distortionCoefficients) 40 [map1, map2], newCameraMatrix = cvutils.computeUndistortMaps(width, height, args.undistortedImageMultiplication, intrinsicCameraMatrix, args.distortionCoefficients)
41 if args.maskFilename is not None: 41 if args.maskFilename is not None:
42 mask = cv2.imread(args.maskFilename) 42 mask = cv2.imread(args.maskFilename, cv2.IMREAD_GRAYSCALE)
43 undistortedMask = cv2.remap(mask, map1, map2, interpolation=cv2.INTER_LINEAR)/255 43 undistortedMask = cv2.remap(mask, map1, map2, interpolation=cv2.INTER_LINEAR)/255
44 44
45 if capture.isOpened(): 45 if capture.isOpened():
46 ret = True 46 ret = True
47 frameNum = args.firstFrameNum 47 frameNum = args.firstFrameNum