adding runtime Android logging in Debug
This commit is contained in:
parent
7159845021
commit
bc9a9b714c
@ -318,11 +318,12 @@ class JavaWrapperGenerator(object):
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
/*
|
|
||||||
|
#ifdef DEBUG
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
#define MODULE_LOG_TAG "OpenCV.%s"
|
#define MODULE_LOG_TAG "OpenCV.%s"
|
||||||
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, MODULE_LOG_TAG, __VA_ARGS__))
|
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, MODULE_LOG_TAG, __VA_ARGS__))
|
||||||
*/
|
#endif // DEBUG
|
||||||
|
|
||||||
""" % module)
|
""" % module)
|
||||||
self.cpp_code.write( "\n".join(['#include "opencv2/%s/%s"' % (module, os.path.basename(f)) \
|
self.cpp_code.write( "\n".join(['#include "opencv2/%s/%s"' % (module, os.path.basename(f)) \
|
||||||
@ -503,14 +504,14 @@ class JavaWrapperGenerator(object):
|
|||||||
# jni_func(..) { return cv_func(..); }
|
# jni_func(..) { return cv_func(..); }
|
||||||
ret = "return "
|
ret = "return "
|
||||||
ext = ""
|
ext = ""
|
||||||
default = "return 0"
|
default = "return 0;"
|
||||||
if fi.ctype == "void":
|
if fi.ctype == "void":
|
||||||
ret = ""
|
ret = ""
|
||||||
default = ""
|
default = ""
|
||||||
elif fi.ctype == "string":
|
elif fi.ctype == "string":
|
||||||
ret = "return env->NewStringUTF"
|
ret = "return env->NewStringUTF"
|
||||||
ext = ".c_str()"
|
ext = ".c_str()"
|
||||||
default = 'return env->NewStringUTF("")'
|
default = 'return env->NewStringUTF("");'
|
||||||
elif fi.ctype in self.classes: # wrapped class:
|
elif fi.ctype in self.classes: # wrapped class:
|
||||||
ret = "return (jlong) new " + self.classes[fi.ctype].jname
|
ret = "return (jlong) new " + self.classes[fi.ctype].jname
|
||||||
|
|
||||||
@ -541,20 +542,26 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_$fname
|
|||||||
($args)
|
($args)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
//LOGD("$module::$fname()");
|
#ifdef DEBUG
|
||||||
|
LOGD("$module::$fname()");
|
||||||
|
#endif // DEBUG
|
||||||
$j2cv
|
$j2cv
|
||||||
$ret( $cvname( $cvargs )$ext );
|
$ret( $cvname( $cvargs )$ext );
|
||||||
} catch(cv::Exception e) {
|
} catch(cv::Exception e) {
|
||||||
//LOGD("$module::$fname() catched cv::Exception: %s", e.what());
|
#ifdef DEBUG
|
||||||
|
LOGD("$module::$fname() catched cv::Exception: %s", e.what());
|
||||||
|
#endif // DEBUG
|
||||||
jclass je = env->FindClass("org/opencv/CvException");
|
jclass je = env->FindClass("org/opencv/CvException");
|
||||||
if(!je) je = env->FindClass("java/lang/Exception");
|
if(!je) je = env->FindClass("java/lang/Exception");
|
||||||
env->ThrowNew(je, e.what());
|
env->ThrowNew(je, e.what());
|
||||||
$default;
|
$default
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
//LOGD("$module::$fname() catched ...");
|
#ifdef DEBUG
|
||||||
|
LOGD("$module::$fname() catched unknown exception (...)");
|
||||||
|
#endif // DEBUG
|
||||||
jclass je = env->FindClass("java/lang/Exception");
|
jclass je = env->FindClass("java/lang/Exception");
|
||||||
env->ThrowNew(je, "Unknown exception in JNI code {$module::$fname()}");
|
env->ThrowNew(je, "Unknown exception in JNI code {$module::$fname()}");
|
||||||
$default;
|
$default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,8 +608,8 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_$fname
|
|||||||
if name == "Mat":
|
if name == "Mat":
|
||||||
continue
|
continue
|
||||||
self.java_code.write( "\n\n" + indent + "// C++: class %s" % (ci.cname) + "\n" )
|
self.java_code.write( "\n\n" + indent + "// C++: class %s" % (ci.cname) + "\n" )
|
||||||
|
self.java_code.write( indent + "//javadoc: " + name + "\n" ) #java doc comment
|
||||||
self.java_code.write( indent + "public static class %s {\n\n" % (ci.jname) )
|
self.java_code.write( indent + "public static class %s {\n\n" % (ci.jname) )
|
||||||
|
|
||||||
# self
|
# self
|
||||||
self.java_code.write( indent_m + "protected final long nativeObj;\n" )
|
self.java_code.write( indent_m + "protected final long nativeObj;\n" )
|
||||||
self.java_code.write( indent_m + "protected %s(long addr) { nativeObj = addr; }\n\n" \
|
self.java_code.write( indent_m + "protected %s(long addr) { nativeObj = addr; }\n\n" \
|
||||||
@ -689,5 +696,3 @@ if __name__ == "__main__":
|
|||||||
generator = JavaWrapperGenerator()
|
generator = JavaWrapperGenerator()
|
||||||
generator.gen(srcfiles, module, dstdir)
|
generator.gen(srcfiles, module, dstdir)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user