How to detect and measure small dents on a car body using OpenCV and C++?

I’m developing a hail damage scanner that detects and measures even the smallest dents on a car body using high-resolution 3D models. I’m using C++ and OpenCV for this purpose. My goal is to accurately identify and quantify the size and position of dents.

I’ve experimented with edge detection and contour analysis in OpenCV. I used the Canny edge detector and found contours to isolate potential dents. However, I’m struggling with differentiating small dents from noise and reflections in the images.

What I Was Expecting:
I expected to get clear boundaries of the dents that can be measured accurately. Any advice on improving the detection accuracy or alternative methods in OpenCV that might work better for this task would be appreciated.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#include <opencv2/opencv.hpp>
#include <iostream>
int main() {
// Load the image
cv::Mat image = cv::imread("car_body.jpg", cv::IMREAD_GRAYSCALE);
if (image.empty()) {
std::cerr << "Could not open the image file" << std::endl;
return -1;
}
// Apply GaussianBlur to reduce noise
cv::Mat blurred;
cv::GaussianBlur(image, blurred, cv::Size(5, 5), 1.5);
// Apply Canny edge detector
cv::Mat edges;
cv::Canny(blurred, edges, 50, 150);
// Find contours
std::vector<std::vector<cv::Point>> contours;
cv::findContours(edges, contours, cv::RETR_TREE, cv::CHAIN_APPROX_SIMPLE);
// Draw contours
cv::Mat contourImage = cv::Mat::zeros(image.size(), CV_8UC3);
for (size_t i = 0; i < contours.size(); i++) {
cv::drawContours(contourImage, contours, (int)i, cv::Scalar(0, 255, 0), 2);
}
// Display the result
cv::imshow("Contours", contourImage);
cv::waitKey(0);
return 0;
}
</code>
<code>#include <opencv2/opencv.hpp> #include <iostream> int main() { // Load the image cv::Mat image = cv::imread("car_body.jpg", cv::IMREAD_GRAYSCALE); if (image.empty()) { std::cerr << "Could not open the image file" << std::endl; return -1; } // Apply GaussianBlur to reduce noise cv::Mat blurred; cv::GaussianBlur(image, blurred, cv::Size(5, 5), 1.5); // Apply Canny edge detector cv::Mat edges; cv::Canny(blurred, edges, 50, 150); // Find contours std::vector<std::vector<cv::Point>> contours; cv::findContours(edges, contours, cv::RETR_TREE, cv::CHAIN_APPROX_SIMPLE); // Draw contours cv::Mat contourImage = cv::Mat::zeros(image.size(), CV_8UC3); for (size_t i = 0; i < contours.size(); i++) { cv::drawContours(contourImage, contours, (int)i, cv::Scalar(0, 255, 0), 2); } // Display the result cv::imshow("Contours", contourImage); cv::waitKey(0); return 0; } </code>
#include <opencv2/opencv.hpp>
#include <iostream>

int main() {
    // Load the image
    cv::Mat image = cv::imread("car_body.jpg", cv::IMREAD_GRAYSCALE);
    if (image.empty()) {
        std::cerr << "Could not open the image file" << std::endl;
        return -1;
    }

    // Apply GaussianBlur to reduce noise
    cv::Mat blurred;
    cv::GaussianBlur(image, blurred, cv::Size(5, 5), 1.5);

    // Apply Canny edge detector
    cv::Mat edges;
    cv::Canny(blurred, edges, 50, 150);

    // Find contours
    std::vector<std::vector<cv::Point>> contours;
    cv::findContours(edges, contours, cv::RETR_TREE, cv::CHAIN_APPROX_SIMPLE);

    // Draw contours
    cv::Mat contourImage = cv::Mat::zeros(image.size(), CV_8UC3);
    for (size_t i = 0; i < contours.size(); i++) {
        cv::drawContours(contourImage, contours, (int)i, cv::Scalar(0, 255, 0), 2);
    }

    // Display the result
    cv::imshow("Contours", contourImage);
    cv::waitKey(0);

    return 0;
}

New contributor

iosif9619 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật