c++ fitLine function does not work correctly for three input points!

asked 2015-10-13 08:58:28 -0600

In development environment of VS2010, opencv 2.4.11, and a C++ console program, I found a while ago that the fitLine function did not output a correct result, when just three 2D points are inputted to the function. The three input points were almost collinear, and I used a std::vector<point2f> for the input points, and a Vec4f for an output, however, the fitLine function surprisingly outputted a completely wrong result. I think this is a serious bug, could anyone answer this?

edit retag flag offensive close merge delete

Comments

5

If you don't provide exact examples/cases of malfunction, well, I don't think anybody is gonna be able to know what's wrong

LorenaGdL gravatar imageLorenaGdL ( 2015-10-13 09:22:59 -0600 )edit

Hi, LorenaGdl, I'm sorry, but my program is too big to show here. After reading your reply, firstly, I tried a simple console application in which just three points in a line are input to the fitLine function as Point2f points. The result was correct. Secondly, I ran my program in debug mode, and then find the image coordinates of the 3 nearly collinear points causing said completely incorrect result. I input the three found points in the above test console program and the result is correct at this time. The difference of the two cases is that in my gdi program the fitLine function is called in a for loop (repeated 4 times to detect 4 sides of a rectangular shape). I guess the error is related to a data structure of the vector (std::vector and Vec4f) in the fitLine function.

skdskim gravatar imageskdskim ( 2015-10-15 06:39:14 -0600 )edit

Are there any preconditions in using opencv in MFC GUI programming? Since I use vs2010, the MFC program can not be built with opencv 3.0 and with versions up to 2.4.11, well built with MFC library in both debug and release modes. But, errors like this time sometimes occur especially when using the vector data in standard library and opencv. For example, HoughLinesP function works well within a function body, but when returning from the function, a memory heap corruption error occurs in freeing the vector data automatically.

skdskim gravatar imageskdskim ( 2015-10-15 09:18:26 -0600 )edit