如题,我import pygame and cv2 想在一个gui接口中放置一个摄影画面
可是不知道哪边需要更改
以下是影像程式的片段 求救!!!
w, h = 200, 150
cap = cv2.VideoCapture(0)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, w)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, h)
def get_img():
retval,image=cap.read()
return image
for i in range(100):
image=get_img()
def camera_frame():
frame = cv2.flip(image, 1)
cv2image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)
img = Image.fromarray(cv2image)
return img
class PiTft(ui.Scene):
def __init__(self):
ui.Scene.__init__(self)
im = camera_frame()
pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode)
self.preview = ui.ImageView(ui.Rect(MARGIN, MARGIN, 200, 150), pg_img)
self.add_child(self.preview)