An automated computer vision script to detect imperfections in T-fillet welds. This project uses image processing techniques to distinguish between continuous weld beads and discontinuous defects like porosity or cracks.
- Language: Python 3
- Library: OpenCV (
cv2), NumPy - Technique: Canny Edge Detection, Morphological Filtering
- Region of Interest (ROI): Automatically masks the top and bottom of the image to focus strictly on the welding zone.
- Noise Reduction: Uses Gaussian Blur to filter out micro-spatter and surface texture.
- Smart Filtering: Distinguishes defects based on contour length:
- Ignored: Small noise (< 10px) and continuous weld lines (> 100px).
- Detected: Medium-sized broken segments (10px - 100px) representing defects.
- Coordinate Logging: Outputs exact
(x, y)coordinates of every detected imperfection.
- Preprocessing: The image is converted to grayscale and smoothed with a
5x5Gaussian Blur. - Masking: A rectangular mask creates a "tunnel vision" effect, isolating the center weld.
- Edge Detection:
cv2.Canny(Thresholds 50, 150) identifies high-contrast edges. - Analysis: The script calculates the
arcLengthof every contour. Continuous lines are marked green (safe), while broken lines are marked red (defects).
- Clone the repository.
- Ensure you have the required libraries:
pip install opencv-python numpy
- Place your weld image (e.g.,
badweld2.jpg) in the project folder. - Run the script:
python weld_check.py
- How to use Canny Edge Detection to extract structural features from metal surfaces.
- Using Bitwise Operations (Masking) to focus algorithms on specific image regions.
- Calculating Moments to find the centroid coordinates of irregular shapes.