Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

What does "sig[i] = cv::Mat(sigv).clone().reshape(1);" do?

i KNOW reshape() get a vector and make a matrix from it. But why in this line of code:

sig[i] = cv::Mat(sigv).clone().reshape(1);

It came after the clone() ? What does this line of code do exactly?

What does "sig[i] = cv::Mat(sigv).clone().reshape(1);" do?

i KNOW reshape() get a vector and make a matrix from it. But why in this line of code:

sig[i] = cv::Mat(sigv).clone().reshape(1);

It came after the clone() ? What does this line of code do exactly?

EDIT: More information:

//Do EMD and report
//
vector<cv::Mat> sig(5);
cout << "\nEMD: " << endl;
// Oi Vey, parse histograms to earth movers signatures
//
for( i=0; i<5; ++i) {
vector<cv::Vec3f> sigv;
// (re)normalize histogram to make the bin weights sum to 1.
//
cv::normalize(hist[i], hist[i], 1, 0, cv::NORM_L1);
for( int h = 0; h < h_bins; h++ )
for( int s = 0; s < s_bins; s++ ) {
float bin_val = hist[i].at<float>(h, s);
if( bin_val != 0 )
sigv.push_back( cv::Vec3f(bin_val, (float)h, (float)s));
}
// make Nx3 32fC1 matrix, where N is the number of nonzero histogram bins
//
sig[i] = cv::Mat(sigv).clone().reshape(1);