- 
      
- 
        Save tstellanova/7453398 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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