Commit 09e96c92 authored by Lars Bittrich's avatar Lars Bittrich
Browse files

Some code cleanup -> old uncommented code removed

reworking of simulated raman interface to work with smaller data
ramancontrol now works with a config file to switch interfaces and default path
parent eaebe41d
Loading
Loading
Loading
Loading
+5 −16
Original line number Diff line number Diff line
@@ -116,8 +116,8 @@ class DataSet(object):
            from opticalscan import loadAndPasteImage
            
            # try to load png and check for detection contours
            buggyimage = recreatefullimage
            if not buggyimage and os.path.exists(self.getLegacyImageName()):
            recreatefullimage = recreatefullimage or not os.path.exists(self.getLegacyImageName())
            if not recreatefullimage:
                img = cv2imread_fix(self.getLegacyImageName())
                Nc = len(self.particlecontours)
                if Nc>0:
@@ -125,12 +125,12 @@ class DataSet(object):
                    contpixels = img[contour[:,0,1],contour[:,0,0]]
                    if np.all(contpixels[:,1]==255) and np.all(contpixels[:,2]==0) \
                        and np.all(contpixels[:,0]==0):
                        buggyimage = True
                if not buggyimage:
                        recreatefullimage = True
                if not recreatefullimage:
                    cv2imwrite_fix(self.getImageName(), img)
                del img
            
            if buggyimage:
            if recreatefullimage:
                print("recreating fullimage from grid data")
                imgdata = None
                zvalimg = None
@@ -154,9 +154,6 @@ class DataSet(object):
                del self.particleimgs
            
            self.version = 1
            #os.remove(self.getLegacyImageName())
            #os.remove(self.getLegacyDetectImageName())
            #self.save()
        # add later conversion for higher version numbers here
        
    def getSubImage(self, img, index, draw=True):
@@ -261,11 +258,3 @@ class DataSet(object):
    def save(self):
        saveData(self, self.fname)
        
 No newline at end of file
        
if __name__ == '__main__':
    dset = loadData(r'C:\Users\brandt\Desktop\20180723DemoTZW\20180723DemoTZW.pkl')
    print(dset.detectParams)
#    dset.seedpoints = np.array([])
#    dset.seeddeletepoints = np.array([])
#    dset.save()
        
 No newline at end of file
+7 −22
Original line number Diff line number Diff line
@@ -443,7 +443,6 @@ class ParticleDetectionView(QtWidgets.QWidget):
    @QtCore.pyqtSlot()
    def updateImageSeeds(self):
        if self.dataset is not None:
#            seedradius = self.seedradiusedit.value()
            n1,n2,m1,m2 = self.imgclip
            p0 = np.array([[m1,n1]], dtype=np.int32)
            seedpoints = []
@@ -454,23 +453,10 @@ class ParticleDetectionView(QtWidgets.QWidget):
            for point in arr1:                  #Josef says: I replaced the commented logic with the one right here below, as the old one somehow did not work.... The for-loop might become slow at some point??
                if point[0] > (m1-point[2]) and point[0] <= (m2+point[2]) and point[1] > (n1-point[2]) and point[1] <= (n2+point[2]):
                    seedpoints.append([point[0] - p0[0][0], point[1] - p0[0][1], point[2]])
#            if arr1.shape[0]>0:
#                ind = (arr1[:,0]>m1-seedradius)&(arr1[:,0]<=m2+seedradius) 
#                ind &= (arr1[:,1]>n1-seedradius)&(arr1[:,1]<=n2+seedradius)
#                if np.any(ind):
#                    arr1[ind, :2] -= p0
#                    seedpoints = arr1.tolist()
#             
            arr2 = self.dataset.seeddeletepoints
            for point in arr2:                  #Josef says: I replaced the commented logic with the one right here below, as the old one somehow did not work.... The for-loop might become slow at some point??
                if point[0] > (m1-point[2]) and point[0] <= (m2+point[2]) and point[1] > (n1-point[2]) and point[1] <= (n2+point[2]):
                    seeddeletepoints.append([point[0] - p0[0][0], point[1] - p0[0][1], point[2]])
#            if arr2.shape[0]>0:
#                ind = (arr2[:,0]>m1-seedradius)&(arr2[:,0]<=m2+seedradius) 
#                ind &= (arr2[:,1]>n1-seedradius)&(arr2[:,1]<=n2+seedradius)
#                if np.any(ind):
#                    arr2[ind, :2] -= p0
#                    seeddeletepoints = arr2.tolist()

            self.imglabel.updateSeedPoints(seedpoints, seeddeletepoints)
        
@@ -657,7 +643,6 @@ if __name__ == "__main__":
    from dataset import DataSet
    from time import time
    
#    fname = r"D:\Projekte\Mikroplastik\Waferreinigung_Kerzenfilter\WaferMilliQH118\fullimage.tif"
    fname = r"C:\Users\brandt\Desktop\20180723DemoTZW\fullimage.tif"
    app = QtWidgets.QApplication(sys.argv)
    

fakeData/image.bmp

0 → 100755
+1.03 MiB
Loading image diff...
+0 −1
Original line number Diff line number Diff line
@@ -526,7 +526,6 @@ class OpticalScan(QtWidgets.QWidget):
        self.timer.start(100.)           
            
if __name__ == "__main__":
    import sys
    from WITecCOM import WITecCOM

    app = QtWidgets.QApplication(sys.argv)
+28 −18
Original line number Diff line number Diff line
@@ -19,27 +19,37 @@ along with this program, see COPYING.
If not, see <https://www.gnu.org/licenses/>.
"""
import os
from socket import gethostname
from WITecCOM import WITecCOM
#from renishawcom import RenishawCOM
from simulatedraman import SimulatedRaman
import configparser

__all__ = ["RamanControl", "defaultPath", "simulatedRaman"]


__all__ = ["RamanControl", "simulatedRaman", "defaultPath"]
config = configparser.ConfigParser()
config.read('gepard.cfg')

interface = "SIMULATED_RAMAN_CONTROL"
defaultPath = os.path.split(__file__)[0]

RamanControl = SimulatedRaman
hostname = gethostname()
if "SIMULATED_RAMAN_CONTROL" not in os.environ:
    if "NO_WITEC_CONTROL" not in os.environ:
        WITecCOM.hostname = hostname
        #defaultPath = r"D:\Projekte\Mikroplastik"
        RamanControl = WITecCOM
#    elif hostname == RenishawCOM.hostname and "NO_RENISHAW_CONTROL" not in os.environ:
#        RamanControl = RenishawCOM
try: 
    defaultPath = config["Defaults"]["file_path"]
except KeyError:
    pass

try:
    interface = config["Interface"]["raman_interface"]
except KeyError:
    pass

if RamanControl == SimulatedRaman:
if interface == "SIMULATED_RAMAN_CONTROL":
    from simulatedraman import SimulatedRaman
    RamanControl = SimulatedRaman
    print("WARNING: using only simulated raman control!")
    simulatedRaman = True
else:
elif interface == "SIMULATED_RAMAN_CONTROL":
    from WITecCOM import WITecCOM
    RamanControl = WITecCOM
    simulatedRaman = False
elif interface == "RENISHAW_CONTROL":
    raise NotImplementedError
    simulatedRaman = False
    
 No newline at end of file
Loading