Ask Your Question

konradN's profile - activity

2015-11-23 14:14:52 -0600 received badge  Scholar (source)
2015-11-23 14:14:48 -0600 received badge  Supporter (source)
2015-11-23 13:27:36 -0600 commented answer Detecting objects in OpenCV

Thank you for your code. Everything is working. I don't know how but I tested it before and can not do it. You solved my big problem. Thank you very much !!!

2015-11-20 02:49:05 -0600 commented question Detecting objects in OpenCV

I tried with this manual: http://www.learnopencv.com/blob-detec... ,but it's not quite working :(

2015-11-20 02:46:01 -0600 commented question Detecting objects in OpenCV

I just balance settings in HoguhCircles and it's quite okey, but I must test it on robot. Do you have any experience with Blob function?

2015-11-19 08:15:17 -0600 commented question Detecting objects in OpenCV

But I even don't use object storage. So what's its impact?

2015-11-19 02:46:51 -0600 asked a question How to detect orange ball?

I've got problems with detection of orange ball from picture at the bottom. I include my code. I tried a lot of settings but can't find sollution. Any help? Program is compiling. There are all declarations and video connection.

enter code here

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

        //src.convertTo(src, -1, 0.7, 0);
        //medianBlur(src, src, 3);

        imwrite("./pic/temp1.jpg",src);
        //src = imread("circle.jpg"); 

        Mat hsv_src;
        cvtColor(src, hsv_src, CV_BGR2HSV );
        imwrite("./pic/tempcol.jpg",hsv_src);
        Mat hsv_src1;
        inRange(hsv_src, Scalar(0, 120, 120), Scalar(30, 255, 255),hsv_src1);
        imwrite("./pic/temprange.jpg",hsv_src1);
        Mat hsv_src2;
          /// Reduce the noise so we avoid false circle detection
         GaussianBlur( hsv_src1, hsv_src2, Size(9, 9), 0, 0 );
        imwrite("./pic/tempgaus.jpg",hsv_src2);
        adaptiveThreshold(hsv_src2, hsv_src2, 255, 0, 0, 51, -25);
        imwrite("./pic/tempthre.jpg",hsv_src2);


          vector<Vec3f> circles;

          /// Apply the Hough Transform to find the circles
          HoughCircles( hsv_src2, circles, CV_HOUGH_GRADIENT, 1, src.rows/8, 100, 20, 0, 0 );
        imwrite("./pic/hough.jpg",hsv_src1);

          /// Draw the circles detected
          for( size_t i = 0; i < circles.size(); i++ )
          {
              //Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
              //int radius = cvRound(circles[i][2]);
                                Vec3i c = circles[i];
              //circle center;
              //circle( src, center, 3, Scalar(0,255,0), -1, 8, 0 );
                                 circle(src, Point(c[0], c[1]), c[2], Scalar(0, 0, 255), 3, CV_AA);
              //circle outline;
             //circle( src, center, radius, Scalar(0,0,255), 3, 8, 0 );
                               circle(src, Point(c[0], c[1]), 2, Scalar(0, 255, 0), 3, CV_AA);
           }

          /// Show your results
            cout<<"znaleziono: "<<circles.size()<<endl;
          namedWindow( "Hough Circle Transform Demo", CV_WINDOW_AUTOSIZE );
          imshow( "Hough Circle Transform Demo", src );

image description

2015-11-18 09:26:01 -0600 commented question Detecting objects in OpenCV

I've added firts photo. As you can see there is noise stripe on the left side but still ball is visible.

2015-11-18 09:24:54 -0600 received badge  Editor (source)
2015-11-17 13:53:58 -0600 asked a question Detecting objects in OpenCV

I've got problem with detecting orange ball in OpenCV. In the pictures you see results after function inRange and the second one is thresholding (which is now not in the code). In both ways HoughCirles don't see circle which is seen in front of both pictures. They are not in good quality because of the camera (you can see the noise), but I think that function should have no problem in recognizing circle. Thank you for all help. My code:

  `enter code here`                 
       CvMemStorage *storage = cvCreateMemStorage(0); //storage area for all contours
        VideoCapture cap(0);
        if (!cap.isOpened())// if supposed not success, 
        {
                cout<<" cannot open the videofile"<<endl;// exit program
            return -1;
        }

        bool bSuccess = cap.read(src);
        if (!bSuccess)
            {
                cout<<"cannot read the frame from video file"<<endl;
                break;
            }
        imwrite("temp1.jpg",src);

        imwrite("tempblu.jpg",src);
        Mat hsv_src
        cvtColor(src, hsv_src, COLOR_BGR2HSV );
        imwrite("tempcol.jpg",hsv_src);
        inRange(hsv_src, Scalar(0, 120, 120), Scalar(30, 255, 255), hsv_src);
        imwrite("temprange.jpg",hsv_src);

          /// Reduce the noise so we avoid false circle detection
         GaussianBlur( hsv_src, hsv_src, Size(9, 9), 2, 2 );

          vector<Vec3f> circles;

          /// Apply the Hough Transform to find the circles
          HoughCircles( hsv_src, circles, CV_HOUGH_GRADIENT, 1, src_gray.rows/8, 200, 100, 0, 0 );

          /// Draw the circles detected
          for( size_t i = 0; i < circles.size(); i++ )
          {
              Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
              int radius = cvRound(circles[i][2]);
              // circle center
              circle( src, center, 3, Scalar(0,255,0), -1, 8, 0 );
              // circle outline
              circle( src, center, radius, Scalar(0,0,255), 3, 8, 0 );
           }

          /// Show your results
          cout<<"Circles found: "<<circles.size()<<endl;
          namedWindow( "Hough Circle Transform Demo", CV_WINDOW_AUTOSIZE );
          imshow( "Hough Circle Transform Demo", src );

image description

image description

image description