c++ - Error in findnonzero() while storing the coordinates of non zero elements in vector -


I was trying to store the non-zero element index of a matte img1 in vector vp1 but it is a < Code> cv shows: Exception on memory space error occurs when there is no non-zero element in the mat. Example code is below where non-zero element indicies for IMG is successful and storage in VP is successful, but the foundation of non-zero elements for IMG1 to VP1 shows storage error. Any help will be appreciated to solve it. I want coordinates in the vector of the point because my other algorithm is running on its basis.

  #include & lt; Iostream & gt; #include & lt; Opencv2 / core / core.hpp & gt; #include & lt; Opencv2 / highgui / highgui.hpp & gt; Using namespace cv; Int main () {Mat img (10, 10, CV_8U, Scaler :: All (0)); Img.at & lt; Uchar & gt; (0,2) = 1; Of vector & lt; Point & gt; Vice President; Search Nanjiro (IMG, VP); Mat IMG1 (10, 10, cv_8u, scalar :: all (0)); Of vector & lt; Point & gt; VP1; Search Nanjiro (IMG1, VP1); Return 0; }   

This error is due to zero zero elements in cv :: mat. I think this is correct in the updated versions.

Although it increases the complexity, I give a simpler solution (as explained in the comment by @burks)

  vector & lt; Point & gt; Places; Int count = countNonZero (binarymate); If (count & lt; 0) {findNonZero (binary, location); }    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -