c++ - Double pointer of Mat initialization -
i trying make mat array using opencv. array store number n of region of interest, , each region have store information of last 5 frames. i'm trying use double pointer mat. question how initialize it? i'm trying this:
in header of class: mat *objs_avgwb[25];
and initialize in source file: vseg.objs_avgwb = new mat[vseg.avgw][25];
instead of mucking around pointers , new, better option use containers provided standard library. don't need worry how you'll initialize them, since can resized dynamically.
for each set of features in frame, create std::vector of cv::mat objects, 1 each region of interest. then, use std::deque hold features each frame.
std::deque<std::vector<cv::mat>> roi_history; on each new frame, push_back each roi onto std::vector representing rois in frame:
std::vector<cv::mat> new_rois; new_rois.push_back(roi1); new_rois.push_back(roi2); // etc... you pop off oldest frame , push new data keep 5 frames in queue:
roi_history.pop_back(); roi_history.push_front(new_rois); you can access each roi in history using operator[] example, access fourth roi found in previous frame (remember zero-indexing!):
cv::mat my_roi = roi_history[1][3]; // ^ ^ // | fourth roi // | // recent history (zero current frame)
Comments
Post a Comment