小编Mik*_*anh的帖子

如何将视频用作avcapture输入

尝试针对应用程序测试各种相机输入,但由于每次都要使网络摄像头做同样的事情并且更换镜头,因此只想拍摄视频并将其用作输入.

我可以看到如何查询OSX for AVCapture设备,但有可能创建一个并将其注册到系统,同时从保存的视频文件中提供帧吗?

macos video-capture avcapture

6
推荐指数
0
解决办法
170
查看次数

如何将 moderngl fbo(帧缓冲区对象)读回 numpy 数组?

我有 2 个 FBO 之一,我一直在用它在 glsl 中进行一些计算,我需要将纹理数据(dtype='f4')读回一个 numpy 数组以进行进一步计算。我在文档中没有找到任何解释如何执行此操作的内容。有什么帮助吗?

我用这个创建纹理

self.texturePing = self.ctx.texture( (width, height), 4, dtype='f4')
self.texturePong = self.ctx.texture( (width, height), 4, dtype='f4')
Run Code Online (Sandbox Code Playgroud)

我像这样处理它们:

def render(self, time, frame_time):
        self.line_texture.use(0)
        self.transform['lineImg'].value = 0
        for _ in range (2):
            self.fbo2.use()
            self.texturePing.use(1)
            self.transform['prevData'].value = 1

            self.process_vao.render(moderngl.TRIANGLE_STRIP)

            #this rendered to texturePong 
            self.fbo1.use() #texture Ping


            self.texturePong.use(1)
            self.transform['prevData'].value = 1                
            self.process_vao.render(moderngl.TRIANGLE_STRIP)

        #stop drawing to the fbo and draw to the screen
        self.ctx.screen.use()
        self.ctx.clear(1.0, 1.0, 1.0, 0.0) #might be unnecessary   
        #tell the canvas to use this …
Run Code Online (Sandbox Code Playgroud)

python opengl numpy python-moderngl

3
推荐指数
1
解决办法
876
查看次数