How to detect simple geometric shapes using OpenCV

If you have only these regular shapes, there is a simple procedure as follows : Find Contours in the image ( image should be binary as given in your question) Approximate each contour using approxPolyDP function. First, check number of elements in the approximated contours of all the shapes. It is to recognize the shape. … Read more

Detect semicircle in OpenCV

Use houghCircle directly on your image, don’t extract edges first. Then test for each detected circle, how much percentage is really present in the image: int main() { cv::Mat color = cv::imread(“../houghCircles.png”); cv::namedWindow(“input”); cv::imshow(“input”, color); cv::Mat canny; cv::Mat gray; /// Convert it to gray cv::cvtColor( color, gray, CV_BGR2GRAY ); // compute canny (don’t blur with … Read more