Cron job Issue in raspberry-pi

半腔热情 提交于 2020-01-05 08:26:27

问题


from time import sleep
import datetime
import os
import shutil
import cv2
from filename import opvideo


## Adding New Directory
path= '/home/pi/Desktop/teasr/input-video'+opvideo
os.makedirs(path)
path1= '/home/pi/Desktop/teasr/input-image'+opvideo
os.makedirs(path1)
os.makedirs('/home/pi/Desktop/teasr/output-video'+opvideo)


#######capturing

cap = cv2.VideoCapture(0)

# Define the codec and create VideoWriter object
fourcc = cv2.cv.CV_FOURCC(*'XVID')
out = cv2.VideoWriter('/home/pi/Desktop/teasr/input-video'+opvideo+ '/video.h264',fourcc, 15.0, (640,480))
i=0
while(cap.isOpened()):
    ret, frame = cap.read()
    if ret==True:

        # write the flipped frame
        out.write(frame)
        cv2.imshow('frame',frame)
        i=i+1
        if cv2.waitKey(1) & i>160:
            cap.release()
            out.release()
            cv2.destroyAllWindows()
            break
    else:
        break
`

I am looking to run my code after every 10 minutes using cron job. But whenever i my code running it is not capturing video but it is making directory.I am using USB camera for making video. If i am running my code in terminal every thing looks fine and camera is also working. But at cron job it is not working properly.Please help me out to run my full code using cron job.My main purpose is to make video after every 10 mintues when raspberry pi gets switched on. Hoping that someone may help.

来源:https://stackoverflow.com/questions/47090354/cron-job-issue-in-raspberry-pi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!