Skip to content

Instantly share code, notes, and snippets.

@mike-lawrence
Created May 7, 2012 16:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mike-lawrence/2628805 to your computer and use it in GitHub Desktop.
Save mike-lawrence/2628805 to your computer and use it in GitHub Desktop.
comparing openCV vs SimpleCV capture performance
import cv
import time
tolerance = 2
webcam_stream = cv.CaptureFromCAM(0)
print cv.GetCaptureProperty(webcam_stream,cv.CV_CAP_PROP_FPS)
print cv.GetCaptureProperty(webcam_stream,cv.CV_CAP_PROP_FRAME_WIDTH)
print cv.GetCaptureProperty(webcam_stream,cv.CV_CAP_PROP_FRAME_HEIGHT)
start = time.time()
images = []
while (time.time()-start)<1:
this_image = cv.QueryFrame(webcam_stream)
this_image_time = time.time()
images.append([this_image,this_image_time])
print(len(images))
i = 0
last_image_time = images[0][1]
for j in range(len(images)-1):
last_image = images[j][0]
this_image = images[j+1][0]
diff = cv.CloneImage(this_image)
cv.AbsDiff(this_image,last_image,diff)
if cv.Avg(diff)>tolerance:
i = i + 1
print [i,images[j+1][1]-last_image_time]
last_image_time = images[j+1][1]
import SimpleCV
import numpy
import time
tolerance = 2
webcam_stream = SimpleCV.Camera(0)
print webcam_stream.getAllProperties()
start = time.time()
images = []
while (time.time()-start)<1:
images.append([webcam_stream.getImage(),time.time()])
time.sleep(0.001)
print(len(images))
i = 0
last_image_time = images[0][1]
for j in range(len(images)-1):
image1 = images[j]
image2 = images[j+1]
diff = (image1[0]-image2[0])
if (numpy.average(diff.getNumpy()))>tolerance:
i = i + 1
print [i,image2[1]-last_image_time]
last_image_time = image2[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment