开发者

Image Processing for Augmented Reality

I need some help on Augmented Reality. I have develop a small application.NOw I want to use shape detection algorithm or specially c开发者_如何学Goircle 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜