Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Using iterator with sparseMat value

I am trying to access elements in a sparseMat using value and the iterator.. The elements are of the type Vec5f, which has been declared. typedef Vec<float, 5=""> Vec5f;

The iterator is declared with cv::SparseMatConstIterator_<float> it = sparseLoc.begin<float>(); cv::SparseMatConstIterator_<float> it_end = sparseLoc.end<float>();

The IDE (Eclipse) doesn't allow using type <vec5f> for this.

The loop is for(; it != it_end; ++it) { float Iter = it; const SparseMat::Node itNode = it.node(); Spot = it.value<vec5f>(); Intens = Spot[I]; Vert = Spot[V]; Horiz = Spot[H]; DeltaH = Spot[DH]; DeltaI = Spot[DI]; itTestFile << Iter << ", " << Intens << ", " << Vert << ", " << Horiz<< ", " << DeltaH << ", " << DeltaI << endl;

 }

(If you are trying to figure out its purpose, I am trying to see how the iterator and the x,y access compare.) I get the exception

OpenCV Error: Assertion failed (_m->type() == DataType<_Tp>::type) in SparseMatConstIterator_, file /usr/local/include/opencv2/core/mat.inl.hpp, line 2888 terminate called after throwing an instance of 'cv::Exception' what(): /usr/local/include/opencv2/core/mat.inl.hpp:2888: error: (-215) _m->type() == DataType<_Tp>::type in function SparseMatConstIterator

It doesn't show the calling line number. i tried changing the Vec5f in the it.value statement and I get the same exception. So, I assume it is thrown by the SparseMatConstInterator_ declaration.

Any hints on how to fix this?

Thanks Ralph

click to hide/show revision 2
No.2 Revision

updated 2016-11-25 11:16:41 -0600

berak gravatar image

Using iterator with sparseMat value

I am trying to access elements in a sparseMat using value and the iterator.. The elements are of the type Vec5f, which has been declared. typedef Vec<float, 5=""> Vec5f;

The iterator is declared with with

 cv::SparseMatConstIterator_<float> it = sparseLoc.begin<float>();
 cv::SparseMatConstIterator_<float> it_end = sparseLoc.end<float>();

sparseLoc.end<float>();

The IDE (Eclipse) doesn't allow using type <vec5f> for this.

The loop is is

for(; it != it_end; ++it)
     {
         float Iter = it;
*it;
         const SparseMat::Node SparseMat::Node* itNode = it.node();
         Spot = it.value<vec5f>();
it.value<Vec5f>();
         Intens = Spot[I];
         Vert = Spot[V];
         Horiz = Spot[H];
         DeltaH = Spot[DH];
         DeltaI = Spot[DI];
         itTestFile << Iter << ", " <<  Intens << ", " <<  Vert  << ", " << Horiz<< ", "
                         <<  DeltaH  << ", " << DeltaI << endl;

endl;
     }

(If you are trying to figure out its purpose, I am trying to see how the iterator and the x,y access compare.) I get the exception

OpenCV Error: Assertion failed (_m->type() == DataType<_Tp>::type) in SparseMatConstIterator_, file /usr/local/include/opencv2/core/mat.inl.hpp, line 2888
terminate called after throwing an instance of 'cv::Exception'
what(): /usr/local/include/opencv2/core/mat.inl.hpp:2888: error: (-215) _m->type() == DataType<_Tp>::type in function SparseMatConstIterator

SparseMatConstIterator

It doesn't show the calling line number. i tried changing the Vec5f in the it.value statement and I get the same exception. So, I assume it is thrown by the SparseMatConstInterator_ declaration.

Any hints on how to fix this?

Thanks Ralph

click to hide/show revision 3
No.3 Revision

updated 2016-11-25 11:17:35 -0600

berak gravatar image

Using iterator with sparseMat value

I am trying to access elements in a sparseMat using value and the iterator.. The elements are of the type Vec5f, which has been declared.

typedef Vec<float, 5=""> Vec5f; 

5> Vec5f;

The iterator is declared with

 cv::SparseMatConstIterator_<float> it = sparseLoc.begin<float>();
 cv::SparseMatConstIterator_<float> it_end = sparseLoc.end<float>();

The IDE (Eclipse) doesn't allow using type <vec5f> for this.

The loop is

for(; it != it_end; ++it)
     {
         float Iter = *it;
         const SparseMat::Node* itNode = it.node();
         Spot = it.value<Vec5f>();
         Intens = Spot[I];
         Vert = Spot[V];
         Horiz = Spot[H];
         DeltaH = Spot[DH];
         DeltaI = Spot[DI];
         itTestFile << Iter << ", " <<  Intens << ", " <<  Vert  << ", " << Horiz<< ", "
                         <<  DeltaH  << ", " << DeltaI << endl;
     }

(If you are trying to figure out its purpose, I am trying to see how the iterator and the x,y access compare.) I get the exception

OpenCV Error: Assertion failed (_m->type() == DataType<_Tp>::type) in SparseMatConstIterator_, file /usr/local/include/opencv2/core/mat.inl.hpp, line 2888
terminate called after throwing an instance of 'cv::Exception'
  what():  /usr/local/include/opencv2/core/mat.inl.hpp:2888: error: (-215) _m->type() == DataType<_Tp>::type in function SparseMatConstIterator

It doesn't show the calling line number. i tried changing the Vec5f in the it.value statement and I get the same exception. So, I assume it is thrown by the SparseMatConstInterator_ declaration.

Any hints on how to fix this?

Thanks Ralph