Commit e54ea7ca authored by Martin Drechsler's avatar Martin Drechsler

Now it works with the Zyla, maybe not with the dummy.

parent 07ac6e35
......@@ -11,6 +11,8 @@ from PyQt5.QtWidgets import QMainWindow, QPushButton, QLabel
from pyqtgraph.Qt import QtGui, QtCore
from pyqtgraph import dockarea
import pyqtgraph as pg
from pyqtgraph import console
from pyqtgraph_sublasses import CustomRectangularROI
from zylaCameraWorker import CameraWorker
from cameraParameterTree import CameraParameterTree
......@@ -61,7 +63,7 @@ class GuiMainWindow(QMainWindow):
self.label = QLabel("Counter of frames")
self.d1.addWidget(self.label)
self.param_tree = CameraParameterTree()
self.d3.addWidget(self.param_tree.t)
......@@ -86,7 +88,7 @@ class GuiMainWindow(QMainWindow):
## rOI
self.rois = []
self.rois.append(pg.TestROI([0, 0], [10, 10], pen=(0, 9)))
self.rois.append(CustomRectangularROI([0, 0]))
for r in self.rois:
self.view.addItem(r)
# r.sigRegionChanged.connect(self.updateRoi)
......@@ -105,6 +107,9 @@ class GuiMainWindow(QMainWindow):
self.camera_button_pressed
)
self.console = console.ConsoleWidget(namespace = {'np': np, 'cam': backend.cam})
self.d4.addWidget(self.console)
def camera_button_pressed(self):
if self.isCameraAcquiring:
......@@ -136,7 +141,7 @@ class GuiMainWindow(QMainWindow):
self.ROIdata[self.iROIdata] = self.newData
self.iROIdata = np.mod(self.frame_index + 1, len(self.ROIdata))
self.curve.setData(self.ROIdata)
@QtCore.pyqtSlot(np.ndarray, int)
def updateImage(self, image, acq_index):
......
......@@ -29,31 +29,30 @@ class BasicAcquisitonParameters(pTypes.GroupParameter):
self.addChild({'name': 'Pixel Binning', 'type': 'list', 'values': ['1x1', '2x2', '4x4', '8x8']})
self.addChild({'name': 'Image Area', 'type': 'list', 'values': ['2048x2048', '1024x1024', '512x512', '256x256'], 'readonly': True})
self.addChild({'name': 'Exposure Time', 'type': 'float', 'value': .1, 'suffix': 's', 'siPrefix': True, 'step': 0.05})
self.addChild({'name': 'Frame Rate', 'type': 'float', 'value': 10, 'readonly': True})
self.addChild({'name': 'Frame Rate', 'type': 'float', 'value': 0, 'readonly': True})
#exposure time and frame rate connected because they are the inverse of each other
#later, they should be set so that the framerate is the maximum possible value given an exposure time
self.exposureTimeWidget = self.param('Exposure Time')
self.frameRateWidget = self.param('Frame Rate')
self.exposureTimeWidget.sigValueChanged.connect(self.expTimeChanged)
self.frameRateWidget.sigValueChanged.connect(self.frameRateChanged)
# self.exposureTimeWidget = self.param('Exposure Time')
# self.frameRateWidget = self.param('Frame Rate')
# self.exposureTimeWidget.sigValueChanged.connect(self.expTimeChanged)
# self.frameRateWidget.sigValueChanged.connect(self.frameRateChanged)
#set image area according to binning
self.param('Pixel Binning').sigValueChanged.connect(self.binningChanged)
def expTimeChanged(self):
self.frameRateWidget.setValue(1.0 / self.exposureTimeWidget.value(), blockSignal=self.frameRateChanged)
# def expTimeChanged(self):
# self.frameRateWidget.setValue(1.0 / self.exposureTimeWidget.value(), blockSignal=self.frameRateChanged)
def frameRateChanged(self):
self.exposureTimeWidget.setValue(1.0 / self.frameRateWidget.value(), blockSignal=self.expTimeChanged)
# def frameRateChanged(self):
# self.exposureTimeWidget.setValue(1.0 / self.frameRateWidget.value(), blockSignal=self.expTimeChanged)
def binningChanged(self):
if self.param('Pixel Binning').value() == '1x1':
self.param('Image Area').setValue('2048x2048')
if self.param('Pixel Binning').value() == '2x2':
print('hola 2x2')
self.param('Image Area').setValue('1024x1024')
if self.param('Pixel Binning').value() == '4x4':
self.param('Image Area').setValue('512x512')
......
......@@ -80,7 +80,9 @@ class AndorBase(SDK3Camera):
def __init__(self, camNum):
#some helper attributes (Martin)
self.helper = Helper_messager()
self.acq_queue = Queue.Queue(maxsize=10)
self.current_image = None
......@@ -758,6 +760,7 @@ class AndorBase(SDK3Camera):
px_encoding, 'Mono16')
img.shape = (ys, xs)
self.current_image = img
self.acq_queue.put(self.current_image)
SDK3.QueueBuffer(self.handle, bufs[self.acq_index_i%len(bufs)].ctypes.data_as(SDK3.POINTER(SDK3.AT_U8)), bufs[self.acq_index_i%len(bufs)].nbytes)
self.helper.imageAquiredSignal.emit(self.acq_index_i)
......
......@@ -24,7 +24,7 @@ class AndorZyla:
self.ImageArea = AndorFeats()
self.CameraName = 'Dummy'
self.acq_queue = Queue(maxsize=5)
self.acq_queue = Queue(maxsize=10)
self.helper = Helper_messager()
self.current_image = None
......@@ -64,11 +64,14 @@ class AndorZyla:
pass
def _twoD_gaussian(self, lim=10, sigma=1, x0=0, y0=0):
start = time.time()
N = self.ImageArea.getValue()
x, y = np.meshgrid(np.linspace(-lim, lim, N), np.linspace(-lim, lim, N))
d = np.sqrt((x - x0) ** 2 + (y - y0) ** 2)
g = np.exp(-((d) ** 2 / (2.0 * sigma ** 2)))
noise = np.random.rand(N, N)
end = time.time()
print(end-start)
time.sleep(self.ExposureTime.getValue())
return g + noise
......
......@@ -11,8 +11,8 @@ Created on Thu Apr 4 11:10:20 2019
import numpy as np
from PyQt5 import QtCore
# from drivers.andorzyla import AndorZyla
from dummyAndor import AndorZyla
from drivers.andorzyla import AndorZyla
#from dummyAndor import AndorZyla
import threading
......@@ -67,11 +67,15 @@ class CameraWorker(QtCore.QObject):
print('Acq parameters: ')
for p in params.children()[0].children():
print(p.name(), p.value())
params.child('Basic acq parameters').child('Camera name').setValue(self.cam.CameraName)
params.child('Basic acq parameters').child('Camera name').setValue(self.cam.CameraModel.getValue())
self.cam.ExposureTime.setValue(params.child('Basic acq parameters')
.child('Exposure Time').value()
)
self.cam.FrameRate.setValue(self.cam.FrameRate.max()
)
params.child('Basic acq parameters').child('Frame Rate').setValue(self.cam.FrameRate.getValue())
self.cam.AOIBinning.setString(params.child('Basic acq parameters').child('Pixel Binning').value()
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment