I've been trying to use the SimpleCV (www.simplecv.org) module to run image recognition and manipulation. Unfortunately, my incoming video feed has been quite finicky, and I'm not sure what I did wrong. Just using some basic sample code:
import cvwindow = cv.NamedWindow("camera", 1开发者_JAVA技巧)
capture = cv.CreateCameraCapture(0)
width = int(cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_WIDTH))
height = int(cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_HEIGHT))
while 1:
img = cv.QueryFrame(capture)
cv.ShowImage("camera", img)
k = cv.WaitKey(1)
if(k == 102):
cv.destroyWindow("camera")
break
Which works perfectly when I plug in my Logitech Webcam 500. However, when I attempt to use my Vimicro Altair camera, I get a grey screen, and when saving to file, the file is empty.
I also attempted to use SimpleCV code, based off their cookbook along the lines of:
mycam = Camera()
img = mycam.getImage()
which was equally unsuccessful, however instead of returning no data, simply returned an image that was completely black.
I'm at quite a loss of what is causing this, I tried the exact same system on my laptop, which failed to even get an image from the Logitech cam. I'm running Windows 7 64-bit with Python 2.7 and SimpleCV 1.1.
Thanks
I'm one of the SimpleCV developers. It appears you are trying to use the standard python openCV wrapper.
What I recommend doing is just run the example here: https://github.com/sightmachine/SimpleCV/blob/develop/SimpleCV/examples/display/simplecam.py
Or here is the code as well:
import time, webbrowser
from SimpleCV import *
#create JPEG streamers
js = JpegStreamer(8080)
cam = Camera()
cam.getImage().save(js)
webbrowser.open("http://localhost:8080", 2)
while (1):
i = cam.getImage()
i.save(js)
time.sleep(0.01) #yield to the webserver
精彩评论