예제 #1
0
 
    # 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

  # Increment frame
  t += 1

  if show: 
    ocv.cvShowImage ('Track', target)
    # Break if ESC
    if ocv.cvWaitKey (5) & 255 == 27:
      break
  
ocv.cvSaveImage(outimagefile,target)

예제 #2
0
        pastx = xpos
        pasty = ypos
      if at==1:
        colour = ocv.CV_RGB(255,255,0)
        ocv.cvLine(output, ocv.cvPoint(xpos,ypos), ocv.cvPoint(pastx,pasty),ocv.CV_RGB(0,0,0),1)
        dbetween = sqrt((xpos-pastx)**2 + (ypos-pasty)**2) 
        ocv.cvPutText(output, str(round(dbetween,2)), ocv.cvPoint(int((xpos+pastx)/2),int((ypos+pasty)/2)), font, ocv.CV_RGB(0,0,0));
      #if ang<-2*pi or ang>0.0:
      #  print "Watch out! Angle outside of bounds: " + str(ang)
      x = -axis # NOTE: negative x axis for drawing!   
      y = 0  
      tox = x*cos(ang)+y*sin(ang)
      toy = x*-sin(ang)+y*cos(ang)
      tox += xpos # translate
      toy += ypos
      ocv.cvLine(output, ocv.cvPoint(xpos,ypos), ocv.cvPoint(tox,toy), colour,2)
      ocv.cvCircle(output, ocv.cvPoint(tox,toy),4,colour,ocv.CV_FILLED)
      ocv.cvPutText(output, str(round(-ang,2)), ocv.cvPoint(xpos+10,ypos), font, ocv.CV_RGB(0,0,0));
    at += 1
  print >> tracks

  # Increment frame
  t += 1
 
  if show:
    ocv.cvShowImage ('Track', output)
    # Break if ESC
    if ocv.cvWaitKey (5) & 255 == 27:
      break