简体   繁体   English

AttributeError: 'kivy.properties.ObjectProperty' 对象没有属性

[英]AttributeError: 'kivy.properties.ObjectProperty' object has no attribute

I try to put texture into Image but get this error.我尝试将纹理放入 Image 中,但出现此错误。 It seems python not able to get this atribute from Image, but it should.似乎 python 无法从 Image 获取此属性,但它应该。 Sorry for bad English抱歉英语不好

this is my kv.py file这是我的 kv.py 文件

import cv2
import kivy
import numpy as np
from kivy.app import App
from kivy.core.image import Texture
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty
from kivy.clock import Clock
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
import SliderTest

class Wrapper(BoxLayout):
    def __init__(self, **kwargs):
        super(Wrapper, self).__init__(**kwargs)
        self.cam1 = ObjectProperty(None)


class CamMain(App):
    def build(self):
        Clock.schedule_interval(self.update, 1.0 / 33.0)
        self.capture = cv2.VideoCapture(0)
        return Wrapper()

    def update(self, dt):
        _, frame = self.capture.read()
        texture = Texture.create(size=(frame.shape[1], frame.shape[0]), colorfmt='bgr')
        result = cv2.flip(frame, 0)
        texture.blit_buffer(result.tostring(), colorfmt='bgr', bufferfmt='ubyte')
        App.get_running_app().root.cam1.texture = texture


if __name__ == "__main__":
    CamMain().run()

this is my CamMain.kv file这是我的 CamMain.kv 文件

<Wrapper>:
    hue: hue
    saturation: saturation
    value:value
    cam1:cam1
    orientation: 'vertical'

    GridLayout:
        cols:2

        BoxLayout:
            orientation: 'vertical'
            spacing:20
            padding:25
            Image:
                id:cam1
                size: self.texture_size

App.get_running_app().root.cam1.texture = texture AttributeError: 'kivy.properties.ObjectProperty' object has no attribute 'texture' App.get_running_app().root.cam1.texture = 纹理 AttributeError: 'kivy.properties.ObjectProperty' 对象没有属性 'texture'

我只需要在init之外移动 cam1 = ObjectProperty(None)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError:“ kivy.properties.ObjectProperty”对象没有属性“ text” - AttributeError: 'kivy.properties.ObjectProperty' object has no attribute 'text' &#39;kivy.properties.ObjectProperty&#39; 对象没有属性 &#39;text&#39; - 'kivy.properties.ObjectProperty' object has no attribute 'text' AttributeError: 'kivy.properties.ObjectProperty' object 没有属性 'background_normal' - AttributeError: 'kivy.properties.ObjectProperty' object has no attribute 'background_normal' Python Kivy 错误:'kivy.properties.ObjectProperty' object 没有属性文本 - Python Kivy error: 'kivy.properties.ObjectProperty' object has no attribute text Python / kivy-TypeError:“ kivy.properties.ObjectProperty”对象不可迭代 - Python/kivy - TypeError: 'kivy.properties.ObjectProperty' object is not iterable Kivy AttributeError: object 没有属性 - Kivy AttributeError: object has no attribute Kivy:AttributeError:&#39;...&#39;对象没有属性&#39;...&#39;,但它有 - Kivy: AttributeError: '...' object has no attribute '...', but it has AttributeError:&#39;NoneType&#39;对象没有属性&#39;text&#39;kivy - AttributeError: 'NoneType' object has no attribute 'text' kivy Kivy AttributeError: 'NoneType' object 没有属性 'current' - Kivy AttributeError: 'NoneType' object has no attribute 'current' Kivy - AttributeError: 'DialogContent' object 没有属性 'manager' - Kivy - AttributeError: 'DialogContent' object has no attribute 'manager'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM