我一直在尝试使用OpenCV的MSER算法的Python实现(opencv 2.4.11)和Java实现(opencv 2.4.10).有趣的是,我注意到MSER的detect在Python和Java中返回不同类型的输出.在Python中,detect返回一个点列表列表,其中每个点列表代表一个检测到的blob.在Java中,Mat返回a,其中每行是单个点,其相关直径表示检测到的blob.我想重现Java中的Python行为,其中blob由一组点定义,而不是一个点.有谁知道发生了什么?
蟒蛇:
frame = cv2.imread('test.jpg')
mser = cv2.MSER(**dict((k, kw[k]) for k in MSER_KEYS))
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
regions = mser.detect(gray, None)
print("REGIONS ARE: " + str(regions))
where the dict given to cv2.MSER is
{'_delta':7, '_min_area': 2000, '_max_area': 20000, '_max_variation': .25, '_min_diversity': .2, '_max_evolution': 200, '_area_threshold': 1.01, '_min_margin': .003, '_edge_blur_size': 5}
Run Code Online (Sandbox Code Playgroud)
Python输出:
REGIONS ARE: [array([[197, 58],
[197, 59],
[197, 60],
...,
[143, 75],
[167, 86],
[172, 98]], dtype=int32), array([[114, 2],
[114, 1],
[114, 0],
...,
[144, 56], …Run Code Online (Sandbox Code Playgroud)