Struct cv::Animation#

Represents an animation with multiple frames. The Animation struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP). It provides support for looping, background color settings, frame timing, and frame storage.

Collaboration diagram for cv::Animation:

cv::Animation Node1 cv::Animation   + Animation() Node2 int     Node2->Node1 +loop_count Node13 std::vector< int >     Node2->Node13 +elements Node17 cv::Mat   + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() and 152 more... + diag() + eye() + eye() + getDefaultAllocator() + getStdAllocator() + ones() + ones() + ones() + ones() + setDefaultAllocator() + zeros() + zeros() + zeros() + zeros() # forEach_impl() Node2->Node17 +cols +dims +dummy +flags +rows Node3 cv::Scalar_< double >   + Scalar_() + Scalar_() + Scalar_() + Scalar_() + Scalar_() + Scalar_() + conj() + isReal() + mul() + operator Scalar_< T2 >() + operator=() + operator=() + all() Node3->Node1 +bgcolor Node4 cv::Vec< double, 4 >   + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() and 17 more... + all() + diag() + eye() + ones() + randn() + randu() + zeros() Node4->Node3 Node5 cv::Matx< double, cn, 1 >   + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() and 33 more... + all() + diag() + eye() + ones() + randn() + randu() + zeros() Node5->Node4 Node6 double     Node6->Node5 +val Node7 cv::Matx< _Tp, m, n >   + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() and 33 more... + all() + diag() + eye() + ones() + randn() + randu() + zeros() Node7->Node5 < double, cn, 1 > Node10 cv::Matx< _Tp, cn, 1 >   + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() and 33 more... + all() + diag() + eye() + ones() + randn() + randu() + zeros() Node7->Node10 < _Tp, cn, 1 > Node8 _Tp     Node8->Node7 +val Node8->Node10 +val Node9 cv::Vec< _Tp, cn >   + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() and 17 more... + all() + diag() + eye() + ones() + randn() + randu() + zeros() Node9->Node4 < double, 4 > Node12 cv::Vec< _Tp, 4 >   + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() and 17 more... + all() + diag() + eye() + ones() + randn() + randu() + zeros() Node9->Node12 < _Tp, 4 > Node10->Node9 Node10->Node12 Node11 cv::Scalar_< _Tp >   + Scalar_() + Scalar_() + Scalar_() + Scalar_() + Scalar_() + Scalar_() + conj() + isReal() + mul() + operator Scalar_< T2 >() + operator=() + operator=() + all() Node11->Node3 < double > Node12->Node11 Node13->Node1 +durations Node14 std::vector< T >     Node14->Node13 < int > Node16 std::vector< cv::Mat >     Node14->Node16 < cv::Mat > Node15 T     Node15->Node14 +elements Node16->Node1 +frames Node17->Node1 +still_image Node17->Node16 +elements Node18 uint8_t     Node18->Node17 +data +dataend +datalimit +datastart Node19 cv::MatAllocator   + MatAllocator() + ~MatAllocator() + allocate() + allocate() + copy() + deallocate() + download() + getBufferPoolController() + map() + unmap() + upload() Node19->Node17 +allocator Node20 UMatData *     Node20->Node17 +u Node21 MatSize     Node21->Node17 +size Node22 MatStep     Node22->Node17 +step

cv::Animation Node1 cv::Animation   + Animation() Node2 int     Node2->Node1 +loop_count Node13 std::vector< int >     Node2->Node13 +elements Node17 cv::Mat   + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() and 152 more... + diag() + eye() + eye() + getDefaultAllocator() + getStdAllocator() + ones() + ones() + ones() + ones() + setDefaultAllocator() + zeros() + zeros() + zeros() + zeros() # forEach_impl() Node2->Node17 +cols +dims +dummy +flags +rows Node3 cv::Scalar_< double >   + Scalar_() + Scalar_() + Scalar_() + Scalar_() + Scalar_() + Scalar_() + conj() + isReal() + mul() + operator Scalar_< T2 >() + operator=() + operator=() + all() Node3->Node1 +bgcolor Node4 cv::Vec< double, 4 >   + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() and 17 more... + all() + diag() + eye() + ones() + randn() + randu() + zeros() Node4->Node3 Node5 cv::Matx< double, cn, 1 >   + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() and 33 more... + all() + diag() + eye() + ones() + randn() + randu() + zeros() Node5->Node4 Node6 double     Node6->Node5 +val Node7 cv::Matx< _Tp, m, n >   + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() and 33 more... + all() + diag() + eye() + ones() + randn() + randu() + zeros() Node7->Node5 < double, cn, 1 > Node10 cv::Matx< _Tp, cn, 1 >   + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() + Matx() and 33 more... + all() + diag() + eye() + ones() + randn() + randu() + zeros() Node7->Node10 < _Tp, cn, 1 > Node8 _Tp     Node8->Node7 +val Node8->Node10 +val Node9 cv::Vec< _Tp, cn >   + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() and 17 more... + all() + diag() + eye() + ones() + randn() + randu() + zeros() Node9->Node4 < double, 4 > Node12 cv::Vec< _Tp, 4 >   + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() + Vec() and 17 more... + all() + diag() + eye() + ones() + randn() + randu() + zeros() Node9->Node12 < _Tp, 4 > Node10->Node9 Node10->Node12 Node11 cv::Scalar_< _Tp >   + Scalar_() + Scalar_() + Scalar_() + Scalar_() + Scalar_() + Scalar_() + conj() + isReal() + mul() + operator Scalar_< T2 >() + operator=() + operator=() + all() Node11->Node3 < double > Node12->Node11 Node13->Node1 +durations Node14 std::vector< T >     Node14->Node13 < int > Node16 std::vector< cv::Mat >     Node14->Node16 < cv::Mat > Node15 T     Node15->Node14 +elements Node16->Node1 +frames Node17->Node1 +still_image Node17->Node16 +elements Node18 uint8_t     Node18->Node17 +data +dataend +datalimit +datastart Node19 cv::MatAllocator   + MatAllocator() + ~MatAllocator() + allocate() + allocate() + copy() + deallocate() + download() + getBufferPoolController() + map() + unmap() + upload() Node19->Node17 +allocator Node20 UMatData *     Node20->Node17 +u Node21 MatSize     Node21->Node17 +size Node22 MatStep     Node22->Node17 +step

Detailed Description#

Represents an animation with multiple frames. The Animation struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP). It provides support for looping, background color settings, frame timing, and frame storage.

Examples
samples/cpp/tutorial_code/imgcodecs/animations.cpp.

Constructor & Destructor Documentation#

Animation()#

cv::Animation::Animation(
int loopCount = 0,
Scalar bgColor = Scalar() )

Python:

cv.Animation([, loopCount[, bgColor]]) -> <Animation object>

Constructs an Animation object with optional loop count and background color.

Parameters

  • loopCount — An integer representing the number of times the animation should loop:

    • 0 (default) indicates infinite looping, meaning the animation will replay continuously.

    • Positive values denote finite repeat counts, allowing the animation to play a limited number of times.

    • If a negative value or a value beyond the maximum of 0xffff (65535) is provided, it is reset to 0 (infinite looping) to maintain valid bounds.

  • bgColor — A Scalar object representing the background color in BGR format:

    • Defaults to Scalar(), indicating an empty color (usually transparent if supported).

    • This background color provides a solid fill behind frames that have transparency, ensuring a consistent display appearance.

Member Data Documentation#

bgcolor#

Scalar cv::Animation::bgcolor

Background color of the animation in BGRA format.

durations#

std::vector< int > cv::Animation::durations

Duration for each frame in milliseconds.

Note

(GIF) Due to file format limitation

  • Durations must be multiples of 10 milliseconds. Any provided value will be rounded down to the nearest 10ms (e.g., 88ms → 80ms).

  • 0ms(or smaller than expected in user application) duration may cause undefined behavior, e.g. it is handled with default duration.

  • Over 65535 * 10 milliseconds duration is not supported.

frames#

std::vector< Mat > cv::Animation::frames

Vector of frames, where each Mat represents a single frame.

loop_count#

int cv::Animation::loop_count

Number of times the animation should loop. 0 means infinite looping.

Note

At some file format, when N is set, whether it is displayed N or N+1 times depends on the implementation of the user application. This loop times behaviour has not been documented clearly.

still_image#

Mat cv::Animation::still_image

image that can be used for the format in addition to the animation or if animation is not supported in the reader (like in PNG).

Source file#

The documentation for this struct was generated from the following file: