我一直在尝试使用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
答案 0 :(得分:2)
我在OpenCV C ++中使用了orb,如果我没记错的话,掩码必须是CV_8UC1类型,其值为0和255(至少这是我使用的)。你有没有试过这样的?
答案 1 :(得分:0)
答案 2 :(得分:0)
上面代码中的错误是必须将掩码更改为Uint8。因此,这会将掩码更改为值为0到255的CV_8UC1类型。这是使用SIFT功能而非ORB功能的经过全面测试的有效Python代码(版本3):
data source=xx.xx.xx.xx;initial catalog=ca-xx;user id=ca-xx;password=xxxx;connection timeout=600