Ask Your Question
0

fitLine always crashes

asked 2013-06-03 04:37:14 -0600

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?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-06-03 05:16:49 -0600

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);
edit flag offensive delete link more

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 ( 2013-06-03 05:30:23 -0600 )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 ( 2013-06-03 05:36:57 -0600 )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 ( 2013-06-03 05:58:33 -0600 )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 ( 2013-06-03 06:03:13 -0600 )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 ( 2014-01-12 14:10:23 -0600 )edit

Question Tools

Stats

Asked: 2013-06-03 04:37:14 -0600

Seen: 2,616 times

Last updated: Jun 03 '13