forked from shoaibahmed/FCN-TensorFlow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualizer.py
More file actions
71 lines (55 loc) · 2.17 KB
/
Copy pathvisualizer.py
File metadata and controls
71 lines (55 loc) · 2.17 KB
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
71
import os
import random
from os import listdir
from os.path import isfile, join
from optparse import OptionParser
import cv2
def visualize(options):
print(options)
for root, dirs, files in os.walk(options.outputDir):
path = root.split('/')
print ("Directory:", os.path.basename(root))
inputFileNames = []
outputFileNames = []
for file in files:
# print(file)
if file.endswith(options.outputExtension):
outputFileName = str(os.path.abspath(os.path.join(root, file)))
# imageName = self.options.imagesOutputDirectory + '/' + 'test_' + imageName[:-4] + '_prob' + imageName[-4:]
inputFileName = str(file).split('_')
inputFileName = options.inputDir + inputFileName[1] + options.inputExtension
inputFileNames.append(inputFileName)
outputFileNames.append(outputFileName)
print ("%d files found" % len(inputFileNames))
fileIndex = 0
maxIndex = len(inputFileNames) - 1
while True:
print(inputFileNames[fileIndex])
outputIm = cv2.imread(outputFileNames[fileIndex])
inputIm = cv2.imread(inputFileNames[fileIndex])
cv2.imshow("Input", inputIm)
cv2.imshow("Output", outputIm)
pressedKey = chr(cv2.waitKey(0) & 255)
if pressedKey == 'q':
break
elif pressedKey == 'a':
if fileIndex == 0:
fileIndex = maxIndex
else:
fileIndex -= 1
elif pressedKey == 'd':
if fileIndex == maxIndex:
fileIndex = 0
else:
fileIndex += 1
if __name__ == "__main__":
# Command line options
parser = OptionParser()
parser.add_option("--outputDir", action="store", type="string", dest="outputDir", default=u"./outputImages/", help="Directory for reading in the output images")
parser.add_option("--inputDir", action="store", type="string", dest="inputDir", default=u"./data/", help="Directory for reading in the input images")
parser.add_option("--outputExtension", action="store", type="string", dest="outputExtension", default=".jpg", help="Extension of output files")
parser.add_option("--inputExtension", action="store", type="string", dest="inputExtension", default=".jpg", help="Extension of input files")
# Parse command line options
(options, args) = parser.parse_args()
visualize(options)
print ("Done")