到目前为止,我已经设法开始拍照,但我现在想要一个按钮来终止游戏中时光倒流——我已经尝试了很多方法,包括 .kill() 和 .terminate() 但无法正常工作。
这是我当前的 python 代码:
import sys, os, time, datetime
import subprocess
import signal
from time import sleep
tlfreq = int(sys.argv[1])
tltime = int(sys.argv[2])
dir = '/var/www/timelapse/' + sys.argv[3]
if not os.path.exists(dir):
os.makedirs(dir)
cmd = ('raspistill -t ' + str(tltime) + " -tl " + str(tlfreq) + " -o " + dir + "/photo_%04d.jpg")
pro = subprocess.Popen(cmd, stdout=subprocess.PIPE,
shell=True, preexec_fn=os.setsid)
print "Pictures are now being taken every" , tlfreq/1000 , "second/s for a total of", tltime/3600000 , "hours. These are being stored in", dir
也许我需要一个“if variable = 1 then kill”命令,然后将变量发送给 python。
如有任何帮助,我们将不胜感激!
非常感谢, 丹
最佳答案
您可以使用此代码创建新的 python 脚本 kill_raspystill.py
import os
os.system("pkill raspistill")
并在您按下按钮时调用该脚本。
关于python - 树莓派 : terminate raspistill command from python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18825899/