_camera_opencv_highgui.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:Projects 作者: it2school 项目源码 文件源码
def get_surface(self, dest_surf = None):
        camera = self.camera

        im = highgui.cvQueryFrame(camera)
        #convert Ipl image to PIL image
        #print type(im)
        if im:
            xx = opencv.adaptors.Ipl2NumPy(im)
            #print type(xx)
            #print xx.iscontiguous()
            #print dir(xx)
            #print xx.shape
            xxx = numpy.reshape(xx, (numpy.product(xx.shape),))

            if xx.shape[2] != 3:
                raise ValueError("not sure what to do about this size")

            pg_img = pygame.image.frombuffer(xxx, (xx.shape[1],xx.shape[0]), "RGB")

            # if there is a destination surface given, we blit onto that.
            if dest_surf:
                dest_surf.blit(pg_img, (0,0))
            return dest_surf
            #return pg_img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号