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
e3836e5b
Commit
e3836e5b
authored
Apr 24, 2019
by
Martin Drechsler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
roi now automoves when changing binning
parent
d88f54ae
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
16 deletions
+97
-16
cameraGui.py
cameraGui.py
+24
-10
dummyAndor.py
dummyAndor.py
+19
-6
pyqtgraph_subclasses.py
pyqtgraph_subclasses.py
+54
-0
No files found.
cameraGui.py
View file @
e3836e5b
...
...
@@ -12,7 +12,7 @@ from pyqtgraph.Qt import QtGui, QtCore
from
pyqtgraph
import
dockarea
import
pyqtgraph
as
pg
from
pyqtgraph
import
console
from
pyqtgraph_sublasses
import
CustomRectangularROI
from
pyqtgraph_sub
c
lasses
import
CustomRectangularROI
from
zylaCameraWorker
import
CameraWorker
from
cameraParameterTree
import
CameraParameterTree
...
...
@@ -20,7 +20,7 @@ import sys
import
numpy
as
np
class
GuiMainWindow
(
QMainWindow
):
class
Camera
GuiMainWindow
(
QMainWindow
):
def
__init__
(
self
):
super
()
.
__init__
()
...
...
@@ -96,6 +96,7 @@ class GuiMainWindow(QMainWindow):
self
.
ROIdata
=
np
.
zeros
(
1000
)
self
.
iROIdata
=
0
self
.
current_image_size
=
2048
self
.
_initialize_image
()
def
make_connections
(
self
,
backend
):
...
...
@@ -107,7 +108,7 @@ class GuiMainWindow(QMainWindow):
self
.
camera_button_pressed
)
self
.
console
=
console
.
ConsoleWidget
(
namespace
=
{
'np'
:
np
,
'cam'
:
backend
.
cam
})
self
.
console
=
console
.
ConsoleWidget
(
namespace
=
{
'np'
:
np
,
'cam'
:
backend
.
cam
,
'roi'
:
self
.
rois
[
0
]
})
self
.
d4
.
addWidget
(
self
.
console
)
def
camera_button_pressed
(
self
):
...
...
@@ -117,6 +118,7 @@ class GuiMainWindow(QMainWindow):
self
.
cameraButton
.
setText
(
'Start Acquisition'
)
self
.
isCameraAcquiring
=
False
else
:
self
.
repositionRoi
()
self
.
cameraButton
.
setText
(
'Stop Acquisition'
)
self
.
frame_index
=
0
self
.
previous_frame_index
=
0
...
...
@@ -134,14 +136,25 @@ class GuiMainWindow(QMainWindow):
def
updateRois
(
self
):
for
roi
in
self
.
rois
:
self
.
lastRoi
=
roi
roiSlice
=
roi
.
getArrayRegion
(
self
.
img
.
image
,
img
=
self
.
img
)
self
.
newData
=
np
.
mean
(
roiSlice
)
self
.
newData
=
roiSlice
.
sum
(
)
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
()]
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
]
new_x
,
new_y
=
new_size
/
old_size
*
x
,
new_size
/
old_size
*
y
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
):
...
...
@@ -152,9 +165,10 @@ class GuiMainWindow(QMainWindow):
)
# n = 1024
self
.
img
.
setImage
(
image
)
self
.
img
.
setImage
(
image
,
autoDownsample
=
True
)
self
.
updateRois
()
self
.
frame_index
=
self
.
frame_index
+
1
self
.
current_image_size
=
image
.
shape
[
0
]
def
frame_counter
(
self
):
self
.
counter
=
self
.
counter
+
1
...
...
@@ -176,11 +190,11 @@ class GuiMainWindow(QMainWindow):
if
__name__
==
"__main__"
:
app
=
QtGui
.
QApplication
([])
myGuiMainW
Indow
=
GuiMainWindow
()
myGuiMainW
indow
=
Camera
GuiMainWindow
()
cameraWorker
=
CameraWorker
()
cameraWorker
.
make_connections
(
myGuiMainW
I
ndow
)
myGuiMainW
I
ndow
.
make_connections
(
cameraWorker
)
cameraWorker
.
make_connections
(
myGuiMainW
i
ndow
)
myGuiMainW
i
ndow
.
make_connections
(
cameraWorker
)
cameraThread
=
QtCore
.
QThread
()
cameraWorker
.
moveToThread
(
cameraThread
)
...
...
dummyAndor.py
View file @
e3836e5b
...
...
@@ -20,9 +20,9 @@ class AndorZyla:
self
.
ExposureTime
=
AndorFeats
()
self
.
FrameRate
=
AndorFeats
()
self
.
CameraAcquiring
=
AndorFeats
()
self
.
Binning
=
AndorFeats
()
self
.
AOI
Binning
=
AndorFeats
()
self
.
ImageArea
=
AndorFeats
()
self
.
Camera
Name
=
'Dummy'
self
.
Camera
Model
=
AndorFeats
()
self
.
acq_queue
=
Queue
(
maxsize
=
10
)
self
.
helper
=
Helper_messager
()
...
...
@@ -34,13 +34,15 @@ class AndorZyla:
self
.
ExposureTime
.
setValue
(
0.5
)
self
.
FrameRate
.
setValue
(
10
)
self
.
Binning
.
setValue
(
'1x1'
)
self
.
ImageArea
.
setValue
(
50
)
self
.
AOIBinning
.
setValue
(
'1x1'
)
self
.
ImageArea
.
setValue
(
2048
)
self
.
CameraModel
.
setValue
(
'dummy'
)
def
Init
(
self
):
print
(
"Dummy camera initialized"
)
def
live_acquisition_loop
(
self
):
t
=
threading
.
currentThread
()
while
getattr
(
t
,
"do_run"
,
True
):
...
...
@@ -56,6 +58,7 @@ class AndorZyla:
def
AcquisitionStart
(
self
):
self
.
CameraAcquiring
.
setValue
(
True
)
self
.
_set_image_area
()
def
AcquisitionStop
(
self
):
self
.
CameraAcquiring
.
setValue
(
False
)
...
...
@@ -63,6 +66,11 @@ class AndorZyla:
def
_flush
(
self
):
pass
def
_set_image_area
(
self
):
d
=
{
'1x1'
:
2048
,
'2x2'
:
1024
,
'4x4'
:
512
,
'8x8'
:
256
}
self
.
ImageArea
.
setValue
(
d
[
self
.
AOIBinning
.
getValue
()])
def
_twoD_gaussian
(
self
,
lim
=
10
,
sigma
=
1
,
x0
=
0
,
y0
=
0
):
start
=
time
.
time
()
N
=
self
.
ImageArea
.
getValue
()
...
...
@@ -71,9 +79,8 @@ class AndorZyla:
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
return
noise
*
10
class
AndorFeats
:
...
...
@@ -92,3 +99,9 @@ class AndorFeats:
g
=
np
.
exp
(
-
((
d
)
**
2
/
(
2.0
*
sigma
**
2
)))
noise
=
np
.
random
.
rand
(
N
,
N
)
return
g
+
noise
def
max
(
self
):
return
0
def
setString
(
self
,
s
):
self
.
value
=
s
\ No newline at end of file
pyqtgraph_subclasses.py
0 → 100644
View file @
e3836e5b
# -*- coding: utf-8 -*-
"""
Some sub-classes from pyqtgraph.
"""
from
pyqtgraph
import
ROI
class
CustomRectangularROI
(
ROI
):
"""
Rectangular ROI subclass with a single scale handle at the top-right corner.
============== =============================================================
**Arguments**
pos (length-2 sequence) The position of the ROI origin.
See ROI().
size (length-2 sequence) The size of the ROI. See ROI().
centered (bool) If True, scale handles affect the ROI relative to its
center, rather than its origin.
sideScalers (bool) If True, extra scale handles are added at the top and
right edges.
**args All extra keyword arguments are passed to ROI()
============== =============================================================
"""
def
__init__
(
self
,
pos
,
size
=
[
8
,
8
],
centered
=
False
,
sideScalers
=
False
):
#ROI.__init__(self, pos, size, **args)
super
()
.
__init__
(
pos
,
size
,
centered
,
sideScalers
)
## handles scaling horizontally around center
self
.
addScaleHandle
([
1
,
0.5
],
[
0.5
,
0.5
])
self
.
addScaleHandle
([
0
,
0.5
],
[
0.5
,
0.5
])
## handles scaling vertically from opposite edge
self
.
addScaleHandle
([
0.5
,
0
],
[
0.5
,
1
])
self
.
addScaleHandle
([
0.5
,
1
],
[
0.5
,
0
])
## handles scaling both vertically and horizontally
self
.
addScaleHandle
([
1
,
1
],
[
0
,
0
])
self
.
addScaleHandle
([
0
,
0
],
[
1
,
1
])
#self.sigRegionChangeFinished.connect(self.correct_scaling)
def
correct_scaling
(
self
):
x
,
y
=
self
.
pos
()[
0
],
self
.
pos
()[
1
]
if
x
%
8
!=
0
or
y
%
8
!=
0
:
self
.
setPos
((
x
//
8
)
*
8
,
(
y
//
8
)
*
8
)
sx
,
sy
=
self
.
size
()[
0
],
self
.
size
()[
1
]
if
sx
%
8
!=
0
or
sy
%
8
!=
0
:
self
.
setSize
((
sx
//
8
)
*
8
,
(
sy
//
8
)
*
8
)
\ No newline at end of file
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