Exemplo n.º 1
0
while True:
  # check to see if we should stop
  if max_frames:
    if t > max_frames:
      break
  # capture the next frame
  frame = ocv.cvQueryFrame(cap)
  # if we've reached the end of the video
  if frame is None:
    break

  if t>=(max_frames-NUM_FRAMES):
 
    # Convert to floating point
    ocv.cvConvert(frame,working)
 
    # Smooth it to remove artifacts
    ocv.cvSmooth(working,working,ocv.CV_GAUSSIAN,3,3,0.5)

    # Add to accumulator
    ocv.cvAcc(working,accumulator)

    # Divide accumulator my number of frames for mean background
    ocv.cvDiv(accumulator,ones,background,1.0/n)

    # Convert background to target (for viewing/saving)
    ocv.cvConvert(background,target)
 
    # Increment accumulator divisor
    n += 1
Exemplo n.º 2
0
# 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) 
masked = 	ocv.cvCreateImage(frame_size,8,1) 
  
#mask = ocv.cvLoadImage(maskname,0)
backgray = ocv.cvLoadImage(backname,0) 
#print back
#print frame_size.width, frame_size.height 
#ocv.cvConvertImage(back,backgray)
ocv.cvConvert(backgray,background)

if show:
  ocv.cvNamedWindow ('Track', ocv.CV_WINDOW_AUTOSIZE)
  ocv.cvMoveWindow ('Track', 100, 100)
  font = ocv.cvInitFont(None,ocv.CV_FONT_HERSHEY_PLAIN, 1.0, 1.0, 0, 1, 8)

#######################################

tracks = open(trackname,'w')

targets = []
for i in range(ntargets):
  targets.append([0.0,0.0,0.0,0.0,0.0,0.0,0.0])

while True: