Project Malmo  0.37.0
TimestampedVideoFrame.h
1 // --------------------------------------------------------------------------------------------------
2 // Copyright (c) 2016 Microsoft Corporation
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
5 // associated documentation files (the "Software"), to deal in the Software without restriction,
6 // including without limitation the rights to use, copy, modify, merge, publish, distribute,
7 // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in all copies or
11 // substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
14 // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 // --------------------------------------------------------------------------------------------------
19 
20 #ifndef _TIMESTAMPEDVIDEOFRAME_H_
21 #define _TIMESTAMPEDVIDEOFRAME_H_
22 
23 // Local:
24 #include "TimestampedUnsignedCharVector.h"
25 
26 // Boost:
27 #include <boost/date_time/posix_time/posix_time_types.hpp>
28 
29 // STL:
30 #include <vector>
31 
32 namespace malmo
33 {
36  {
37  enum Transform {
38  IDENTITY
41  };
42  enum FrameType {
43  _MIN_FRAME_TYPE = 0
44  , VIDEO = _MIN_FRAME_TYPE
48  , _MAX_FRAME_TYPE
49  };
50  static const int FRAME_HEADER_SIZE = 20;
51 
53  boost::posix_time::ptime timestamp;
54 
56  short width;
57 
59  short height;
60 
62  short channels;
63 
66 
68  float pitch;
69 
71  float yaw;
72 
74  float xPos;
75 
77  float yPos;
78 
80  float zPos;
81 
83  std::vector<unsigned char> pixels;
84 
87 
88  bool operator==(const TimestampedVideoFrame& other) const;
89  friend std::ostream& operator<<(std::ostream& os, const TimestampedVideoFrame& tsvidframe);
90  friend std::ostream& operator<<(std::ostream& os, const TimestampedVideoFrame::FrameType& frametype);
91  float ntoh_float(uint32_t value) const;
92  };
93 }
94 
95 #endif
An array of unsigned chars with an attached timestamp saying when it was collected.
Definition: TimestampedUnsignedCharVector.h:33
An image with an attached timestamp saying when it was collected.
Definition: TimestampedVideoFrame.h:36
short channels
The number of channels. e.g. 3 for RGB data, 4 for RGBD.
Definition: TimestampedVideoFrame.h:62
float yPos
The y pos of the player at render time.
Definition: TimestampedVideoFrame.h:77
FrameType
Definition: TimestampedVideoFrame.h:42
@ COLOUR_MAP
24bpp colour map
Definition: TimestampedVideoFrame.h:47
@ DEPTH_MAP
32bpp float depthmap
Definition: TimestampedVideoFrame.h:45
@ LUMINANCE
8bpp greyscale bitmap
Definition: TimestampedVideoFrame.h:46
@ VIDEO
Normal video, either 24bpp RGB or 32bpp RGBD.
Definition: TimestampedVideoFrame.h:44
float xPos
The x pos of the player at render time.
Definition: TimestampedVideoFrame.h:74
float yaw
The yaw of the player at render time.
Definition: TimestampedVideoFrame.h:71
Transform
Definition: TimestampedVideoFrame.h:37
@ RAW_BMP
Layout bytes as raw BMP data (bottom-to-top RGB)
Definition: TimestampedVideoFrame.h:39
@ REVERSE_SCANLINE
Interpret input bytes as reverse scanline BGR.
Definition: TimestampedVideoFrame.h:40
@ IDENTITY
Don't alter the incoming bytes in any way.
Definition: TimestampedVideoFrame.h:38
boost::posix_time::ptime timestamp
The timestamp.
Definition: TimestampedVideoFrame.h:53
short height
The height of the image in pixels.
Definition: TimestampedVideoFrame.h:59
short width
The width of the image in pixels.
Definition: TimestampedVideoFrame.h:56
std::vector< unsigned char > pixels
The pixels, stored as channels then columns then rows. Length should be width*height*channels.
Definition: TimestampedVideoFrame.h:83
float zPos
The z pos of the player at render time.
Definition: TimestampedVideoFrame.h:80
FrameType frametype
The type of video data - eg 24bpp RGB, or 32bpp float depth.
Definition: TimestampedVideoFrame.h:65
float pitch
The pitch of the player at render time.
Definition: TimestampedVideoFrame.h:68