gpt4 book ai didi

python - OpenCV 的 Python ORB 模块的掩码格式是什么?

转载 作者:太空宇宙 更新时间:2023-11-03 22:27:07 24 4
gpt4 key购买 nike

我一直在尝试使用 ORB 来查找关键点/描述符,我需要屏蔽掉部分图像,因为图像的两个部分中的许多特征非常相似。但是,我无法确定 detectandcompute 函数的 mask 参数的正确格式,并且文档对我来说不明确。我试着查看源代码,但我对 C++ 不够熟悉,无法理解它。我认为它只是一个二进制数组,其中 1 = 使用和 0 = 忽略,但我尝试过的每个掩码都不返回任何关键点。下面是一些示例代码:

img1_gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
img2_gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
#ignore the left half of the first image
mask1 = np.ones(img1_gray.shape)
mask1[:,:mask1.shape[1]/2] = 0
#ignore the right half of the second image
mask2 = np.ones(img2_gray.shape)
mask2[:,mask2.shape[1]/2:] = 0
kp1, des1 =orb.detectAndCompute(img1_gray,mask1)
kp2, des2 =orb.detectAndCompute(img2_gray,mask2)

文档在这里:http://docs.opencv.org/3.0-beta/modules/features2d/doc/feature_detection_and_description.html

img1 img2

最佳答案

我在 OpenCV C++ 中使用过 orb,如果我没记错的话,掩码必须是 CV_8UC1 类型,值为 0 和 255(至少我是这样使用的)。你已经尝试过了吗?

关于python - OpenCV 的 Python ORB 模块的掩码格式是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35951675/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com