我使用Raspberry Pi 3使用SimpleCV检测运动,然后检测到运动时应该拍摄图像。我正在使用USB相机。这是我正在使用的代码:使用SimpleCV运动检测捕获运动图像
from SimpleCV import *
import os
cam = Camera()
threshold = 5.0 # if mean exceeds this amount do something
while True:
previous = cam.getImage() #grab a frame
time.sleep(0.5) #wait for half a second
current = cam.getImage() #grab another frame
diff = current - previous
matrix = diff.getNumpy()
mean = matrix.mean()
if mean >= threshold:
time.sleep(2)
os.popen("fswebcam -d /dev/video0 -r 352x280
/home/pi/Desktop/image.jpg")
print "Motion Detected"
当检测到运动时,它会打印“运动检测”,以便运行,但不会拍摄图像。我试着在终端上运行fswebcam -d/dev/video0 -r 352x280 /home/pi/Desktop/image.jpg,它工作正常。另外,当我运行代码自己在python中获取图像时,它也起作用,但是在if语句中它不起作用。我试图从终端运行程序,并再次运动检测的作品,但我得到这个错误:错误 选择输入0 VIDEO_S_Input:设备或资源忙
这里有什么问题吗?