Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
total_control_app
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Drechsler
total_control_app
Commits
e5c1f542
Commit
e5c1f542
authored
May 01, 2019
by
Martin Drechsler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some changes
parent
63640556
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
38 deletions
+36
-38
cameraGui.py
cameraGui.py
+19
-20
zylaCameraWorker.py
zylaCameraWorker.py
+17
-18
No files found.
cameraGui.py
View file @
e5c1f542
...
@@ -46,17 +46,12 @@ class CameraGuiMainWindow(QMainWindow):
...
@@ -46,17 +46,12 @@ class CameraGuiMainWindow(QMainWindow):
self
.
d2
=
dockarea
.
Dock
(
"Zyla Camera Analysis"
)
self
.
d2
=
dockarea
.
Dock
(
"Zyla Camera Analysis"
)
self
.
d3
=
dockarea
.
Dock
(
"Zyla Camera Control"
)
self
.
d3
=
dockarea
.
Dock
(
"Zyla Camera Control"
)
self
.
d4
=
dockarea
.
Dock
(
"Measurement and saving"
)
self
.
d4
=
dockarea
.
Dock
(
"Measurement and saving"
)
self
.
area
.
addDock
(
self
.
d1
)
self
.
area
.
addDock
(
self
.
d1
)
self
.
area
.
addDock
(
self
.
d2
,
"left"
,
self
.
d1
)
self
.
area
.
addDock
(
self
.
d2
,
"left"
,
self
.
d1
)
self
.
area
.
addDock
(
self
.
d3
,
"right"
,
self
.
d1
)
self
.
area
.
addDock
(
self
.
d3
,
"right"
,
self
.
d1
)
self
.
area
.
addDock
(
self
.
d4
,
"bottom"
,
self
.
d3
)
self
.
area
.
addDock
(
self
.
d4
,
"bottom"
,
self
.
d3
)
# button spinbox and label
## button spinbox and label
self
.
cameraButton
=
QPushButton
(
"Start Acquisition"
)
self
.
cameraButton
=
QPushButton
(
"Start Acquisition"
)
self
.
isCameraAcquiring
=
False
self
.
isCameraAcquiring
=
False
self
.
d3
.
addWidget
(
self
.
cameraButton
)
self
.
d3
.
addWidget
(
self
.
cameraButton
)
...
@@ -85,7 +80,7 @@ class CameraGuiMainWindow(QMainWindow):
...
@@ -85,7 +80,7 @@ class CameraGuiMainWindow(QMainWindow):
# self.p.setRange(xRange = (0, 10), yRange = (0, 255))
# self.p.setRange(xRange = (0, 10), yRange = (0, 255))
self
.
curve
=
self
.
p
.
plot
(
pen
=
"y"
)
self
.
curve
=
self
.
p
.
plot
(
pen
=
"y"
)
#
#
rOI
# rOI
self
.
rois
=
[]
self
.
rois
=
[]
self
.
rois
.
append
(
CustomRectangularROI
([
0
,
0
]))
self
.
rois
.
append
(
CustomRectangularROI
([
0
,
0
]))
for
r
in
self
.
rois
:
for
r
in
self
.
rois
:
...
@@ -99,17 +94,17 @@ class CameraGuiMainWindow(QMainWindow):
...
@@ -99,17 +94,17 @@ class CameraGuiMainWindow(QMainWindow):
self
.
_initialize_image
()
self
.
_initialize_image
()
def
make_connections
(
self
,
backend
):
def
make_connections
(
self
,
backend
):
#
#
backend connections
#
backend connections
backend
.
imageReadySignal
.
connect
(
self
.
updateImage
)
backend
.
imageReadySignal
.
connect
(
self
.
updateImage
)
#
#
internal connections
#
internal connections
self
.
frames_checker_timer
.
timeout
.
connect
(
self
.
frame_counter
)
self
.
frames_checker_timer
.
timeout
.
connect
(
self
.
frame_counter
)
self
.
cameraButton
.
clicked
.
connect
(
self
.
cameraButton
.
clicked
.
connect
(
self
.
camera_button_pressed
)
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
)
self
.
d4
.
addWidget
(
self
.
console
)
def
camera_button_pressed
(
self
):
def
camera_button_pressed
(
self
):
if
self
.
isCameraAcquiring
:
if
self
.
isCameraAcquiring
:
...
@@ -123,8 +118,9 @@ class CameraGuiMainWindow(QMainWindow):
...
@@ -123,8 +118,9 @@ class CameraGuiMainWindow(QMainWindow):
self
.
previous_frame_index
=
0
self
.
previous_frame_index
=
0
self
.
frames_checker_timer
.
start
(
1000
)
self
.
frames_checker_timer
.
start
(
1000
)
self
.
isCameraAcquiring
=
True
self
.
isCameraAcquiring
=
True
def
_initialize_image
(
self
):
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
.
setAspectLocked
(
True
)
self
.
view
.
addItem
(
self
.
img
)
self
.
view
.
addItem
(
self
.
img
)
...
@@ -140,12 +136,15 @@ class CameraGuiMainWindow(QMainWindow):
...
@@ -140,12 +136,15 @@ class CameraGuiMainWindow(QMainWindow):
self
.
ROIdata
[
self
.
iROIdata
]
=
self
.
newData
self
.
ROIdata
[
self
.
iROIdata
]
=
self
.
newData
self
.
iROIdata
=
np
.
mod
(
self
.
frame_index
+
1
,
len
(
self
.
ROIdata
))
self
.
iROIdata
=
np
.
mod
(
self
.
frame_index
+
1
,
len
(
self
.
ROIdata
))
self
.
curve
.
setData
(
self
.
ROIdata
)
self
.
curve
.
setData
(
self
.
ROIdata
)
def
repositionRoi
(
self
):
def
repositionRoi
(
self
):
old_size
=
self
.
current_image_size
old_size
=
self
.
current_image_size
aux_dict
=
{
'1x1'
:
2048
,
'2x2'
:
1024
,
'4x4'
:
512
,
'8x8'
:
256
}
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
)
print
(
'sizes:'
,
old_size
,
new_size
)
for
roi
in
self
.
rois
:
for
roi
in
self
.
rois
:
x
,
y
,
sx
,
sy
=
roi
.
pos
()[
0
],
roi
.
pos
()[
1
],
roi
.
size
()[
0
],
roi
.
size
()[
1
]
x
,
y
,
sx
,
sy
=
roi
.
pos
()[
0
],
roi
.
pos
()[
1
],
roi
.
size
()[
0
],
roi
.
size
()[
1
]
...
@@ -153,7 +152,7 @@ class CameraGuiMainWindow(QMainWindow):
...
@@ -153,7 +152,7 @@ class CameraGuiMainWindow(QMainWindow):
new_sx
,
new_sy
=
new_size
/
old_size
*
sx
,
new_size
/
old_size
*
sy
new_sx
,
new_sy
=
new_size
/
old_size
*
sx
,
new_size
/
old_size
*
sy
roi
.
setPos
([
new_x
,
new_y
])
roi
.
setPos
([
new_x
,
new_y
])
roi
.
setSize
([
new_sx
,
new_sy
])
roi
.
setSize
([
new_sx
,
new_sy
])
@
QtCore
.
pyqtSlot
(
np
.
ndarray
,
int
)
@
QtCore
.
pyqtSlot
(
np
.
ndarray
,
int
)
def
updateImage
(
self
,
image
,
acq_index
):
def
updateImage
(
self
,
image
,
acq_index
):
...
@@ -164,7 +163,7 @@ class CameraGuiMainWindow(QMainWindow):
...
@@ -164,7 +163,7 @@ class CameraGuiMainWindow(QMainWindow):
)
)
# n = 1024
# n = 1024
self
.
img
.
setImage
(
image
,
autoDownsample
=
True
)
self
.
img
.
setImage
(
image
,
autoDownsample
=
True
)
self
.
updateRois
()
self
.
updateRois
()
self
.
frame_index
=
self
.
frame_index
+
1
self
.
frame_index
=
self
.
frame_index
+
1
self
.
current_image_size
=
image
.
shape
[
0
]
self
.
current_image_size
=
image
.
shape
[
0
]
...
...
zylaCameraWorker.py
View file @
e5c1f542
...
@@ -11,7 +11,7 @@ Created on Thu Apr 4 11:10:20 2019
...
@@ -11,7 +11,7 @@ Created on Thu Apr 4 11:10:20 2019
import
numpy
as
np
import
numpy
as
np
from
PyQt5
import
QtCore
from
PyQt5
import
QtCore
#from drivers.andorzyla import AndorZyla
#
from drivers.andorzyla import AndorZyla
from
dummyAndor
import
AndorZyla
from
dummyAndor
import
AndorZyla
import
threading
import
threading
...
@@ -24,20 +24,19 @@ class CameraWorker(QtCore.QObject):
...
@@ -24,20 +24,19 @@ class CameraWorker(QtCore.QObject):
self
.
cam
=
AndorZyla
(
0
)
self
.
cam
=
AndorZyla
(
0
)
self
.
cam
.
Init
()
self
.
cam
.
Init
()
#self.cam.ExposureTime.setValue(0.1)
print
(
"camera worker initialized"
)
print
(
"camera worker initialized"
)
def
make_connections
(
self
,
frontend
):
def
make_connections
(
self
,
frontend
):
# frontend connections
# frontend connections
params
=
frontend
.
param_tree
.
p
params
=
frontend
.
param_tree
.
p
frontend
.
cameraButton
.
clicked
.
connect
(
lambda
:
self
.
run
(
params
))
frontend
.
cameraButton
.
clicked
.
connect
(
lambda
:
self
.
run
(
params
))
# internal connections
# internal connections
self
.
cam
.
helper
.
imageAquiredSignal
.
connect
(
self
.
new_image_acquired
)
self
.
cam
.
helper
.
imageAquiredSignal
.
connect
(
self
.
new_image_acquired
)
def
__del__
(
self
):
def
__del__
(
self
):
print
(
"adios camera worker"
)
print
(
"adios camera worker"
)
#@QtCore.pyqtSlot()
#
@QtCore.pyqtSlot()
def
run
(
self
,
params
):
def
run
(
self
,
params
):
if
self
.
cam
.
CameraAcquiring
.
getValue
():
if
self
.
cam
.
CameraAcquiring
.
getValue
():
self
.
_stop_acquisition_loop
()
self
.
_stop_acquisition_loop
()
...
@@ -46,7 +45,9 @@ class CameraWorker(QtCore.QObject):
...
@@ -46,7 +45,9 @@ class CameraWorker(QtCore.QObject):
else
:
else
:
self
.
_configure_acq_parameters
(
params
)
self
.
_configure_acq_parameters
(
params
)
self
.
_start_acquisition_loop
()
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
()
self
.
acq_thread
.
start
()
print
(
"acquisiting now starting"
)
print
(
"acquisiting now starting"
)
...
@@ -62,23 +63,21 @@ class CameraWorker(QtCore.QObject):
...
@@ -62,23 +63,21 @@ class CameraWorker(QtCore.QObject):
self
.
cam
.
AcquisitionStop
()
self
.
cam
.
AcquisitionStop
()
self
.
cam
.
_flush
()
self
.
cam
.
_flush
()
def
_configure_acq_parameters
(
self
,
params
):
def
_configure_acq_parameters
(
self
,
params
):
print
(
'Acq parameters: '
)
print
(
'Acq parameters: '
)
for
p
in
params
.
children
()[
0
]
.
children
():
for
p
in
params
.
children
()[
0
]
.
children
():
print
(
p
.
name
(),
p
.
value
())
print
(
p
.
name
(),
p
.
value
())
params
.
child
(
'Basic acq parameters'
)
.
child
(
'Camera name'
)
.
setValue
(
self
.
cam
.
CameraModel
.
getValue
())
params
.
child
(
'Basic acq parameters'
)
.
child
(
'Camera name'
)
.
setValue
(
self
.
cam
.
ExposureTime
.
setValue
(
params
.
child
(
'Basic acq parameters'
)
self
.
cam
.
CameraModel
.
getValue
())
.
child
(
'Exposure Time'
)
.
value
()
self
.
cam
.
ExposureTime
.
setValue
(
)
params
.
child
(
'Basic acq parameters'
)
.
child
(
'Exposure Time'
)
.
value
()
self
.
cam
.
FrameRate
.
setValue
(
self
.
cam
.
FrameRate
.
max
()
)
)
self
.
cam
.
FrameRate
.
setValue
(
self
.
cam
.
FrameRate
.
max
())
params
.
child
(
'Basic acq parameters'
)
.
child
(
'Frame Rate'
)
.
setValue
(
self
.
cam
.
FrameRate
.
getValue
())
params
.
child
(
'Basic acq parameters'
)
.
child
(
'Frame Rate'
)
.
setValue
(
self
.
cam
.
AOIBinning
.
setString
(
params
.
child
(
'Basic acq parameters'
)
.
child
(
'Pixel Binning'
)
.
value
()
self
.
cam
.
FrameRate
.
getValue
())
)
self
.
cam
.
AOIBinning
.
setString
(
params
.
child
(
'Basic acq parameters'
)
.
child
(
'Pixel Binning'
)
.
value
()
)
@
QtCore
.
pyqtSlot
(
int
)
@
QtCore
.
pyqtSlot
(
int
)
def
new_image_acquired
(
self
,
acq_index
):
def
new_image_acquired
(
self
,
acq_index
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment