convert cv::Mat to vector<vector<uchar>> img;
how do i efficiently convert cv::Mat to vector<vector<uchar>> img. right now i am trying beolove code:
vector<vector<Vec3b>> inputImg(OrigImg.cols,vector<Vec3b>(OrigImg.rows));
for(int i=0;i<OrigImg.cols;i++) {
for(int j=0;j<OrigImg.rows;j++) {
inputImg[i][j] = backgroundSubImg.at<cv::Vec3b>(j,i);
}
}
Why i'm trying to do is since it looks like accessing each pixel in cv::Mat or scanning hole image is little bit slower by using backgroundSubImg.at<cv::vec3b>(j,i); i want to access the color values of this pixels only by its position. Right now my algorithm is accessing every pixel 6404608 times in each cycle.