Package pyvision :: Package surveillance :: Module optical_flow :: Class OpticalFlow
[hide private]
[frames] | no frames]

Class OpticalFlow

source code

This class tracks the motion of the camera. This can be used for things like video stablization or to better understand camera motion across multiple frames.

This uses the LK optical flow algorithm to track point correspondences from one frame to another.

It can output the frame to frame camera motion as a homography.

Instance Methods [hide private]
 
__init__(self, tile_size='ORIG')
Create the camera tracker
source code
 
update(self, frame)
This tracks the points_b to the next frame using the LK tracker.
source code
 
_selectTrackingPoints(self, frame)
This uses the OpenCV get good features to track to initialize a set of tracking points_b.
source code
list of pv.Point()
_opticalFlow(self)
Compute the optical flow between frames using cv.CalcOpticalFlow
source code
 
asHomography(self, forward=True)
Get the transformation as a homography.
source code
 
annotateFrame(self, frame, color='white')
Renders optical flow information to the frame.
source code
Method Details [hide private]

__init__(self, tile_size='ORIG')
(Constructor)

source code 

Create the camera tracker

Parameters:
  • tile_size - Frames will be resized to these dimensions before tracking.

update(self, frame)

source code 

This tracks the points_b to the next frame using the LK tracker. Add more good points_b to track.

Parameters:
  • frame (pv.Image) - update optical flow for the frame.

_opticalFlow(self)

source code 

Compute the optical flow between frames using cv.CalcOpticalFlow

Returns: list of pv.Point()
a list of tracks for the new image

asHomography(self, forward=True)

source code 

Get the transformation as a homography.

Parameters:
  • forward - switch between the forward and reverse transform.

annotateFrame(self, frame, color='white')

source code 

Renders optical flow information to the frame.

Parameters:
  • frame (pv.Image) - the frame that will be annotated
  • type