Pas encore de compte ?
Feature Detection and Matching
Copyright (c) 2020 Alexandra Raibolt
Testé sous Anaconda et Python 3.7
# Imports from matplotlib import pyplot as plt import cv2 as cv import numpy as np 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) # SURF is a feature detector and descriptor # Initiate SURF detector SURF = cv.xfeatures2d.SURF_create() # Find the keypoints with SURF keypoints = SURF.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/SURF-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 SURF keypoints, descriptors = SURF.compute(image, keypoints) # Print the descriptor size in bytes print("Size of Descriptor:", SURF.descriptorSize(), "\n") # Print the descriptor type print("Type of Descriptor:", SURF.descriptorType(), "\n") # Print the default norm type print("Default Norm Type:", SURF.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-SURF.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