Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::fitline for C++

Hello, I try the fitline with this coding as I understand that the Input vector of 2D or 3D points, stored in std::vector<> or Mat. The contours is already in vector 2D form yet I still get the error.

Unhandled exception at 0x00007ff93cada1c8 in momentcontour.exe: Microsoft C++ exception: cv::Exception at memory location 0x00f9d7b0..

Any point that I'm missing?

vector< vector<point> > contours; vector<moments> mu(contours.size() ); for( int i = 0; i < contours.size(); i++ ) { mu[i] = moments( contours[i], false ); TOTALM00 = TOTALM00 + mu[i].m00; } Vec4f line; cv::fitLine(contours,line,CV_DIST_L2,0,0.01,0.01); //HU Moments

click to hide/show revision 2
No.2 Revision

updated 2015-09-22 04:11:05 -0600

berak gravatar image

cv::fitline for C++

Hello, I try the fitline with this coding as I understand that the Input vector of 2D or 3D points, stored in std::vector<> or Mat. The contours is already in vector 2D form yet I still get the error.

Unhandled exception at 0x00007ff93cada1c8 in momentcontour.exe: Microsoft C++ exception: cv::Exception at memory location 0x00f9d7b0..

Any point that I'm missing?

vector< vector<point> vector<Point> > contours;
  vector<moments> vector<Moments> mu(contours.size() );
  for( int i = 0; i < contours.size(); i++ )
     { mu[i] = moments( contours[i], false ); 
       TOTALM00 = TOTALM00 + mu[i].m00;
     }
  Vec4f line;
  cv::fitLine(contours,line,CV_DIST_L2,0,0.01,0.01);
    //HU Moments

Moments