This project is an image processing pipeline that uses ArUco markers to detect and analyze objects in images. The pipeline can correct perspective distortions, calculate object dimensions, and draw bounding boxes around detected objects. The project is designed to process multiple images in batch mode and save the processed output.
- Perspective Correction: Uses ArUco markers to correct the perspective of an image based on a reference image.
- Object Detection: Detects objects in the image using contours.
- Dimension Measurement: Computes the width and height of detected objects in real-world units (e.g., centimeters).
- Batch Processing: Supports multiple sample images at once.
- Automatic Mask Generation: Uses different masking techniques (Canny, ArUco, HSV, etc.) to detect features and contours.
This project requires Python 3 and the following Python libraries:
- opencv-python
- numpy
- argparse
You can install these dependencies using pip:
pip install opencv-python numpy
First, clone this repository to your local machine:
git clone https://github.com/yourusername/aruco-image-processing.git
cd aruco-image-processing
The pipeline can be executed through the command line. You can provide multiple sample images as input, along with a reference image that contains the ArUco markers used for perspective correction.
python scanner.py --reference <path_to_reference_image> --samples <path_to_sample_image1> <path_to_sample_image2> ...
- --reference (-r): Path to the reference image containing ArUco markers (default: Reference_sheet.png).
- --samples (-s): Paths to one or more sample image files that you want to process.
python scanner.py --reference Reference_sheet.png --samples sample1.jpg sample2.jpg sample3.jpg
This will process each of the provided sample images and save the processed output as <sample_name>_processed.jpg.
If you have a directory full of images and you’d like to process all the images in it, you can use a script to pass all files in a directory to the pipeline:
python script_name.py --reference Reference_sheet.png --samples images/*.jpg
For each input image, the pipeline:
- Detects ArUco markers in the image for perspective correction.
- Corrects the perspective of the image based on the reference image.
- Detects objects (e.g., rectangles) and calculates their dimensions.
- Draws bounding boxes around detected objects and overlays the dimensions.
- Saves the processed image as <sample_name>_processed.jpg.
The project directory is organized as follows:
└── petridish_scanner/
├── scanner.py # Main Python script for running the pipeline
├── marker_generator.py # Python script for generating ArUco marker sheets for reference
├── README.md # Project documentation
├── Reference_sheet.png # Example reference image containing ArUco markers
└── requirements.txt # Project dependencies