本文整理汇总了Python中pyqtgraph.flowchart.library.registerNodeType函数的典型用法代码示例。如果您正苦于以下问题:Python registerNodeType函数的具体用法?Python registerNodeType怎么用?Python registerNodeType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了registerNodeType函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addColorTransform
def addColorTransform(f,name):
node = numpyInNumpyOutNode(
nodeName=name,
uiTemplate=[],
f=f,
)
fclib.registerNodeType(node,[('Image-ColorSpace',)])
示例2: __init__
def __init__(self, parent=None):
super(Demo, self).__init__()
self.setWindowTitle("Plotting the Wiimote")
self.showFullScreen()
self.layout = QtGui.QGridLayout()
self.setLayout(self.layout)
self.flowchart = Flowchart(terminals={
'xDataIn': {'io': 'in'},
'yDataIn': {'io': 'in'},
'zDataIn': {'io': 'in'},
'xDataOut': {'io': 'out'},
'yDataOut': {'io': 'out'},
'zDataOut': {'io': 'out'}
})
self.layout.addWidget(self.flowchart.widget(), 0, 0, 3, 1)
fclib.registerNodeType(WiimoteNode, [('Display',)])
self.wii_node = self.flowchart.createNode('Wiimote', pos=(0, 0))
self.axes = ['x', 'y', 'z']
# positions for all nodes; order:
# raw_node xpos, raw_node ypos, filtered_node xpos, filtered_node ypos,
# filter_node xpos, filter_node ypos
self.positions = {
'x': [-450, -350, -300, -350, -375, -150],
'y': [-150, -350, 0, -350, -75, -150],
'z': [150, -350, 300, -350, 225, -150],
}
# create, style, config and connect the elements for every axis
for axis in self.axes:
index = self.axes.index(axis)
plot_raw = pyqtgraph.PlotWidget()
plot_filtered = pyqtgraph.PlotWidget()
# add widget for this axis in next row
self.layout.addWidget(plot_filtered, index, 2, 1, 2)
self.configPlotItems(axis, plot_raw, plot_filtered)
self.createNodes(axis, plot_raw, plot_filtered)
self.connectNodes(axis)
pyqtgraph.setConfigOptions(antialias=True)
self.flowchart.setInput(xDataIn=0)
self.flowchart.setInput(yDataIn=0)
self.flowchart.setInput(zDataIn=0)
示例3: execute
def execute(self, *args,**kwargs):
inputList = []
# iterate over all terminals in ordere they where added
for termName in self.terminals.keys():
term = self.terminals[termName]
if termName in self._inputs:
inputData = kwargs[termName]
if inputData is not None:
inputList.append(inputData)
return {'dataOut':inputList}
fclib.registerNodeType(MakeList, [('Container',)])
class MakeTuple(MyNode):
""" make a tuple from input(s) """
nodeName = "MakeTuple"
uiTemplate=[
]
def __init__(self, name):
terminals = OrderedDict()
terminals['Input']=dict(io='in')
terminals['dataOut']=dict(io='out')
MyNode.__init__(self, name, terminals=terminals,nodeSize=(100,150),allowAddInput=True)
示例4: dict
'z_rotation_out': dict(io='out')
}
CtrlNode.__init__(self, node_name, terminals=terminals)
def process(self, **kwds):
out = [kwds['x_axis_in'] - 512, kwds['z_axis_in'] - 512]
return {
'x_rotation_out': np.array([0, out[0]]),
'z_rotation_out': np.array([0, out[1]])
}
fclib.registerNodeType(CustomNormalVectorNode, [('NVN',)])
def input_from_cmd():
"""
checks if cmd args are exactly 2 in number
:return: void
"""
if len(sys.argv) != 2:
raise Exception("Insufficient number of CMD Args! Mac Address Required")
def add_plot_widget_to_layout(layout, offset, columns):
"""
示例5: Flowchart
fc = Flowchart(terminals={
#'sigOut': {'io': 'in'},
#'sigOut2': {'io': 'in'}#,
#'sigIn': {'io': 'out'} #We don't currently need any outputs from FC
}, name='Connections')
# Remove the unnecessary input and output nodes
fc.removeNode(fc.inputNode)
fc.removeNode(fc.outputNode)
flowchart = fc.widget()
d3.addWidget(flowchart)
flowchart_dock.addWidget(fc.widget().chartWidget)
#Register own node types
fclib.registerNodeType(OscilloscopeNode, [('SciEdu',)])
fclib.registerNodeType(FilterNode, [('SciEdu',)])
fclib.registerNodeType(CharToBinaryNode, [('SciEdu',)])
# fclib.registerNodeType(BinaryToCharNode, [('SciEdu',)]) # TODO
fclib.registerNodeType(ParityNode, [('SciEdu',)])
fclib.registerNodeType(CheckParityNode, [('SciEdu',)])
fclib.registerNodeType(FFTNode, [('SciEdu',)])
fclib.registerNodeType(SigGenNode, [('SciEdu',)])
fclib.registerNodeType(AmplifierNode, [('SciEdu',)])
fclib.registerNodeType(LineEncoderNode, [('SciEdu',)])
fclib.registerNodeType(RectifierNode, [('SciEdu',)])
fclib.registerNodeType(DCBlockNode, [('SciEdu',)])
fclib.registerNodeType(DigiAdderNode, [('SciEdu',)])
fclib.registerNodeType(NoiseNode, [('SciEdu',)])
# Test thread generation (Not in use now)
示例6: process
self.view = view
def process(self, data, display=True):
## if process is called with display=False, then the flowchart is being operated
## in batch processing mode, so we should skip displaying to improve performance.
if display and self.view is not None:
## the 'data' argument is the value given to the 'data' terminal
if data is None:
self.view.setImage(np.zeros((1,1))) # give a blank array to clear the view
else:
self.view.setImage(data)
## register the class so it will appear in the menu of node types.
## It will appear in the 'display' sub-menu.
fclib.registerNodeType(ImageViewNode, [('Display',)])
## We will define an unsharp masking filter node as a subclass of CtrlNode.
## CtrlNode is just a convenience class that automatically creates its
## control widget based on a simple data structure.
class UnsharpMaskNode(CtrlNode):
"""Return the input data passed through scipy.ndimage.gaussian_filter."""
nodeName = "UnsharpMask"
uiTemplate = [
('sigma', 'spin', {'value': 1.0, 'step': 1.0, 'range': [0.0, None]}),
('strength', 'spin', {'value': 1.0, 'dec': True, 'step': 0.5, 'minStep': 0.01, 'range': [0.0, None]}),
]
def __init__(self, name):
## Define the input / output terminals available on this node
terminals = {
'dataIn': dict(io='in'), # each terminal needs at least a name and
示例7: ctrlWidget
def ctrlWidget(self):
if self.ui is None:
self.ui = ComboBox()
self.ui.currentIndexChanged.connect(self.plotSelected)
self.updateUi()
return self.ui
def plotSelected(self, index):
self.setPlot(self.ui.value())
def setPlotList(self, plots):
"""
Specify the set of plots (ImageView) that the user may
select from.
*plots* must be a dictionary of {name: plot} pairs.
"""
self.plots = plots
self.updateUi()
def updateUi(self):
# sets list and automatically preserves previous selection
self.ui.setItems(self.plots)
try:
self.ui.setValue(self.plots)
except ValueError:
pass
fclib.registerNodeType(ImagePlotNode, [('Display',)])
示例8: set_update_rate
self.connect_button.setText("disconnect")
self.set_update_rate(self.update_rate_input.value())
def set_update_rate(self, rate):
if rate == 0: # use callbacks for max. update rate
self.wiimote.accelerometer.register_callback(self.update_accel)
self.update_timer.stop()
else:
self.wiimote.accelerometer.unregister_callback(self.update_accel)
self.update_timer.start(1000.0/rate)
def process(self, **kwdargs):
x,y,z = self._acc_vals
return {'accelX': np.array([x]), 'accelY': np.array([y]), 'accelZ': np.array([z])}
fclib.registerNodeType(WiimoteNode, [('Sensor',)])
###############################################################################################################
class BufferNode(CtrlNode):
"""
Buffers the last n samples provided on input and provides them as a list of
length n on output.
A spinbox widget allows for setting the size of the buffer.
Default size is 32 samples.
"""
nodeName = "Buffer"
uiTemplate = [
('size', 'spin', {'value': 100.0, 'step': 1.0, 'range': [0.0, 128.0]}),
]
def __init__(self, name):
示例9: numpyInNumpyOutNode
ew = vigra.filters.tensorEigenvalues(tensor)
if sortEigenValues :
ew = np.sort(ew,axis=2)
if eigenvalue<=1:
return ew[:,:,eigenvalue]
else :
return ew
node = numpyInNumpyOutNode(
nodeName="BoundaryTensor",
uiTemplate=[('scale', 'spin', {'value': 1.50, 'step': 0.25, 'range': [0.01, None]})],
f=vigra.filters.boundaryTensor2D,
doChannelWise=True,
tensor=True
)
fclib.registerNodeType(node,[('Image-Tensors',)])
node = numpyInNumpyOutNode(
nodeName="StructureTensor",
uiTemplate=[
('innerScale', 'spin', {'value': 1.50, 'step': 0.25, 'range': [0.01, None]}),
('outerScale', 'spin', {'value': 2.50, 'step': 0.25, 'range': [0.01, None]}),
],
f=vigra.filters.structureTensor,
doChannelWise=True,
tensor=True
)
fclib.registerNodeType(node,[('Image-Tensors',)])
node = numpyInNumpyOutNode(
示例10: _brightness
########################################################
def _brightness(image,factor):
return vigra.colors.brightness(image,factor=float(factor),range='auto')
def _contrast(image,factor):
return vigra.colors.contrast(image,factor=float(factor),range='auto')
def _gammaCorrection(image,gamma):
return vigra.colors.gammaCorrection(image,gamma=float(gamma),range='auto')
node = vigraNode(
nodeName="Brightness",
uiTemplate=[ ('factor', 'spin', {'value': 1.00, 'step': 0.20, 'range': [0.10, None]}) ],
f=_brightness,
)
fclib.registerNodeType(node,[('Image-Color/Intensity',)])
node = vigraNode(
nodeName="Contrast",
uiTemplate=[ ('factor', 'spin', {'value': 1.00, 'step': 0.20, 'range': [0.10, None]}) ],
f=_contrast,
)
fclib.registerNodeType(node,[('Image-Color/Intensity',)])
node = vigraNode(
nodeName="GammaCorrection",
uiTemplate=[ ('gamma', 'spin', {'value': 1.00, 'step': 0.20, 'range': [0.10, None]}) ],
f=_gammaCorrection,
)
fclib.registerNodeType(node,[('Image-Color/Intensity',)])
示例11: raw_input
raw_input("Press the 'sync' button on the back of your Wiimote Plus " +
"or buttons (1) and (2) on your classic Wiimote.\n" +
"Press <return> once the Wiimote's LEDs start blinking.")
if len(sys.argv) == 1:
addr, name = find()[0]
elif len(sys.argv) == 2:
addr = sys.argv[1]
name = None
elif len(sys.argv) == 3:
addr, name = sys.argv[1:3]
print("Connecting to %s (%s)" % (name, addr))
wm = connect(addr, name)
#
fclib.registerNodeType(WiiMoteNode, [('Display',)])
wiiMoteNode = fc.createNode('WiiMote', pos=(0, 0))
fc.connectTerminals(fc['dataIn'], wiiMoteNode['dataIn'])
data = wm.accelerometer
# three widgets for x-, y- & z-Axis
xPlot = pg.PlotWidget()
yPlot = pg.PlotWidget()
zPlot = pg.PlotWidget()
# add widgets to grid layout
layout.addWidget(xPlot, 0, 1)
layout.addWidget(yPlot, 0, 2)
layout.addWidget(zPlot, 0, 3)
xGaussianNode = fc.createNode('GaussianFilter', pos=(150, -150))
yGaussianNode = fc.createNode('GaussianFilter', pos=(300, -150))
示例12: Selector
class Selector(MyCtrlNode):
""" Since the windows to show are limited one might need a selector"""
nodeName = "Selector2"
uiTemplate=[('selection', 'combo', {'values': ['A', 'B'], 'index': 0})]
def __init__(self, name):
terminals = {
'A': dict(io='in'),
'B': dict(io='in'),
'dataOut': dict(io='out'), # to specify whether it is input or output
} # other more advanced options are available
# as well..
MyCtrlNode.__init__(self, name, terminals=terminals)
def execute(self, A,B, display=True):
selection=self.ctrls['selection'].currentIndex()
if selection==0:
return {'dataOut': A}
else:
return {'dataOut': B}
"""
node = numpyInNumpyOutNode(
nodeName="selctor2",
uiTemplate=[
('radius','intSpin', {'value': 1, 'min': 1, 'max': 1e9 })
],
f=_normalize
)
"""
fclib.registerNodeType(Selector,[('Data-Selector',)])
示例13: dict
outputDataDict = dict(trainLoss=trainLoss, testLoss=testLoss, testAcc=testAcc)
self.sigOutputDataChanged.emit(outputDataDict)
def plotTestData(self, it, testLossesDict, testAccuraciesDict):
trainLoss = {outputName: lossArr[:it] for outputName, lossArr in self.trainLoss.items()}
testLoss = {outputName: lossArr[:it // self.testInterval] for outputName, lossArr in self.testLoss.items()}
testAcc = {outputName: lossArr[:it // self.testInterval] for outputName, lossArr in self.testAcc.items()}
# emit a signal to the plotting gods
outputDataDict = dict(trainLoss=trainLoss, testLoss=testLoss, testAcc=testAcc)
self.sigOutputDataChanged.emit(outputDataDict)
fclib.registerNodeType(SolverNode, [('Layers',)])
class RemoteSolver(QtCore.QObject):
sigTrainDataUpdated = QtCore.Signal(object, object) # iteration, trainLoss Dictionary
sigTestDataUpdated = QtCore.Signal(object, object, object) # iteration, testLoss Dictionary, testAcc dictionary
def __init__(self, filename, niter, testInterval, testIter, weights=None, mode=0):
import pyqtgraph.multiprocess as mp
# create a remote process
proc = mp.QtProcess()
# import this module in remote process
rcaffe = proc._import('caffe')
# this solver lives in the remote process
示例14: numpyInNumpyOutNode
import vigra
import math
from node_base import numpyInNumpyOutNode
import pyqtgraph.flowchart.library as fclib
#######################################################
#
# FILTERS
#
########################################################
# ERROR!!!
"""
node = numpyInNumpyOutNode(
nodeName="HourGlassFilter",
uiTemplate=[
('scale','spin', {'value': 1.50, 'step': 0.25, 'range': [0.01, None]})
,
('rho', 'spin', {'value': 1.50, 'step': 0.25, 'range': [0.01, None]})
],
f=vigra.filters.hourGlassFilter2D
)
fclib.registerNodeType(node,[('Image-Tensors',)])
"""
def _powerdGaussianSmoothing(img,sigma,power):
img=img**power
result = vigra.filters.gaussianSmoothing(img,sigma=sigma)
示例15: decrease_buffer_size
def decrease_buffer_size(self):
size = self.ctrls['size'].value()
self.ctrls['size'].setValue(size - 1.0)
def process(self, **kwds):
size = int(self.ctrls['size'].value())
self._buffer = np.append(self._buffer, kwds['dataIn'])
self._buffer = self._buffer[-size:]
if self.buttons is None:
self.register_buttons(kwds['buttons'])
output = self._buffer
return {'dataOut': output}
fclib.registerNodeType(BufferNode, [('Data',)])
class WiimoteNode(Node):
"""
Outputs sensor data from a Wiimote.
Supported sensors: accelerometer (3 axis)
Text input box allows for setting a Bluetooth MAC address.
Pressing the "connect" button tries connecting to the Wiimote.
Update rate can be changed via a spinbox widget. Setting it to "0"
activates callbacks everytime a new sensor value arrives (which is
quite often -> performance hit)
"""
nodeName = "Wiimote"