E. KOW
E. KOW

Reputation: 121

what does opencv fitLine do?

According to this answer, cv::fitLine with distType set to CV_DIST_L2 is a standard least squares method. However, looking at the code it's seems to use a different formula:

origin = (mean(x), mean(y)); // this is as in standard ls

angle = 0.5 * atan2( 2 * cov(x, y), (var(x) - var(y)));

can someone explain me the last formula?

Edit: this is actually a total least squares. For more information read here.

Upvotes: 2

Views: 4637

Answers (1)

Kirill Meisser
Kirill Meisser

Reputation: 13

As of September 2024, the OpenCV fitLine() function with the DIST_L2 option uses the Ordinary Least Squares Method, not the Total Least Squares Method.

Upvotes: 0

Related Questions