# -*- coding: utf-8 -*- """ GEPARD - Gepard-Enabled PARticle Detection Copyright (C) 2018 Lars Bittrich and Josef Brandt, Leibniz-Institut für Polymerforschung Dresden e. V. This program 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. This program 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, see COPYING. If not, see . """ import cv2 from ..helperfunctions import cv2imread_fix, cv2imwrite_fix class InstrumentComBase(object): videoScaleFactor: float = 1.0 @classmethod def setVideoScaleFactor(cls, newFac) -> None: cls.videoScaleFactor = float(newFac) def __init__(self, logger=None): self.name = None self.connected = False self.timeseries = False self.logger = logger def _scaleVideoImage(self, imagePath: str) -> None: """ For convenience.. Takes the image at the indicated path and scales it to the videoScaleFactor. """ img = cv2imread_fix(imagePath) img = cv2.resize(img, None, fx=self.videoScaleFactor, fy=self.videoScaleFactor) cv2imwrite_fix(imagePath, img) def getRamanPositionShift(self): """ Compute the shift between laser spot and image center""" raise NotImplementedError def connect(self): self.connected = True return True def disconnect(self): self.connected = False def getPosition(self): raise NotImplementedError def getSoftwareZ(self): raise NotImplementedError def getUserZ(self): raise NotImplementedError def moveToAbsolutePosition(self, x, y, z=None, epsxy=0.11, epsz=0.011): raise NotImplementedError def moveZto(self, z, epsz=0.011): raise NotImplementedError def saveImage(self, fname): raise NotImplementedError def getImageDimensions(self, mode: str = 'df'): """ Get the image width and height in um and the orientation angle in degrees. """ raise NotImplementedError def initiateMeasurement(self, specScanSettings): raise NotImplementedError def triggerMeasurement(self, num): raise NotImplementedError def finishMeasurement(self, aborted=False): raise NotImplementedError def updateImageConfig(self, dsetpath: str) -> None: """ Can be overloaded if the instrcontrol needs to update image config fro dataset folder :param dsetpath: filepath to the dataset :return: """ pass