From: Andrey Kamaev Date: Wed, 20 Mar 2013 16:46:22 +0000 (+0400) Subject: Java wrapper is adapted for cv::String X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~3955^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=688d170de749a4db1e5227828ae354ad39f5c8f5;p=platform%2Fupstream%2Fopencv.git Java wrapper is adapted for cv::String --- diff --git a/modules/java/CMakeLists.txt b/modules/java/CMakeLists.txt index cf99226..694e960 100644 --- a/modules/java/CMakeLists.txt +++ b/modules/java/CMakeLists.txt @@ -272,6 +272,8 @@ endif(ANDROID) add_library(${the_module} SHARED ${handwrittren_h_sources} ${handwrittren_cpp_sources} ${generated_cpp_sources} ${copied_files} "${JAR_FILE}" "${JAR_FILE}.dephelper") +set_target_properties(${the_module} PROPERTIES COMPILE_DEFINITIONS OPENCV_NOSTL) + if(BUILD_FAT_JAVA_LIB) set(__deps ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULES_BUILD}) list(REMOVE_ITEM __deps ${the_module} opencv_ts) diff --git a/modules/java/generator/gen_java.py b/modules/java/generator/gen_java.py index 030f6c8..49171b2 100755 --- a/modules/java/generator/gen_java.py +++ b/modules/java/generator/gen_java.py @@ -285,13 +285,13 @@ type_dict = { "CvSlice" : { "j_type" : "Range", "jn_args" : (("int", ".start"), ("int", ".end")), "jni_var" : "Range %(n)s(%(n)s_start, %(n)s_end)", "jni_type" : "jdoubleArray", "suffix" : "II"}, - "string" : { "j_type" : "String", "jn_type" : "String", + "String" : { "j_type" : "String", "jn_type" : "String", "jni_type" : "jstring", "jni_name" : "n_%(n)s", - "jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); std::string n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)', + "jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); cv::String n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)', "suffix" : "Ljava_lang_String_2"}, "c_string": { "j_type" : "String", "jn_type" : "String", "jni_type" : "jstring", "jni_name" : "n_%(n)s.c_str()", - "jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); std::string n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)', + "jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); cv::String n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)', "suffix" : "Ljava_lang_String_2"}, "TermCriteria": { "j_type" : "TermCriteria", "jn_args" : (("int", ".type"), ("int", ".maxCount"), ("double", ".epsilon")), "jni_var" : "TermCriteria %(n)s(%(n)s_type, %(n)s_maxCount, %(n)s_epsilon)", "jni_type" : "jdoubleArray", @@ -417,7 +417,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual { 'j_code' : """ - // C++: Size getTextSize(const std::string& text, int fontFace, double fontScale, int thickness, int* baseLine); + // C++: Size getTextSize(const cv::String& text, int fontFace, double fontScale, int thickness, int* baseLine); //javadoc:getTextSize(text, fontFace, fontScale, thickness, baseLine) public static Size getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine) { if(baseLine != null && baseLine.length != 1) @@ -430,7 +430,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual """ private static native double[] n_getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine);\n""", 'cpp_code' : """ -// C++: Size getTextSize(const std::string& text, int fontFace, double fontScale, int thickness, int* baseLine); +// C++: Size getTextSize(const cv::String& text, int fontFace, double fontScale, int thickness, int* baseLine); JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize (JNIEnv*, jclass, jstring, jint, jdouble, jint, jintArray); JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize @@ -445,7 +445,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize } const char* utf_text = env->GetStringUTFChars(text, 0); - std::string n_text( utf_text ? utf_text : "" ); + cv::String n_text( utf_text ? utf_text : "" ); env->ReleaseStringUTFChars(text, utf_text); int _baseLine; @@ -1196,7 +1196,7 @@ extern "C" { ret = "return (jlong) _retval_;" elif fi.ctype.startswith('vector'): # c-tor ret = "return (jlong) _retval_;" - elif fi.ctype == "string": + elif fi.ctype == "String": ret = "return env->NewStringUTF(_retval_.c_str());" default = 'return env->NewStringUTF("");' elif fi.ctype in self.classes: # wrapped class: @@ -1218,8 +1218,8 @@ extern "C" { retval = fi.ctype + " _retval_ = " if fi.ctype == "void": retval = "" - elif fi.ctype == "string": - retval = "std::" + retval + elif fi.ctype == "String": + retval = "cv::" + retval elif fi.ctype.startswith('vector'): retval = type_dict[fi.ctype]['jni_var'] % {"n" : '_ret_val_vector_'} + " = " c_epilogue.append("Mat* _retval_ = new Mat();") diff --git a/modules/java/generator/src/cpp/features2d_manual.hpp b/modules/java/generator/src/cpp/features2d_manual.hpp index 39fcafa..b76737c 100644 --- a/modules/java/generator/src/cpp/features2d_manual.hpp +++ b/modules/java/generator/src/cpp/features2d_manual.hpp @@ -84,7 +84,7 @@ public: //not supported: SimpleBlob, Dense CV_WRAP static javaFeatureDetector* create( int detectorType ) { - std::string name; + cv::String name; if (detectorType > DYNAMICDETECTOR) { name = "Dynamic"; @@ -104,37 +104,37 @@ public: switch(detectorType) { case FAST: - name += "FAST"; + name = name + "FAST"; break; case STAR: - name += "STAR"; + name = name + "STAR"; break; case SIFT: - name += "SIFT"; + name = name + "SIFT"; break; case SURF: - name += "SURF"; + name = name + "SURF"; break; case ORB: - name += "ORB"; + name = name + "ORB"; break; case MSER: - name += "MSER"; + name = name + "MSER"; break; case GFTT: - name += "GFTT"; + name = name + "GFTT"; break; case HARRIS: - name += "HARRIS"; + name = name + "HARRIS"; break; case SIMPLEBLOB: - name += "SimpleBlob"; + name = name + "SimpleBlob"; break; case DENSE: - name += "Dense"; + name = name + "Dense"; break; case BRISK: - name += "BRISK"; + name = name + "BRISK"; break; default: CV_Error( CV_StsBadArg, "Specified feature detector type is not supported." ); @@ -146,14 +146,14 @@ public: return (javaFeatureDetector*)((FeatureDetector*) detector); } - CV_WRAP void write( const std::string& fileName ) const + CV_WRAP void write( const cv::String& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); ((FeatureDetector*)this)->write(fs); fs.release(); } - CV_WRAP void read( const std::string& fileName ) + CV_WRAP void read( const cv::String& fileName ) { FileStorage fs(fileName, FileStorage::READ); ((FeatureDetector*)this)->read(fs.root()); @@ -208,7 +208,7 @@ public: //supported: FlannBased, BruteForce, BruteForce-L1, BruteForce-Hamming, BruteForce-HammingLUT CV_WRAP static javaDescriptorMatcher* create( int matcherType ) { - std::string name; + cv::String name; switch(matcherType) { @@ -240,14 +240,14 @@ public: return (javaDescriptorMatcher*)((DescriptorMatcher*) matcher); } - CV_WRAP void write( const std::string& fileName ) const + CV_WRAP void write( const cv::String& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); ((DescriptorMatcher*)this)->write(fs); fs.release(); } - CV_WRAP void read( const std::string& fileName ) + CV_WRAP void read( const cv::String& fileName ) { FileStorage fs(fileName, FileStorage::READ); ((DescriptorMatcher*)this)->read(fs.root()); @@ -294,7 +294,7 @@ public: //not supported: Calonder CV_WRAP static javaDescriptorExtractor* create( int extractorType ) { - std::string name; + cv::String name; if (extractorType > OPPONENTEXTRACTOR) { @@ -305,22 +305,22 @@ public: switch(extractorType) { case SIFT: - name += "SIFT"; + name = name + "SIFT"; break; case SURF: - name += "SURF"; + name = name + "SURF"; break; case ORB: - name += "ORB"; + name = name + "ORB"; break; case BRIEF: - name += "BRIEF"; + name = name + "BRIEF"; break; case BRISK: - name += "BRISK"; + name = name + "BRISK"; break; case FREAK: - name += "FREAK"; + name = name + "FREAK"; break; default: CV_Error( CV_StsBadArg, "Specified descriptor extractor type is not supported." ); @@ -332,14 +332,14 @@ public: return (javaDescriptorExtractor*)((DescriptorExtractor*) extractor); } - CV_WRAP void write( const std::string& fileName ) const + CV_WRAP void write( const cv::String& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); ((DescriptorExtractor*)this)->write(fs); fs.release(); } - CV_WRAP void read( const std::string& fileName ) + CV_WRAP void read( const cv::String& fileName ) { FileStorage fs(fileName, FileStorage::READ); ((DescriptorExtractor*)this)->read(fs.root()); @@ -401,7 +401,7 @@ public: //unsupported: Vector CV_WRAP static javaGenericDescriptorMatcher* create( int matcherType ) { - std::string name; + cv::String name; switch(matcherType) { @@ -421,14 +421,14 @@ public: return (javaGenericDescriptorMatcher*)((GenericDescriptorMatcher*) matcher); } - CV_WRAP void write( const std::string& fileName ) const + CV_WRAP void write( const cv::String& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); ((GenericDescriptorMatcher*)this)->write(fs); fs.release(); } - CV_WRAP void read( const std::string& fileName ) + CV_WRAP void read( const cv::String& fileName ) { FileStorage fs(fileName, FileStorage::READ); ((GenericDescriptorMatcher*)this)->read(fs.root());