-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_input_images.py
executable file
·70 lines (55 loc) · 1.76 KB
/
check_input_images.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
64
65
66
67
68
69
70
#!/usr/bin/env python3
import os
import sys
import iio
#-----------------------------------------------------------------------
if __name__ == '__main__':
"""
arg0 : the command
arg1 : im1 (input)
arg2 : im2 (input)
arg3 : disparity map truth (input) optional
"""
f = open("algo_info.txt","a")
is_ok = True
file1 = sys.argv[1]
file2 = sys.argv[2]
file3 = sys.argv[3] if (len(sys.argv) == 4) else None
# check the image format
im1 = iio.read(file1)
im2 = iio.read(file2)
if im1 is None or im2 is None:
f.write("message=Input pairs cannot be read in a good format.\n")
is_ok = False
if file3 != None:
try:
im3 = iio.read(file3)
print("ici")
except:
print("la")
f.write("message=Input disparity cannot be read in a good TIFF format.\n")
is_ok = False
else:
im3 = None
if is_ok == False:
f.write("message=Please, check your data.\n")
f.close()
exit(5)
# check the triplets image size
if (im1.shape != im2.shape):
f.write("message=Input pairs have not the same size\n")
is_ok = False
if im3 is not None:
if im3.shape[0:2] != im1.shape[0:2]:
f.write("message=Input disparity have not the size of the pair.\n")
is_ok = False
# check the number of bands of the input pairs
if im1.shape[2] > 3 or im2.shape[2] > 3:
f.write("message=Input pairs have not 3 channels\n")
is_ok = False
if is_ok == False:
f = open("algo_info.txt","a")
f.write("message=Please check your data.\n")
f.close()
exit(5)
exit(0)