forked from ImSwitch/ImSwitch
-
Notifications
You must be signed in to change notification settings - Fork 11
/
HistoScanManager.py
63 lines (50 loc) · 2.12 KB
/
HistoScanManager.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
import enum
import glob
import cv2
import os
import numpy as np
from PIL import Image
from scipy import signal as sg
import os
from imswitch.imcommon.model import dirtools
import json
from imswitch.imcommon.framework import Signal, SignalInterface
from imswitch.imcommon.model import initLogger
class HistoScanManager(SignalInterface):
def __init__(self, HistoScanInfo, *args, **kwargs):
super().__init__(*args, **kwargs)
self.__logger = initLogger(self)
self.histoConfigFilename = "config.json"
# get default configs
self.defaultConfigPath = os.path.join(dirtools.UserFileDirs.Root, "histoController")
if not os.path.exists(self.defaultConfigPath):
os.makedirs(self.defaultConfigPath)
try:
with open(os.path.join(self.defaultConfigPath, self.histoConfigFilename)) as jf:
self.defaultConfig = json.load(jf)
self.offsetX = self.defaultConfig["offsetX"]
self.offsetY = self.defaultConfig["offsetY"]
except Exception as e:
self.__logger.error(f"Could not load default config from {self.defaultConfigPath}: {e}")
self.offsetX = 0
self.offsetY = 0
def writeConfig(self, data):
with open(os.path.join(self.defaultConfigPath, self.histoConfigFilename), "w") as outfile:
json.dump(data, outfile, indent=4)
def update(self):
return None
# Copyright (C) 2020-2023 ImSwitch developers
# This file is part of ImSwitch.
#
# ImSwitch is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ImSwitch is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.