久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <tfoot id='XK3ui'></tfoot>

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

      <small id='XK3ui'></small><noframes id='XK3ui'>

      1. 在 Kivy 中顯示一個(gè) numpy 數(shù)組

        Display a numpy array in Kivy(在 Kivy 中顯示一個(gè) numpy 數(shù)組)

          <tbody id='3gyx8'></tbody>
          <legend id='3gyx8'><style id='3gyx8'><dir id='3gyx8'><q id='3gyx8'></q></dir></style></legend>
          <tfoot id='3gyx8'></tfoot>

          • <bdo id='3gyx8'></bdo><ul id='3gyx8'></ul>
            <i id='3gyx8'><tr id='3gyx8'><dt id='3gyx8'><q id='3gyx8'><span id='3gyx8'><b id='3gyx8'><form id='3gyx8'><ins id='3gyx8'></ins><ul id='3gyx8'></ul><sub id='3gyx8'></sub></form><legend id='3gyx8'></legend><bdo id='3gyx8'><pre id='3gyx8'><center id='3gyx8'></center></pre></bdo></b><th id='3gyx8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='3gyx8'><tfoot id='3gyx8'></tfoot><dl id='3gyx8'><fieldset id='3gyx8'></fieldset></dl></div>
            1. <small id='3gyx8'></small><noframes id='3gyx8'>

                • 本文介紹了在 Kivy 中顯示一個(gè) numpy 數(shù)組的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  首先,我對kivy完全陌生,所以我有點(diǎn)掙扎.

                  first of all, I'm totally new to kivy, so I'm struggling a bit.

                  我正在嘗試在 kivy 窗口中顯示一個(gè) numpy 數(shù)組.到目前為止,我發(fā)現(xiàn)這應(yīng)該使用紋理類(http://kivy.org/docs/api-kivy.graphics.texture.html).

                  I'm trying to display a numpy array in a kivy window. So far i figured out that this should work using the Texture Class (http://kivy.org/docs/api-kivy.graphics.texture.html).

                  隨著我的 numpy 數(shù)組不時(shí)發(fā)生變化,我正在嘗試將以下代碼調(diào)整為我的應(yīng)用程序.

                  As my numpy array changes from time to time, I'm trying to adjust the following code to my application.

                  # create a 64x64 texture, defaults to rgb / ubyte
                  texture = Texture.create(size=(64, 64))
                  
                  # create 64x64 rgb tab, and fill with values from 0 to 255
                  # we'll have a gradient from black to white
                  size = 64 * 64 * 3
                  buf = [int(x * 255 / size) for x in range(size)]
                  
                  # then, convert the array to a ubyte string
                  buf = b''.join(map(chr, buf))
                  
                  # then blit the buffer
                  texture.blit_buffer(buf, colorfmt='rgb', bufferfmt='ubyte')
                  
                  # that's all ! you can use it in your graphics now :)
                  # if self is a widget, you can do this
                  with self.canvas:
                      Rectangle(texture=texture, pos=self.pos, size=(64, 64))
                  

                  似乎創(chuàng)建紋理并對其進(jìn)行更改可以正常工作,但我不明白如何顯示紋理.

                  It seems that creating the texture and changing it works as it should, but i dont get, how to display the texture.

                  誰能給我解釋一下,如何使用

                  Can anybody explain to me, how to use the

                  with self.canvas:
                      Rectangle(texture=texture, pos=self.pos, size=(64, 64))
                  

                  在某種程度上,我可以看到我的圖片/numpy 數(shù)組.

                  in a way, that I get to see my picture/numpy array.

                  提前非常感謝!Holzroller

                  Thanks alot in advance! Holzroller

                  我發(fā)現(xiàn)使用 Kivy 1.8.0 和紋理類有點(diǎn)亂.所以我通過 github 升級到 Kivy 1.9.0(在 Ubuntu 14.04 LTS 中通過 apt-get 安裝 Kivy 為您提供 1.8.0 版本),我可以使用以下代碼查看紋理.希望對和我有同樣問題的人有所幫助.

                  I figured out that using Kivy 1.8.0 and the Texture Class is a bit messy. So I upgraded to Kivy 1.9.0 via github (installing Kivy via apt-get in Ubuntu 14.04 LTS serves you the 1.8.0 version) and I get to see the Texture using the following code. I hope that helps people who are having the same problem as me.

                  from kivy.graphics.texture import Texture
                  from kivy.graphics import Rectangle
                  from kivy.uix.widget import Widget
                  from kivy.base import runTouchApp
                  from array import array
                  from kivy.core.window import Window
                  
                  
                  # create a 64x64 texture, defaults to rgb / ubyte
                  texture = Texture.create(size=(1280, 1024), colorfmt='rgb')
                  
                  # create 64x64 rgb tab, and fill with values from 0 to 255
                  # we'll have a gradient from black to white
                  size = 1280 * 1024 * 3
                  buf = [int(x * 255 / size) for x in range(size)]
                  
                  # then, convert the array to a ubyte string
                  arr = array('B', buf)
                  # buf = b''.join(map(chr, buf))
                  
                  # then blit the buffer
                  texture.blit_buffer(arr, colorfmt='rgb', bufferfmt='ubyte')
                  
                  # that's all ! you can use it in your graphics now :)
                  # if self is a widget, you can do this
                  root = Widget()
                  with root.canvas:
                      Rectangle(texture=texture, pos=(0, 0), size=(1280*3, 1024*3))
                  
                  runTouchApp(root)
                  

                  基本上我回到了原來的問題:我有一個(gè) numpy 數(shù)組(類型 'numpy.ndarray'; dtype 'uint8'),我正在嘗試將其轉(zhuǎn)換為一種格式,以便紋理向我顯示圖像.我試圖將其分解為與我在上面發(fā)布的示例代碼中相同的方式.但我很遺憾沒有工作.我真的不知道我在這里做錯(cuò)了什么.(我的 numpy 數(shù)組在以下代碼中稱為 im2)

                  Basically I'm back to the original Problem: I have a numpy array (type 'numpy.ndarray'; dtype 'uint8') and I'm trying to convert it into a format, so that the texture will show me the image. I tried to break it down to the same way it is done in the example code i posted above. But i sadly doesn't work. I really do not know what I'm doing wrong here. (my numpy array is called im2 in the folling code)

                  list1 = numpy.array(im2).reshape(-1,).tolist()
                  
                  arr = array('B', list1)
                  
                  texture.blit_buffer(arr, colorfmt='rgb', bufferfmt='ubyte')
                  

                  推薦答案

                  Numpy 有一個(gè) tostring() 屬性,如果源數(shù)組是 uint8 類型,您可以直接使用該屬性.你甚至不需要重塑:

                  Numpy have a tostring() attribute, that you could use directly, if the source array is uint8 type. You don't even need to reshape:

                  texture = Texture.create(size=(16, 16), colorfmt="rgb"))
                  arr = numpy.ndarray(shape=[16, 16, 3], dtype=numpy.uint8)
                  # fill your numpy array here
                  data = arr.tostring()
                  texture.blit_buffer(data, bufferfmt="ubyte", colorfmt="rgb"
                  

                  關(guān)于你在評論中談?wù)摰膯栴},我看到 2 點(diǎn):

                  About the issue you're talking in the comment, i see 2 points:

                  1. 確保在主線程中調(diào)用來自 ROS 的回調(diào).也許更新被忽略了.
                  2. 當(dāng)您手動更改紋理時(shí),不會通知使用它的關(guān)聯(lián)對象,您需要這樣做.添加一個(gè) self.canvas.ask_update() 以確保畫布在下一幀重新顯示.

                  這篇關(guān)于在 Kivy 中顯示一個(gè) numpy 數(shù)組的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Display numpy/opencv/matplotlib image in Kivy(在 Kivy 中顯示 numpy/opencv/matplotlib 圖像)
                  Formatting Multi dimensional arrays Python(格式化多維數(shù)組 Python)
                  Saving numpy array in mongodb(在mongodb中保存numpy數(shù)組)
                  Unable to apply methods on timestamps using Series built-ins(無法使用 Series 內(nèi)置函數(shù)對時(shí)間戳應(yīng)用方法)
                  Pandas Timedelta in Days(Pandas Timedelta 以天為單位)
                  How to convert Numpy array to Panda DataFrame(如何將 Numpy 數(shù)組轉(zhuǎn)換為 Panda DataFrame)
                  1. <i id='Y89hg'><tr id='Y89hg'><dt id='Y89hg'><q id='Y89hg'><span id='Y89hg'><b id='Y89hg'><form id='Y89hg'><ins id='Y89hg'></ins><ul id='Y89hg'></ul><sub id='Y89hg'></sub></form><legend id='Y89hg'></legend><bdo id='Y89hg'><pre id='Y89hg'><center id='Y89hg'></center></pre></bdo></b><th id='Y89hg'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Y89hg'><tfoot id='Y89hg'></tfoot><dl id='Y89hg'><fieldset id='Y89hg'></fieldset></dl></div>

                        <tbody id='Y89hg'></tbody>
                      <tfoot id='Y89hg'></tfoot>
                      <legend id='Y89hg'><style id='Y89hg'><dir id='Y89hg'><q id='Y89hg'></q></dir></style></legend>

                          • <bdo id='Y89hg'></bdo><ul id='Y89hg'></ul>

                            <small id='Y89hg'></small><noframes id='Y89hg'>

                            主站蜘蛛池模板: 国产欧美一区二区三区久久手机版 | 美国一级片在线观看 | 国产一区二区三区四区五区加勒比 | 6080yy精品一区二区三区 | 国产在线观看一区 | 国产美女视频一区 | 超碰在线97国产 | 69精品久久久久久 | 久久久精品久久久 | 91资源在线观看 | 国产成人精品一区二区在线 | 欧美成人影院在线 | 老头搡老女人毛片视频在线看 | 亚洲毛片在线观看 | 日韩在线一区视频 | 国产日韩一区二区三区 | 亚洲一区免费 | 国产在线精品一区二区 | 日韩一区和二区 | 日韩欧美一区二区三区免费观看 | 中文字幕一区二区三区不卡在线 | 成人国产精品色哟哟 | 精品国产综合 | 午夜视频免费网站 | 亚洲欧美中文字幕在线观看 | 日韩欧美一区二区三区免费观看 | 99久久精品国产一区二区三区 | 最新中文字幕在线 | 亚洲www| 美国黄色毛片 | 成人在线视频观看 | 美女久久视频 | 欧美一区二区三区久久精品视 | 欧美精品中文 | tube国产 | 欧美激情久久久 | 亚洲成人在线免费 | 亚洲精品一区在线观看 | 亚洲精品片 | 午夜在线观看免费 | 91久久久久久久久久久 |