| 1 | ////////////////////////////////////////////////////////////////////// |
| 2 | // // |
| 3 | // VideoFrame - An image with a timestamp, like from a video // |
| 4 | // source // |
| 5 | // // |
| 6 | // Tom Drummond 3 April 2002 // |
| 7 | // // |
| 8 | ////////////////////////////////////////////////////////////////////// |
| 9 | |
| 10 | #ifndef CVD_VIDEOFRAME_H |
| 11 | #define CVD_VIDEOFRAME_H |
| 12 | |
| 13 | #include <cvd/image.h> |
| 14 | |
| 15 | namespace CVD |
| 16 | { |
| 17 | |
| 18 | namespace VideoFrameFlags |
| 19 | { |
| 20 | /// Fields etc |
| 21 | enum FieldType |
| 22 | { |
| 23 | Top, |
| 24 | Bottom, |
| 25 | Both, |
| 26 | Progressive, |
| 27 | Unknown |
| 28 | }; |
| 29 | } |
| 30 | |
| 31 | /// A frame from a VideoBuffer. |
| 32 | /// @param T The pixel type of the video frames |
| 33 | /// @ingroup gVideoFrame |
| 34 | template <class T> |
| 35 | class VideoFrame : public BasicImage<T> |
| 36 | { |
| 37 | public: |
| 38 | /// (Used internally) Construct a VideoFrame around a block of memory. The |
| 39 | /// memory is not managed by the VideoFrame so must me managed seperately |
| 40 | /// @param t The time (in seconds) of this frame |
| 41 | /// @param data The image data for this frame |
| 42 | /// @param size The size of this video frame |
| 43 | VideoFrame(double t, T* data, const ImageRef& size, VideoFrameFlags::FieldType f = VideoFrameFlags::Unknown) |
| 44 | : BasicImage<T>(data, size) |
| 45 | , my_field(f) |
| 46 | , my_timestamp(t) |
| 47 | { |
| 48 | } |
| 49 | |
| 50 | /// (Used internally) Construct a VideoFrame from a BasicImage |
| 51 | /// @param t The time (in seconds) of this frame |
| 52 | /// @param im The image data for this frame. BasicImages do not manage their own |
| 53 | /// memory, so this must be managed externally |
| 54 | VideoFrame(double t, const BasicImage<T>& im, VideoFrameFlags::FieldType f = VideoFrameFlags::Unknown) |
| 55 | : BasicImage<T>(im) |
| 56 | , my_field(f) |
| 57 | , my_timestamp(t) |
| 58 | { |
| 59 | } |
| 60 | |
| 61 | /// What is the time (since boot) of this frame? |
| 62 | double timestamp() const |
| 63 | { |
| 64 | return my_timestamp; |
| 65 | } |
| 66 | |
| 67 | VideoFrameFlags::FieldType field() const |
| 68 | { |
| 69 | return my_field; |
| 70 | } |
| 71 | |
| 72 | protected: |
| 73 | /// We don't usually <code>delete</code> video frames. Some special destruction is usually needed. |
| 74 | virtual ~VideoFrame() |
| 75 | { |
| 76 | } |
| 77 | |
| 78 | VideoFrameFlags::FieldType my_field; /// Type of field in this frame |
| 79 | double my_timestamp; ///< No of seconds since boot of this frame |
| 80 | }; |
| 81 | |
| 82 | } |
| 83 | |
| 84 | #endif |