Ask Your Question

Tomazi's profile - activity

2019-07-18 08:26:10 -0600 received badge  Notable Question (source)
2019-03-19 17:29:43 -0600 received badge  Popular Question (source)
2019-03-05 21:26:05 -0600 received badge  Notable Question (source)
2018-08-28 01:18:14 -0600 received badge  Popular Question (source)
2018-04-11 03:06:33 -0600 received badge  Notable Question (source)
2017-07-20 10:45:45 -0600 received badge  Notable Question (source)
2017-05-24 17:48:22 -0600 received badge  Popular Question (source)
2017-02-28 10:54:53 -0600 received badge  Famous Question (source)
2017-02-02 03:58:48 -0600 received badge  Notable Question (source)
2016-06-04 14:57:22 -0600 received badge  Popular Question (source)
2016-02-08 10:35:19 -0600 received badge  Famous Question (source)
2016-02-03 10:55:45 -0600 received badge  Famous Question (source)
2015-12-11 08:08:34 -0600 received badge  Popular Question (source)
2015-07-07 05:09:07 -0600 received badge  Popular Question (source)
2015-03-20 08:31:33 -0600 received badge  Notable Question (source)
2015-02-27 10:56:18 -0600 received badge  Notable Question (source)
2014-11-19 01:52:01 -0600 received badge  Popular Question (source)
2014-10-10 14:14:17 -0600 received badge  Notable Question (source)
2014-08-21 14:41:36 -0600 received badge  Popular Question (source)
2014-05-28 11:01:18 -0600 received badge  Popular Question (source)
2014-03-13 23:51:01 -0600 marked best answer How to extract Frames from AVI video

Hey peeps so far i manage OpenCV to play a video.avi but what should i do now extract frames...?

below is the code i written so far that got my video playing:

#include<opencv\cv.h>
#include<opencv\highgui.h>
#include<opencv\ml.h>
#include<opencv\cxcore.h>



int main( int argc, char** argv ) {
cvNamedWindow( "DisplayVideo", CV_WINDOW_AUTOSIZE );
CvCapture* capture = cvCreateFileCapture( argv[1] );
IplImage* frame;
while(1) {
frame = cvQueryFrame( capture );
if( !frame ) break;
cvShowImage( "DisplayVideo", frame );
char c = cvWaitKey(33);
if( c == 27 ) break;
}
cvReleaseCapture( &capture );
cvDestroyWindow("DisplayVideo" );
}
2014-03-13 23:39:41 -0600 received badge  Popular Question (source)
2013-05-01 20:15:34 -0600 asked a question What are contours and why use them

Hey People...!

My question might be very lame but could someone define in simple words what are contours and why is it useful to find contours within image...?

And could could someone suggest a good article

Regards

2013-04-03 07:23:28 -0600 asked a question Writing & showing Image

Hey people....

I am recording a video footage and preforming various image processing methods on each frame to obtain desired result.

Now once I get the result I am looking for i want to capture and store a particular frame on my hdd.

To do this I am using imwrite function to write the frame as a jpg. then I use imshow to display this frame in a namesWindow.

The problem is that when all the conditions are meet to store the image my program instead of storing the image, gives me a run time error.......

Here is the code:

for(vector<double>::iterator iter_dis = Left_Point_distance.begin(); iter_dis != Left_Point_distance.end();++iter_dis)
{
  if(*iter_dis > 20 && center.y >= 120 && center.x >=510 && Box[0].width > Box[0].height)
  {
    char* window_Punches = "Punches";
    namedWindow(window_Punches ,1);

    Mat Hook;

    imwrite("C:\\Hook.jpg", Hook);
    imshow(window_Punches, Hook);
  }

  if(*iter_dis >20 && center.y <=60)
  {
  }
}

Going through opencv tutorials This is how this how its done but in my case is not working......

Further more all the process takes place in a infinite while loop, and videoframes are stored in Mat frame; which is then displayed in a window using imshow function.

Can anybody spot what am doing wrong here....?

2013-04-02 20:58:50 -0600 asked a question Capture and store frame

Hey People.....!

I am at the end of my iBoxing software project which detects, tracks and classifies variety of punches....The final major bit of my application is to capture a frame at which a PUNCH has been detected and store it somewhere in Project directory or anywhere....

QUESTIONS:

1.How can I grab & store frames from camera?

2013-04-01 17:50:29 -0600 commented answer Calculating points distance (application freezes)

HEHE thank you so much Not to sure how i didn't spot this but but once again THANKS. regards

2013-04-01 17:30:41 -0600 asked a question Calculating points distance (application freezes)

Hello people...!

Got a rather odd question but it is really stooping my development.

I am calculating a distance between two points for two separate center points of a bounding box. My application works fine after I put the code to calculate the distance between points of the first center.

When I add the code to my application to calculate the distance between points of the second center point my application freezes completely.

There are no compiler errors neither run time errors the application just stops (freezes) after a second or 2 and stays like this forever.....

vector<Point> Rightarm;
    vector<Point> Leftarm;

    vector<Point> Left_Arm_xy;
    vector<Point> Right_Arm_xy;

    vector<double> Left_Point_distance;
    vector<double> Right_Point_distance;    

Left_Arm_xy.push_back(cv::Point(center.x,center.y));

    Right_Arm_xy.push_back(cv::Point(center1.x,center1.y));


    double Pt1; 
    double Pt2; 
    for(vector<Point>::iterator iter_a = Left_Arm_xy.begin()+1; iter_a != Left_Arm_xy.end(); ++iter_a)
    {

        Pt1 = pow((double) iter_a->x - (iter_a -1)->x,2);
        Pt2 = pow((double) iter_a->y - (iter_a -1)->y,2);

            double result_a;
            result_a  = (Pt1 + Pt2);

            Left_Point_distance.push_back(sqrt(result_a));

    }



    //----------------------------------------------------------------------------->

    double Pt3; 
    double Pt4; 
    for(vector<Point>::iterator iter_b = Right_Arm_xy.begin()+1; iter_b != Right_Arm_xy.end(); iter_b)
    {

        Pt3 = pow((double) iter_b->x - (iter_b -1)->x,2);
        Pt4 = pow((double) iter_b->y - (iter_b -1)->y,2);

            double result_b;
            result_b  = (Pt3 + Pt4);

            Right_Point_distance.push_back(sqrt(result_b));

    }

Really have no idea of why this could be happening....could anyone possibly suggest an issue that exists withing the code....? Regards

2013-03-27 21:53:35 -0600 commented answer OpenCV C++ Drawing and Analyzing Line

Thx for yours response....what ever I try with this Line business my program crashes.......I know it is something to with my Start and End Points. I take my points from a vector that stores the center point of a bounding box in each frame, Please check My edited to this question: ^^^^^^^^^^^^^^^^^^^^^^^

2013-03-27 18:38:14 -0600 asked a question Drawing a Line from set of points

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...?

2013-03-27 03:50:34 -0600 received badge  Student (source)
2013-03-26 23:28:52 -0600 asked a question 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);
2013-03-26 16:04:36 -0600 commented answer C++ OpenCV Eliminate smaller Contours

ok this seems to work but......following the tutorial it is how the code there was written so why in my instance it wouldn't work.....?

2013-03-26 13:11:38 -0600 asked a question C++ OpenCV Eliminate smaller Contours

I am developing a OpenCV project.

I am currently working on detecting contours of particular ROI (Region Of Interest). What I want to achieve is to eliminate all the smaller contours in other words I do not want these smaller contours to be drown at all.

So Far if I have coded this algorithm to do this job:

vector<vector<Point>> contours;
    vector<Vec4i> hierarchy;
    findContours(mBlur, contours, hierarchy, CV_RETR_EXTERNAL,  CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
    //----------------------------------------------------------------------------->
    //Contours Vectors
    vector<vector<Point> > contours_poly(contours.size());
    vector<Rect> boundRect (contours.size());
    vector<Moments> ContArea(contours.size());

    //----------------------------------------------------------------------------->

    //Detecting Contours
    for( int i = 0; i < contours.size(); i++ )
    {  
        ContArea[i] = moments(contours[i], false);
    }

    vector<Point2f> ContCenter(contours.size());
    for(int i = 0; i < contours.size(); i++)
    {
        ContCenter[i] = Point2f(ContArea[i].m10/ContArea[i].m00, ContArea[i].m01/ContArea[i].m00);  
    }

    Mat drawing = Mat::zeros( mBlur.size(), CV_8UC3 );
    for(int i = 0; i < contours.size(); i++)
    {
        Scalar color = Scalar(255,255,255);
        drawContours( drawing, contours_poly, i, color, 1, 8, vector<Vec4i>(), 0, Point() );
        fillPoly(drawing, contours, Scalar(255,0,0));
    }

    for(int i = 0; i < contours.size(); i++)
    {
       printf(" * Contour[%d] - Area (M_00) = %.2f - Area OpenCV: %.2f - Length: %.2f \n", i, ContArea[i].m00, contourArea(contours[i]), arcLength( contours[i], true ) );

       if(ContArea[i].m00 > 1000)
       {
           Scalar color = Scalar(0,255,0);
           drawContours( drawing, contours, i, color, 2, 8, hierarchy, 0, Point() );
           circle( drawing, ContCenter[i], 4, color, -1, 8, 0 );
       }

    }

I have used this tutorial to compute the above code: [Link To Tutorial] (http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/moments/moments.html)

OK so everything seems to work well contours with are over 1000 are drawn and highlighted but the contours that are less then 1000 are also drawn but are not highlighted.

I want these smaller contours that are not highlighted not to be drown at all is it possible....? using the above code...?

2013-02-22 20:41:29 -0600 asked a question Retrieving two highest values from vector

Hi people

I have declared a vector that stores an area of all Bounding Boxes in a given frame. I then used a iterated this vector from beginning to end to retrieve value. I then sorted these values in ascending order (lowest -> highest).

Here is the Code i use:

  double area = contourArea(boundingBoxArea);
        list_area.push_back(area);
        sort(list_area.begin(), list_area.end());
        vector<double>::const_iterator area_iter;

        int i = 0;
        for(area_iter = list_area.begin(); area_iter != list_area.end(); area_iter++)
        {
            i++;
            cout<<"Iterator " <<i<< " size is : " <<*area_iter<<endl;
        }

My issue is that I am only interested in the last two values out of the set of numbers (2 highest values) but I cant really get my head around it to how should i go about it to achieve my goal.

Anyone out here has a suggestion or solution to my problem...?

Regards

2013-02-21 14:59:28 -0600 asked a question OpenCV Draw draw contours of 2 largest objects

I am doing a OpenCV software that detects boxing gloves therefore i want to detect and draw only 2 largest contours (one for each boxing glove).

My software draws contours for everything and some things are noise only which ofcourse i dont want

My code for drawing contours:

   vector<vector<Point> > contours;
    vector<Vec4i> hierarchy;
    findContours(mBlur, contours, hierarchy, CV_RETR_EXTERNAL,  CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
    //----------------------------------------------------------------------------->

    vector<vector<Point> > contours_poly(contours.size());
    vector<Rect> boundRect (contours.size());
    vector<Point2f> boundingBoxArea(boundRect.size());

    //----------------------------------------------------------------------------->

    for( int i = 0; i < contours.size(); i++ )
     { 
       approxPolyDP( Mat(contours[i]), contours_poly[i], 3, true );
       boundRect[i] = boundingRect( Mat(contours_poly[i]) );

     }

    /// Draw polygonal contour + bonding rects
   Mat drawing = Mat::zeros( range_out.size(), CV_8UC3 );

    for( int i = 0; i< contours.size(); i++ )
        {

           Scalar color = Scalar(0,0,255);
           drawContours( drawing, contours_poly, i, color, 1, 8, vector<Vec4i>(), 0, Point() );
           fillPoly(drawing, contours, Scalar(255,0,0));

       }

Example Image image description My program already segments the gloves by color, The problelem is that at times small contours are drawn in random locations due to noise. Now of course the gloves contours are by far dominant and this is why i want to keep only the contours of these. Hope this makes my question clearer

Could someone suggest a solution please I am coding in C++ environment regards

2013-02-19 18:05:13 -0600 commented answer OpenCV Drawing Bounding Box CenterPoint

Yes i used this evenly but before i found few issues with the code i provided

2013-02-19 16:46:10 -0600 asked a question OpenCV Drawing Bounding Box CenterPoint

I am trying to draw a Dot in Bounding Box that will represent the Center Point of that box. I have computed the center Point but it is only outputted in CMD and I wont this Point to be visible on a image.

I am working with OpenCV2.4.3 on Visual Studio 2010 C++

 for(int i= 0; i < boundRect.size(); i++ )
       {
            //BoundingBox Area
            boundingBoxArea.clear();
            boundingBoxArea.push_back(Point2f(boundRect[i].x, boundRect[i].y));
            boundingBoxArea.push_back(Point2f(boundRect[i].x + boundRect[i].width, boundRect[i].y));
            boundingBoxArea.push_back(Point2f(boundRect[i].x + boundRect[i].width, boundRect[i].y + boundRect[i].height));
            boundingBoxArea.push_back(Point2f(boundRect[i].x, boundRect[i].y + boundRect[i].height));

            double area0 = contourArea(boundingBoxArea);

            cout << "area of bounding box no." << i << " = " << area0 << endl;

            //Bounding Box Centroid
            area0 = (boundRect[i].x + boundRect[i].width)/2, (boundRect[i].y + boundRect[i].height)/2;

            cout<<"Rectangle " <<i<< " Centroid possition is at: " "=" <<area0<<endl;
            cout<<""<<endl;
            cout<<""<<endl;
     }

The above is the code that i use well only a small part but a part that is responsible for calculations on Bounding Boxes