Pas encore de compte ?
Testé sous Anaconda et Python 3.7
import cv2 as cv import matplotlib.pyplot as plt # Open and convert the input and training-set image from BGR to GRAYSCALE image1 = cv.imread(filename = 'image1.jpg', flags = cv.IMREAD_GRAYSCALE) image2 = cv.imread(filename = 'image2.jpg', flags = cv.IMREAD_GRAYSCALE) # Initiate AKAZE descriptor AKAZE = cv.AKAZE_create() # Find the keypoints and compute the descriptors for input and training-set image keypoints1, descriptors1 = AKAZE.detectAndCompute(image1, None) keypoints2, descriptors2 = AKAZE.detectAndCompute(image2, None) # create BFMatcher object BFMatcher = cv.BFMatcher(normType = cv.NORM_HAMMING, crossCheck = True) # Matching descriptor vectors using Brute Force Matcher matches = BFMatcher.match(queryDescriptors = descriptors1, trainDescriptors = descriptors2) # Sort them in the order of their distance matches = sorted(matches, key = lambda x: x.distance) # Draw first 15 matches output = cv.drawMatches(img1 = image1, keypoints1 = keypoints1, img2 = image2, keypoints2 = keypoints2, matches1to2 = matches[:15], outImg = None, flags = cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS) plt.imshow(output) plt.show()
Source : https://stackoverflow.com/questions/62571115/how-to-implement-brisk-using-python-and-opencv-to-detect-features
Testé sous Anaconda et Python 3.7
# Imports from matplotlib import pyplot as plt import cv2 as cv import os import pickle # Open and convert a input # image from BGR to GRAYSCALE image = cv.imread(filename = 'Figures/pexels-bestbe-models-2412691.jpg', flags = cv.IMREAD_GRAYSCALE) # AKAZE is a feature detector and descriptor # Initiate AKAZE detector AKAZE = cv.AKAZE_create() # Find the keypoints with AKAZE keypoints = AKAZE.detect(image, None) # Print number of keypoints detected print("Number of keypoints Detected:", len(keypoints), "\n") # Save Keypoints to a file index = [] for point in keypoints: temp = (point.pt, point.size, point.angle, point.response, point.octave, point.class_id) index.append(temp) # File name filename = "Outputs/AKAZE-keypoints.txt" # Delete a file if it exists if os.path.exists(filename): os.remove(filename) # Open a file file = open(filename, "wb") # Write file.write(pickle.dumps(index)) # Close a file file.close() # Compute the descriptors with AKAZE keypoints, descriptors = AKAZE.compute(image, keypoints) # Print the descriptor size in bytes print("Size of Descriptor:", AKAZE.descriptorSize(), "\n") # Print the descriptor type print("Type of Descriptor:", AKAZE.descriptorType(), "\n") # Print the default norm type print("Default Norm Type:", AKAZE.defaultNorm(), "\n") # Print shape of descriptor print("Shape of Descriptor:", descriptors.shape, "\n") # Draw only 50 keypoints on input image image = cv.drawKeypoints(image = image, keypoints = keypoints[:50], outImage = None, flags = cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS) # Plot input image # Turn interactive plotting off plt.ioff() # Create a new figure plt.figure() plt.axis('off') plt.imshow(image) plt.show() plt.imsave(fname = 'Figures/feature-detection-AKAZE.jpg', arr = image, dpi = 300) # Close it plt.close()
Feature Detection and Description
Copyright (c) 2020 Alexandra Raibolt
Bienvenu, je m’appelle Eric Soupet et je suis l'administrateur du site elodees.com. elodees.com est un état de l'art de l'Intelligence Artificielle et se veut collaboratif, vous pouvez dès à présent proposer du contenu tels que des articles, des événements, des tutoriels, ... alors n'hésitez pas !
Crédit des images de la plate-forme : Pixabay - Pixabay License | Pexels - Pexels License