This project involves processing a video taken by a Remote Operated Vehicle (ROV) to estimate the width of crab shells using computer vision techniques. The project uses various technologies including Azure Custom Vision, Detectron2, and PyTorch.
-
Data Collection and Annotation:
- Collected crab data from various sources including MBARI, Google Open Image dataset, and Google Image search.
- Annotated images using LabelImg and uploaded them to Google Drive.
- Converted annotations to Azure Custom Vision format.
-
Frame Extraction and Image Filtering:
- Exported unique frames from the video by tracking points until they were outside the frame.
- Uploaded frames to Azure Custom Vision for detection.
- Filtered detection probabilities and cropped detected crabs.
-
Instance Segmentation Model:
- Created an instance segmentation model using Detectron2 and PyTorch.
- Converted annotations from LabelMe format to COCO format.
- Trained the model and used it for inference to detect crab shells.
-
Width Estimation:
- Calculated the distance between two red dots in the video to establish a pixel-to-centimeter ratio.
- Estimated crab shell widths and saved the data to a CSV file.
- Python 3.7+
- PyTorch
- Detectron2
- OpenCV
- Pandas
- LabelImg
-
Clone the repository:
git clone https://github.com/MatthewNader2/Crab-Shell-Width-Estimation.git cd crab-shell-width-estimation -
Install the required dependencies:
pip install -r requirements.txt
-
Set up the Detectron2 environment:
python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
- Annotate images and upload to Google Drive.
- Convert annotations to Azure Custom Vision format.
- Use the provided scripts to extract frames from the video, upload to Azure Custom Vision, and filter detections.
- Train the instance segmentation model and use it for inference.
- Calculate crab shell widths using the pixel-to-centimeter ratio and save the results to a CSV file.
data/: Contains the annotated images and CSV files.scripts/: Contains the scripts for data preprocessing, model training, and inference.notebooks/: Jupyter notebooks for exploratory data analysis and model evaluation.
Here are some sample images used in the project:
This project is licensed under the MIT License - see the LICENSE file for details.
- MBARI
- Google Open Image Dataset
- Facebook AI Research (FAIR) for Detectron2

.png)
.png)
.png)