Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV C++ Drawing and Analyzing Line

I am working on a OpenCV program capable of detecting Boxers punches and categories them. At the moment my program goes through all the different image processing, finds and detects contours, draws bounding boxes on ROI's (Region Of Interest), I am also computing some properties of each bounding box such as: Area and Center Point.

Now what i want to do is to draw a line from each bounding box starting from the center point and analyze that line for its Angle and Length. Have a look at the Image that illustrates my aim:

image description

So hopefully now you guys have a better overview..........

My Question here is How do i draw such line from starting position to end position store it in a vector to analyse it...?

I did some research on various functions that draw lines but non of them seem to be appropriate for my purpose. Here are some Research links:

Opencv Draw Line & Line iterator & poly lines

Also looked at arcLength, fitLine, clipLine & Hough transform

Could some one indicate me which technique would best fit my aim...? Some good read, examples, Or just suggest how to even start this whole thing

Regards Hopefully my problem is well understood by now

OpenCV C++ Drawing and Analyzing Line

I am working on a OpenCV program capable of detecting Boxers punches and categories them. At the moment my program goes through all the different image processing, finds and detects contours, draws bounding boxes on ROI's (Region Of Interest), I am also computing some properties of each bounding box such as: Area and Center Point.

Now what i want to do is to draw a line from each bounding box starting from the center point and analyze that line for its Angle and Length. Have a look at the Image that illustrates my aim:

image description

So hopefully now you guys have a better overview..........

My Question here is How do i draw such line from starting position to end position store it in a vector to analyse it...?

I did some research on various functions that draw lines but non of them seem to be appropriate for my purpose. Here are some Research links:

Opencv Draw Line & Line iterator & poly lines

Also looked at arcLength, fitLine, clipLine & Hough transform

Could some one indicate me which technique would best fit my aim...? Some good read, examples, Or just suggest how to even start this whole thing

Regards Hopefully my problem is well understood by now

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;

    cout<<" "<<endl;
    cout<<" "<<endl;

    if(center.x > center1.x)
    {
        Leftarm.push_back(center);
        Rightarm.push_back(center1);

    }
        else
        {
            Leftarm.push_back(center1);
            Rightarm.push_back(center);

        }

    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(Leftarm.size() >= 20)
        {
            Leftarm.clear();
        }

            cvLine(&drawing, Point(Rightarm[0]), Point(Rightarm[i]), Scalar( 255, 255, 255 ), 2,8);

OpenCV C++ Drawing and Analyzing Line

I am working on a OpenCV program capable of detecting Boxers punches and categories them. At the moment my program goes through all the different image processing, finds and detects contours, draws bounding boxes on ROI's (Region Of Interest), I am also computing some properties of each bounding box such as: Area and Center Point.

Now what i want to do is to draw a line from each bounding box starting from the center point and analyze that line for its Angle and Length. Have a look at the Image that illustrates my aim:

image description

So hopefully now you guys have a better overview..........

My Question here is How do i draw such line from starting position to end position store it in a vector to analyse it...?

I did some research on various functions that draw lines but non of them seem to be appropriate for my purpose. Here are some Research links:

Opencv Draw Line & Line iterator & poly lines

Also looked at arcLength, fitLine, clipLine & Hough transform

Could some one indicate me which technique would best fit my aim...? Some good read, examples, Or just suggest how to even start this whole thing

Regards Hopefully my problem is well understood by now

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;

    cout<<" "<<endl;
    cout<<" "<<endl;

    if(center.x > center1.x)
    {
        Leftarm.push_back(center);
        Rightarm.push_back(center1);

    }
        else
        {
            Leftarm.push_back(center1);
            Rightarm.push_back(center);

        }

    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(Leftarm.size() >= 20)
        {
            Leftarm.clear();
        }

            cvLine(&drawing, Point(Rightarm[0]), Point(Rightarm[i]), Scalar( 255, 255, 255 ), 2,8);