-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSPD.py
More file actions
67 lines (55 loc) · 1.74 KB
/
Copy pathSPD.py
File metadata and controls
67 lines (55 loc) · 1.74 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
# Main handler for GUI/terminal calls
import json
import sys
import os
from PySide2.QtWidgets import QApplication
from core.processing import smokepoint
from core.processing_options import argsHandler
from gui.MainWindow import SPDMain
from core.utils import resultPlotting
def jsonLoader(args):
config = args.config
# Check if file exists
if not(os.path.isfile(config)):
print('File does not exists!')
exit(1)
# Load configs
with open(config, 'r') as json_file:
try:
json_dict = json.load(json_file)
args.ThresholdCore = json_dict['core_%']
args.ThresholdContour = json_dict['contour_%']
args.cut = list(json_dict['cut'].values())
args.mm = json_dict['conv_factor']
args.DerivativeThreshold = json_dict['der_threshold']
args.CentroidTolerance = json_dict['centroid_tol']
except:
print('The provided json file is not in the correct format!')
exit(1)
def CMDsp(args):
sp_vals = smokepoint(args)
sp = sp_vals['sp_height']
print('SP found at {}px'.format(sp))
if(args.mm):
mm_val = sp * args.mm
print('SP found at {} mm'.format(mm_val))
resultPlotting(sp_vals,args)
if __name__ == '__main__':
args = argsHandler()
if(args.cmd):
# Load config file
if(args.config):
jsonLoader(args)
# Call terminal function
CMDsp(args)
else:
app = QApplication([])
if os.name == 'nt':
app.setStyle('Fusion')
window = SPDMain()
window.show()
# For the moment fix the size
h = window.height()
w = window.width()
window.setFixedSize(w, h)
sys.exit(app.exec_())