Commit e5c1f542 authored by Martin Drechsler's avatar Martin Drechsler

some changes

parent 63640556
......@@ -46,17 +46,12 @@ class CameraGuiMainWindow(QMainWindow):
self.d2 = dockarea.Dock("Zyla Camera Analysis")
self.d3 = dockarea.Dock("Zyla Camera Control")
self.d4 = dockarea.Dock("Measurement and saving")
self.area.addDock(self.d1)
self.area.addDock(self.d2, "left", self.d1)
self.area.addDock(self.d3, "right", self.d1)
self.area.addDock(self.d4, "bottom", self.d3)
## button spinbox and label
# button spinbox and label
self.cameraButton = QPushButton("Start Acquisition")
self.isCameraAcquiring = False
self.d3.addWidget(self.cameraButton)
......@@ -85,7 +80,7 @@ class CameraGuiMainWindow(QMainWindow):
# self.p.setRange(xRange = (0, 10), yRange = (0, 255))
self.curve = self.p.plot(pen="y")
## rOI
# rOI
self.rois = []
self.rois.append(CustomRectangularROI([0, 0]))
for r in self.rois:
......@@ -99,17 +94,17 @@ class CameraGuiMainWindow(QMainWindow):
self._initialize_image()
def make_connections(self, backend):
##backend connections
# backend connections
backend.imageReadySignal.connect(self.updateImage)
##internal connections
# internal connections
self.frames_checker_timer.timeout.connect(self.frame_counter)
self.cameraButton.clicked.connect(
self.camera_button_pressed
)
self.cameraButton.clicked.connect(self.camera_button_pressed)
self.console = console.ConsoleWidget(namespace = {'np': np, 'cam': backend.cam, 'roi': self.rois[0]})
self.console = console.ConsoleWidget(
namespace = {'np': np, 'cam': backend.cam, 'roi': self.rois[0]}
)
self.d4.addWidget(self.console)
def camera_button_pressed(self):
if self.isCameraAcquiring:
......@@ -123,8 +118,9 @@ class CameraGuiMainWindow(QMainWindow):
self.previous_frame_index = 0
self.frames_checker_timer.start(1000)
self.isCameraAcquiring = True
def _initialize_image(self):
## lock the aspect ratio so pixels are always square
# lock the aspect ratio so pixels are always square
self.view.setAspectLocked(True)
self.view.addItem(self.img)
......@@ -140,12 +136,15 @@ class CameraGuiMainWindow(QMainWindow):
self.ROIdata[self.iROIdata] = self.newData
self.iROIdata = np.mod(self.frame_index + 1, len(self.ROIdata))
self.curve.setData(self.ROIdata)
def repositionRoi(self):
old_size = self.current_image_size
aux_dict = {'1x1': 2048, '2x2': 1024, '4x4': 512, '8x8': 256}
new_size = aux_dict[self.param_tree.p.child('Basic acq parameters').child('Pixel Binning').value()]
new_size = aux_dict[
self.param_tree.p.child('Basic acq parameters')
.child('Pixel Binning').value()
]
print('sizes:', old_size, new_size)
for roi in self.rois:
x, y, sx, sy = roi.pos()[0], roi.pos()[1], roi.size()[0], roi.size()[1]
......@@ -153,7 +152,7 @@ class CameraGuiMainWindow(QMainWindow):
new_sx, new_sy = new_size/old_size * sx, new_size/old_size * sy
roi.setPos([new_x, new_y])
roi.setSize([new_sx, new_sy])
@QtCore.pyqtSlot(np.ndarray, int)
def updateImage(self, image, acq_index):
......@@ -164,7 +163,7 @@ class CameraGuiMainWindow(QMainWindow):
)
# n = 1024
self.img.setImage(image, autoDownsample = True)
self.img.setImage(image, autoDownsample=True)
self.updateRois()
self.frame_index = self.frame_index + 1
self.current_image_size = image.shape[0]
......
......@@ -11,7 +11,7 @@ Created on Thu Apr 4 11:10:20 2019
import numpy as np
from PyQt5 import QtCore
#from drivers.andorzyla import AndorZyla
# from drivers.andorzyla import AndorZyla
from dummyAndor import AndorZyla
import threading
......@@ -24,20 +24,19 @@ class CameraWorker(QtCore.QObject):
self.cam = AndorZyla(0)
self.cam.Init()
#self.cam.ExposureTime.setValue(0.1)
print("camera worker initialized")
def make_connections(self, frontend):
# frontend connections
params = frontend.param_tree.p
frontend.cameraButton.clicked.connect(lambda: self.run(params))
frontend.cameraButton.clicked.connect(lambda: self.run(params))
# internal connections
self.cam.helper.imageAquiredSignal.connect(self.new_image_acquired)
def __del__(self):
print("adios camera worker")
#@QtCore.pyqtSlot()
# @QtCore.pyqtSlot()
def run(self, params):
if self.cam.CameraAcquiring.getValue():
self._stop_acquisition_loop()
......@@ -46,7 +45,9 @@ class CameraWorker(QtCore.QObject):
else:
self._configure_acq_parameters(params)
self._start_acquisition_loop()
self.acq_thread = threading.Thread(target=self.cam.live_acquisition_loop)
self.acq_thread = threading.Thread(
target=self.cam.live_acquisition_loop
)
self.acq_thread.start()
print("acquisiting now starting")
......@@ -62,23 +63,21 @@ class CameraWorker(QtCore.QObject):
self.cam.AcquisitionStop()
self.cam._flush()
def _configure_acq_parameters(self, params):
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.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()
)
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()
)
@QtCore.pyqtSlot(int)
def new_image_acquired(self, acq_index):
......
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