当前位置: 首页>>代码示例>>Python>>正文


Python app.Canvas方法代码示例

本文整理汇总了Python中vispy.app.Canvas方法的典型用法代码示例。如果您正苦于以下问题:Python app.Canvas方法的具体用法?Python app.Canvas怎么用?Python app.Canvas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vispy.app的用法示例。


在下文中一共展示了app.Canvas方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from vispy import app [as 别名]
# 或者: from vispy.app import Canvas [as 别名]
def __init__(self, size, cam):

        app.Canvas.__init__(self, show=False, size=size)
        self.shape = (size[1], size[0])
        self.yz_flip = np.eye(4, dtype=np.float32)
        self.yz_flip[1, 1], self.yz_flip[2, 2] = -1, -1

        self.set_cam(cam)

        # Set up shader programs
        self.program_col = gloo.Program(_vertex_code_colored, _fragment_code_colored)
        self.program_tex = gloo.Program(_vertex_code_textured, _fragment_code_textured)

        # Texture where we render the color/depth and its FBO
        self.col_tex = gloo.Texture2D(shape=self.shape + (3,))
        self.fbo = gloo.FrameBuffer(self.col_tex, gloo.RenderBuffer(self.shape))
        self.fbo.activate()
        gloo.set_state(depth_test=True, blend=False, cull_face=True)
        gl.glEnable(gl.GL_LINE_SMOOTH)
        gloo.set_clear_color((0.0, 0.0, 0.0))
        gloo.set_viewport(0, 0, *self.size) 
开发者ID:kirumang,项目名称:Pix2Pose,代码行数:23,代码来源:renderer.py

示例2: get_max_texture_sizes

# 需要导入模块: from vispy import app [as 别名]
# 或者: from vispy.app import Canvas [as 别名]
def get_max_texture_sizes():
    """Get maximum texture sizes for 2D and 3D rendering.

    Returns
    -------
    MAX_TEXTURE_SIZE_2D : int or None
        Max texture size allowed by the vispy canvas during 2D rendering.
    MAX_TEXTURE_SIZE_3D : int or None
        Max texture size allowed by the vispy canvas during 2D rendering.
    """
    # A canvas must be created to access gl values
    c = Canvas(show=False)
    try:
        MAX_TEXTURE_SIZE_2D = gl.glGetParameter(gl.GL_MAX_TEXTURE_SIZE)
    finally:
        c.close()
    if MAX_TEXTURE_SIZE_2D == ():
        MAX_TEXTURE_SIZE_2D = None
    # vispy doesn't expose GL_MAX_3D_TEXTURE_SIZE so hard coding
    # MAX_TEXTURE_SIZE_3D = gl.glGetParameter(gl.GL_MAX_3D_TEXTURE_SIZE)
    # if MAX_TEXTURE_SIZE_3D == ():
    #    MAX_TEXTURE_SIZE_3D = None
    MAX_TEXTURE_SIZE_3D = 2048

    return MAX_TEXTURE_SIZE_2D, MAX_TEXTURE_SIZE_3D 
开发者ID:napari,项目名称:napari,代码行数:27,代码来源:vispy_base_layer.py

示例3: __init__

# 需要导入模块: from vispy import app [as 别名]
# 或者: from vispy.app import Canvas [as 别名]
def __init__(self):
        app.Canvas.__init__(self,
                            keys='interactive')

        self.program = gloo.Program(VERT_SHADER, FRAG_SHADER)
        self.program['index'] = [(x,) for x in range(num_bins)] * num_lines
        self.program['line'] = [(x,) * num_bins for x in range(num_lines)]
        self.program['map_offset'] = 0

        self.program['num_bins'] = num_bins
        self.program['num_lines'] = num_lines

        heightmap = np.random.random(size=(num_lines, num_bins)).astype('float32')

        self.program['heightmap'] = gloo.Texture2D(data=heightmap, internalformat='r32f')
        #print (dir(self.program['heightmap']))

        self.program['colormap'] = Colormap(['r', 'g', 'b']).map(np.linspace(0, 1, 64)).astype('float32')

        gloo.set_viewport(0, 0, *self.physical_size)

        gloo.set_state(clear_color='black', blend=True,
                       blend_func=('src_alpha', 'one_minus_src_alpha'))

        self.show() 
开发者ID:strfry,项目名称:OpenNFB,代码行数:27,代码来源:waterfall.py

示例4: __init__

# 需要导入模块: from vispy import app [as 别名]
# 或者: from vispy.app import Canvas [as 别名]
def __init__(self, vertices, faces, size, K, R, t, clip_near, clip_far,
                 bg_color=(0.0, 0.0, 0.0, 0.0), ambient_weight=0.1,
                 render_rgb=True, render_depth=True):
        """
        mode is from ['rgb', 'depth', 'rgb+depth']
        """
        app.Canvas.__init__(self, show=False, size=size)

        #gloo.gl.use_gl('gl2 debug')

        self.size = size
        self.shape = (self.size[1], self.size[0])
        self.bg_color = bg_color
        self.ambient_weight = ambient_weight
        self.render_rgb = render_rgb
        self.render_depth = render_depth

        self.rgb = np.array([])
        self.depth = np.array([])

        # Model matrix
        self.mat_model = np.eye(4, dtype=np.float32) # From object space to world space

        # View matrix (transforming also the coordinate system from OpenCV to
        # OpenGL camera space)
        self.mat_view = np.eye(4, dtype=np.float32) # From world space to eye space
        self.mat_view[:3, :3], self.mat_view[:3, 3] = R, t.squeeze()
        yz_flip = np.eye(4, dtype=np.float32)
        yz_flip[1, 1], yz_flip[2, 2] = -1, -1
        self.mat_view = yz_flip.dot(self.mat_view) # OpenCV to OpenGL camera system
        self.mat_view = self.mat_view.T # OpenGL expects column-wise matrix format

        # Projection matrix
        self.mat_proj = _compute_calib_proj(K, 0, 0, size[0], size[1], clip_near, clip_far)

        # Create buffers
        self.vertex_buffer = gloo.VertexBuffer(vertices)
        self.index_buffer = gloo.IndexBuffer(faces.flatten().astype(np.uint32))

        # We manually draw the hidden canvas
        self.update() 
开发者ID:meiqua,项目名称:patch_linemod,代码行数:43,代码来源:renderer.py

示例5: __init__

# 需要导入模块: from vispy import app [as 别名]
# 或者: from vispy.app import Canvas [as 别名]
def __init__(self, setup_method, draw_method,
                 handlers=dict(), frame_rate=60):
        app.Canvas.__init__(
            self,
            title=builtins.title,
            size=(builtins.width, builtins.height),
            keys='interactive',
            resizable=True,
        )

        self.setup_method = setup_method
        self.draw_method = draw_method

        self.looping = None
        self.redraw = None
        self.setup_done = False
        self.timer = app.Timer(1.0 / frame_rate, connect=self.on_timer)

        self.handlers = dict()
        for handler_name in handler_names:
            self.handlers[handler_name] = handlers.get(handler_name, _dummy)

        self.handler_queue = []

        self._save_fname = 'screen'
        self._save_fname_num = 0
        self._save_flag = False

        p5.renderer.initialize_renderer()
        p5.renderer.clear() 
开发者ID:p5py,项目名称:p5,代码行数:32,代码来源:base.py

示例6: init

# 需要导入模块: from vispy import app [as 别名]
# 或者: from vispy.app import Canvas [as 别名]
def init(self):
        self.canvas = Canvas()
        self.widget = self.canvas.native

        self.gr_block.set_history(bins)
        self.win = np.blackman(bins) 
开发者ID:strfry,项目名称:OpenNFB,代码行数:8,代码来源:waterfall.py

示例7: __init__

# 需要导入模块: from vispy import app [as 别名]
# 或者: from vispy.app import Canvas [as 别名]
def __init__(self):
        app.Canvas.__init__(self, size=(512, 512),
                            title='Rotating cube (GL version)',
                            keys='interactive') 
开发者ID:timctho,项目名称:VNect-tensorflow,代码行数:6,代码来源:vispy_test.py

示例8: __init__

# 需要导入模块: from vispy import app [as 别名]
# 或者: from vispy.app import Canvas [as 别名]
def __init__(self, size, cam):

        app.Canvas.__init__(self, show=False, size=size)
        self.shape = (size[1], size[0])
        self.yz_flip = np.eye(4, dtype=np.float32)
        self.yz_flip[1, 1], self.yz_flip[2, 2] = -1, -1

        self.set_cam(cam)

        # Set up shader programs
        self.program_col = gloo.Program(_vertex_code_colored, _fragment_code_colored)
        self.program_bbox = gloo.Program(_vertex_code_colored, _fragment_code_bbox)
        self.program_tex = gloo.Program(_vertex_code_textured, _fragment_code_textured)
        self.program_bg = gloo.Program(_vertex_code_background, _fragment_code_background)

        # Texture where we render the color/depth and its FBO
        self.col_tex = gloo.Texture2D(shape=self.shape + (3,))
        self.fbo = gloo.FrameBuffer(self.col_tex, gloo.RenderBuffer(self.shape))
        self.fbo.activate()
        gloo.set_state(depth_test=True, blend=False, cull_face=True)
        gl.glEnable(gl.GL_LINE_SMOOTH)
        gloo.set_clear_color((0.0, 0.0, 0.0))
        gloo.set_viewport(0, 0, *self.size)

        # Set up background render quad in NDC
        quad = [[-1, -1], [1, -1], [1, 1], [-1, 1]]
        tex = [[0, 1], [1, 1], [1, 0], [0, 0]]
        vertices_type = [('a_position', np.float32, 2), ('a_texcoord', np.float32, 2)]
        collated = np.asarray(list(zip(quad, tex)), vertices_type)
        self.bg_vbuffer = gloo.VertexBuffer(collated)
        self.bg_ibuffer = gloo.IndexBuffer([0, 1, 2, 0, 2, 3]) 
开发者ID:fabi92,项目名称:eccv18-rgb_pose_refinement,代码行数:33,代码来源:renderer.py

示例9: __init__

# 需要导入模块: from vispy import app [as 别名]
# 或者: from vispy.app import Canvas [as 别名]
def __init__(
            self, *,
            image_acquirer=None,
            width=640, height=480,
            display_rate=30.,
            background_color='gray',
            vsync=True
    ):
        """
        As far as we know, Vispy refreshes the canvas every 1/30 sec at the
        fastest no matter which faster number is specified. If we set any
        value which is greater than 30, then Vispy's callback is randomly
        called.
        """

        #
        app.Canvas.__init__(
            self, size=(width, height), vsync=vsync, autoswap=True
        )

        #
        self._ia = image_acquirer

        #
        self._background_color = background_color
        self._has_filled_texture = False
        self._width, self._height = width, height

        #
        self._is_dragging = False

        # If it's True, the canvas keeps image acquisition but do not
        # draw images on the canvas:
        self._pause_drawing = False

        #
        self._origin = [0, 0]

        #
        self._display_rate = display_rate
        self._timer = app.Timer(
            1. / self._display_rate, connect=self.update, start=True
        )

        #
        self._buffers = [] 
开发者ID:genicam,项目名称:harvesters_gui,代码行数:48,代码来源:canvas.py


注:本文中的vispy.app.Canvas方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。