【发布时间】:2020-09-08 18:33:58
【问题描述】:
我正在使用 ORB 来检测一组图像上的关键点,如下例所示:
我想要做的是:我想在图像的特定坐标处手动设置 22 个点,并将从这些点中提取的特征存储到特征向量中。例如:
之后,将这些特征分别存储到第 22 维向量中。
我目前用来加载我的图像并设置关键点的代码是这样的:
import matplotlib.pyplot as plt
import numpy as np
import os
import pandas as pd
from sklearn.utils import Bunch
from skimage.io import imread
import skimage
import cv2
DATADIR = "C:/Dataset"
CATEGORIES = ["class 1", "class 2", "class 3", "class 4", "class 5"]
def load_image_files(fullpath):
descr = "A image classification dataset"
for category in CATEGORIES:
path = os.path.join(DATADIR, category)
for person in os.listdir(path):
personfolder = os.path.join(path, person)
for imgname in os.listdir(personfolder):
class_num = CATEGORIES.index(category)
fullpath = os.path.join(personfolder, imgname)
imageList = skimage.io.imread(fullpath)
orb = cv2.ORB_create(22)
kp, des = orb.detectAndCompute(imageList, None)'''
orb = cv2.ORB_create()
key_points = [cv2.KeyPoint(64, 9, 1), cv2.KeyPoint(107, 6, 10), cv2.KeyPoint(171, 10, 10)]
kp, des = orb.compute(imageList, key_points)
drawnImages = cv2.drawKeypoints(imageList, kp, None, flags= cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
cv2.imshow("Image", drawnImages)
cv2.waitKey(0)
return Bunch(target_names=CATEGORIES,
images=images,
DESCR=descr)
这些是我希望从中提取特征的坐标
p1 = 60, 10
p2 = 110, 10
p3 = 170, 10
p4 = 25, 60
p5 = 60, 40
p6 = 110, 35
p7 = 170, 35
p8 = 190, 60
p9 = 30, 95
p10 = 60, 80
p11 = 100, 105
p12 = 120, 105
p13 = 160, 180
p14 = 185, 95
p15 = 25, 160
p16 = 55, 160
p17 = 155, 160
p18 = 185, 160
p19 = 65, 200
p20 = 83, 186
p21 = 128, 186
p22 = 157, 197
【问题讨论】:
-
代码很大,很难理解。下次请提供minimum reproducible example
标签: python opencv computer-vision feature-extraction