# 将Texture格式的图片对象转换为numpy def texture_to_numpy(self,data): image=numpy.asarray(bytearray(data.pixels), dtype='uint8').reshape((data.height,data.width,4)) r_chanel=numpy.copy(image[:,:,0]) g_chanel=numpy.copy(image[:,:,1]) b_chanel=numpy.copy(image[:,:,2]) image[:, :, 0]=b_chanel image[:, :, 1]=g_chanel image[:, :, 2]=r_chanel
# 将numpy格式图片对象转为Texture def numpy_to_texture(self,frame): # frame=cv2.imread("ddd.jpg") buf1 = cv2.flip(frame, 0) buf = buf1.tostring() image_texture = Texture.create(size=(frame.shape[1], frame.shape[0]), colorfmt='bgr') image_texture.blit_buffer(buf, colorfmt='bgr', bufferfmt='ubyte')
查看更多关于kivy texture图片格式和opencv numpy图片格式互转的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did126874