Mau*_*its 4 python opencv image-processing orb
我想使用图像中先前检测到的 ORB 特征位置来提取另一幅图像中的 ORB 描述符,使用较早确定的位置,从而绕过检测器。
我似乎无法获得检测到的特征的深层副本进行处理,然后再传回以生成新的描述符。
f1关键点为im_y图像作品生成描述符代码:
from matplotlib import pyplot as plt
import copy as cp
import cv2
im_x = cv2.imread('stinkbug1.png', 0)
im_y = cv2.imread('stinkbug2.png', 0)
orb = cv2.ORB()
# Keypoint detection in first image
f1 = orb.detect(im_x, None)
f1, d1 = orb.compute(im_x, f1)
# Make a copy of the orginal key points
f2 = cp.deepcopy(f1)
# Magic processing here
# Get descriptors from second y image using the detected points from the x image
f2, d2 = orb.compute(im_y, f2)
# f2 and d2 are now an empty list and a <NoneType>
Run Code Online (Sandbox Code Playgroud)
显然,deepcopy 不适用于 KeyPoint。由于特征 f1 只是一个关键点列表,您可以手动复制关键点列表:
def features_deepcopy (f):
return [cv2.KeyPoint(x = k.pt[0], y = k.pt[1],
_size = k.size, _angle = k.angle,
_response = k.response, _octave = k.octave,
_class_id = k.class_id) for k in f]
f2 = features_deepcopy(f1)
Run Code Online (Sandbox Code Playgroud)
我希望这个能帮上忙 ;-)
克里斯托夫
| 归档时间: |
|
| 查看次数: |
980 次 |
| 最近记录: |