libalvision  2.1.4.13
 All Classes Namespaces Files Functions Variables 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 
12 # include <alvision/alimage.h>
13 # include <iostream>
14 # include <fstream>
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 
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  std::ifstream fVideoStreamIn;
105  std::ofstream fVideoStreamOut;
106  std::string 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_
unsigned int pixelDepth
Definition: alvideo.h:33
int getStreamResolution(const unsigned int pStreamNumber) const
Definition: alvideo.h:91
unsigned int width
Definition: alvideo.h:30
unsigned int userSpaceSize
Definition: alvideo.h:43
unsigned int width
Definition: alvideo.h:50
int getStreamWidth(const unsigned int pStreamNumber) const
Definition: alvideo.h:89
unsigned int resolution
Definition: alvideo.h:52
unsigned int sizePerImage
Definition: alvideo.h:56
bool isOpenForWriting() const
Definition: alvideo.h:87
int getStreamHeight(const unsigned int pStreamNumber) const
Definition: alvideo.h:90
bool recordVideo(const std::string pFilePath, const unsigned int pUserSpaceSize, const std::vector< streamHeader > &pStreamHeaderVector)
unsigned int numberOfFrames
Definition: alvideo.h:44
int getStreamNbLayers(const unsigned int pStreamNumber) const
Definition: alvideo.h:93
unsigned int nbLayers
Definition: alvideo.h:54
unsigned int getCurrentFrameNumber() const
Definition: alvideo.h:84
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)
unsigned int getNumberOfFrames() const
Definition: alvideo.h:82
unsigned int getNumberOfStreams() const
Definition: alvideo.h:83
bool isOpenForReading() const
Definition: alvideo.h:86
bool getPrecedingFrame(ALImage &pImage, const bool pCheckFormat=true)
bool getFrame(ALImage &pImage, const unsigned int pFrameNumber, const unsigned int pStreamNumber, const bool pCheckFormat=true)
unsigned int colorSpace
Definition: alvideo.h:53
const unsigned char * getMagicNumber() const
Definition: alvideo.h:81
int getStreamSizePerImage(const unsigned int pStreamNumber) const
Definition: alvideo.h:95
vision defines
int getStreamColorSpace(const unsigned int pStreamNumber) const
Definition: alvideo.h:92
unsigned int height
Definition: alvideo.h:31
handle image
unsigned int numberOfStreams
Definition: alvideo.h:45
unsigned int magicNumber
Definition: alvideo.h:42
unsigned int height
Definition: alvideo.h:51
unsigned int colorSpace
Definition: alvideo.h:32
int getStreamPixelDepth(const unsigned int pStreamNumber) const
Definition: alvideo.h:94
bool getNextFrame(ALImage &pImage, const bool pCheckFormat=true)
void closeVideo()
unsigned int pixelDepth
Definition: alvideo.h:55
unsigned int getCurrentStreamNumber() const
Definition: alvideo.h:85
bool goToFrame(const unsigned int pFrameNumber, const unsigned int pStreamNumber)
bool readVideo(const std::string pFilePath)