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

    • <bdo id='ZNvBH'></bdo><ul id='ZNvBH'></ul>
      <tfoot id='ZNvBH'></tfoot>

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

    3. <legend id='ZNvBH'><style id='ZNvBH'><dir id='ZNvBH'><q id='ZNvBH'></q></dir></style></legend>

      Kivy 相機作為 KV 語言小部件

      Kivy Camera as KV language widget(Kivy 相機作為 KV 語言小部件)
        <bdo id='7WvwE'></bdo><ul id='7WvwE'></ul>
          • <legend id='7WvwE'><style id='7WvwE'><dir id='7WvwE'><q id='7WvwE'></q></dir></style></legend>
              <tbody id='7WvwE'></tbody>

            <tfoot id='7WvwE'></tfoot>

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

                <small id='7WvwE'></small><noframes id='7WvwE'>

                本文介紹了Kivy 相機作為 KV 語言小部件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在使用帶有網絡攝像頭的 Kivy.我按照@Arnav 的 this example 使用 opencv 來形成和將相機顯示為小部件.我已經擴展"了python中的布局,添加了兩個按鈕作為測試,為更復雜的布局做準備.

                I am using Kivy with a webcam. I have followed this example by @Arnav of using opencv to form and display the camera as a widget. I have "extended" the layout within python it to add two buttons as a test, in preparation for a more complicated layout.

                class CamApp(App):
                    def build(self):
                        self.capture = cv2.VideoCapture(0)
                        self.my_camera = KivyCamera(capture=self.capture, fps=30,resolution=(1920,1080))
                        root = BoxLayout(orientation = 'vertical')
                        root.add_widget(self.my_camera,1)
                        box2 = BoxLayout(orientation = 'vertical')
                        btn1 = Button(text='Hello world 1')
                        btn2 = Button(text='Hello world 2')
                        box2.add_widget(btn1)
                        box2.add_widget(btn2)
                        root.add_widget(box2, 0)
                        return root
                        #return Builder.load_string(kv)
                

                雖然這可行,但我更愿意將 UI 組件從 python 中移出并放入 kv 語言 文件中.問題是知道如何在 kv 文件中描述"self.my_camera?

                While this works I would prefer to move the UI components out of python and into a kv language file. The problem is knowing how to "describe" the self.my_camera in the kv file?

                我不確定是否將 KivyCamera 類作為 kv 文件中的 widget 繼承,即

                I am not sure whether to inherit the KivyCamera class as a widget within the kv file i.e.

                kv = '''
                <Cam1@KivyCamera>:
                    texture: self.my_camera
                    resolution: (1920, 1080)
                    pos: self.pos
                    size: self.size
                

                或者是否使用canvas小部件

                <MyWidget>:
                    canvas:
                        Rectangle:
                            source: self.my_camera
                            pos: self.pos
                            size: self.size
                

                我嘗試過其他被黑"的實現,但在所有情況下,問題都是通過 self.my_camera 鏈接到 kv 文件.

                I have tried other "hacked" implementations, but in all cases the problem is linking through the self.my_camera into the kv file.

                有什么建議嗎?

                推薦答案

                也許這個例子可以幫到你.

                Perhaps this example may help you.

                # Import 'kivy.core.text' must be called in entry point script
                # before import of cv2 to initialize Kivy's text provider.
                # This fixes crash on app exit.
                
                import kivy.core.text
                import cv2
                from kivy.app import App
                from kivy.base import EventLoop
                from kivy.uix.image import Image
                from kivy.clock import Clock
                from kivy.graphics.texture import Texture
                from kivy.uix.boxlayout import BoxLayout
                from kivy.core.window import Window
                
                
                class KivyCamera(Image):
                
                    def __init__(self, **kwargs):
                        super(KivyCamera, self).__init__(**kwargs)
                        self.capture = None
                
                    def start(self, capture, fps=30):
                        self.capture = capture
                        Clock.schedule_interval(self.update, 1.0 / fps)
                
                    def stop(self):
                        Clock.unschedule_interval(self.update)
                        self.capture = None
                
                    def update(self, dt):
                        return_value, frame = self.capture.read()
                        if return_value:
                            texture = self.texture
                            w, h = frame.shape[1], frame.shape[0]
                            if not texture or texture.width != w or texture.height != h:
                                self.texture = texture = Texture.create(size=(w, h))
                                texture.flip_vertical()
                            texture.blit_buffer(frame.tobytes(), colorfmt='bgr')
                            self.canvas.ask_update()
                
                
                capture = None
                
                
                class QrtestHome(BoxLayout):
                
                    def init_qrtest(self):
                        pass
                
                    def dostart(self, *largs):
                        global capture
                        capture = cv2.VideoCapture(0)
                        self.ids.qrcam.start(capture)
                
                    def doexit(self):
                        global capture
                        if capture != None:
                            capture.release()
                            capture = None
                        EventLoop.close()
                
                
                class qrtestApp(App):
                
                    def build(self):
                        Window.clearcolor = (.4,.4,.4,1)
                        Window.size = (400, 300)
                        homeWin = QrtestHome()
                        homeWin.init_qrtest()
                        return homeWin
                
                    def on_stop(self):
                        global capture
                        if capture:
                            capture.release()
                            capture = None
                
                qrtestApp().run()
                

                還有kv文件:

                <QrtestHome>:
                
                    BoxLayout:
                        orientation: "vertical"
                
                        Label:
                            height: 20
                            size_hint_y: None
                            text: 'Testing the camera'
                
                        KivyCamera:
                            id: qrcam
                
                        BoxLayout:
                            orientation: "horizontal"
                            height: 20
                            size_hint_y: None
                
                            Button:
                                id: butt_start
                                size_hint: 0.5,1
                                text: "start"
                                on_press: root.dostart()
                
                            Button:
                                id: butt_exit
                                text: "quit"
                                size_hint: 0.5,1
                                on_press: root.doexit()
                

                這篇關于Kivy 相機作為 KV 語言小部件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                message.channel.id Discord PY(message.channel.id Discord PY)
                How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)

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

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

                    <tfoot id='qzGsM'></tfoot>

                      <legend id='qzGsM'><style id='qzGsM'><dir id='qzGsM'><q id='qzGsM'></q></dir></style></legend>
                          <bdo id='qzGsM'></bdo><ul id='qzGsM'></ul>
                            <tbody id='qzGsM'></tbody>
                          主站蜘蛛池模板: 日韩一区二区三区av | 国产精品久久久av | 欧美成年黄网站色视频 | 国产成人综合在线 | 91亚洲国产成人久久精品网站 | 久久精品色欧美aⅴ一区二区 | 日韩精品一区二区三区中文在线 | a级在线免费 | 91精品国产一区二区三区 | 懂色一区二区三区免费观看 | 亚洲在线中文字幕 | av香港经典三级级 在线 | 久久精品欧美电影 | 国产在线观看 | 亚洲精品成人网 | 国产二区三区 | 日韩免费视频一区二区 | 欧美最猛黑人xxxx黑人 | 国产98色在线 | 91视频中文 | 亚洲欧美久久 | 国产精品我不卡 | 亚洲精品日韩综合观看成人91 | 久久精品二区亚洲w码 | 四虎成人免费电影 | 日韩欧美视频免费在线观看 | 一区二区免费 | 国产伊人精品 | 久久国| 国产精品国产馆在线真实露脸 | 激情一区二区三区 | 国产精品免费在线 | 国产精品欧美精品 | 久久国产精品久久久久久 | www国产亚洲精品久久网站 | 欧美一区成人 | 日韩一区不卡 | 日韩欧美在线观看 | 欧美日韩视频 | 91视频亚洲 | 国产一区二 |