-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfinal_test_v3.py
55 lines (40 loc) · 1.68 KB
/
final_test_v3.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
# Version 3
# command: $ python final_test_v[x] [partition number] [number of partitions]
import os
import sys
import glob
t = 0
n = 1
if len(sys.argv) > 1:
t = int(sys.argv[1])
if len(sys.argv) > 2:
n = int(sys.argv[2])
path_in = './slide_img/' # where the home images are
path_out = './slide_img_out/' #where we want the output to go
num_files = len(glob.glob1(path_in,'*.pgm')) #number of file of type
num_in_div = num_files/n #number of file per division
if num_in_div == 0: #catch if num_in_div == 0
num_in_div = num_files + 1
re_in_div = num_files%n #number of remainder
start_val = t * num_in_div #calc start position of array
if (start_val + num_in_div) <= num_files:
end_val = start_val + num_in_div #if will not go out of bounds
else:
end_val = start_val + re_in_div #if iteration will hit upper limit
print end_val
img_names = glob.glob1(path_in,'*.pgm')[start_val:end_val] #tells up what the names of each file we are using stored as an array
img_count = len(img_names) #tells us how many images there are
#print "%02d" % (t) used for debug
for i in range(0,img_count):
key_file = path_out + img_names[i].replace('.pgm','') +'.vl'
cmd = '~/vlfeat-0.9.17/bin/glnxa64/sift' + " " + './slide_img/' + img_names[i] + " -o " + key_file
print cmd
error_code = os.system(cmd)
if (error_code <> 0):
raise Exception("ERROR: SIFT didn't run correctly on " + img_name[i])
print "Terminating process."
sys.exit(1)
# v3 updated system to take specify which numeric files for better compatablility with
# distributed systems
# v2 updated program so that all files of given type can be read in for use
# v1 program tested working