def open_instrument(self): """Doc.""" try: self._inst = uc480.UC480_Camera(serial=self.serial.encode(), reopen_policy="new") except Exception as exc: # general 'Exception' is due to bad exception handeling in instrumental-lib... raise IOError(f"{self.log_ref} disconnected - {exc}")
def search_live_image(source=source, source_mag=10., flake_mag=126.5): try: sys.path.append(r'D:\Nonlinear_setup\Python_codes') global cam, bg bg = np.load( 'D:/Nonlinear_setup/Python_codes/search_live_image_bg.npy') bg = 1. * bg / np.max(bg) try: from instrumental.drivers.cameras import uc480 cam = uc480.UC480_Camera() except: pass clahe = cv2.createCLAHE(clipLimit=.1, tileGridSize=(80, 80)) def capture_image(): img = cam.latest_frame() img = (img / bg).astype(np.uint8) # img = clahe.apply(img) img = cv2.equalizeHist(img) img = filters.minimum_filter(img, 3) # img = cv2.fastNlMeansDenoising(img) return np.fliplr(img) def press(event): if event.key == 'b': get_live_image_bg() global bg bg = np.load( 'D:/Nonlinear_setup/Python_codes/search_live_image_bg.npy') bg = 1. * bg / np.max(bg) cam.auto_blacklevel = 1 cam.auto_exposure = 1 cam.auto_framerate = 1 cam.auto_gain = 1 cam.start_live_video() # cam.start_capture() flake = capture_image() search_single_image(flake, source, source_mag, flake_mag) _fig.canvas.mpl_connect('key_press_event', press) plt.pause(1e-6) while True: flake = capture_image() search_single_image(flake, source, source_mag, flake_mag, update=True) plt.pause(1e-6) except KeyboardInterrupt: cam.stop_live_video()
# -*- coding: utf-8 -*- """ Created on Tue Nov 13 11:14:13 2018 @author: USUARIO """ import sys import numpy as np import matplotlib.pyplot as plt from instrumental.drivers.cameras import uc480 import time sys.path.append('C:\Program Files\Thorlabs\Scientific Imaging\ThorCam') myCamera = uc480.UC480_Camera() print('Model {}'.format(myCamera.model)) print('Serial number {}'.format(myCamera.serial)) #raw_image = myCamera.grab_image(exposure_time='50 ms') myCamera.start_live_video('10 Hz') time.sleep(1) raw_image = myCamera.latest_frame() r = raw_image[:, :, 0] g = raw_image[:, :, 1] b = raw_image[:, :, 2]
self.focusTimer.stop() self.camera.close() if self.standAlone is True: zMoveTo(self.actuator, 0) if __name__ == '__main__': print('Focus lock module running in stand-alone mode') app = QtGui.QApplication([]) cam = uc480.UC480_Camera() DEVICENUMBER = 0x1 adw = ADwin.ADwin(DEVICENUMBER, 1) scan.setupDevice(adw) # initialize fpar_52 (z) ADwin position parameters pos_zero = tools.convert(0, 'XtoU') adw.Set_FPar(52, pos_zero) zMoveTo(adw, 10) win = focusWidget(cam, adw) win.fworker.standAlone = True
from pygame import mixer mixer.init() sys.path.append(os.path.abspath(r"D:\WMP_setup\Python_codes")) sys.path.append(os.path.abspath(r"D:\Nonlinear_setup\Python_codes")) from neo_common_code import * from instrumental.drivers.cameras import uc480 from anal_measure_beam_profile_with_camera import * global cam try: if not cam.model == 'C1285R12M': raise Exception else: print('Camera C1285R12M already online.') except: cam = uc480.UC480_Camera('C1285R12M') print('Camera C1285R12M online.') cam.auto_exposure = False cam.auto_framerate = False cam.auto_gain = False try: import TL_slider_2 #sc def block_sc(): TL_slider_2.block_laser_2() def unblock_sc(): TL_slider_2.unblock_laser_2() except: print "SC shutter not connected"
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setWindowTitle('PyFLUX') self.cwidget = QtGui.QWidget() self.setCentralWidget(self.cwidget) # Actions in menubar menubar = self.menuBar() fileMenu = menubar.addMenu('Measurement') self.psfMeasAction = QtGui.QAction('PSF measurement', self) self.psfMeasAction.setStatusTip('Routine to measure one MINFLUX PSF') fileMenu.addAction(self.psfMeasAction) self.psfMeasAction.triggered.connect(self.psfMeasurement) self.minfluxMeasAction = QtGui.QAction('MINFLUX measurement', self) self.minfluxMeasAction.setStatusTip( 'Routine to perform a tcspc-MINFLUX measurement') fileMenu.addAction(self.minfluxMeasAction) # GUI layout grid = QtGui.QGridLayout() self.cwidget.setLayout(grid) # Dock Area dockArea = DockArea() grid.addWidget(dockArea, 0, 0) # Scan scanDock = Dock('Confocal scan', size=(1, 1)) DEVICENUMBER = 0x1 self.adw = drivers.ADwin.ADwin(DEVICENUMBER, 1) scan.setupDevice(self.adw) self.scanWidget = scan.scanWidget(self.adw) scanDock.addWidget(self.scanWidget) dockArea.addDock(scanDock, 'left') # tcspc measurement tcspcDock = Dock("Time-correlated single-photon counting") ph = drivers.picoharp.PicoHarp300() self.tcspcWidget = tcspc.tcspcWidget(ph) tcspcDock.addWidget(self.tcspcWidget) dockArea.addDock(tcspcDock, 'bottom', scanDock) # focus lock focusDock = Dock("Focus Lock") uc480Camera = uc480.UC480_Camera() self.focusWidget = focus.focusWidget(uc480Camera, self.adw) focusDock.addWidget(self.focusWidget) dockArea.addDock(focusDock, 'right') # xy drift xyDock = Dock("xy drift control") andorCamera = ccd.CCD() self.xyWidget = xy.xyWidget(andorCamera) xyDock.addWidget(self.xyWidget) xyDock.addWidget(self.xyWidget) dockArea.addDock(xyDock, 'top', focusDock) # threads self.scanThread = QtCore.QThread(self) self.scanThread.start() self.scanWidget.scworker.moveToThread(self.scanThread) self.focusThread = QtCore.QThread(self) self.focusThread.start() self.focusWidget.fworker.moveToThread(self.focusThread) self.xyThread = QtCore.QThread(self) self.xyThread.start() self.xyWidget.xyworker.moveToThread(self.xyThread) # self.tcspcThread = QtCore.QThread(self) # self.tcspcThread.start() # self.tcspcWidget.tcspcworker.moveToThread(self.tcspcThread) # sizes to fit my screen properly self.scanWidget.setMinimumSize(1000, 550) self.xyWidget.setMinimumSize(800, 300) self.move(1, 1)