Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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&lt;OrigImg.rows;j++)" {="" inputimg[i][j]="backgroundSubImg.at&lt;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.

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: code:

vector<vector<vec3b>> inputImg(OrigImg.cols,vector<vec3b>(OrigImg.rows)); for(int i=0;i<origimg.cols;i++) {="" for(int="" j="0;j&lt;OrigImg.rows;j++)" {="" inputimg[i][j]="backgroundSubImg.at&lt;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.

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));

vector<vector<Vec3b>> inputImg(OrigImg.cols,vector<Vec3b>(OrigImg.rows));
for(int i=0;i<origimg.cols;i++) {="" for(int="" j="0;j&lt;OrigImg.rows;j++)" {="" inputimg[i][j]="backgroundSubImg.at&lt;cv::Vec3b">(j,i);
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.