第1部分: 我正在运行一个Python脚本,使用cv2将视频从网络摄像头保存到pendrive。在
import cv2,os
dypa = ('/media/pi/PSYCH') #specify the absolute output path here
fnam1 = 'output.avi' #specify the output file name here
fnam2 = 'output1.avi'
dypa1 = os.path.join(dypa,fnam1)
dypa2 = os.path.join(dypa, fnam2)
if __name__ == "__main__":
# find the webcam
capture = cv2.VideoCapture(0)
capture1 = capture
# video recorder
fourcc = cv2.cv.CV_FOURCC(*'XVID')
videoOut = cv2.VideoWriter(dypa1, fourcc, 10.0, (640, 480))
videoOut1 = cv2.VideoWriter(dypa2, fourcc, 10.0, (640, 480))
# record video
while (capture.isOpened() and capture1.isOpened()):
ret, frame = capture.read()
ret1, frame1 = capture1.read()
if ret:
videoOut.write(frame)
else:
break
if ret1:
frame1 = cv2.flip(frame1,1)
videoOut1.write(frame1)
else:
break
# Tiny Pause
key = cv2.waitKey(1)
capture1.release()
videoOut1.release()
capture.release()
videoOut.release()
cv2.destroyAllWindows()
如果我知道pendrive的名字(“/media/pi/PSYCH”),我就能做到这一点。但是我把命令放在bash文件中
sudo nano /etc/rc.local
并补充道
^{pr2}$以便在启动时执行。在
当我重新启动时,仍然存在一个
/media/pi/PSYCH
但现在无法进入pendrive
/media/pi/PSYCH1
一。下一次重新启动,它位于/media/pi/PSYCH2,依此类推。在
附言:我用的是Rasberry Pi3和Raspbian Jessie
解决方案:
在代码中,我注释掉了所有显示交互。 我还评论了
key = cv2.waitKey(1)
我在中编辑了命令rc.本地到
然后我在代码.py使用库文件
^{pr2}$然后写一个
这就给了pendrive和相机安装的时间,这就造成了心理问题。在
相关问题 更多 >
编程相关推荐