-
Notifications
You must be signed in to change notification settings - Fork 7
/
test_diver_tracker.py
executable file
·59 lines (47 loc) · 1.92 KB
/
test_diver_tracker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
"""
Maintainer: Jahid (email: [email protected])
Interactive Robotics and Vision Lab
http://irvlab.cs.umn.edu/
Any part of this repo can be used for academic and educational purposes only
"""
import cv2
import os
import glob
import argparse
# local libraries
from libs.trackerPipeline import FollowerPipeline
if __name__ == '__main__':
""" for testing (a single) diver tracking
> use argument --test_vid to test video or sequence of images
other arguments:
--im_dir >> path of image folder
--vid >> path of the test video file
--image_ext >> image extension
"""
parser = argparse.ArgumentParser()
parser.add_argument('--im_dir', required=False, dest='im_dir', type=str, default='test_data/im1/', help='Folder containing images')
parser.add_argument('--vid', required=False, dest='vid', type=str, default='test_data/test1.avi', help='Video file')
parser.add_argument('--test_vid', required=False, dest='test_vid', type=bool, default=True, help='Test video or images')
parser.add_argument('--image_ext', type=str, default='*.jpg')
args = parser.parse_args()
follower = FollowerPipeline()
if not args.test_vid:
# test a sequence of images
IMAGE_PATHS = glob.glob(os.path.join(args.im_dir, args.image_ext))
IMAGE_PATHS.sort(key=lambda f: int(filter(str.isdigit, f)))
for im_file in IMAGE_PATHS:
frame = cv2.imread(im_file)
follower.ImageProcessor(frame, vizualize=True, wait_time=10)
else:
# test on a video file
counter=0
cap = cv2.VideoCapture(args.vid)
while(cap.isOpened()):
ret, frame = cap.read()
if frame is not None:
follower.ImageProcessor(frame, vizualize=True, wait_time=1)
else:
counter += 1
if counter > 10: break
cap.release()