这里是一个简单的 Python 代码,用于批量提取图像的特征向量:
import os
import cv2
import numpy as np
def extract_features(image_paths):
# 存储特征向量的列表
features = []
# 遍历图像路径列表
for image_path in image_paths:
# 读取图像
image = cv2.imread(image_path)
# 提取 SIFT 特征
sift = cv2