Utilizing the power of YOLOv8 and Segment Anything by Meta AI, this Python script offers sophisticated template matching and precise orientation detection capabilities, revolutionizing image analysis with cutting-edge technology."
- Python 3.x
- Segment Anything
pip install 'git+https://github.com/facebookresearch/segment-anything.git' wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth
- YoloV8
pip install ultralytics
- OpenCV
pip install opencv-python
- Numpy
pip install numpy
- ScikitLearn
pip install scikit-learn
- Matplotlib
pip install matplotlib
-
Clone the repository:
git clone https://github.com/vinod-polinati/ImageSegmentation.git
-
Navigate to the project directory:
cd ImageSegmentation
-
Run the
YoloV8_Sam.ipynb
script with the paths to your template and test images
The YoloV8_Sam.ipynb
script performs the following steps:
- Image Loading: Load the template image and the test image.
- Feature Detection and Description:
- Use the ORB (Oriented FAST and Rotated BRIEF) detector to find keypoints and compute descriptors for both images.
- Feature Matching:
- Match the descriptors of the template image with those of the test image using a Brute-Force matcher.
- Homography Estimation:
- Calculate the homography matrix using RANSAC (Random Sample Consensus) to find a perspective transformation between the keypoints.
- Transform Template Corners:
- Use the homography matrix to transform the corners of the template image onto the test image.
- Rotation Angle Calculation:
- Determine the rotation angle based on the homography matrix.
- Annotate Test Image:
- Draw a polygon around the detected object (template) on the test image and annotate the rotation angle.
- Display Result:
- Show the annotated test image with the detected object and rotation angle.
- Ensure that the specified paths to the template and test images are correct.
- The script will display the annotated test image in a window. Press 'Q' to close the window and end the script.
Feel free to modify and integrate this script into your projects for template matching and orientation detection tasks.