Python 属性错误:';kivy.properties.ObjectProperty';对象没有属性
我尝试将纹理放入图像中,但出现了这个错误。python似乎无法从图像中获取此阿斯巴布丁,但它应该这样做。对不起,英语不好 这是我的kv.py文件Python 属性错误:';kivy.properties.ObjectProperty';对象没有属性,python,kivy,Python,Kivy,我尝试将纹理放入图像中,但出现了这个错误。python似乎无法从图像中获取此阿斯巴布丁,但它应该这样做。对不起,英语不好 这是我的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 ObjectPrope
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()
这是我的camman.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
:
色调
饱和:饱和
价值:价值
cam1:cam1
方向:“垂直”
网格布局:
科尔斯:2
盒子布局:
方向:“垂直”
间距:20
填充:25
图片:
身份证号码:cam1
大小:self.texture\u大小
App.get_running_App().root.cam1.texture=纹理
AttributeError:'kivy.properties.ObjectProperty'对象没有属性'texture'我只需将cam1=ObjectProperty(无)移动到init之外