Utility functions for Mat videos. More...
#include <MatVid.hpp>
Static Public Member Functions | |
| static Mat | readseq (const string &filename, int flags, int fmin, int fmax, int fstep=1) |
| load video from sequence of image files. | |
| static Mat | readavi (VideoCapture &vc, int nframes, int fstep=1, double scale=1.0) |
| load video from AVI video. | |
| static Mat | create (int frames, int rows, int cols, int type) |
| allocate a new Mat video. | |
| static Mat | frame (const Mat &vid, int f) |
| get a frame from a Mat video. | |
| static Mat | subvid (const Mat &vid, const Range &frange, const Range &rrange, const Range &crange) |
| get a sub-video from a Mat video, using Range. | |
| static Mat | subvid (const Mat &vid, int fmin, int fmax, int rmin, int rmax, int cmin, int cmax) |
| get a sub-video from a Mat video. | |
| static Mat | repeat (const Mat &img, int nf) |
| create a Mat video by repeating an image. | |
| static void | reduce (const Mat &vid, Mat &out, int reduceOp) |
| reduce a video to a single image. | |
| static double | norm2 (const Mat &vid) |
| compute L2-norm squared of vid. | |
| static Mat | vectorize (const Mat &vid, bool flag_col=true) |
| vectorize a Mat video into a matrix. | |
| static Mat | unvectorize (const Mat &m, int rows, int cols) |
| unvectorize a matrix into a Mat video. | |
| static Mat | vectorize1 (const Mat &m, bool flag_col=true) |
| vectorize an image into a vector. | |
| static Mat | unvectorize1 (const Mat &v, int rows, int cols) |
| unvectorize a vector into a Mat image. | |
| static void | show (const Mat &vid, double fps=30.0, double alpha=1.0, double beta=0.0) |
| show a Mat video. | |
| static Mat | montage (const vector< Mat > &vids, int sizex=5, int spacing=2, const Scalar &fill=0, int border=0) |
| create a montage of videos. | |
| static void | dump_matlab (const Mat &vid, ostream &output) |
| debugging: dump a Mat video into a Matlab readable output stream. | |
| static int | savedat (string filename, const Mat &input, string ftype="double", string history="", string opt="") |
| save all frames if video in Dat file. | |
| static int | savedat2 (string filename, Mat input, string ftype="double", string history="", string opt="") |
| static Mat | loaddat (string filename, string opt="") |
| load video frames from Dat file. | |
| static void | savedatinfo (string filename, DatDescriptor desc) |
| static DatDescriptor | loaddatinfo (string filename, int verbose) |
| static void | showvid (Mat vid, int fr) |
| static Mat | loadavi (string filename) |
| static void | saveavi (string filename, Mat img) |
Utility functions for Mat videos.
video is stored as a Mat class with 3 dimensions. pixels indices are: vid.at(t, y, x); vid.at(frame, row, col); the number of frames is vid.size[0], and the dimensions of each frame are vid.size[1] x vid.size[2] (y by x). Functions are provided for creating and processing these video Mats.
Definition at line 41 of file MatVid.hpp.
| Mat MatVid::create | ( | int | frames, | |
| int | rows, | |||
| int | cols, | |||
| int | type | |||
| ) | [static] |
allocate a new Mat video.
| frames | number of frames (t) | |
| rows | number of rows (y) | |
| cols | number of columns (x) | |
| type | the data type (opencv type) |
Definition at line 42 of file MatVid.cpp.
| Mat MatVid::frame | ( | const Mat & | vid, | |
| int | f | |||
| ) | [static] |
get a frame from a Mat video.
Actually only returns a Mat that points to the frame. DOES NOT MAKE A COPY!
| vid | the Mat video | |
| f | frame number |
Definition at line 233 of file MatVid.cpp.
| Mat MatVid::loaddat | ( | string | filename, | |
| string | opt = "" | |||
| ) | [static] |
load video frames from Dat file.
| filename | the path from where to load data. | |
| opt | option string:"d" - dump descriptor, "t" - output has the same type as the dat-file (default is double) |
Definition at line 478 of file MatVid.cpp.
| Mat MatVid::montage | ( | const vector< Mat > & | vids, | |
| int | sizex = 5, |
|||
| int | spacing = 2, |
|||
| const Scalar & | fill = 0, |
|||
| int | border = 0 | |||
| ) | [static] |
create a montage of videos.
Takes a set of videos and converts it into a montage video.
| vids | vector of Mat videos | |
| sizex | number of videos per row | |
| spacing | spacing between videos (in pixels) | |
| fill | fill color for the spaces between the videos | |
| border | border width around the whole montage |
Definition at line 410 of file MatVid.cpp.
| double MatVid::norm2 | ( | const Mat & | vid | ) | [static] |
compute L2-norm squared of vid.
| vid | the Mat video |
Definition at line 219 of file MatVid.cpp.
| Mat MatVid::readavi | ( | VideoCapture & | vc, | |
| int | nframes, | |||
| int | fstep = 1, |
|||
| double | scale = 1.0 | |||
| ) | [static] |
load video from AVI video.
[broken].
Definition at line 100 of file MatVid.cpp.
| Mat MatVid::readseq | ( | const string & | filename, | |
| int | flags, | |||
| int | fmin, | |||
| int | fmax, | |||
| int | fstep = 1 | |||
| ) | [static] |
load video from sequence of image files.
For each frame number (fmin:fstep:fmax), the filename is passed through sprintf to insert the frame number. The output video is always grayscale, and color images are automatically converted to grayscale.
| filename | the filename. | |
| flags | [unused] | |
| fmin | first frame number | |
| fmax | last frame number | |
| fstep | frame step increment |
Definition at line 48 of file MatVid.cpp.
| void MatVid::reduce | ( | const Mat & | vid, | |
| Mat & | out, | |||
| int | reduceOp | |||
| ) | [static] |
reduce a video to a single image.
This is analogous to "reduce" in OpenCV, except the reduction is applied to a video along the frames. (for SUM and AVG, converts to OPT_MAT_TYPE).
| vid | the Mat video | |
| out | destination matrix | |
| reduceOp | reduce operation (see OpenCV reduce) |
Definition at line 187 of file MatVid.cpp.
| Mat MatVid::repeat | ( | const Mat & | img, | |
| int | nf | |||
| ) | [static] |
create a Mat video by repeating an image.
Repeats img nf times and returns it. The returned Mat has copies the data from the image.
| img | the image | |
| nf | number of frames |
Definition at line 174 of file MatVid.cpp.
| int MatVid::savedat | ( | string | filename, | |
| const Mat & | input, | |||
| string | ftype = "double", |
|||
| string | history = "", |
|||
| string | opt = "" | |||
| ) | [static] |
save all frames if video in Dat file.
Input video frames can have different channels and must have type CV_8U or CV_64F
| filename | the path where to store the output file. | |
| input | vector containing input frames for video | |
| ftype | format in which to store data, can have value "unsigned_1" or "double" (default="double") | |
| history | optional history string to store histor of file | |
| opt | [future use for zip files] |
Definition at line 554 of file MatVid.cpp.
| void MatVid::show | ( | const Mat & | vid, | |
| double | fps = 30.0, |
|||
| double | alpha = 1.0, |
|||
| double | beta = 0.0 | |||
| ) | [static] |
show a Mat video.
If vid type is OPT_MAT_TYPE, then converts to 8-bit grayscale as: pix8 = alpha*pixel+beta
| vid | the Mat video | |
| fps | frames per second | |
| alpha | scale pixel values | |
| beta | add to pixel values |
Definition at line 388 of file MatVid.cpp.
| Mat MatVid::subvid | ( | const Mat & | vid, | |
| int | fmin, | |||
| int | fmax, | |||
| int | rmin, | |||
| int | rmax, | |||
| int | cmin, | |||
| int | cmax | |||
| ) | [static] |
get a sub-video from a Mat video.
Actually only returns a Mat pointing to the sub-video. DOES NOT MAKE A COPY! Uses the same indexing as Range.
| vid | the Mat video | |
| fmin | frame start | |
| fmax | frame end | |
| rmin | row start | |
| rmax | row end | |
| cmin | column start | |
| cmax | column end |
Definition at line 169 of file MatVid.cpp.
| Mat MatVid::subvid | ( | const Mat & | vid, | |
| const Range & | frange, | |||
| const Range & | rrange, | |||
| const Range & | crange | |||
| ) | [static] |
get a sub-video from a Mat video, using Range.
Actually only returns a Mat pointing to the sub-video. DOES NOT MAKE A COPY!
| vid | the Mat video | |
| frange | frame range | |
| rrange | row range | |
| crange | column range |
Definition at line 151 of file MatVid.cpp.
| Mat MatVid::unvectorize | ( | const Mat & | m, | |
| int | rows, | |||
| int | cols | |||
| ) | [static] |
unvectorize a matrix into a Mat video.
| m | the vectorized video matrix | |
| rows | number of rows in a video frame | |
| cols | number of columns in a video frame |
Definition at line 307 of file MatVid.cpp.
| Mat MatVid::unvectorize1 | ( | const Mat & | v, | |
| int | rows, | |||
| int | cols | |||
| ) | [static] |
unvectorize a vector into a Mat image.
| v | the vectorized image | |
| rows | number of rows in the image | |
| cols | number of columns in the image |
Definition at line 365 of file MatVid.cpp.
| Mat MatVid::vectorize | ( | const Mat & | vid, | |
| bool | flag_col = true | |||
| ) | [static] |
vectorize a Mat video into a matrix.
[Currently only supports flag_col=true]
| vid | the Mat video [T x Y x X] | |
| flag_col | if true, store as columns. Otherwise, store as rows. |
Definition at line 269 of file MatVid.cpp.
| Mat MatVid::vectorize1 | ( | const Mat & | m, | |
| bool | flag_col = true | |||
| ) | [static] |
vectorize an image into a vector.
[Currently only supports flag_col=true]
| m | the Mat image [Y x X] | |
| flag_col | if true, store as columns. Otherwise, store as rows. |
Definition at line 332 of file MatVid.cpp.
1.6.1