Class for extracting spatio-temporal patches (cubes) from a video (online mode). More...
#include <PatchExtractor.hpp>
Public Types | |
| enum | fill_type { FILL_NN, FILL_NNFILL, FILL_VOTE } |
fill type for generating images from patch labels. More... | |
Public Member Functions | |
| PatchExtractor (const PatchOptions &patopt, int vrows, int vcols) | |
| create a new PatchExtractor. | |
| void | reset () |
| reset the buffer. | |
| int | framesToNextPatch () |
| returns the number of frames needed to complete next patch. | |
| bool | addFrames (const Mat &vid) |
| add frames to the buffer. | |
| const vector< Mat > & | getPatches () |
| return the last formed patches. | |
| const Mat & | getCenterFrame () |
| return the center frame of the video buffer. | |
| const Mat & | getPatchFrames () |
| return the frames (Mat video) associated with the current set of patches. | |
| const Mat & | getbuf () |
| return the current video buffer. | |
| const Mat & | getbuf_zm () |
| return the current zero-mean video buffer. | |
| void | patchLabelsToImage (const Mat &patLabels, Mat &imgLabels, fill_type fillMode=FILL_NN) |
| convert patch labels to an image. | |
| void | dump (ostream &output) const |
| debugging: dump to an output stream. | |
| void | dump_matlab_init (ostream &output) const |
| debugging: dump initial info to a matlab-readable output stream (pat struct). | |
| void | dump_matlab_patches (ostream &output) const |
| debugging: dump current patches to a matlab-readable output stream (pat struct). | |
Public Attributes | |
| PatchOptions | patopt |
| options for extracting patches. | |
| int | vrows |
| number of rows in the video frame. | |
| int | vcols |
| number of columns in the video frame. | |
| vector< Point2i > | locyx |
| (y,x) coordinates of top-left of each patch. | |
| vector< bool > | locyx_mask |
| patch mask depending on pixel variance. | |
| int | locz |
| current z location of the patches (z of the first frame of the patch). | |
| int | curz |
| z location for next frame added. | |
| int | nextz |
| value of curz that will form a new patch. | |
| Point3i | coff |
| offset to center of patch. | |
| vector< int > | allx |
| all x-locations on step grid. | |
| vector< int > | ally |
| all y-locations on step grid. | |
| Mat | vbuf |
| video buffer to store current frames [vrows,vcols,patopt.win.z] type=OPT_MAT_TYPE. | |
| Mat | vbuf_zm |
| video buffer w/o mean [vrows,vcols,patopt.win.z] type=OPT_MAT_TYPE. | |
| vector< Mat > | patches |
| the set of patches. | |
| bool | flag_zm |
| flag if vbuf_zm is used. | |
| Mat | frame_center |
| center frame of the video buffer (reference to vbuf). | |
| Mat | frame_patches |
| center frames of the video buffer (reference to vbuf). | |
Private Member Functions | |
| void | getLoc () |
| get all locations that might have a patch. | |
| void | processNextPatch () |
| process patches after they have been formed. | |
Friends | |
| ostream & | operator<< (ostream &output, const PatchExtractor &cov) |
| debugging: dump to an output stream. | |
Class for extracting spatio-temporal patches (cubes) from a video (online mode).
The extractor works in an "online" mode, where frames are added sequentially. When enough frames are added a true flag is returned, which indicates that new patches have been formed. Normalization of patches is handled efficiently, and access is given to the current video buffer. Also included is a function for converting a set of labels corresponding to each patche to an image.
The actual patches will be in different places, depending on the normalization used: 1) norm_none --> patches are sub-videos of the buffer (vbuf); 2) norm_zm --> patches are sub-videos of the buffer (vbuf_zm); 3) norm_zmuv --> patches are local copies. Note that in some cases, the patches are just references to a sub-videos of the video buffer. Hence, it is not allowed to modify the patches.
Definition at line 34 of file PatchExtractor.hpp.
fill type for generating images from patch labels.
| FILL_NN |
use nearest-neighbor. |
| FILL_NNFILL |
use nearest-neighbor (fill in patches). |
| FILL_VOTE |
overlapping patches vote. |
Definition at line 41 of file PatchExtractor.hpp.
| PatchExtractor::PatchExtractor | ( | const PatchOptions & | patopt, | |
| int | vrows, | |||
| int | vcols | |||
| ) |
create a new PatchExtractor.
| patopt | patch options. | |
| vrows | number of rows in the video frame. | |
| vcols | number of columns in the video frame. |
Definition at line 38 of file PatchExtractor.cpp.
| bool PatchExtractor::addFrames | ( | const Mat & | vid | ) |
add frames to the buffer.
| vid | the Mat video to add (all frames are added). |
Definition at line 177 of file PatchExtractor.cpp.
| void PatchExtractor::dump | ( | ostream & | output | ) | const |
debugging: dump to an output stream.
Definition at line 485 of file PatchExtractor.cpp.
| void PatchExtractor::dump_matlab_init | ( | ostream & | output | ) | const |
debugging: dump initial info to a matlab-readable output stream (pat struct).
Definition at line 497 of file PatchExtractor.cpp.
| void PatchExtractor::dump_matlab_patches | ( | ostream & | output | ) | const |
debugging: dump current patches to a matlab-readable output stream (pat struct).
Definition at line 509 of file PatchExtractor.cpp.
| int PatchExtractor::framesToNextPatch | ( | ) |
returns the number of frames needed to complete next patch.
Definition at line 172 of file PatchExtractor.cpp.
| const Mat & PatchExtractor::getbuf | ( | ) |
return the current video buffer.
Definition at line 391 of file PatchExtractor.cpp.
| const Mat & PatchExtractor::getbuf_zm | ( | ) |
return the current zero-mean video buffer.
Only valid if zero-mean normalization is used.
Definition at line 395 of file PatchExtractor.cpp.
| const Mat & PatchExtractor::getPatchFrames | ( | ) |
return the frames (Mat video) associated with the current set of patches.
The number of frames will be the z-step size. TODO: Except on the first call, which will also include the beginning frames.
Definition at line 387 of file PatchExtractor.cpp.
| void PatchExtractor::patchLabelsToImage | ( | const Mat & | patLabels, | |
| Mat & | imgLabels, | |||
| fill_type | fillMode = FILL_NN | |||
| ) |
convert patch labels to an image.
Works when patLabels has channels, which are passed to imgLabels. (implementation of segm_mask.m)
| patLabels | the label for each patch. | |
| imgLabels | output image (has the same type as patLabels). | |
| fillMode | mode for filling in patches. |
Definition at line 403 of file PatchExtractor.cpp.
| void PatchExtractor::processNextPatch | ( | ) | [private] |
process patches after they have been formed.
applies the normalization.
Definition at line 265 of file PatchExtractor.cpp.
| void PatchExtractor::reset | ( | ) |
reset the buffer.
i.e. start a new video.
Definition at line 163 of file PatchExtractor.cpp.
| ostream& operator<< | ( | ostream & | output, | |
| const PatchExtractor & | cov | |||
| ) | [friend] |
debugging: dump to an output stream.
| vector<int> PatchExtractor::allx |
all x-locations on step grid.
Definition at line 55 of file PatchExtractor.hpp.
| vector<int> PatchExtractor::ally |
all y-locations on step grid.
Definition at line 56 of file PatchExtractor.hpp.
| Point3i PatchExtractor::coff |
offset to center of patch.
Definition at line 54 of file PatchExtractor.hpp.
z location for next frame added.
Definition at line 52 of file PatchExtractor.hpp.
flag if vbuf_zm is used.
Definition at line 62 of file PatchExtractor.hpp.
center frame of the video buffer (reference to vbuf).
Definition at line 63 of file PatchExtractor.hpp.
center frames of the video buffer (reference to vbuf).
Definition at line 64 of file PatchExtractor.hpp.
| vector<Point2i> PatchExtractor::locyx |
(y,x) coordinates of top-left of each patch.
Definition at line 49 of file PatchExtractor.hpp.
| vector<bool> PatchExtractor::locyx_mask |
patch mask depending on pixel variance.
Definition at line 50 of file PatchExtractor.hpp.
current z location of the patches (z of the first frame of the patch).
Definition at line 51 of file PatchExtractor.hpp.
value of curz that will form a new patch.
Definition at line 53 of file PatchExtractor.hpp.
| vector<Mat> PatchExtractor::patches |
the set of patches.
Definition at line 61 of file PatchExtractor.hpp.
options for extracting patches.
Definition at line 46 of file PatchExtractor.hpp.
video buffer to store current frames [vrows,vcols,patopt.win.z] type=OPT_MAT_TYPE.
Definition at line 59 of file PatchExtractor.hpp.
video buffer w/o mean [vrows,vcols,patopt.win.z] type=OPT_MAT_TYPE.
Definition at line 60 of file PatchExtractor.hpp.
number of columns in the video frame.
Definition at line 47 of file PatchExtractor.hpp.
number of rows in the video frame.
Definition at line 47 of file PatchExtractor.hpp.
1.6.1