#include <opencv2/opencv.hpp>
int main() {
// Step 1: Read input image
cv::Mat inputImage = cv::imread("path/to/your/image.jpg");
// Step 2: Convert image to grayscale
cv::Mat grayscaleImage;
cv::cvtColor(inputImage, grayscaleImage, cv::COLOR_BGR2GRAY);
// Step 3: Apply GaussianBlur to reduce noise and improve detection
cv::Mat blurredImage;
cv::GaussianBlur(grayscaleImage, blurredImage, cv::Size(5, 5), 0);
// Step 4: Apply Canny edge detection
cv::Mat edgesImage;
cv::Canny(blurredImage, edgesImage, 50, 150);
// Step 5: Find contours in the edges image
std::vector<std::vector<cv::Point>> contours;
cv::findContours(edgesImage, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE);
// Step 6: Iterate through contours and filter based on area to find potential road signs
for (const auto& contour : contours) {
double area = cv::contourArea(contour);
if (area > 1000) {
// Step 7: Draw bounding rectangle around potential road sign
cv::Rect boundingRect = cv::boundingRect(contour);
cv::rectangle(inputImage, boundingRect, cv::Scalar(0, 255, 0), 2);
// Step 8: Perform character recognition (OCR) if needed
// Step 9: Print information or take further actions based on recognition results
}
}
// Step 10: Display the result
cv::imshow("Road Sign Detection", inputImage);
cv::waitKey(0);
return 0;
}