Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benjamin Jakimow
EO Time Series Viewer
Commits
70fde35e
Commit
70fde35e
authored
Nov 27, 2012
by
Megan Kratz
Browse files
merge from Luke
parents
dde6a2ac
aca9c831
Changes
29
Hide whitespace changes
Inline
Side-by-side
examples/GLIsosurface.py
0 → 100644
View file @
70fde35e
# -*- coding: utf-8 -*-
## This example uses the isosurface function to convert a scalar field
## (a hydrogen orbital) into a mesh for 3D display.
## Add path to library (just for examples; you do not need this)
import
sys
,
os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
))
from
pyqtgraph.Qt
import
QtCore
,
QtGui
import
pyqtgraph
as
pg
import
pyqtgraph.opengl
as
gl
app
=
QtGui
.
QApplication
([])
w
=
gl
.
GLViewWidget
()
w
.
show
()
w
.
setCameraPosition
(
distance
=
40
)
g
=
gl
.
GLGridItem
()
g
.
scale
(
2
,
2
,
1
)
w
.
addItem
(
g
)
import
numpy
as
np
## Define a scalar field from which we will generate an isosurface
def
psi
(
i
,
j
,
k
,
offset
=
(
25
,
25
,
50
)):
x
=
i
-
offset
[
0
]
y
=
j
-
offset
[
1
]
z
=
k
-
offset
[
2
]
th
=
np
.
arctan2
(
z
,
(
x
**
2
+
y
**
2
)
**
0.5
)
phi
=
np
.
arctan2
(
y
,
x
)
r
=
(
x
**
2
+
y
**
2
+
z
**
2
)
**
0.5
a0
=
1
#ps = (1./81.) * (2./np.pi)**0.5 * (1./a0)**(3/2) * (6 - r/a0) * (r/a0) * np.exp(-r/(3*a0)) * np.cos(th)
ps
=
(
1.
/
81.
)
*
1.
/
(
6.
*
np
.
pi
)
**
0.5
*
(
1.
/
a0
)
**
(
3
/
2
)
*
(
r
/
a0
)
**
2
*
np
.
exp
(
-
r
/
(
3
*
a0
))
*
(
3
*
np
.
cos
(
th
)
**
2
-
1
)
return
ps
#return ((1./81.) * (1./np.pi)**0.5 * (1./a0)**(3/2) * (r/a0)**2 * (r/a0) * np.exp(-r/(3*a0)) * np.sin(th) * np.cos(th) * np.exp(2 * 1j * phi))**2
print
(
"Generating scalar field.."
)
data
=
np
.
abs
(
np
.
fromfunction
(
psi
,
(
50
,
50
,
100
)))
print
(
"Generating isosurface.."
)
verts
=
pg
.
isosurface
(
data
,
data
.
max
()
/
4.
)
md
=
gl
.
MeshData
.
MeshData
(
vertexes
=
verts
)
colors
=
np
.
ones
((
md
.
faceCount
(),
4
),
dtype
=
float
)
colors
[:,
3
]
=
0.2
colors
[:,
2
]
=
np
.
linspace
(
0
,
1
,
colors
.
shape
[
0
])
md
.
setFaceColors
(
colors
)
m1
=
gl
.
GLMeshItem
(
meshdata
=
md
,
smooth
=
False
,
shader
=
'balloon'
)
m1
.
setGLOptions
(
'additive'
)
#w.addItem(m1)
m1
.
translate
(
-
25
,
-
25
,
-
20
)
m2
=
gl
.
GLMeshItem
(
meshdata
=
md
,
smooth
=
True
,
shader
=
'balloon'
)
m2
.
setGLOptions
(
'additive'
)
w
.
addItem
(
m2
)
m2
.
translate
(
-
25
,
-
25
,
-
50
)
## Start Qt event loop unless running in interactive mode.
if
sys
.
flags
.
interactive
!=
1
:
app
.
exec_
()
examples/GLMeshItem.py
View file @
70fde35e
# -*- coding: utf-8 -*-
"""
Simple examples demonstrating the use of GLMeshItem.
## This example uses the isosurface function to convert a scalar field
## (a hydrogen orbital) into a mesh for 3D display.
"""
## Add path to library (just for examples; you do not need this)
import
sys
,
os
...
...
@@ -15,52 +16,117 @@ app = QtGui.QApplication([])
w
=
gl
.
GLViewWidget
()
w
.
show
()
w
.
setCameraPosition
(
distance
=
40
)
g
=
gl
.
GLGridItem
()
g
.
scale
(
2
,
2
,
1
)
w
.
addItem
(
g
)
import
numpy
as
np
def
psi
(
i
,
j
,
k
,
offset
=
(
25
,
25
,
50
)):
x
=
i
-
offset
[
0
]
y
=
j
-
offset
[
1
]
z
=
k
-
offset
[
2
]
th
=
np
.
arctan2
(
z
,
(
x
**
2
+
y
**
2
)
**
0.5
)
phi
=
np
.
arctan2
(
y
,
x
)
r
=
(
x
**
2
+
y
**
2
+
z
**
2
)
**
0.5
a0
=
1
#ps = (1./81.) * (2./np.pi)**0.5 * (1./a0)**(3/2) * (6 - r/a0) * (r/a0) * np.exp(-r/(3*a0)) * np.cos(th)
ps
=
(
1.
/
81.
)
*
1.
/
(
6.
*
np
.
pi
)
**
0.5
*
(
1.
/
a0
)
**
(
3
/
2
)
*
(
r
/
a0
)
**
2
*
np
.
exp
(
-
r
/
(
3
*
a0
))
*
(
3
*
np
.
cos
(
th
)
**
2
-
1
)
## Example 1:
## Array of vertex positions and array of vertex indexes defining faces
## Colors are specified per-face
verts
=
np
.
array
([
[
0
,
0
,
0
],
[
2
,
0
,
0
],
[
1
,
2
,
0
],
[
1
,
1
,
1
],
])
faces
=
np
.
array
([
[
0
,
1
,
2
],
[
0
,
1
,
3
],
[
0
,
2
,
3
],
[
1
,
2
,
3
]
])
colors
=
np
.
array
([
[
1
,
0
,
0
,
0.3
],
[
0
,
1
,
0
,
0.3
],
[
0
,
0
,
1
,
0.3
],
[
1
,
1
,
0
,
0.3
]
])
## Mesh item will automatically compute face normals.
m1
=
gl
.
GLMeshItem
(
vertexes
=
verts
,
faces
=
faces
,
faceColors
=
colors
,
smooth
=
False
)
m1
.
translate
(
5
,
5
,
0
)
m1
.
setGLOptions
(
'additive'
)
w
.
addItem
(
m1
)
## Example 2:
## Array of vertex positions, three per face
## Colors are specified per-vertex
verts
=
verts
[
faces
]
## Same mesh geometry as example 2, but now we are passing in 12 vertexes
colors
=
np
.
random
.
random
(
size
=
(
verts
.
shape
[
0
],
3
,
4
))
#colors[...,3] = 1.0
m2
=
gl
.
GLMeshItem
(
vertexes
=
verts
,
vertexColors
=
colors
,
smooth
=
False
,
shader
=
'balloon'
)
m2
.
translate
(
-
5
,
5
,
0
)
w
.
addItem
(
m2
)
## Example 3:
## icosahedron
md
=
gl
.
MeshData
.
sphere
(
rows
=
10
,
cols
=
20
)
#colors = np.random.random(size=(md.faceCount(), 4))
#colors[:,3] = 0.3
#colors[100:] = 0.0
colors
=
np
.
ones
((
md
.
faceCount
(),
4
),
dtype
=
float
)
colors
[::
2
,
0
]
=
0
colors
[:,
1
]
=
np
.
linspace
(
0
,
1
,
colors
.
shape
[
0
])
md
.
setFaceColors
(
colors
)
m3
=
gl
.
GLMeshItem
(
meshdata
=
md
,
smooth
=
False
)
#, shader='balloon')
#m3.translate(-5, -5, 0)
w
.
addItem
(
m3
)
#def psi(i, j, k, offset=(25, 25, 50)):
#x = i-offset[0]
#y = j-offset[1]
#z = k-offset[2]
#th = np.arctan2(z, (x**2+y**2)**0.5)
#phi = np.arctan2(y, x)
#r = (x**2 + y**2 + z **2)**0.5
#a0 = 1
##ps = (1./81.) * (2./np.pi)**0.5 * (1./a0)**(3/2) * (6 - r/a0) * (r/a0) * np.exp(-r/(3*a0)) * np.cos(th)
#ps = (1./81.) * 1./(6.*np.pi)**0.5 * (1./a0)**(3/2) * (r/a0)**2 * np.exp(-r/(3*a0)) * (3 * np.cos(th)**2 - 1)
return
ps
#
return ps
#return ((1./81.) * (1./np.pi)**0.5 * (1./a0)**(3/2) * (r/a0)**2 * (r/a0) * np.exp(-r/(3*a0)) * np.sin(th) * np.cos(th) * np.exp(2 * 1j * phi))**2
#
#return ((1./81.) * (1./np.pi)**0.5 * (1./a0)**(3/2) * (r/a0)**2 * (r/a0) * np.exp(-r/(3*a0)) * np.sin(th) * np.cos(th) * np.exp(2 * 1j * phi))**2
print
(
"Generating scalar field.."
)
data
=
np
.
abs
(
np
.
fromfunction
(
psi
,
(
50
,
50
,
100
)))
#
print("Generating scalar field..")
#
data = np.abs(np.fromfunction(psi, (50,50,100)))
#data = np.fromfunction(lambda i,j,k: np.sin(0.2*((i-25)**2+(j-15)**2+k**2)**0.5), (50,50,50));
print
(
"Generating isosurface.."
)
faces
=
pg
.
isosurface
(
data
,
data
.
max
()
/
4.
)
m
=
gl
.
GLMeshItem
(
faces
)
w
.
addItem
(
m
)
m
.
translate
(
-
25
,
-
25
,
-
50
)
##data = np.fromfunction(lambda i,j,k: np.sin(0.2*((i-25)**2+(j-15)**2+k**2)**0.5), (50,50,50));
#print("Generating isosurface..")
#verts = pg.isosurface(data, data.max()/4.)
#md = gl.MeshData.MeshData(vertexes=verts)
#colors = np.ones((md.vertexes(indexed='faces').shape[0], 4), dtype=float)
#colors[:,3] = 0.3
#colors[:,2] = np.linspace(0, 1, colors.shape[0])
#m1 = gl.GLMeshItem(meshdata=md, color=colors, smooth=False)
#w.addItem(m1)
#m1.translate(-25, -25, -20)
#m2 = gl.GLMeshItem(vertexes=verts, color=colors, smooth=True)
#w.addItem(m2)
#m2.translate(-25, -25, -50)
#data = np.zeros((5,5,5))
#data[2,2,1:4] = 1
#data[2,1:4,2] = 1
#data[1:4,2,2] = 1
#tr.translate(-2.5, -2.5, 0)
#data = np.ones((2,2,2))
#data[0, 1, 0] = 0
#faces = pg.isosurface(data, 0.5)
#m = gl.GLMeshItem(faces)
#w.addItem(m)
#m.setTransform(tr)
## Start Qt event loop unless running in interactive mode.
if
sys
.
flags
.
interactive
!=
1
:
...
...
examples/GLSurfacePlot.py
0 → 100644
View file @
70fde35e
# -*- coding: utf-8 -*-
"""
This example demonstrates the use of GLSurfacePlotItem.
"""
## Add path to library (just for examples; you do not need this)
import
sys
,
os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
))
from
pyqtgraph.Qt
import
QtCore
,
QtGui
import
pyqtgraph
as
pg
import
pyqtgraph.opengl
as
gl
import
scipy.ndimage
as
ndi
import
numpy
as
np
## Create a GL View widget to display data
app
=
QtGui
.
QApplication
([])
w
=
gl
.
GLViewWidget
()
w
.
show
()
w
.
setCameraPosition
(
distance
=
50
)
## Add a grid to the view
g
=
gl
.
GLGridItem
()
g
.
scale
(
2
,
2
,
1
)
g
.
setDepthValue
(
10
)
# draw grid after surfaces since they may be translucent
w
.
addItem
(
g
)
## Simple surface plot example
## x, y values are not specified, so assumed to be 0:50
z
=
ndi
.
gaussian_filter
(
np
.
random
.
normal
(
size
=
(
50
,
50
)),
(
1
,
1
))
p1
=
gl
.
GLSurfacePlotItem
(
z
=
z
,
shader
=
'shaded'
,
color
=
(
0.5
,
0.5
,
1
,
1
))
p1
.
scale
(
16.
/
49.
,
16.
/
49.
,
1.0
)
p1
.
translate
(
-
18
,
2
,
0
)
w
.
addItem
(
p1
)
## Saddle example with x and y specified
x
=
np
.
linspace
(
-
8
,
8
,
50
)
y
=
np
.
linspace
(
-
8
,
8
,
50
)
z
=
0.1
*
((
x
.
reshape
(
50
,
1
)
**
2
)
-
(
y
.
reshape
(
1
,
50
)
**
2
))
p2
=
gl
.
GLSurfacePlotItem
(
x
=
x
,
y
=
y
,
z
=
z
,
shader
=
'normalColor'
)
p2
.
translate
(
-
10
,
-
10
,
0
)
w
.
addItem
(
p2
)
## Manually specified colors
z
=
ndi
.
gaussian_filter
(
np
.
random
.
normal
(
size
=
(
50
,
50
)),
(
1
,
1
))
x
=
np
.
linspace
(
-
12
,
12
,
50
)
y
=
np
.
linspace
(
-
12
,
12
,
50
)
colors
=
np
.
ones
((
50
,
50
,
4
),
dtype
=
float
)
colors
[...,
0
]
=
np
.
clip
(
np
.
cos
(((
x
.
reshape
(
50
,
1
)
**
2
)
+
(
y
.
reshape
(
1
,
50
)
**
2
))
**
0.5
),
0
,
1
)
colors
[...,
1
]
=
colors
[...,
0
]
p3
=
gl
.
GLSurfacePlotItem
(
z
=
z
,
colors
=
colors
.
reshape
(
50
*
50
,
4
),
shader
=
'shaded'
,
smooth
=
False
)
p3
.
scale
(
16.
/
49.
,
16.
/
49.
,
1.0
)
p3
.
translate
(
2
,
-
18
,
0
)
w
.
addItem
(
p3
)
## Animated example
## compute surface vertex data
cols
=
100
rows
=
100
x
=
np
.
linspace
(
-
8
,
8
,
cols
+
1
).
reshape
(
cols
+
1
,
1
)
y
=
np
.
linspace
(
-
8
,
8
,
rows
+
1
).
reshape
(
1
,
rows
+
1
)
d
=
(
x
**
2
+
y
**
2
)
*
0.1
d2
=
d
**
0.5
+
0.1
## precompute height values for all frames
phi
=
np
.
arange
(
0
,
np
.
pi
*
2
,
np
.
pi
/
20.
)
z
=
np
.
sin
(
d
[
np
.
newaxis
,...]
+
phi
.
reshape
(
phi
.
shape
[
0
],
1
,
1
))
/
d2
[
np
.
newaxis
,...]
## create a surface plot, tell it to use the 'heightColor' shader
## since this does not require normal vectors to render (thus we
## can set computeNormals=False to save time when the mesh updates)
p4
=
gl
.
GLSurfacePlotItem
(
x
=
x
[:,
0
],
y
=
y
[
0
,:],
shader
=
'heightColor'
,
computeNormals
=
False
,
smooth
=
False
)
p4
.
shader
()[
'colorMap'
]
=
np
.
array
([
0.2
,
2
,
0.5
,
0.2
,
1
,
1
,
0.2
,
0
,
2
])
p4
.
translate
(
10
,
10
,
0
)
w
.
addItem
(
p4
)
index
=
0
def
update
():
global
p4
,
z
,
index
index
-=
1
p4
.
setData
(
z
=
z
[
index
%
z
.
shape
[
0
]])
timer
=
QtCore
.
QTimer
()
timer
.
timeout
.
connect
(
update
)
timer
.
start
(
30
)
## Start Qt event loop unless running in interactive mode.
if
sys
.
flags
.
interactive
!=
1
:
app
.
exec_
()
examples/GLshaders.py
0 → 100644
View file @
70fde35e
# -*- coding: utf-8 -*-
"""
Demonstration of some of the shader programs included with pyqtgraph.
"""
## Add path to library (just for examples; you do not need this)
import
sys
,
os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
))
from
pyqtgraph.Qt
import
QtCore
,
QtGui
import
pyqtgraph
as
pg
import
pyqtgraph.opengl
as
gl
app
=
QtGui
.
QApplication
([])
w
=
gl
.
GLViewWidget
()
w
.
show
()
w
.
setCameraPosition
(
distance
=
15
,
azimuth
=-
90
)
g
=
gl
.
GLGridItem
()
g
.
scale
(
2
,
2
,
1
)
w
.
addItem
(
g
)
import
numpy
as
np
md
=
gl
.
MeshData
.
sphere
(
rows
=
10
,
cols
=
20
)
x
=
np
.
linspace
(
-
8
,
8
,
6
)
m1
=
gl
.
GLMeshItem
(
meshdata
=
md
,
smooth
=
True
,
color
=
(
1
,
0
,
0
,
0.2
),
shader
=
'balloon'
,
glOptions
=
'additive'
)
m1
.
translate
(
x
[
0
],
0
,
0
)
m1
.
scale
(
1
,
1
,
2
)
w
.
addItem
(
m1
)
m2
=
gl
.
GLMeshItem
(
meshdata
=
md
,
smooth
=
True
,
shader
=
'normalColor'
,
glOptions
=
'opaque'
)
m2
.
translate
(
x
[
1
],
0
,
0
)
m2
.
scale
(
1
,
1
,
2
)
w
.
addItem
(
m2
)
m3
=
gl
.
GLMeshItem
(
meshdata
=
md
,
smooth
=
True
,
shader
=
'viewNormalColor'
,
glOptions
=
'opaque'
)
m3
.
translate
(
x
[
2
],
0
,
0
)
m3
.
scale
(
1
,
1
,
2
)
w
.
addItem
(
m3
)
m4
=
gl
.
GLMeshItem
(
meshdata
=
md
,
smooth
=
True
,
shader
=
'shaded'
,
glOptions
=
'opaque'
)
m4
.
translate
(
x
[
3
],
0
,
0
)
m4
.
scale
(
1
,
1
,
2
)
w
.
addItem
(
m4
)
m5
=
gl
.
GLMeshItem
(
meshdata
=
md
,
smooth
=
True
,
color
=
(
1
,
0
,
0
,
1
),
shader
=
'edgeHilight'
,
glOptions
=
'opaque'
)
m5
.
translate
(
x
[
4
],
0
,
0
)
m5
.
scale
(
1
,
1
,
2
)
w
.
addItem
(
m5
)
m6
=
gl
.
GLMeshItem
(
meshdata
=
md
,
smooth
=
True
,
color
=
(
1
,
0
,
0
,
1
),
shader
=
'heightColor'
,
glOptions
=
'opaque'
)
m6
.
translate
(
x
[
5
],
0
,
0
)
m6
.
scale
(
1
,
1
,
2
)
w
.
addItem
(
m6
)
#def psi(i, j, k, offset=(25, 25, 50)):
#x = i-offset[0]
#y = j-offset[1]
#z = k-offset[2]
#th = np.arctan2(z, (x**2+y**2)**0.5)
#phi = np.arctan2(y, x)
#r = (x**2 + y**2 + z **2)**0.5
#a0 = 1
##ps = (1./81.) * (2./np.pi)**0.5 * (1./a0)**(3/2) * (6 - r/a0) * (r/a0) * np.exp(-r/(3*a0)) * np.cos(th)
#ps = (1./81.) * 1./(6.*np.pi)**0.5 * (1./a0)**(3/2) * (r/a0)**2 * np.exp(-r/(3*a0)) * (3 * np.cos(th)**2 - 1)
#return ps
##return ((1./81.) * (1./np.pi)**0.5 * (1./a0)**(3/2) * (r/a0)**2 * (r/a0) * np.exp(-r/(3*a0)) * np.sin(th) * np.cos(th) * np.exp(2 * 1j * phi))**2
#print("Generating scalar field..")
#data = np.abs(np.fromfunction(psi, (50,50,100)))
##data = np.fromfunction(lambda i,j,k: np.sin(0.2*((i-25)**2+(j-15)**2+k**2)**0.5), (50,50,50));
#print("Generating isosurface..")
#verts = pg.isosurface(data, data.max()/4.)
#md = gl.MeshData.MeshData(vertexes=verts)
#colors = np.ones((md.vertexes(indexed='faces').shape[0], 4), dtype=float)
#colors[:,3] = 0.3
#colors[:,2] = np.linspace(0, 1, colors.shape[0])
#m1 = gl.GLMeshItem(meshdata=md, color=colors, smooth=False)
#w.addItem(m1)
#m1.translate(-25, -25, -20)
#m2 = gl.GLMeshItem(vertexes=verts, color=colors, smooth=True)
#w.addItem(m2)
#m2.translate(-25, -25, -50)
## Start Qt event loop unless running in interactive mode.
if
sys
.
flags
.
interactive
!=
1
:
app
.
exec_
()
examples/Legend.py
View file @
70fde35e
...
...
@@ -6,13 +6,14 @@ from pyqtgraph.Qt import QtCore, QtGui
plt
=
pg
.
plot
()
l
=
pg
.
LegendItem
((
100
,
60
),
(
60
,
10
))
# args are (size, position)
l
.
setParentItem
(
plt
.
graphicsItem
())
# Note we do NOT call plt.addItem in this case
plt
.
addLegend
()
#l = pg.LegendItem((100,60), offset=(70,30)) # args are (size, offset)
#l.setParentItem(plt.graphicsItem()) # Note we do NOT call plt.addItem in this case
c1
=
plt
.
plot
([
1
,
3
,
2
,
4
],
pen
=
'r'
)
c2
=
plt
.
plot
([
2
,
1
,
4
,
3
],
pen
=
'g'
)
l
.
addItem
(
c1
,
'red plot'
)
l
.
addItem
(
c2
,
'green plot'
)
c1
=
plt
.
plot
([
1
,
3
,
2
,
4
],
pen
=
'r'
,
name
=
'red plot'
)
c2
=
plt
.
plot
([
2
,
1
,
4
,
3
],
pen
=
'g'
,
fillLevel
=
0
,
fillBrush
=
(
255
,
255
,
255
,
30
),
name
=
'green plot'
)
#
l.addItem(c1, 'red plot')
#
l.addItem(c2, 'green plot')
## Start Qt event loop unless running in interactive mode or using pyside.
...
...
examples/VideoSpeedTest.py
View file @
70fde35e
...
...
@@ -61,37 +61,41 @@ ui.alphaCheck.toggled.connect(updateLUT)
def
updateScale
():
global
ui
spins
=
[
ui
.
minSpin1
,
ui
.
maxSpin1
,
ui
.
minSpin2
,
ui
.
maxSpin2
,
ui
.
minSpin3
,
ui
.
maxSpin3
]
if
ui
.
rgbCheck
.
isChecked
():
if
ui
.
rgb
Levels
Check
.
isChecked
():
for
s
in
spins
[
2
:]:
s
.
setEnabled
(
True
)
else
:
for
s
in
spins
[
2
:]:
s
.
setEnabled
(
False
)
ui
.
rgbCheck
.
toggled
.
connect
(
updateScale
)
ui
.
rgb
Levels
Check
.
toggled
.
connect
(
updateScale
)
cache
=
{}
def
mkData
():
global
data
,
cache
,
ui
dtype
=
ui
.
dtypeCombo
.
currentText
()
dtype
=
(
ui
.
dtypeCombo
.
currentText
()
,
ui
.
rgbCheck
.
isChecked
())
if
dtype
not
in
cache
:
if
dtype
==
'uint8'
:
if
dtype
[
0
]
==
'uint8'
:
dt
=
np
.
uint8
loc
=
128
scale
=
64
mx
=
255
elif
dtype
==
'uint16'
:
elif
dtype
[
0
]
==
'uint16'
:
dt
=
np
.
uint16
loc
=
4096
scale
=
1024
mx
=
2
**
16
elif
dtype
==
'float'
:
elif
dtype
[
0
]
==
'float'
:
dt
=
np
.
float
loc
=
1.0
scale
=
0.1
data
=
np
.
random
.
normal
(
size
=
(
20
,
512
,
512
),
loc
=
loc
,
scale
=
scale
)
data
=
ndi
.
gaussian_filter
(
data
,
(
0
,
3
,
3
))
if
dtype
!=
'float'
:
if
ui
.
rgbCheck
.
isChecked
():
data
=
np
.
random
.
normal
(
size
=
(
20
,
512
,
512
,
3
),
loc
=
loc
,
scale
=
scale
)
data
=
ndi
.
gaussian_filter
(
data
,
(
0
,
6
,
6
,
0
))
else
:
data
=
np
.
random
.
normal
(
size
=
(
20
,
512
,
512
),
loc
=
loc
,
scale
=
scale
)
data
=
ndi
.
gaussian_filter
(
data
,
(
0
,
6
,
6
))
if
dtype
[
0
]
!=
'float'
:
data
=
np
.
clip
(
data
,
0
,
mx
)
data
=
data
.
astype
(
dt
)
cache
[
dtype
]
=
data
...
...
@@ -100,7 +104,7 @@ def mkData():
updateLUT
()
mkData
()
ui
.
dtypeCombo
.
currentIndexChanged
.
connect
(
mkData
)
ui
.
rgbCheck
.
toggled
.
connect
(
mkData
)
ptr
=
0
lastTime
=
ptime
.
time
()
...
...
@@ -113,7 +117,7 @@ def update():
useLut
=
None
if
ui
.
scaleCheck
.
isChecked
():
if
ui
.
rgbCheck
.
isChecked
():
if
ui
.
rgb
Levels
Check
.
isChecked
():
useScale
=
[
[
ui
.
minSpin1
.
value
(),
ui
.
maxSpin1
.
value
()],
[
ui
.
minSpin2
.
value
(),
ui
.
maxSpin2
.
value
()],
...
...
examples/VideoTemplate.ui
View file @
70fde35e
...
...
@@ -25,7 +25,6 @@
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<zorder>
fpsLabel
</zorder>
</widget>
</item>
<item
row=
"0"
column=
"1"
>
...
...
@@ -84,7 +83,7 @@
</widget>
</item>
<item
row=
"3"
column=
"1"
>
<widget
class=
"QCheckBox"
name=
"rgbCheck"
>
<widget
class=
"QCheckBox"
name=
"rgb
Levels
Check"
>
<property
name=
"text"
>
<string>
RGB
</string>
</property>
...
...
@@ -218,6 +217,13 @@
</property>
</widget>
</item>
<item
row=
"2"
column=
"1"
>
<widget
class=
"QCheckBox"
name=
"rgbCheck"
>
<property
name=
"text"
>
<string>
RGB
</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
...
...
examples/VideoTemplate_pyqt.py
View file @
70fde35e
...
...
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file './examples/VideoTemplate.ui'
#
# Created: Sun
Sep
9
1
4:41:31
2012
# Created: Sun
Nov
4
1
8:24:20
2012
# by: PyQt4 UI code generator 4.9.1
#
# WARNING! All changes made in this file will be lost!
...
...
@@ -55,9 +55,9 @@ class Ui_MainWindow(object):
self
.
scaleCheck
=
QtGui
.
QCheckBox
(
self
.
centralwidget
)
self
.
scaleCheck
.
setObjectName
(
_fromUtf8
(
"scaleCheck"
))
self
.
gridLayout_2
.
addWidget
(
self
.
scaleCheck
,
3
,
0
,
1
,
1
)
self
.
rgbCheck
=
QtGui
.
QCheckBox
(
self
.
centralwidget
)
self
.
rgbCheck
.
setObjectName
(
_fromUtf8
(
"rgbCheck"
))
self
.
gridLayout_2
.
addWidget
(
self
.
rgbCheck
,
3
,
1
,
1
,
1
)
self
.
rgb
Levels
Check
=
QtGui
.
QCheckBox
(
self
.
centralwidget
)
self
.
rgb
Levels
Check
.
setObjectName
(
_fromUtf8
(
"rgb
Levels
Check"
))
self
.
gridLayout_2
.
addWidget
(
self
.
rgb
Levels
Check
,
3
,
1
,
1
,
1
)
self
.
horizontalLayout
=
QtGui
.
QHBoxLayout
()
self
.
horizontalLayout
.
setObjectName
(
_fromUtf8
(
"horizontalLayout"
))
self
.
minSpin1
=
SpinBox
(
self
.
centralwidget
)
...
...
@@ -124,6 +124,9 @@ class Ui_MainWindow(object):
self
.
fpsLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
fpsLabel
.
setObjectName
(
_fromUtf8
(
"fpsLabel"
))
self
.
gridLayout_2
.
addWidget
(
self
.
fpsLabel
,
0
,
0
,
1
,
4
)
self
.
rgbCheck
=
QtGui
.
QCheckBox
(
self
.
centralwidget
)
self
.
rgbCheck
.
setObjectName
(
_fromUtf8
(
"rgbCheck"
))
self
.
gridLayout_2
.
addWidget
(
self
.
rgbCheck
,
2
,
1
,
1
,
1
)
MainWindow
.
setCentralWidget
(
self
.
centralwidget
)
self
.
retranslateUi
(
MainWindow
)
...
...
@@ -138,12 +141,13 @@ class Ui_MainWindow(object):
self
.
dtypeCombo
.
setItemText
(
1
,
QtGui
.
QApplication
.
translate
(
"MainWindow"
,
"uint16"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
dtypeCombo
.
setItemText
(
2
,
QtGui
.
QApplication
.
translate
(
"MainWindow"
,
"float"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
scaleCheck
.
setText
(
QtGui
.
QApplication
.
translate
(
"MainWindow"
,
"Scale Data"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
rgbCheck
.
setText
(
QtGui
.
QApplication
.
translate
(
"MainWindow"
,
"RGB"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
rgb
Levels
Check
.
setText
(
QtGui
.
QApplication
.
translate
(
"MainWindow"
,
"RGB"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
label_2
.
setText
(
QtGui
.
QApplication
.
translate
(
"MainWindow"
,
"<--->"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
label_3
.
setText
(
QtGui
.
QApplication
.
translate
(
"MainWindow"
,
"<--->"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))