Ask Your Question
1

cv::fitline

asked 2013-06-15 08:11:15 -0600

soheil1365 gravatar image

Hi guys

I am using opencv /C++ I am using cv::fitline for fitting one line btw different given 2D points.

    cv::fitLine(vecDraw,myLine,CV_DIST_L1,0,0.01,0.01);

after executing this code as you know my output is in "myLine" variable. my question:

do I need to use cv::Line after cv::fitline for drawing the line on one image or cv::fitline draw our line itself? if using cv::Line is necessary how can I use it regarding to "myLine" variable which containes my requested line?

thanks in advance

I need your help as soon as possible.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
5

answered 2013-06-15 08:22:29 -0600

berak gravatar image

no, fitLine won't draw anything by itself.

if you got a Vec4f myLine, the first 2 elements are the direction vec, the next 2 are a point on the line, so to draw a line with (approx.) length 5:

line( img, Point(myLine[2],myLine[3]), Point(myLine[2]+myLine[0]*5,myLine[3]+myLine[1]*5, ... )
edit flag offensive delete link more

Comments

thank you very much... these two second elements are points on the fitted line or are the given points? if they are on the fit line, they should have some distance with exact points that I gave to fitline function Am I right?

soheil1365 gravatar imagesoheil1365 ( 2013-06-15 09:12:41 -0600 )edit

Can you describe me more what you mean by "length 5" in your response?

soheil1365 gravatar imagesoheil1365 ( 2013-06-15 09:18:03 -0600 )edit

i don't understand.

you get a point and a normalized direction, that's it.

berak gravatar imageberak ( 2013-06-15 09:21:14 -0600 )edit

thank you...

soheil1365 gravatar imagesoheil1365 ( 2013-06-15 09:27:46 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-06-15 08:11:15 -0600

Seen: 14,443 times

Last updated: Jun 15 '13