Optimizing the train data computation from HOGs

asked 2018-11-08 15:12:37 -0500

nikola gravatar image

updated 2018-11-08 15:19:16 -0500

Currently I am using the following function to convert a vector of HOG descriptors to a cv::Mat trainData to be used by a SVM classifier:

void HOGs2Mat(std::vector<std::vector<float>> & HOGs, cv::Mat & mat) {
    size_t descriptorsSize = HOGs[0].size();
    for ( size_t i = 0; i < HOGs.size(); ++i )
         for ( size_t j = 0; j < descriptorsSize; ++j )
              mat.at<float>(i, j) = HOGs[i][j];

However I am currently looking for a faster way of doing the same thing by avoiding the nested loops. Is there a way to update the trainData with some matrix operations?

edit retag flag offensive close merge delete