1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 07:13:02 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Alekhin
2021-10-15 15:59:36 +00:00
537 changed files with 39768 additions and 10712 deletions
@@ -36,10 +36,6 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
sourceSets {
main {
+1 -5
View File
@@ -58,7 +58,7 @@
//
// - Use find_package() in app/CMakeLists.txt:
//
// find_package(OpenCV 3.4 REQUIRED java)
// find_package(OpenCV @OPENCV_VERSION_MAJOR@.@OPENCV_VERSION_MINOR@ REQUIRED java)
// ...
// target_link_libraries(native-lib ${OpenCV_LIBRARIES})
//
@@ -128,10 +128,6 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
sourceSets {
main {
+19 -15
View File
@@ -267,6 +267,8 @@ class ClassInfo(GeneralInfo):
for m in decl[2]:
if m.startswith("="):
self.jname = m[1:]
if m == '/Simple':
self.smart = False
if self.classpath:
prefix = self.classpath.replace('.', '_')
@@ -457,7 +459,7 @@ class JavaWrapperGenerator(object):
def clear(self):
self.namespaces = ["cv"]
classinfo_Mat = ClassInfo([ 'class cv.Mat', '', [], [] ], self.namespaces)
classinfo_Mat = ClassInfo([ 'class cv.Mat', '', ['/Simple'], [] ], self.namespaces)
self.classes = { "Mat" : classinfo_Mat }
self.module = ""
self.Module = ""
@@ -478,10 +480,15 @@ class JavaWrapperGenerator(object):
if name in type_dict and not classinfo.base:
logging.warning('duplicated: %s', classinfo)
return
if self.isSmartClass(classinfo):
jni_name = "*((*(Ptr<"+classinfo.fullNameCPP()+">*)%(n)s_nativeObj).get())"
else:
jni_name = "(*("+classinfo.fullNameCPP()+"*)%(n)s_nativeObj)"
type_dict.setdefault(name, {}).update(
{ "j_type" : classinfo.jname,
"jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),),
"jni_name" : "(*("+classinfo.fullNameCPP()+"*)%(n)s_nativeObj)", "jni_type" : "jlong",
"jni_name" : jni_name,
"jni_type" : "jlong",
"suffix" : "J",
"j_import" : "org.opencv.%s.%s" % (self.module, classinfo.jname)
}
@@ -489,7 +496,8 @@ class JavaWrapperGenerator(object):
type_dict.setdefault(name+'*', {}).update(
{ "j_type" : classinfo.jname,
"jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),),
"jni_name" : "("+classinfo.fullNameCPP()+"*)%(n)s_nativeObj", "jni_type" : "jlong",
"jni_name" : "&("+jni_name+")",
"jni_type" : "jlong",
"suffix" : "J",
"j_import" : "org.opencv.%s.%s" % (self.module, classinfo.jname)
}
@@ -979,7 +987,13 @@ class JavaWrapperGenerator(object):
ret = "return env->NewStringUTF(_retval_.c_str());"
default = 'return env->NewStringUTF("");'
elif self.isWrapped(fi.ctype): # wrapped class:
ret = "return (jlong) new %s(_retval_);" % self.fullTypeNameCPP(fi.ctype)
ret = None
if fi.ctype in self.classes:
ret_ci = self.classes[fi.ctype]
if self.isSmartClass(ret_ci):
ret = "return (jlong)(new Ptr<%(ctype)s>(new %(ctype)s(_retval_)));" % { 'ctype': ret_ci.fullNameCPP() }
if ret is None:
ret = "return (jlong) new %s(_retval_);" % self.fullTypeNameCPP(fi.ctype)
elif fi.ctype.startswith('Ptr_'):
c_prologue.append("typedef Ptr<%s> %s;" % (self.fullTypeNameCPP(fi.ctype[4:]), fi.ctype))
ret = "return (jlong)(new %(ctype)s(_retval_));" % { 'ctype':fi.ctype }
@@ -1221,17 +1235,7 @@ JNIEXPORT void JNICALL Java_org_opencv_%(module)s_%(j_cls)s_delete
if ci.smart != None:
return ci.smart
# if parents are smart (we hope) then children are!
# if not we believe the class is smart if it has "create" method
ci.smart = False
if ci.base or ci.name == 'Algorithm':
ci.smart = True
else:
for fi in ci.methods:
if fi.name == "create":
ci.smart = True
break
ci.smart = True # smart class is not properly handled in case of base/derived classes
return ci.smart
def smartWrap(self, ci, fullname):
+26
View File
@@ -1372,6 +1372,32 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJ
}
//
// Mat Mat Mat::matMul(Mat m)
//
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1matMul__JJ
(JNIEnv* env, jclass, jlong self, jlong m_nativeObj);
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1matMul__JJ
(JNIEnv* env, jclass, jlong self, jlong m_nativeObj)
{
static const char method_name[] = "Mat::n_1matMul__JJ()";
try {
LOGD("%s", method_name);
Mat* me = (Mat*) self; //TODO: check for NULL
Mat& m = *((Mat*)m_nativeObj);
Mat _retval_ = (*me) * m;
return (jlong) new Mat(_retval_);
} catch(const std::exception &e) {
throwJavaException(env, &e, method_name);
} catch (...) {
throwJavaException(env, 0, method_name);
}
return 0;
}
//
// static Mat Mat::ones(int rows, int cols, int type)
@@ -28,9 +28,9 @@ public class ConvertersTest extends OpenCVTestCase {
byte value1 = 2;
byte value2 = 4;
byte value3 = 3;
truth.add(new Byte(value1));
truth.add(new Byte(value2));
truth.add(new Byte(value3));
truth.add(Byte.valueOf(value1));
truth.add(Byte.valueOf(value2));
truth.add(Byte.valueOf(value3));
assertEquals(truth, bs);
}
@@ -248,9 +248,9 @@ public class ConvertersTest extends OpenCVTestCase {
byte value1 = 2;
byte value2 = 4;
byte value3 = 3;
truth.add(new Byte(value1));
truth.add(new Byte(value2));
truth.add(new Byte(value3));
truth.add(Byte.valueOf(value1));
truth.add(Byte.valueOf(value2));
truth.add(Byte.valueOf(value3));
assertEquals(truth, bs);
}
@@ -276,10 +276,10 @@ public class ConvertersTest extends OpenCVTestCase {
byte value2 = 2;
byte value3 = 3;
byte value4 = 4;
bytes.add(new Byte(value1));
bytes.add(new Byte(value2));
bytes.add(new Byte(value3));
bytes.add(new Byte(value4));
bytes.add(Byte.valueOf(value1));
bytes.add(Byte.valueOf(value2));
bytes.add(Byte.valueOf(value3));
bytes.add(Byte.valueOf(value4));
dst = Converters.vector_char_to_Mat(bytes);
truth = new Mat(4, 1, CvType.CV_8SC1);
@@ -499,10 +499,10 @@ public class ConvertersTest extends OpenCVTestCase {
byte value2 = 2;
byte value3 = 3;
byte value4 = 4;
bytes.add(new Byte(value1));
bytes.add(new Byte(value2));
bytes.add(new Byte(value3));
bytes.add(new Byte(value4));
bytes.add(Byte.valueOf(value1));
bytes.add(Byte.valueOf(value2));
bytes.add(Byte.valueOf(value3));
bytes.add(Byte.valueOf(value4));
dst = Converters.vector_uchar_to_Mat(bytes);
truth = new Mat(4, 1, CvType.CV_8UC1);