Frame Difference Annotations

Annotators for finding difference between subsequent frames.

The annotator implemented here detects differences from one frame to the next. It also collects summaries of the overall brightness and saturation of a frame. These are all useful for detecting shot boundaries and scene breaks.

class dvt.annotate.diff.DiffAnnotator(**kwargs)[source]

Bases: dvt.abstract.FrameAnnotator

Annotator for detecting differences between frames.

The annotator will return data for each frame in a given batch by showing how much a frame differs compares to the next one. It computes two kinds of differences. The first down samples the image to a small square and takes pixel-by-pixel differences between the frames. The second computes a histogram in HSV space and compares the histogram counts between frames. Results for both are given by taking quantiles of the differences. The histogram differences are normalized to account for comparisons across different image sizes.

Additionally, the average value (darkness) of each frame is provided to assist with putting the differences in context.

quantiles

A list of integers or floats giving the quantiles to return. Set to None to only return the average value of each frame. Inputs are given as percentiles, so [50] will return the median.

Type:list
size

Side length of the square that the image will be downsampled to for the pixel-by-pixel comparison.

Type:int
bins

How many bins to include in the histogram differences. Will make this many bins for each of hue, saturation, and value.

Type:int
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 difference annotator.

Parameters:batch (FrameBatch) – A batch of images to annotate.
Returns:A list of dictionaries containing the video name, frame, average value, and any requested quantile and histogram differences.
name = 'diff'