SimpleCV 相机提要不可靠
SimpleCV camera feed unreliable
当我尝试使用相机时,大约有 2/3 的时间它不工作,只显示黑屏,但是另外 1/3 的时间它可以工作并显示图像。
from SimpleCV import *
cam = Camera()
disp = Display()
findFace = HaarCascade("face")
while disp.isNotDone():
img = cam.getImage()
face = img.findHaarFeatures(findFace)
if face:
face.draw()
bb = face[-1].boundingBox()
txt1 = str(bb[0])
txt2 = str(bb[1])
txt3 = str(bb[2])
txt4 = str(bb[3])
text = txt1+" "+txt2+" "+txt3+" "+txt4
img.drawText(text)
img.save(disp)
我试过其他代码,它总是这样对我。我也知道我的网络摄像头是开着的,因为它的灯是亮着的。
当我关闭图像时 window 它会抛出这些错误,尽管只有当我关闭它时才出现
Traceback (most recent call last):
File "C:/Python27/MyTryFace", line 7, in <module>
while disp.isNotDone():
File "C:\Python27\lib\site-packages\SimpleCV\Display.py", line 672, in isNotDone
return not self.isDone()
File "C:\Python27\lib\site-packages\SimpleCV\Display.py", line 650, in isDone
self.checkEvents()
File "C:\Python27\lib\site-packages\SimpleCV\Display.py", line 615, in checkEvents
pressed = pg.key.get_pressed()
error: video system not initialized
我发现在 while 循环开始之前添加 img = cam.getImage()
可以解决我的不可靠性问题。 (这也会在 while 循环中再次出现)
当我尝试使用相机时,大约有 2/3 的时间它不工作,只显示黑屏,但是另外 1/3 的时间它可以工作并显示图像。
from SimpleCV import *
cam = Camera()
disp = Display()
findFace = HaarCascade("face")
while disp.isNotDone():
img = cam.getImage()
face = img.findHaarFeatures(findFace)
if face:
face.draw()
bb = face[-1].boundingBox()
txt1 = str(bb[0])
txt2 = str(bb[1])
txt3 = str(bb[2])
txt4 = str(bb[3])
text = txt1+" "+txt2+" "+txt3+" "+txt4
img.drawText(text)
img.save(disp)
我试过其他代码,它总是这样对我。我也知道我的网络摄像头是开着的,因为它的灯是亮着的。
当我关闭图像时 window 它会抛出这些错误,尽管只有当我关闭它时才出现
Traceback (most recent call last):
File "C:/Python27/MyTryFace", line 7, in <module>
while disp.isNotDone():
File "C:\Python27\lib\site-packages\SimpleCV\Display.py", line 672, in isNotDone
return not self.isDone()
File "C:\Python27\lib\site-packages\SimpleCV\Display.py", line 650, in isDone
self.checkEvents()
File "C:\Python27\lib\site-packages\SimpleCV\Display.py", line 615, in checkEvents
pressed = pg.key.get_pressed()
error: video system not initialized
我发现在 while 循环开始之前添加 img = cam.getImage()
可以解决我的不可靠性问题。 (这也会在 while 循环中再次出现)