Histograms of Optical Flow¶
Annotator to extract dense Optical Flow.
Uses the opencv Gunnar Farneback’s algorithm and represent it as a histogram of optical flow orientation and magnitude (HOFM).
-
class
dvt.annotate.hofm.HOFMAnnotator(**kwargs)[source]¶ Bases:
dvt.abstract.FrameAnnotatorAnnotator to extract dense Optical Flow using the opencv Gunnar Farneback’s algorithm and represent it as a histogram of optical flow orientation and magnitude (HOFM).
The annotator will return the optical flow describing the motion in two subsequent frames as a HOFM feature.
-
freq¶ How often to perform the embedding. For example, setting the frequency to 2 will computer every other frame in the batch.
Type: int
-
blocks¶ How many spatial blocks to divide the frame in, in each dimension. Default is 3, which results in 9 spatial blocks.
Type: int
-
mag_buckets¶ List of bounds for magnitude buckets. Default is [0, 20, 40, 60, 80, 100].
Type: list of ints
-
ang_buckets¶ List of bounds for angle buckets. Default is [0, 45, 90, 135, 180, 225, 270, 315, 360].
Type: list of ints
-
frames¶ An optional list of frames to process. This should be a list of integers or a 1D numpy array of integers. If set to something other than None, the freq input is ignored.
Type: array of ints
-
name¶ A description of the aggregator. Used as a key in the output data.
Type: str
-
annotate(batch)[source]¶ Annotate the batch of frames with the optical flow annotator.
Parameters: batch (FrameBatch) – A batch of images to annotate. Returns: A list of dictionaries containing the video name, frame, and the HOFM optical flow representation of length (len(blocks) * len(blocks) * len(mag_buckets) * len(ang_buckets))
-
name= 'hofm'
-