From c35b00a97e12c8439ef3921ed7deb2a0c940b6ea Mon Sep 17 00:00:00 2001 From: Amro Date: Sat, 23 Jan 2016 17:28:49 +0200 Subject: [PATCH] fix code snippet showing how to use SparseMat generate indices within the size limit (modulo) --- modules/core/include/opencv2/core/mat.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index ffec538657..77fce1db93 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -2359,15 +2359,16 @@ Elements can be accessed using the following methods: SparseMat::find), for example: @code const int dims = 5; - int size[] = {10, 10, 10, 10, 10}; + int size[5] = {10, 10, 10, 10, 10}; SparseMat sparse_mat(dims, size, CV_32F); for(int i = 0; i < 1000; i++) { int idx[dims]; for(int k = 0; k < dims; k++) - idx[k] = rand() + idx[k] = rand() % size[k]; sparse_mat.ref(idx) += 1.f; } + cout << "nnz = " << sparse_mat.nzcount() << endl; @endcode - Sparse matrix iterators. They are similar to MatIterator but different from NAryMatIterator. That is, the iteration loop is familiar to STL users: