- Aldebaran documentation |
- C++ Libraries |
- index

libalvision 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Friends Macros Pages
alvideo.h
Go to the documentation of this file.
1
6 #pragma once
7 #ifndef _LIBALVISION_ALVISION_ALVIDEO_H_
8 #define _LIBALVISION_ALVISION_ALVIDEO_H_
9
10
11 # include <alvision/alvisiondefinitions.h>
12 # include <alvision/alimage.h>
13 # include <iostream>
14 # include <boost/filesystem/fstream.hpp>
15 # include <vector>
16
21 namespace AL
22 {
23 //structures for video raw stream recording
24 /*
25 * streamHeader
26 * @brief single stream header
27 */
28 struct streamHeader
29 {
30 unsigned int width : 32;
31 unsigned int height: 32;
32 unsigned int colorSpace : 32;
33 unsigned int pixelDepth : 32;
34 };
35
36 /*
37 * videoHeader
38 * @brief multiple stream header global header with version field
39 */
40 struct videoHeader
41 {
42 unsigned int magicNumber : 32; // magic number
43 unsigned int userSpaceSize : 32;
44 unsigned int numberOfFrames : 32;
45 unsigned int numberOfStreams : 32;
46 };
47
48 struct streamProperties
49 {
50 unsigned int width;
51 unsigned int height;
52 unsigned int resolution;
53 unsigned int colorSpace;
54 unsigned int nbLayers;
55 unsigned int pixelDepth;
56 unsigned int sizePerImage;
57 };
58
59
60 class ALVideo
61 {
62
63 // .:: methods ::
64
65 public:
66 ALVideo();
67 ~ALVideo();
68
69 bool recordVideo(const std::string pFilePath, const unsigned int pUserSpaceSize, const std::vector<streamHeader>& pStreamHeaderVector);
70 bool readVideo(const std::string pFilePath);
71 void closeVideo();
72 bool goToFrame(const unsigned int pFrameNumber, const unsigned int pStreamNumber);
73 bool getFrame(ALImage & pImage, const unsigned int pFrameNumber, const unsigned int pStreamNumber, const bool pCheckFormat = true);
74 bool getNextFrame(ALImage & pImage, const bool pCheckFormat = true);
75 bool getPrecedingFrame(ALImage & pImage, const bool pCheckFormat = true);
76 bool write(char* ptrImageData, const int pSizeData, const long long pTimeStamp = 0, const char pCameraId = 0,
77 const float pLeftAngle = 0, const float pTopAngle = 0, const float pRightAngle = 0, const float pBottomAngle = 0);
78 bool write(int height, int width, char *imageData, const long long pTimeStamp, const char pCameraId,
79 const float pLeftAngle, const float pTopAngle, const float pRightAngle, const float pBottomAngle);
80
81 inline const unsigned char* getMagicNumber() const { return (unsigned char*)&fMagicNumber; };
82 inline unsigned int getNumberOfFrames() const { return fNumberOfFrames; };
83 inline unsigned int getNumberOfStreams() const { return fNumberOfStreams; };
84 inline unsigned int getCurrentFrameNumber() const { return fCurrentFrameNumber; };
85 inline unsigned int getCurrentStreamNumber() const { return fCurrentStreamNumber; };
86 inline bool isOpenForReading() const { return fIsOpenForReading; };
87 inline bool isOpenForWriting() const { return fIsOpenForWriting; };
88
89 inline int getStreamWidth(const unsigned int pStreamNumber) const { return (pStreamNumber<fNumberOfStreams) ? fStreamPropertiesVector[pStreamNumber].width : -1; };
90 inline int getStreamHeight(const unsigned int pStreamNumber)const { return (pStreamNumber<fNumberOfStreams) ? fStreamPropertiesVector[pStreamNumber].height : -1; };
91 inline int getStreamResolution(const unsigned int pStreamNumber) const { return (pStreamNumber<fNumberOfStreams) ? fStreamPropertiesVector[pStreamNumber].resolution : -1; };
92 inline int getStreamColorSpace(const unsigned int pStreamNumber) const { return (pStreamNumber<fNumberOfStreams) ? fStreamPropertiesVector[pStreamNumber].colorSpace : -1; };
93 inline int getStreamNbLayers(const unsigned int pStreamNumber) const { return (pStreamNumber<fNumberOfStreams) ? fStreamPropertiesVector[pStreamNumber].nbLayers : -1; };
94 inline int getStreamPixelDepth(const unsigned int pStreamNumber) const { return (pStreamNumber<fNumberOfStreams) ? fStreamPropertiesVector[pStreamNumber].pixelDepth : -1; };
95 inline int getStreamSizePerImage(const unsigned int pStreamNumber)const { return (pStreamNumber<fNumberOfStreams) ? fStreamPropertiesVector[pStreamNumber].sizePerImage : -1; };
96
97
98 // .:: members ::
99
100 private:
101 volatile bool fIsOpenForReading;
102 volatile bool fIsOpenForWriting;
103
104 boost::filesystem::ifstream fVideoStreamIn;
105 boost::filesystem::ofstream fVideoStreamOut;
106 qi::Path fFilePath;
107
108 unsigned int fMagicNumber;
109 unsigned int fUserSpaceSize;
110 unsigned int fNumberOfFrames;
111 unsigned int fNumberOfStreams;
112 unsigned int fSizeOfHeader;
113 unsigned int fSizePerMultiplexedFrame;
114 std::vector<struct streamProperties> fStreamPropertiesVector;
115
116 unsigned int fCurrentStreamNumber;
117 unsigned int fCurrentFrameNumber;
118 };
119 }
120
121 #endif // _LIBALVISION_ALVISION_ALVIDEO_H_
AL::ALImage
Definition: alimage.h:28
AL::videoHeader::numberOfStreams
unsigned int numberOfStreams
Definition: alvideo.h:45
AL::ALVideo::getNextFrame
bool getNextFrame(ALImage &pImage, const bool pCheckFormat=true)
AL::streamProperties::sizePerImage
unsigned int sizePerImage
Definition: alvideo.h:56
AL::ALVideo::recordVideo
bool recordVideo(const std::string pFilePath, const unsigned int pUserSpaceSize, const std::vector< streamHeader > &pStreamHeaderVector)
AL::videoHeader::numberOfFrames
unsigned int numberOfFrames
Definition: alvideo.h:44
AL::ALVideo::getStreamPixelDepth
int getStreamPixelDepth(const unsigned int pStreamNumber) const
Definition: alvideo.h:94
AL::videoHeader::userSpaceSize
unsigned int userSpaceSize
Definition: alvideo.h:43
AL::ALVideo::getCurrentStreamNumber
unsigned int getCurrentStreamNumber() const
Definition: alvideo.h:85
alvisiondefinitions.h
vision defines
AL::streamProperties::height
unsigned int height
Definition: alvideo.h:51
AL::streamHeader::pixelDepth
unsigned int pixelDepth
Definition: alvideo.h:33
AL::ALVideo::getStreamHeight
int getStreamHeight(const unsigned int pStreamNumber) const
Definition: alvideo.h:90
AL::ALVideo::closeVideo
void closeVideo()
AL::ALVideo::getNumberOfStreams
unsigned int getNumberOfStreams() const
Definition: alvideo.h:83
AL::streamHeader::colorSpace
unsigned int colorSpace
Definition: alvideo.h:32
AL::ALVideo::getStreamWidth
int getStreamWidth(const unsigned int pStreamNumber) const
Definition: alvideo.h:89
AL::streamProperties::pixelDepth
unsigned int pixelDepth
Definition: alvideo.h:55
AL::ALVideo::write
bool write(char *ptrImageData, const int pSizeData, const long long pTimeStamp=0, const char pCameraId=0, const float pLeftAngle=0, const float pTopAngle=0, const float pRightAngle=0, const float pBottomAngle=0)
AL::streamProperties::width
unsigned int width
Definition: alvideo.h:50
AL::ALVideo::getStreamSizePerImage
int getStreamSizePerImage(const unsigned int pStreamNumber) const
Definition: alvideo.h:95
AL::ALVideo::getStreamResolution
int getStreamResolution(const unsigned int pStreamNumber) const
Definition: alvideo.h:91
AL::streamProperties::colorSpace
unsigned int colorSpace
Definition: alvideo.h:53
alimage.h
handle image
AL::streamHeader::height
unsigned int height
Definition: alvideo.h:31
AL::ALVideo::isOpenForWriting
bool isOpenForWriting() const
Definition: alvideo.h:87
AL::ALVideo::getPrecedingFrame
bool getPrecedingFrame(ALImage &pImage, const bool pCheckFormat=true)
AL::ALVideo::getNumberOfFrames
unsigned int getNumberOfFrames() const
Definition: alvideo.h:82
AL::streamHeader::width
unsigned int width
Definition: alvideo.h:30
AL::streamProperties::resolution
unsigned int resolution
Definition: alvideo.h:52
AL::ALVideo::getStreamNbLayers
int getStreamNbLayers(const unsigned int pStreamNumber) const
Definition: alvideo.h:93
AL::videoHeader
Definition: alvideo.h:40
AL::streamProperties::nbLayers
unsigned int nbLayers
Definition: alvideo.h:54
AL::ALVideo::getStreamColorSpace
int getStreamColorSpace(const unsigned int pStreamNumber) const
Definition: alvideo.h:92
AL::ALVideo::goToFrame
bool goToFrame(const unsigned int pFrameNumber, const unsigned int pStreamNumber)
AL::ALVideo::readVideo
bool readVideo(const std::string pFilePath)
AL::videoHeader::magicNumber
unsigned int magicNumber
Definition: alvideo.h:42
AL::ALVideo::getCurrentFrameNumber
unsigned int getCurrentFrameNumber() const
Definition: alvideo.h:84
AL::ALVideo::isOpenForReading
bool isOpenForReading() const
Definition: alvideo.h:86
AL::ALVideo::ALVideo
ALVideo()
AL::ALVideo
Definition: alvideo.h:60
AL::ALVideo::getMagicNumber
const unsigned char * getMagicNumber() const
Definition: alvideo.h:81
AL::streamProperties
Definition: alvideo.h:48
AL::ALVideo::getFrame
bool getFrame(ALImage &pImage, const unsigned int pFrameNumber, const unsigned int pStreamNumber, const bool pCheckFormat=true)
AL::ALVideo::~ALVideo
~ALVideo()
AL::streamHeader
Definition: alvideo.h:28