def main(): image_dir = sys.argv[1] image_dir = image_dir.rstrip('/') locations = get_locations(image_dir) detectstr = sys.argv[2] detector, matcher = init_feature(detectstr) results = processDirectory(image_dir, detector, matcher, locations) outfile = open(image_dir + detectstr + 'result.txt', 'w') for line in results: outfile.write('#' + line + '\n') outfile.write(str(results[line]) + '\n') outfile.close()
for i, (k, d) in enumerate(ires): print('affine sampling: %d / %d\r' % (i+1, len(params)), end='') keypoints.extend(k) descrs.extend(d) return keypoints, np.array(descrs) if __name__ == '__main__': if len(sys.argv) < 4: print ("Usage %s <image1> <image2> <keypoint_detector>" % sys.argv[0]) exit() img1 = cv2.imread(sys.argv[1], 0) # queryImage img2 = cv2.imread(sys.argv[2], 0) # trainImage detectstr = sys.argv[3] detector, matcher = init_feature(detectstr) print('using', detectstr) cpucount = cv2.getNumberOfCPUs() / 2 pool=ThreadPool(processes = cpucount) print("No. of CPUs: %d" % cpucount) kp1, desc1 = affine_detect(detector, img1, pool=None) kp2, desc2 = affine_detect(detector, img2, pool=None) print('img1 - %d features, img2 - %d features' % (len(kp1), len(kp2))) raw_matches = matcher.knnMatch(desc1, trainDescriptors = desc2, k = 2) #2 p1, p2, kp_pairs = filter_matches(kp1, kp2, raw_matches) if len(p1) >= 4: H, matchMask = cv2.findHomography(p1, p2, cv2.RANSAC, 5.0) print('%d / %d inliers/matched' % (np.sum(matchMask), len(matchMask))) # do not draw outliers (there will be a lot of them)
def main(): image_dir = sys.argv[1] detectstr = sys.argv[2] detector, matcher = init_feature(detectstr) processDirectory(image_dir, detector)