Debian Codegraph @

cvd/localvideoframe.h

raw symbols SCIP
1 /*******************************************************************************
2
3 LocalVideoFrame - A video frame for when the data is local snd should be
4 managed by the program instead of the system. Uses Image
5 to manage the memory. Programs which will only ever use
6 these can be optimized by using the image() methos. These
7 can be deleted sensibly, but it is not currently allowed,
8 to make the interface more consistent.
9
10 E. Rosten - 18 March 2005
11
12 *******************************************************************************/
13
14 #ifndef CVD_LOCALVIDEOFRAME_FRAME_H
15 #define CVD_LOCALVIDEOFRAME_FRAME_H
16
17 #include <cvd/videoframe.h>
18 #include <string>
19
20 namespace CVD
21 {
22 /// A frame from a LocalVideoBuffer, which manages its own data rather than wrapping
23 /// data owned by the system.
24 /// The data is stored internally using Image, and programs which will only ever use
25 /// LocalVideoBuffers can be optimized by using the
26 /// image() method. Being Images, these can be deleted sensibly.
27 /// @param T The pixel type of the video frames
28 /// @ingroup gVideoFrame
29 template <class T>
30 class LocalVideoFrame : public VideoFrame<T>
31 {
32
33 public:
34 virtual ~LocalVideoFrame()
35 {
36 }
37
38 /// Construct a video frame from an Image and a timestamp.
39 /// Note that the local video frame wants to own the image data
40 /// so only a move constructor is provided.
41 /// @param time The timestamp of this frame
42 /// @param local The Image to use for this frame
43 LocalVideoFrame(double time, CVD::Image<T>&& local)
44 : VideoFrame<T>(time, nullptr, local.size())
45 , im(std::move(local))
46 {
47 this->my_data = im.data();
48 }
49
50 /// Returns the image. A LocalVideoFrame can be treated just like any other Image
51 /// (for example it can use optimised copying)
52 Image<T>& image()
53 {
54 return im;
55 }
56 const Image<T>& image() const
57 {
58 return im;
59 }
60
61 double& timestamp()
62 {
63 return this->my_timestamp;
64 }
65
66 private:
67 CVD::Image<T> im;
68 };
69 }
70
71 #endif