Sorry, this content is no longer available

Ask Your Question
0

fitLine always crashes

asked Jun 3 '13

vlad_tepesch gravatar image

Hi i try to use fitLine but it always crashes. I already tried to modify input data (cv::Mat, std::vector<cv::pointd>) and output data(cv::Vect4d, std::vector<cv::pointd>(2), std::vector<double>(4)) formats.

Here is my Code:

std::vector<cv::Point2d> points;
// [...] // push_back some (26) points
std::vector<double> line(4,0);
cv::fitLine(points,line,CV_DIST_L2,0,0.01,0.01);

now it crashes. Iam using winxp VS2010 with a opencv 2.41 build I got no call stack and the crash seems to happen in kernel32.dll xstring

Where is my failure?

Preview: (hide)

1 answer

Sort by » oldest newest most voted
2

answered Jun 3 '13

berak gravatar image
  • make the input Point2f, not Point2d
  • make the output Vec4f // a single one

std::vector<cv::Point2f> points;
points.push_back(cv::Point2f(3,3));
points.push_back(cv::Point2f(4,4));
points.push_back(cv::Point2f(5,5));
Vec4f line;
cv::fitLine(points,line,CV_DIST_L2,0,0.01,0.01);
Preview: (hide)

Comments

2

Thank you very much. But now, please point me to the part of documentation that tells me that only float input data is supported.

vlad_tepesch gravatar imagevlad_tepesch (Jun 3 '13)edit

hmm, indeed it's not mentioned there (but should be!)

if you try with Point2d, you'll get an exception, complaining about the point-depth not being float, so it's probably a matter of experience

berak gravatar imageberak (Jun 3 '13)edit

@berak i have not got any exception that sounds like that. The exception that occurred was on crt or os level.

vlad_tepesch gravatar imagevlad_tepesch (Jun 3 '13)edit

hmm, i got an opencv exception there, not a kernel one.

no idea why you get that.

got neither 2.4.1, nor vs2010, so can't reproduce exactly

berak gravatar imageberak (Jun 3 '13)edit

I obtained exception when trying wCvInvoke.cvFitLine with EmguCV 2.4.2.1777 : "OpenCV: Input sequence must consist of 2d points or 3d points". After this I have not found in documentation about OpenCV fitLine, just this answer clarfied issue.

sergtk gravatar imagesergtk (Jan 12 '14)edit

Question Tools

Stats

Asked: Jun 3 '13

Seen: 2,948 times

Last updated: Jun 03 '13