I've been trying to use ORB to find keypoint/descriptors and I need to mask out part of the image because many features are very similar in two parts of my image. However, I can't determine the correct format of the mask parameter to the detectandcompute function, and the documentation is ambiguous to me. I tried looking at the source code but I am not familiar enough with C++ to understand it. I thought it was just a binary array where 1 = use and 0 = ignore, but every mask I've tried doesn't return any keypoints. Here is some example code:
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)
The documentation is here:http://docs.opencv.org/3.0-beta/modules/features2d/doc/feature_detection_and_description.html