Ask Your Question

Revision history [back]

How can access vector <cv::mat> data by using ptr or data method?

How can access vector <cv::mat> data by using ptr or data method?

I used at method for access vector <cv::mat> data.

This Method is so slow, so I would like to change ptr or data method.

This is my code. How can I change?

vector<mat> conc_img;

vector<mat> loss_img(conc_img);

for (int iter = r_start; iter < r_start + h_size; iter++) {

            for (int nframe = 0; nframe < conc_img.size(); nframe++) {

                part_x[nframe][cnt][0] = loss_img[nframe].at<float>(iter, ref_p[0]);

                part_x[nframe][cnt][1] = loss_img[nframe].at<float>(iter, ref_p[1]);

                part_x[nframe][cnt][2] = loss_img[nframe].at<float>(iter, ref_p[2]);

                part_x[nframe][cnt][3] = loss_img[nframe].at<float>(iter, ref_p[3]);

            }

        }
click to hide/show revision 2
None

updated 2018-04-12 03:15:41 -0600

berak gravatar image

How can access vector <cv::mat> data by using ptr or data method?

How can access vector <cv::mat> data by using ptr or data method?

I used at method for access vector <cv::mat> data.

This Method is so slow, so I would like to change ptr or data method.

This is my code. How can I change?

vector<mat> conc_img;

vector<mat> loss_img(conc_img);

vector<Mat> conc_img;

vector<Mat> loss_img(conc_img);

for (int iter = r_start; iter < r_start + h_size; iter++) {

{

                for (int nframe = 0; nframe < conc_img.size(); nframe++) {

                 part_x[nframe][cnt][0] = loss_img[nframe].at<float>(iter, ref_p[0]);

                 part_x[nframe][cnt][1] = loss_img[nframe].at<float>(iter, ref_p[1]);

                 part_x[nframe][cnt][2] = loss_img[nframe].at<float>(iter, ref_p[2]);

                 part_x[nframe][cnt][3] = loss_img[nframe].at<float>(iter, ref_p[3]);

             }

         }