我目前正在尝试使用python的驾驶员嗜睡检测项目,直到现在它还可以检测到昏昏欲睡,我想在10秒后播放一个声音,如果它持续显示昏昏欲睡。我怎么编程序呢?
发布于 2022-04-06 23:17:16
当条件变为真时,启动一个性能定时器。条件为false后,将start设置为False。如果性能定时器达到10秒,播放声音。可能是这样的:
import time
start = False
while True:
if condition and not start:
start = time.perf_counter()
if not condition:
start = False
if start > 10:
start = False
playsound("my_sound.mp3", block=False)https://stackoverflow.com/questions/71774538
复制相似问题