<bdo id='zHHNp'></bdo><ul id='zHHNp'></ul>

      <legend id='zHHNp'><style id='zHHNp'><dir id='zHHNp'><q id='zHHNp'></q></dir></style></legend>
    1. <small id='zHHNp'></small><noframes id='zHHNp'>

      <i id='zHHNp'><tr id='zHHNp'><dt id='zHHNp'><q id='zHHNp'><span id='zHHNp'><b id='zHHNp'><form id='zHHNp'><ins id='zHHNp'></ins><ul id='zHHNp'></ul><sub id='zHHNp'></sub></form><legend id='zHHNp'></legend><bdo id='zHHNp'><pre id='zHHNp'><center id='zHHNp'></center></pre></bdo></b><th id='zHHNp'></th></span></q></dt></tr></i><div id='zHHNp'><tfoot id='zHHNp'></tfoot><dl id='zHHNp'><fieldset id='zHHNp'></fieldset></dl></div>

        <tfoot id='zHHNp'></tfoot>

        在 Kivy 中显示 numpy/opencv/matplotlib 图像

        时间:2023-10-10

              <legend id='5Q2R9'><style id='5Q2R9'><dir id='5Q2R9'><q id='5Q2R9'></q></dir></style></legend>
                <tbody id='5Q2R9'></tbody>
              <i id='5Q2R9'><tr id='5Q2R9'><dt id='5Q2R9'><q id='5Q2R9'><span id='5Q2R9'><b id='5Q2R9'><form id='5Q2R9'><ins id='5Q2R9'></ins><ul id='5Q2R9'></ul><sub id='5Q2R9'></sub></form><legend id='5Q2R9'></legend><bdo id='5Q2R9'><pre id='5Q2R9'><center id='5Q2R9'></center></pre></bdo></b><th id='5Q2R9'></th></span></q></dt></tr></i><div id='5Q2R9'><tfoot id='5Q2R9'></tfoot><dl id='5Q2R9'><fieldset id='5Q2R9'></fieldset></dl></div>
            1. <tfoot id='5Q2R9'></tfoot>

                <bdo id='5Q2R9'></bdo><ul id='5Q2R9'></ul>

                  <small id='5Q2R9'></small><noframes id='5Q2R9'>

                • 本文介绍了在 Kivy 中显示 numpy/opencv/matplotlib 图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如何在 Kivy 中以标准 numpy/opencv/matplotlib 格式显示图像?Kivy 使用不同的图像内存布局,我不知道是哪一个.

                  How to display image in standard numpy/opencv/matplotlib format in Kivy? Kivy uses different image memory layout and I can't figure out which one.

                  以下代码完全正常.使用 cv2 VideoCapture 捕获图像.我认为图像是 BGR,数组维度是 (360, 480, 3):

                  The following code works totally fine. Image was captured using cv2 VideoCapture. I think image is BGR, array dimensions are (360, 480, 3):

                      ret, image = video_capture.read()
                      cv2.imshow('image', image)
                      cv2.waitKey()
                  

                  尝试使用以下代码显示它会产生混乱的结果:

                  Trying to display it with the following code produce messy results:

                      video_texture = Texture.create(size=image.shape[:2])
                      video_texture.blit_buffer(image.tostring(), colorfmt='rgb', bufferfmt='ubyte')
                  
                      # ...
                  
                      video_panel = self.ids['video_panel']
                      with video_panel.canvas:
                          Rectangle(texture=video_texture, pos=video_panel.pos, size=video_panel.size)
                  

                  推荐答案

                  找到了正确的转换.可能不是最理想的:

                  Found the right transformation. Probably suboptimal:

                      ret, image = video_capture.read()
                      image = np.rot90(np.swapaxes(image, 0, 1))
                      video_texture = Texture.create(size=(image.shape[1], image.shape[0]), colorfmt='rgb')
                      video_texture.blit_buffer(image.tostring(), colorfmt='bgr', bufferfmt='ubyte')
                  

                  这篇关于在 Kivy 中显示 numpy/opencv/matplotlib 图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:问题将 Kivy 设置为全屏 下一篇:Kivy:如何通过 id 获取小部件(没有 kv)

                  相关文章

                  最新文章

                      • <bdo id='8wxN6'></bdo><ul id='8wxN6'></ul>

                      <small id='8wxN6'></small><noframes id='8wxN6'>

                      <i id='8wxN6'><tr id='8wxN6'><dt id='8wxN6'><q id='8wxN6'><span id='8wxN6'><b id='8wxN6'><form id='8wxN6'><ins id='8wxN6'></ins><ul id='8wxN6'></ul><sub id='8wxN6'></sub></form><legend id='8wxN6'></legend><bdo id='8wxN6'><pre id='8wxN6'><center id='8wxN6'></center></pre></bdo></b><th id='8wxN6'></th></span></q></dt></tr></i><div id='8wxN6'><tfoot id='8wxN6'></tfoot><dl id='8wxN6'><fieldset id='8wxN6'></fieldset></dl></div>
                      <tfoot id='8wxN6'></tfoot>

                      <legend id='8wxN6'><style id='8wxN6'><dir id='8wxN6'><q id='8wxN6'></q></dir></style></legend>