在树莓派

时间:2018-10-09 10:47:00

标签: python opencv cv2

import numpy as np
import cv2
import os
import time
import datetime
from threading import Timer
from threading import Thread

def showVideo(capl, secs):
    time.sleep(secs)
    try:
        print("start video")
        while(capl.isOpened()):
            ret, frame = capl.read()
            cv2.namedWindow('frames', cv2.WND_PROP_FULLSCREEN)
            cv2.setWindowProperty('frames', cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
            try:
                cv2.imshow('frames',frame)
                print("imshow")
            except:
                break

            if cv2.waitKey(50) & 0xFF == ord('q'):
                break

        capl.release()
        cv2.destroyAllWindows()
        print("End video")

    except Exception as e:
        print(e)

def bootProgramm():
    fileList = os.listdir('source/')
    getLength = len(fileList)
    i= 0
    print(fileList)
    while (i <= (getLength - 1)):
        print(fileList[i])
        #secs = 10
        #print(secs)

        x=datetime.datetime.now()
        y=x.replace(year=2018, month=10, day=9, hour=14, minute=(46+i), second=0, microsecond=0)
        delta_t = y - x
        secs = delta_t.seconds+1

        capl = cv2.VideoCapture('source/'+fileList[i])
        #showVideo(capl, secs)
        Thread(target = showVideo, args = (capl, secs)).start()    
        #Timer(secs, showVideo, [capl]).start()
        i=i+1


bootProgramm()

这是代码。仅显示第一个视频,我没有看到任何错误。为什么它不能在树莓派中工作?相同的程序在Windows中可以正常运行,但在树莓派中则不能。有人知道为什么吗?请帮助,我被困了很多天。谢谢。

0 个答案:

没有答案