Ask Your Question

rabi's profile - activity

2017-10-09 01:58:36 -0500 received badge  Student (source)
2017-05-03 00:47:52 -0500 received badge  Critic (source)
2017-04-12 00:19:32 -0500 received badge  Supporter (source)
2017-04-11 04:53:07 -0500 commented answer Draw line along countours path (moving object)

Ya, you are write . Now , when I try your way , Still I am getting wrong output . Reason I am not able to uniquely identify each contour and hence it draws line from one contour to other one . Here is code I try

   vector<Point>centroid_points;
    int largest;
  for( int i = 0; i < contours.size(); i++ ){
for( int i = 0; i < contours.size(); i++ ){
Moments mu = moments(contours[i]);
  Point centroid = cv::Point (mu.m10/mu.m00 , mu.m01/mu.m00);
  centroid_points.push_back(centroid);
  largest =i;
  } 
    line(img,centroid_points[0],centroid_points[largest],Scalar(255, 0, 0), 2, 8, 0);
}
2017-04-10 06:38:42 -0500 asked a question Draw line along countours path (moving object)

I have code for moving object . It finds contours and draw rectangle. Now i want to detect the path traversed by moving object i.e. contours. And finally drew a line along with contours movement . Here is function for drawing of rectangle

static void refineSegments(  const Mat& img, Mat& mask, Mat& dst)
         {
 int niters = 3;

vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
    Mat temp;

GaussianBlur(mask, temp, Size(11, 11), 3.5, 3.5);
threshold(temp, temp, 100, 255, THRESH_BINARY); //for web camera
dilate(temp, temp, Mat(), Point(-1,-1), niters);
erode(temp, temp, Mat(), Point(-1,-1), niters*2);
dilate(temp, temp, Mat(), Point(-1,-1), niters*2);

imshow("dilated", temp);


findContours( temp, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE );

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

for( int i = 0; i < contours.size(); i++ )
{
    vector<Point>contour = contours[i];
    double area0 = contourArea(contour);
    if( area0 > 5000)   
        {
    approxPolyDP( Mat(contours[i]), contours_poly[i], 3, true );
    boundRect[i] = boundingRect( Mat(contours_poly[i]) );
        }

}

dst = Mat::zeros(img.size(), CV_8UC3);
if( contours.size() == 0 )
    return;

int idx = 0, largestComp = 0;
double maxArea = 0;

cout<<"Size of contours after removal:"<<contours.size()<<endl;  ///SIZE OF CONTOUR AFTER REMOVAL OF SMALL CONTOURS
for( int i = 0; i< contours.size(); i++ )
{
    Scalar color(0,0,255 );
    vector<Point>test_contour=contours[i];

    rectangle( img, boundRect[i].tl(), boundRect[i].br(), color, 2, 8, 0 );
            //line(img, contours[i], contours[i+1], color, 2, 8, 0 );
           //printf(contours[i]);
}}

Could you change it so that it draw a line along moving contour . Thanks

2017-04-08 11:41:16 -0500 received badge  Enthusiast
2017-04-07 04:17:16 -0500 commented answer Sample requires nonfree module to run

I have already installed opencv in same manner as the above tutorial . However your code is working fine

2017-04-07 04:15:35 -0500 received badge  Scholar (source)
2017-04-07 03:43:31 -0500 asked a question Sample requires nonfree module to run

Hi , I am try to match object using Features2D + Homography module. and try to run the code from opencv documentation . Here is that

But error code is showing as "The sample requires nonfree module that is not available in your OpenCV distribution I have downloaded opencv 3.1 with contrib on ubuntu 16.04 OS

Please tell how to run the code .

2017-04-05 06:18:38 -0500 commented answer Loading 1 frame per 4 second

Your code is helpful. thanks

2017-04-05 05:35:30 -0500 asked a question Loading 1 frame per 4 second

Hi , I have following code

   if ( !cap.isOpened() ) 
   {
     cout << "Cannot open the video file" << endl;
     return -1;
}
double fps = cap.get(CV_CAP_PROP_FPS); 
cout << "Frame per seconds : " << fps << endl;
namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); 
while(1)
{
    Mat frame;

    bool bSuccess = cap.read(frame); 
    if (!bSuccess)
    {
                    cout << "Cannot read the frame from video file" << endl;
                   break;
    }

    imshow("MyVideo", frame);

    if(waitKey(30) == 27)
    {
            cout << "esc key is pressed by user" << endl; 
            break; 
     }

It loads one frame per second. Now , How do I change to read 1 frame in 4 or 5 seconds.

2017-04-04 06:11:17 -0500 commented question Detecting abundant bag using opencv

but it creates another binary image/video to show output , However i need to draw a circle on the same source video. Kindly help me.

2017-04-04 04:13:32 -0500 commented question Detecting abundant bag using opencv

Your code is really helpful , Thanks

2017-04-03 23:37:09 -0500 asked a question Detecting abundant bag using opencv

I want to detect abundant bag in a video surveillance single camera view using opencv. I had already done some research on method and algos for same and what only , I found is :

http://www.ijser.org/paper/REAL-TIME-ABANDONED-BAG-DETECTION-USING-OPENCV.html (www.ijser.org/paper/REAL-TIME-ABANDON...)

Could you help me to find out an algorithm . Should I need to pre-store the sample of bag to be detected?

Thanks in advance

2017-04-03 04:40:14 -0500 commented question Drawing a line for moving object

actually it is too difficult . Could you simplify into just main.cpp and CMakeLists.txt

2017-04-03 01:34:54 -0500 asked a question Drawing a line for moving object

I have real time stream and I want to just draw a line that shows the path of moving object. I am using Opencv 3.1 with C++