2

I need some help on Augmented Reality. I have develop a small application.NOw I want to use shape detection algorithm or specially circle detection algorithm.I want that after my camera get open It should only detect circles and if it gets circles it should get replaced with some corresponding image. I hope you understood what I want to do.

Georg Fritzsche
  • 93,086
  • 26
  • 183
  • 232
hardik
  • 385
  • 1
  • 4
  • 5

1 Answers1

0

To add shape detection algorithm for (circle), you can consider using circle detection with Hough Transform from OpenCV. Taken from OpenCV tutorial website, here are some snippets:

    // Loads an image
    cv::Mat src = cv::imread( filename, cv::IMREAD_COLOR );
    cv::Mat gray;
    cv::cvtColor(src, gray, cv::COLOR_BGR2GRAY);
    cv::medianBlur(gray, gray, 5);
    cv::vector<Vec3f> circles;
    cv::HoughCircles(gray, circles, cv::HOUGH_GRADIENT, 1,
                 gray.rows/16,  // change this value to detect circles with different distances to each other
                 100, 30, 1, 30 // change the last two parameters
            // (min_radius & max_radius) to detect larger circles
    );
    for( size_t i = 0; i < circles.size(); i++ )
    {
        cv::Vec3i c = circles[i];
        cv::Point center = cv::Point(c[0], c[1]);
        // circle center
        cv::circle( src, center, 1, cv::Scalar(0,100,100), 3, cv::LINE_AA);
        // circle outline
        int radius = c[2];
        cv::circle( src, center, radius, cv::Scalar(255,0,255), 3, cv::LINE_AA);
    }

OpenCV can do the task as you mentioned, and is compatible for AR application.