-
Notifications
You must be signed in to change notification settings - Fork 3
/
video_object_detector.py
64 lines (50 loc) · 1.62 KB
/
video_object_detector.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
53
54
55
56
57
58
59
60
61
62
63
import sys, getopt
import numpy
import imageio
import optical_flow as of
import bounding_boxes as bb
def proposal(image, previous_location, method):
grayscale_image = rgb2gray(image)
if(method == "N"):
x = grayscale_image.shape[1]
y = grayscale_image.shape[2]
return
elif(method == "L"):
# Return previous location of image
return previous_location
elif(method == "O"):
# Return optical flow estimate of location of image
return of.optical_flow_location_predictor(grayscale_image, previous_location)
def get_bounding_box_and_location(image, previous_location, method):
def main(argv):
# Get command line arguments
input_file = ''
output_file = ''
proposal_method = ''
classifier_method = ''
try:
opts, args = getopt.getopt(argv,"i:o:p:c:",["ifile=","ofile="])
for opt, arg in opts:
if opt == '-h':
print 'test.py -i <inputfile> -o <outputfile>'
elif opt in ("-i", "--ifile"):
inputfile = arg
elif opt in ("-o", "--ofile"):
outputfile = arg
elif opt in ("-p", "--proposal"):
proposal_method = arg
elif opt in ("-c", "--classifier"):
classifier_method = arg
# Get input and output videos
input_video = imageio.get_reader(input_file)
output_video = imageio.get_writer(output_file)
# initialize location and bounding box variables
location = [0 ,0]
bounding_box = [0, 0, 0, 0]
# Get
location, bounding_box = location_prediction()
for i in range(get_length(input_video)):
frame = input_video.get_data()
location, bounding_box =
if __name__ == "__main__":
main(sys.argv[1:])