This project was developed as part of a job application to demonstrate Computer Vision skills. It implements an automated system for measuring screw lengths in images using OpenCV and Python.
- Image preprocessing for enhanced screw detection
- Screw detection using contour analysis
- Accurate length measurement using Principal Component Analysis (PCA)
- Visualization of detected screws and measurements
- Statistical analysis of screw lengths across multiple images
- Python 3.x
- OpenCV (cv2)
- NumPy
- SciPy
- Clone this repository
- Install the required packages:
pip install opencv-python numpy scipy
- Place your screw images in the
Schrauben/
directory - Run the script:
python screw_measurement.py
- Processed images will be saved in the
processed_screws/
directory - Statistical analysis of the measurements will be printed to the console
The script includes several adjustable parameters that can be modified to optimize performance for different types of screws or image conditions:
- Minimum length threshold
- CLAHE parameters for contrast enhancement
- Thresholding method
- Morphological operation kernel size
- Contour filtering criteria
- PCA axis length multiplier
Refer to the comments in the code for details on adjusting these parameters.
ScrewMeasurement
class: Main class containing the image processing and measurement logicpreprocess_image
: Image preprocessing functiondetect_screw
: Screw detection functionmeasure_length
: Length measurement functionprocess_image
: Single image processing functionprocess_folder
: Batch processing function for multiple imagesanalyze_results
: Statistical analysis function
- Implement a graphical user interface for easier use
- Add support for calibration to convert pixel measurements to real-world units
- Enhance robustness for different lighting conditions and screw types
houmairi
This project is open-source and available under the MIT License.