Fix nan issue in features
[trackerpp.git] / include / VideoReader.h
1 #ifndef _IVIDEO_READER_H_
2 #define _IVIDEO_READER_H_
3
4 #include "SharedPtr.h"
5 #include <string>
6 #include <opencv2/opencv.hpp>
7
8 namespace suanzi {
9
10     typedef enum {
11         URL,
12         File,
13         USB
14     } VideoSrcType;
15
16     TK_DECLARE_PTR(VideoReaderFactory);
17     TK_DECLARE_PTR(VideoReader);
18     TK_DECLARE_PTR(URLReader);
19     TK_DECLARE_PTR(Engine);
20
21     class VideoReaderFactory
22     {
23         public:
24             static VideoReaderPtr createVideoReader(VideoSrcType type, const std::string& url);
25     };
26
27     class VideoReader
28     {
29         public:
30             VideoReader(VideoSrcType type, const std::string& url) : type(type), url(url){}
31
32             virtual ~VideoReader();
33             virtual bool read(cv::Mat& mat){return true;}
34
35         private:
36             VideoSrcType type;
37             EngineWPtr engine;
38
39         protected:
40             std::string url;
41     };
42
43     class UrlReader  : public VideoReader
44     {
45         public:
46             UrlReader(VideoSrcType type, const std::string& url);
47             virtual ~UrlReader();
48             bool read(cv::Mat& mat);
49         private:
50             cv::VideoCapture vcap;
51     };
52
53     class FileReader : public VideoReader
54     {
55         public:
56             FileReader(VideoSrcType type, const std::string& url):VideoReader(type, url){}
57         //    void read(){};
58     };
59
60     class UsbReader : public VideoReader
61     {
62         public:
63             UsbReader(VideoSrcType type, const std::string& url):VideoReader(type, url){}
64         //    void read(){};
65     };
66
67 }
68
69
70 #endif /* _IVIDEO_READER_H_ */