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

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

        <tfoot id='fRw3U'></tfoot>

        <i id='fRw3U'><tr id='fRw3U'><dt id='fRw3U'><q id='fRw3U'><span id='fRw3U'><b id='fRw3U'><form id='fRw3U'><ins id='fRw3U'></ins><ul id='fRw3U'></ul><sub id='fRw3U'></sub></form><legend id='fRw3U'></legend><bdo id='fRw3U'><pre id='fRw3U'><center id='fRw3U'></center></pre></bdo></b><th id='fRw3U'></th></span></q></dt></tr></i><div id='fRw3U'><tfoot id='fRw3U'></tfoot><dl id='fRw3U'><fieldset id='fRw3U'></fieldset></dl></div>
      2. Kivy 使用 opencv.调整图像大小

        时间:2023-10-10

        <tfoot id='4UJ1q'></tfoot>

        <small id='4UJ1q'></small><noframes id='4UJ1q'>

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

              • <bdo id='4UJ1q'></bdo><ul id='4UJ1q'></ul>
                  <tbody id='4UJ1q'></tbody>
                • <legend id='4UJ1q'><style id='4UJ1q'><dir id='4UJ1q'><q id='4UJ1q'></q></dir></style></legend>
                  本文介绍了Kivy 使用 opencv.调整图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想在 kivy 中插入一个 opencv 网络摄像头视频.不幸的是,当我这样做并最大化窗口时,图像不会调整到屏幕尺寸.有没有办法做到这一点?

                  I want to insert an opencv webcam video in kivy. Unfortunately, when I do this and maximize the window the image does not adjust to the screen size. Is there any way to do this ?

                  from kivy.app import App
                  from kivy.uix.image import Image
                  from kivy.clock import Clock
                  from kivy.graphics.texture import Texture
                  import cv2
                  
                  from kivy.uix.boxlayout import BoxLayout
                  from kivy.uix.gridlayout import GridLayout
                  from kivy.uix.widget import Widget
                  from kivy.uix.button import Button
                  from kivy.lang import Builder
                  from kivy.core.window import Window
                  Window.size=(1000,1000)
                  
                  
                  class KivyCamera(Image):
                      def __init__(self, capture, fps, **kwargs):
                          super(KivyCamera, self).__init__(**kwargs)
                          self.capture = capture
                          Clock.schedule_interval(self.update, 1.0 / fps)
                  
                      def update(self, dt):
                          ret, frame = self.capture.read()
                          if ret:
                              buf1 = cv2.flip(frame, 0)
                              buf = buf1.tostring()
                              image_texture = Texture.create(size=(frame.shape[1], frame.shape[0]), colorfmt='rgb')#(480,640)
                              image_texture.blit_buffer(buf, colorfmt='bgr', bufferfmt='ubyte')
                              # display image from the texture
                              self.texture = image_texture
                  
                  
                  class CamApp(App):
                      def build(self):
                          self.camera= cv2.VideoCapture(2)
                          self.my_camera = KivyCamera(capture=self.camera, fps=10,resolution=(1280,960))
                          return self.my_camera
                  
                      def on_stop(self):
                          self.camera.release()
                  
                  
                  if __name__ == '__main__':
                      CamApp().run()
                  

                  我希望当窗口大小增加时框架的大小也会增加.当我尝试更改 Texture 中的大小时,它给了我错误.喜欢要么显示奇怪的图像,要么不打开任何窗口.如果有人可以提供帮助,那就太好了.谢谢 !

                  I am hoping that the size of the frame increases when winow size increases. When I try to change the size in Texture it gives me error. Like either shows weird images or does not open any window. It would be great if somebody could help . Thanks !

                  推荐答案

                  你可以这样做:将类类型更改为 BoxLayout.使用 size_hint=(1,1) 将图像小部件添加到 Boxlayout.在 init 中使用大小绑定,如下所示:

                  you can do this: change the class type to BoxLayout. adding Image widget to Boxlayout with size_hint=(1,1). use size binding in init like this:

                  self.image = Image(size_hint=(1,1))
                  self.add_widget(self.image)
                  self.binding(size=self.Updatesize,
                               pos=self.Updatesize)
                  

                  并像这样在你的类中定义一个函数:

                  and define a function in your class like this:

                  def Updatesize(*args):
                     self.image.size=self.size
                     self.image.pos=self.pos
                  

                  这篇关于Kivy 使用 opencv.调整图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 __init__ word=self.search_box.text AttributeError: 'N 下一篇:Kivy标签中的文本下划线?

                  相关文章

                  最新文章

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

                    <legend id='eeF00'><style id='eeF00'><dir id='eeF00'><q id='eeF00'></q></dir></style></legend>

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

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