mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
Merge pull request #17428 from asmorkalov:as/java_smart_constructors
This commit is contained in:
commit
c6b60e219d
@ -12,6 +12,7 @@ import org.opencv.core.Point;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.core.DMatch;
|
||||
import org.opencv.features2d.DescriptorMatcher;
|
||||
import org.opencv.features2d.BFMatcher;
|
||||
import org.opencv.core.KeyPoint;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
@ -93,6 +94,15 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
|
||||
};
|
||||
}
|
||||
|
||||
// https://github.com/opencv/opencv/issues/11268
|
||||
public void testConstructor()
|
||||
{
|
||||
BFMatcher self_created_matcher = new BFMatcher();
|
||||
Mat train = new Mat(1, 1, CvType.CV_8U, new Scalar(123));
|
||||
self_created_matcher.add(Arrays.asList(train));
|
||||
assertTrue(!self_created_matcher.empty());
|
||||
}
|
||||
|
||||
public void testAdd() {
|
||||
matcher.add(Arrays.asList(new Mat()));
|
||||
assertFalse(matcher.empty());
|
||||
|
@ -12,6 +12,7 @@ import org.opencv.core.Point;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.core.DMatch;
|
||||
import org.opencv.features2d.DescriptorMatcher;
|
||||
import org.opencv.features2d.FlannBasedMatcher;
|
||||
import org.opencv.core.KeyPoint;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
@ -168,6 +169,15 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
|
||||
};
|
||||
}
|
||||
|
||||
// https://github.com/opencv/opencv/issues/11268
|
||||
public void testConstructor()
|
||||
{
|
||||
FlannBasedMatcher self_created_matcher = new FlannBasedMatcher();
|
||||
Mat train = new Mat(1, 1, CvType.CV_8U, new Scalar(123));
|
||||
self_created_matcher.add(Arrays.asList(train));
|
||||
assertTrue(!self_created_matcher.empty());
|
||||
}
|
||||
|
||||
public void testAdd() {
|
||||
matcher.add(Arrays.asList(new Mat()));
|
||||
assertFalse(matcher.empty());
|
||||
|
@ -877,7 +877,10 @@ class JavaWrapperGenerator(object):
|
||||
ret = ""
|
||||
default = ""
|
||||
elif not fi.ctype: # c-tor
|
||||
ret = "return (jlong) _retval_;"
|
||||
if self.isSmartClass(ci):
|
||||
ret = "return (jlong)(new Ptr<%(ctype)s>(_retval_));" % { 'ctype': fi.fullClass(isCPP=True) }
|
||||
else:
|
||||
ret = "return (jlong) _retval_;"
|
||||
elif "v_type" in type_dict[fi.ctype]: # c-tor
|
||||
if type_dict[fi.ctype]["v_type"] in ("Mat", "vector_Mat"):
|
||||
ret = "return (jlong) _retval_;"
|
||||
@ -920,8 +923,12 @@ class JavaWrapperGenerator(object):
|
||||
c_epilogue.append("return " + fi.ctype + "_to_List(env, _ret_val_vector_);")
|
||||
if fi.classname:
|
||||
if not fi.ctype: # c-tor
|
||||
retval = fi.fullClass(isCPP=True) + "* _retval_ = "
|
||||
cvname = "new " + fi.fullClass(isCPP=True)
|
||||
if self.isSmartClass(ci):
|
||||
retval = self.smartWrap(ci, fi.fullClass(isCPP=True)) + " _retval_ = "
|
||||
cvname = "makePtr<" + fi.fullClass(isCPP=True) +">"
|
||||
else:
|
||||
retval = fi.fullClass(isCPP=True) + "* _retval_ = "
|
||||
cvname = "new " + fi.fullClass(isCPP=True)
|
||||
elif fi.static:
|
||||
cvname = fi.fullName(isCPP=True)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user