def main(argv): app = QtGui.QApplication(sys.argv) widget = CGLPlotWidget(aspect=1) gl_context = widget.context() gl_context.makeCurrent() data = np.array(image[:, :, :3].sum(-1), dtype=np.float32) shape = list(data.shape) print shape plat, = cl.get_platforms() ati, intel = plat.get_devices() print intel cl_context = cl.Context(devices=[intel]) implot = ImagePlot(widget.context(), cl_context, shape, share=False, interp=Interp.NEAREST) cl_data = cl.Buffer(cl_context, cl.mem_flags.READ_WRITE, data.nbytes) import pylab cdict = pylab.cm.jet._segmentdata pipe_segment = ColorMap(gl_context, cl_context, cdict, cl_data, implot.texture.cl_image, shape, clim=(np.float32(data.min()), np.float32(data.max())) ) cl.enqueue_copy(implot.queue, cl_data, data) implot.queue.finish() implot._pipe_segments.append(pipe_segment) implot.process() widget.add_plot(implot) widget.show() widget.resize(480, 640,) bring_to_front() sys.exit(app.exec_())
pipe_segment = ComputationalPipe(gl_context, cl_context, (n_vertices,), None, generate_sin, plot1.vtx_array.cl_buffer, np.float32(1.1)) plot1.add_pipe_segment(pipe_segment) pipe_segment = ComputationalPipe(gl_context, cl_context, (n_vertices,), None, generate_sin, plot2.vtx_array.cl_buffer, np.float32(0.6)) plot2.add_pipe_segment(pipe_segment) plot1.process() plot2.process() canvas.add_plot(plot1) canvas.add_plot(plot2) widget = QtGui.QWidget() widget_layout = QtGui.QVBoxLayout(widget) widget.setLayout(widget_layout) widget_layout.addWidget(canvas) slider = QtGui.QSlider(widget) def change_a(value): pipe_segment.kernel_args[1] = np.float32(float(value) / 100.0) pipe_segment.update() slider.valueChanged.connect(change_a)