NUM_FRAMES = 1000 # number of frames to integrate FROM END ####################################### # Log file #if log: # logfile = open("/opt/ibehave/log/scripts.log",'w') # TODO: better logging! # print >> logfile, "-----------------> Model Background" # print >> logfile, invideofile # print >> logfile, background ####################################### # open the video cap = ocv.cvCreateFileCapture(invideofile) # extract the number of frames max_frames = ocv.cvGetCaptureProperty(cap,ocv.CV_CAP_PROP_FRAME_COUNT) # interrogate the first frame to get the size frame = ocv.cvQueryFrame(cap) frame_size = ocv.cvGetSize(frame) working = ocv.cvCreateImage(frame_size,ocv.IPL_DEPTH_32F,3) accumulator = ocv.cvCreateImage(frame_size,ocv.IPL_DEPTH_32F,3) background = ocv.cvCreateImage(frame_size,ocv.IPL_DEPTH_32F,3) ones = ocv.cvCreateImage(frame_size,ocv.IPL_DEPTH_32F,3) target = ocv.cvCloneImage(frame) # Set divisor image all to one ocv.cvSet(ones,ocv.cvScalar(1.0,1.0,1.0,0))
min_width = 10 min_height = 10 min_area = min_width*min_height # max thresholds max_width = 30 max_height = 45 max_area = max_width * max_height # values for dynamics smallmove = 0.2 # fraction of length anglefrom = pi*0.33 # angles of turning angleto = pi*0.66 ####################################### # open the video cap = ocv.cvCreateFileCapture(filename) # extract the number of frames max_frames = ocv.cvGetCaptureProperty(cap,ocv.CV_CAP_PROP_FRAME_COUNT) # interrogate the first frame to get the size t = 1 frame = ocv.cvQueryFrame(cap) frame_size = ocv.cvGetSize(frame) # create some temporary frames gray = ocv.cvCreateImage(frame_size,8,1) #backgray = ocv.cvCreateImage(frame_size,8,1) grayfloat = ocv.cvCreateImage(frame_size,ocv.IPL_DEPTH_32F,1) background = ocv.cvCreateImage(frame_size,ocv.IPL_DEPTH_32F,1) ones = ocv.cvCreateImage(frame_size,ocv.IPL_DEPTH_32F,1) thresh = ocv.cvCreateImage(frame_size,8,1) output = ocv.cvCloneImage(frame)