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
748a0837
Commit
748a0837
authored
Aug 17, 2018
by
Martin Drechsler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Two buttons added nicely: erase and autoscale.
parent
23265307
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
10 deletions
+26
-10
webcamROI.py
webcamROI.py
+26
-10
No files found.
webcamROI.py
View file @
748a0837
...
...
@@ -14,7 +14,7 @@ from PyQt5.QtCore import QTimer
#from myWidgets import anal_control_signal
import
sys
from
PyQt5.QtWidgets
import
QMainWindow
,
QApplication
,
QMessageBox
,
QPushButton
,
QGraphicsProxyWidget
#from myWidgets import anal_control_signal
...
...
@@ -27,7 +27,7 @@ class roiWindow(QMainWindow):
print
(
self
.
aoScan
.
name
,
self
.
aoScan
.
sb
.
val
)
self
.
cap
=
cv2
.
VideoCapture
(
1
)
self
.
cap
=
cv2
.
VideoCapture
(
0
)
self
.
n
=
int
(
1e2
)
self
.
data
=
np
.
zeros
(
self
.
n
)
...
...
@@ -60,14 +60,14 @@ class roiWindow(QMainWindow):
self
.
v2
.
addItem
(
self
.
im2
)
#plot real time
self
.
p
=
self
.
w
.
addPlot
(
row
=
3
,
col
=
0
,
title
=
"
Updating
plot"
)
self
.
p
=
self
.
w
.
addPlot
(
row
=
3
,
col
=
0
,
title
=
"
Time
plot"
)
self
.
p
.
setRange
(
QtCore
.
QRectF
(
0
,
-
10
,
5000
,
20
))
self
.
p
.
setAutoPan
(
y
=
True
)
self
.
p
.
setRange
(
xRange
=
(
0
,
self
.
n
),
yRange
=
(
0
,
255
))
self
.
curve
=
self
.
p
.
plot
(
pen
=
'y'
)
self
.
pv
=
self
.
w
.
addPlot
(
row
=
4
,
col
=
0
,
title
=
"
Updating
plot"
)
self
.
pv
=
self
.
w
.
addPlot
(
row
=
4
,
col
=
0
,
title
=
"
Voltage
plot"
)
self
.
pv
.
setRange
(
QtCore
.
QRectF
(
0
,
-
10
,
5000
,
20
))
self
.
pv
.
setAutoPan
(
y
=
True
)
self
.
curveVoltage
=
self
.
pv
.
plot
(
pen
=
'y'
)
...
...
@@ -75,12 +75,21 @@ class roiWindow(QMainWindow):
self
.
voltageDataY
=
[]
self
.
aoScan
.
ScanTimer
.
timeout
.
connect
(
self
.
updateVoltagePlotvsI
)
self
.
eraseButton
=
QPushButton
(
'Erase'
)
self
.
optionsLayout
=
pg
.
LayoutWidget
()
self
.
eraseButton
=
QPushButton
(
'Erase plot'
)
self
.
eraseButton
.
clicked
.
connect
(
self
.
erasePlot
)
self
.
autoScaleButton
=
QPushButton
(
'Autoscale'
)
self
.
autoScaleButton
.
clicked
.
connect
(
self
.
autoScalePlot
)
self
.
optionsLayout
.
addWidget
(
self
.
eraseButton
,
0
,
0
)
self
.
optionsLayout
.
addWidget
(
self
.
autoScaleButton
,
0
,
1
)
self
.
optionsLayout
.
setGeometry
(
10
,
10
,
300
,
200
)
proxy
=
QGraphicsProxyWidget
()
proxy
.
setWidget
(
self
.
eraseButton
)
self
.
pv
.
addItem
(
proxy
,
row
=
1
,
col
=
1
)
proxy
.
setWidget
(
self
.
optionsLayout
)
self
.
w
.
addItem
(
proxy
,
row
=
5
,
col
=
0
)
self
.
lastRoi
=
None
...
...
@@ -101,12 +110,19 @@ class roiWindow(QMainWindow):
self
.
voltageDataY
=
np
.
append
(
self
.
voltageDataY
,
self
.
newData
)
#○print(' Roi: ', self.voltageDataX[-1], self.voltageDataY[-1])
self
.
pv
.
setRange
(
xRange
=
(
float
(
self
.
aoScan
.
scan_sb_start
.
val
),
float
(
self
.
aoScan
.
scan_sb_stop
.
val
)),
yRange
=
(
0
,
255
))
self
.
curveVoltage
.
setData
(
self
.
voltageDataX
,
self
.
voltageDataY
)
def
erasePlot
(
self
):
self
.
voltageDataX
=
[]
self
.
voltageDataY
=
[]
def
autoScalePlot
(
self
):
x_min
=
float
(
self
.
aoScan
.
scan_sb_start
.
val
)
x_max
=
float
(
self
.
aoScan
.
scan_sb_stop
.
val
)
y_min
=
0
y_max
=
self
.
newData
self
.
pv
.
setRange
(
xRange
=
(
x_min
,
x_max
),
yRange
=
(
y_min
,
y_max
))
def
myCloseEvent
(
self
,
event
):
# this overrides the closeEvent method
...
...
@@ -127,8 +143,8 @@ class roiWindow(QMainWindow):
def
capture
(
self
):
ret
,
frame
=
self
.
cap
.
read
()
#frame = cv2.resize(frame, None, fx = 0.5, fy = 0.5, interpolation = cv2.INTER_CUBIC)
gray_image
=
cv2
.
cvtColor
(
frame
,
cv2
.
COLOR_BGR2GRAY
)
return
gray_image
return
frame
[:,
:,
0
]
def
updateImage
(
self
):
self
.
im1
.
setImage
(
self
.
capture
(),
cmap
=
'Gray'
)
...
...
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