-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
54 lines (44 loc) · 1.47 KB
/
config.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
# -*- coding: utf-8 -*-
# Configuration setting of image annotation tool
import os
try:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
except ImportError:
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
DEFAULT_FILLING_COLOR = QColor(Qt.white)
DEFAULT_BACKGROUND_COLOR = QColor(Qt.black)
# Configuration of flood-fill
connectivity_Floodfill = 4
fixed_range = True
def outputDir(input_fname):
"""Define output directory of an input image"""
baseDir = os.path.dirname(input_fname)
return os.path.join(baseDir, "Output_Images")
def outputFile(input_fname):
"""Define the output file path of an input image.
Save to ./Output_Images/xxx.png. (Remain the original name)"""
outputFileDir = outputDir(input_fname)
filename = os.path.splitext(os.path.basename(input_fname))[0]
filename += ".png"
return os.path.join(outputFileDir, filename)
def getLabelColor(imgPath):
imgRoot = os.path.dirname(imgPath)
path = os.path.join(imgRoot, "label.txt")
if not os.path.exists(path):
return None
file = open(path, 'r')
data = file.read().splitlines()
dict = {}
for info in data:
label = info.split(',')
print label[0]
red = int(label[0])
green = int(label[1])
blue = int(label[2])
name = label[3]
dict[name] = QColor(red, green, blue)
file.close()
return dict