Commit 789b35d8 authored by abratchik's avatar abratchik

improved fix for java wrapper generator (gen_java.py) to avoid generation of…

improved fix for java wrapper generator (gen_java.py) to avoid generation of java methods with duplicate signatures(v3)
parent be028d07
......@@ -1018,7 +1018,7 @@ public:
*
*
*/
CV_WRAP BFMatcher( int _normType=NORM_L2, bool _crossCheck=false );
CV_WRAP BFMatcher( int normType=NORM_L2, bool crossCheck=false );
virtual ~BFMatcher() {}
......@@ -1036,7 +1036,7 @@ public:
pairs. Such technique usually produces best results with minimal number of outliers when there are
enough matches. This is alternative to the ratio test, used by D. Lowe in SIFT paper.
*/
CV_WRAP static Ptr<BFMatcher> create( int _normType=NORM_L2, bool _crossCheck=false ) ;
CV_WRAP static Ptr<BFMatcher> create( int normType=NORM_L2, bool crossCheck=false ) ;
virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const;
protected:
......@@ -1060,7 +1060,7 @@ matches of descriptor sets because flann::Index does not support this. :
class CV_EXPORTS_W FlannBasedMatcher : public DescriptorMatcher
{
public:
FlannBasedMatcher( const Ptr<flann::IndexParams>& indexParams=makePtr<flann::KDTreeIndexParams>(),
CV_WRAP FlannBasedMatcher( const Ptr<flann::IndexParams>& indexParams=makePtr<flann::KDTreeIndexParams>(),
const Ptr<flann::SearchParams>& searchParams=makePtr<flann::SearchParams>() );
virtual void add( InputArrayOfArrays descriptors );
......
......@@ -1155,6 +1155,7 @@ class JavaWrapperGenerator(object):
# java args
args = fi.args[:] # copy
j_signatures=[]
suffix_counter = int(ci.methods_suffixes.get(fi.jname, -1))
while True:
suffix_counter += 1
......@@ -1233,6 +1234,25 @@ class JavaWrapperGenerator(object):
i += 1
j_epilogue.append( "if("+a.name+"!=null){ " + "; ".join(set_vals) + "; } ")
# calculate java method signature to check for uniqueness
j_args = []
for a in args:
if not a.ctype: #hidden
continue
jt = type_dict[a.ctype]["j_type"]
if a.out and a.ctype in ('bool', 'int', 'long', 'float', 'double'):
jt += '[]'
j_args.append( jt + ' ' + a.name )
j_signature = type_dict[fi.ctype]["j_type"] + " " + \
fi.jname + "(" + ", ".join(j_args) + ")"
logging.info("java: " + j_signature)
if(j_signature in j_signatures):
if args:
pop(args)
continue
else:
break
# java part:
# private java NATIVE method decl
......@@ -1297,15 +1317,6 @@ class JavaWrapperGenerator(object):
if fi.classname:
static = fi.static
j_args = []
for a in args:
if not a.ctype: #hidden
continue
jt = type_dict[a.ctype]["j_type"]
if a.out and a.ctype in ('bool', 'int', 'long', 'float', 'double'):
jt += '[]'
j_args.append( jt + ' ' + a.name )
j_code.write( Template(\
""" public $static $j_type $j_name($j_args)
{
......@@ -1448,6 +1459,9 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_${clazz}_$fname
namespace = ('using namespace ' + ci.namespace.replace('.', '::') + ';') if ci.namespace else ''
) )
# adding method signature to dictionarry
j_signatures.append(j_signature)
# processing args with default values
if not args or not args[-1].defval:
break
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment