代码拉取完成,页面将自动刷新
//Example 4-3. Printing all of the nonzero elements of a sparse array
#include <opencv2/opencv.hpp>
#include <iostream>
// Printing all of the nonzero elements of a sparse array
//
using namespace std;
// Summation of a multidimensional array, done plane by plane
//
int main( int argc, char** argv ) {
cout << "\nExample 4-3. Printing all of the nonzero elements of a sparse array"
<< "\nCall:\n" << argv[0] << endl;
// Create a 10x10 sparse matrix with a few nonzero elements
//
int size[] = {10,10};
cv::SparseMat sm( 2, size, CV_32F );
for( int i=0; i<10; i++ ) { // Fill the array
int idx[2];
idx[0] = size[0] * rand();
idx[1] = size[1] * rand();
sm.ref<float>( idx ) += 1.0f;
}
// Print out the nonzero elements
//
cv::SparseMatConstIterator_<float> it = sm.begin<float>();
cv::SparseMatConstIterator_<float> it_end = sm.end<float>();
for(; it != it_end; ++it) {
const cv::SparseMat::Node* node = it.node();
printf(" (%3d,%3d) %f\n", node->idx[0], node->idx[1], *it );
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。