When I try to use the camera approximately 2/3rds of the time it doesn't work, just shows a black screen, however the other 1/3rd of the time it does work and shows an image.
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)
I've tried other codes and it always does this to me. I also know my webcam is on, as the light for it is on.
When I close the image window it throws these errors, though it's only when I close it
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
I found that adding img = cam.getImage()
before the while loop began would fix my unreliability issue. (this will also appear again withing the while loop)