Ask Your Question
0

Drawing a Line from set of points [closed]

asked 2013-03-27 18:38:14 -0500

Tomazi gravatar image

updated 2019-08-24 07:17:11 -0500

Hey Everybody....!

I am trying to draw a line that will link up center points of a bounding box, The points are stored in a vector as the center moves from frame to frame.

Now I am trying to use a CvLine to linke these points together with a line. I am following THIS Opencv Documentation. But CvLine function isynt happy with the parameters I give it.

Here is the code:

vector<Point> Rightarm(20);


vector<Point> Leftarm(20);

    vector<Point>::const_iterator RightIter;
    vector<Point>::const_iterator LeftIter;



   Point center = Point(oko[0].x + (oko[0].width/2), oko[0].y + (oko[0].height/2));
    cout<<"Center Point of Box: 0 is: " <<center<<endl;

    double area = (oko[0].width * oko[0].height);
    cout<<"The Area of Box: 0 is: " <<area<<endl;

    Point center1 = Point(oko[1].x + (oko[1].width/2), oko[1].y + (oko[1].height/2));
    cout<<"Center Point of Box: 1 is: " <<center1<<endl;

    double area1 = (oko[1].width * oko[1].height);
    cout<<"The Area of Box: 1 is: " <<area1<<endl;



Rightarm.push_back(center);
    Leftarm.push_back(center1); 

    if(oko[0].x > oko[1].x)
    {

    }
        else
        {

        }


    for(RightIter = Rightarm.begin(); RightIter != Rightarm.end(); ++RightIter)
    {
        circle(drawing, *RightIter, 3, Scalar(0,0,255), CV_FILLED); 
    }

    if(Rightarm.size() == 20)
        {
            Rightarm.clear();

        }

    for(LeftIter = Leftarm.begin(); LeftIter != Leftarm.end(); ++LeftIter)
    {
        circle(drawing, *LeftIter, 3, Scalar(0,255,0), CV_FILLED);
    }

        if(Rightarm.size() == 20)
        {
            Leftarm.clear();

        }

    cvLine(drawing, center.x, center.y, Scalar(255,255,255),1 ,8 ,CV_AA);

    imshow(window_Input, frame);
    imshow(window_Output, drawing);

Can anyone see where I am going wrong with this...?

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by StevenPuttemans
close date 2013-03-28 05:10:21.579050

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-03-28 05:09:29 -0500

Not that I do not like the fact that you are enthousiast, but please stick to one topic with one question. People are doing their best to answer as soon as possible.

Original post: http://answers.opencv.org/question/10165/opencv-c-drawing-and-analyzing-line/

edit flag offensive delete link more
0

answered 2013-03-28 04:33:23 -0500

berak gravatar image

updated 2013-03-28 04:35:06 -0500

if you wanted a line from center to center1, that would be:

line(drawing, center, center1, Scalar(255,255,255),1 ,8 ,CV_AA);

(it wants two points, not two coords)

also, please prefer http://docs.opencv.org/ to the old willowgarage one for docs

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-03-27 18:38:14 -0500

Seen: 103 times

Last updated: Mar 28 '13