Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
5062CEM_OpenCV_Demo_Python/image_handling.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
23 lines (20 sloc)
1.03 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from classes.ImageHandler import ImageHandler | |
import cv2 | |
if __name__ == "__main__": | |
# Initialises the ImageHandler class | |
imageHandler = ImageHandler() | |
# Create an instance of the class using the SURF (or BRISK) feature detector | |
imageHandler.set_detector("BRISK") | |
# Load an image that we want to find keypoints of interest | |
img = cv2.imread("./images/staff_id.jpg", cv2.IMREAD_COLOR) | |
# Grab some key areas of interest from the training image | |
keypoints = imageHandler.get_keypoints(img) | |
# Extract a descriptor from the training image using the key areas of interest | |
keypoints, descriptor = imageHandler.get_descriptor(img, keypoints) | |
# Draws the keypoints of interest detected from the image | |
img = cv2.drawKeypoints(img, keypoints, (0, 0, 0), cv2.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG) | |
# Displays the image with the detected keypoints | |
cv2.imshow("Window", img) | |
# Waits for the 'ESC' key to be pushed to close the window and end the program | |
if cv2.waitKey(0) == 27: | |
cv2.destroyAllWindows() |