From 74c77d826f2f30918a59eccd64c612d22f2f3f01 Mon Sep 17 00:00:00 2001 From: Alexander Mordvintsev Date: Thu, 21 Aug 2014 14:51:03 +0400 Subject: [PATCH] base class name resolution fixed find_obj.py --- modules/python/common.cmake | 2 ++ modules/python/src2/gen2.py | 17 ++++++++++++++--- samples/python2/find_obj.py | 13 ++++++++----- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/modules/python/common.cmake b/modules/python/common.cmake index c79f5400e0..92b9c08634 100644 --- a/modules/python/common.cmake +++ b/modules/python/common.cmake @@ -16,6 +16,7 @@ endforeach(mp) ocv_list_filterout(candidate_deps "^opencv_cud(a|ev)") ocv_list_filterout(candidate_deps "^opencv_matlab$") ocv_list_filterout(candidate_deps "^opencv_ts$") +ocv_list_filterout(candidate_deps "^opencv_adas$") ocv_add_module(${MODULE_NAME} BINDINGS OPTIONAL ${candidate_deps}) @@ -35,6 +36,7 @@ ocv_list_filterout(opencv_hdrs ".h$") ocv_list_filterout(opencv_hdrs "cuda") ocv_list_filterout(opencv_hdrs "cudev") ocv_list_filterout(opencv_hdrs "opencv2/objdetect/detection_based_tracker.hpp") +ocv_list_filterout(opencv_hdrs "opencv2/ximgproc/structured_edge_detection.hpp") set(cv2_generated_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_include.h" diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py index fc1bb7004e..bacd8582ae 100755 --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@ -267,7 +267,7 @@ class ClassInfo(object): #return sys.exit(-1) if self.bases and self.bases[0].startswith("cv::"): self.bases[0] = self.bases[0][4:] - if self.bases and self.bases[0] == "cv::Algorithm": + if self.bases and self.bases[0] == "Algorithm": self.isalgorithm = True for m in decl[2]: if m.startswith("="): @@ -752,8 +752,19 @@ class PythonWrapperGenerator(object): % (classinfo.name, classinfo.cname)) sys.exit(-1) self.classes[classinfo.name] = classinfo - if classinfo.bases and not classinfo.isalgorithm: - classinfo.isalgorithm = self.classes[classinfo.bases[0].replace("::", "_")].isalgorithm + + if classinfo.bases: + chunks = classinfo.bases[0].split('::') + base = '_'.join(chunks) + while base not in self.classes and len(chunks)>1: + del chunks[-2] + base = '_'.join(chunks) + if base not in self.classes: + print("Generator error: unable to resolve base %s for %s" + % (classinfo.bases[0], classinfo.name)) + sys.exit(-1) + classinfo.bases[0] = "::".join(chunks) + classinfo.isalgorithm |= self.classes[base].isalgorithm def split_decl_name(self, name): chunks = name.split('.') diff --git a/samples/python2/find_obj.py b/samples/python2/find_obj.py index ca4ee4daff..718a14fa57 100755 --- a/samples/python2/find_obj.py +++ b/samples/python2/find_obj.py @@ -4,7 +4,7 @@ Feature-based image matching sample. USAGE - find_obj.py [--feature=[-flann]] [ ] + find_obj.py [--feature=[-flann]] [ ] --feature - Feature to use. Can be sift, surf, orb or brisk. Append '-flann' to feature name to use Flann-based matcher instead bruteforce. @@ -23,14 +23,17 @@ FLANN_INDEX_LSH = 6 def init_feature(name): chunks = name.split('-') if chunks[0] == 'sift': - detector = cv2.SIFT() + detector = cv2.xfeatures2d.SIFT() norm = cv2.NORM_L2 elif chunks[0] == 'surf': - detector = cv2.SURF(800) + detector = cv2.xfeatures2d.SURF(800) norm = cv2.NORM_L2 elif chunks[0] == 'orb': detector = cv2.ORB(400) norm = cv2.NORM_HAMMING + elif chunks[0] == 'akaze': + detector = cv2.AKAZE() + norm = cv2.NORM_HAMMING elif chunks[0] == 'brisk': detector = cv2.BRISK() norm = cv2.NORM_HAMMING @@ -136,8 +139,8 @@ if __name__ == '__main__': try: fn1, fn2 = args except: - fn1 = '../c/box.png' - fn2 = '../c/box_in_scene.png' + fn1 = '../cpp/box.png' + fn2 = '../cpp/box_in_scene.png' img1 = cv2.imread(fn1, 0) img2 = cv2.imread(fn2, 0)