00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef MATVID_HPP
00012 #define MATVID_HPP
00013
00014 using namespace cv;
00015 using namespace std;
00016
00017
00020 class DatDescriptor
00021 {
00022 public:
00023 string data_type;
00024 string byte_order;
00025 double data_sets;
00026 double channels;
00027 vector<double> dimensions;
00028 string feature;
00029 string history;
00030 DatDescriptor();
00031 };
00032
00033
00041 class MatVid
00042 {
00043
00044 public:
00045
00046
00047
00048
00049
00063 static Mat readseq(const string &filename, int flags, int fmin, int fmax, int fstep = 1);
00064
00069 static Mat readavi(VideoCapture & vc, int nframes, int fstep=1, double scale=1.0);
00070
00078 static Mat create(int frames, int rows, int cols, int type);
00079
00088 static Mat frame(const Mat &vid, int f);
00089
00100 static Mat subvid(const Mat &vid, const Range &frange, const Range &rrange, const Range &crange);
00101
00102
00116 static Mat subvid(const Mat &vid, int fmin, int fmax, int rmin, int rmax, int cmin, int cmax);
00117
00124 static Mat repeat(const Mat &img, int nf);
00125
00126
00134 static void reduce(const Mat &vid, Mat &out, int reduceOp);
00135
00140 static double norm2(const Mat &vid);
00141
00142
00143
00144
00152 static Mat vectorize(const Mat &vid, bool flag_col = true);
00153
00161 static Mat unvectorize(const Mat &m, int rows, int cols);
00162
00170 static Mat vectorize1(const Mat &m, bool flag_col = true);
00171
00179 static Mat unvectorize1(const Mat &v, int rows, int cols);
00180
00189 static void show(const Mat &vid, double fps = 30.0, double alpha=1.0, double beta=0.0);
00190
00201 static Mat montage(const vector<Mat> &vids, int sizex=5, int spacing=2, const Scalar &fill = 0, int border=0);
00202
00203
00204
00205
00208 static void dump_matlab(const Mat &vid, ostream &output);
00209
00210
00211
00222 static int savedat(string filename,const Mat &input,string ftype="double",string history="",string opt="");
00223 static int savedat2(string filename,Mat input,string ftype="double",string history="",string opt="");
00224
00231 static Mat loaddat(string filename, string opt="");
00232
00233
00234 static void savedatinfo(string filename, DatDescriptor desc);
00235 static DatDescriptor loaddatinfo(string filename, int verbose);
00236
00237 static void showvid(Mat vid,int fr);
00238
00239 static Mat loadavi(string filename);
00240 static void saveavi(string filename,Mat img);
00241 };
00242
00243 #endif