Ask Your Question
0

How to capture video for particular time for example 10 seconds with simpleCV

asked 2014-06-09 02:27:19 -0600

jjoshi gravatar image

If this is the code how can i capture video for for 10 seconds and perform the given task

from SimpleCV import *

cam = Camera()
threshold = 5.0 # if mean exceeds this amount do something

while True:
        previous = cam.getImage() #grab a frame
        time.sleep(0.5) #wait for half a second
        current = cam.getImage() #grab another frame
        diff = current - previous
        matrix = diff.getNumpy()
        mean = matrix.mean()

        diff.show()

        if mean >= threshold:
                print "Motion Detected"
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-06-14 09:43:17 -0600

kendallv gravatar image

updated 2014-06-14 09:43:44 -0600

How about using the standard Python time library? Google is your friend if you don't know how Python works.

from SimpleCV import *
import time

cam = Camera()
threshold = 5.0 # if mean exceeds this amount do something
time_start = time.time()

while time.time() - time_start < 10:
    previous = cam.getImage() #grab a frame
    time.sleep(0.5) #wait for half a second
    current = cam.getImage() #grab another frame
    diff = current - previous
    matrix = diff.getNumpy()
    mean = matrix.mean()

    diff.show()

    if mean &gt;= threshold:
            print "Motion Detected"
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-06-09 02:27:19 -0600

Seen: 380 times

Last updated: Jun 14 '14