Java wrapper is adapted for cv::String
This commit is contained in:
@@ -272,6 +272,8 @@ endif(ANDROID)
|
|||||||
add_library(${the_module} SHARED ${handwrittren_h_sources} ${handwrittren_cpp_sources} ${generated_cpp_sources}
|
add_library(${the_module} SHARED ${handwrittren_h_sources} ${handwrittren_cpp_sources} ${generated_cpp_sources}
|
||||||
${copied_files}
|
${copied_files}
|
||||||
"${JAR_FILE}" "${JAR_FILE}.dephelper")
|
"${JAR_FILE}" "${JAR_FILE}.dephelper")
|
||||||
|
set_target_properties(${the_module} PROPERTIES COMPILE_DEFINITIONS OPENCV_NOSTL)
|
||||||
|
|
||||||
if(BUILD_FAT_JAVA_LIB)
|
if(BUILD_FAT_JAVA_LIB)
|
||||||
set(__deps ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULES_BUILD})
|
set(__deps ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULES_BUILD})
|
||||||
list(REMOVE_ITEM __deps ${the_module} opencv_ts)
|
list(REMOVE_ITEM __deps ${the_module} opencv_ts)
|
||||||
|
@@ -285,13 +285,13 @@ type_dict = {
|
|||||||
"CvSlice" : { "j_type" : "Range", "jn_args" : (("int", ".start"), ("int", ".end")),
|
"CvSlice" : { "j_type" : "Range", "jn_args" : (("int", ".start"), ("int", ".end")),
|
||||||
"jni_var" : "Range %(n)s(%(n)s_start, %(n)s_end)", "jni_type" : "jdoubleArray",
|
"jni_var" : "Range %(n)s(%(n)s_start, %(n)s_end)", "jni_type" : "jdoubleArray",
|
||||||
"suffix" : "II"},
|
"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_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"},
|
"suffix" : "Ljava_lang_String_2"},
|
||||||
"c_string": { "j_type" : "String", "jn_type" : "String",
|
"c_string": { "j_type" : "String", "jn_type" : "String",
|
||||||
"jni_type" : "jstring", "jni_name" : "n_%(n)s.c_str()",
|
"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"},
|
"suffix" : "Ljava_lang_String_2"},
|
||||||
"TermCriteria": { "j_type" : "TermCriteria", "jn_args" : (("int", ".type"), ("int", ".maxCount"), ("double", ".epsilon")),
|
"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",
|
"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' :
|
'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)
|
//javadoc:getTextSize(text, fontFace, fontScale, thickness, baseLine)
|
||||||
public static Size getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine) {
|
public static Size getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine) {
|
||||||
if(baseLine != null && baseLine.length != 1)
|
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""",
|
""" private static native double[] n_getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine);\n""",
|
||||||
'cpp_code' :
|
'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 (JNIEnv*, jclass, jstring, jint, jdouble, jint, jintArray);
|
||||||
|
|
||||||
JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize
|
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);
|
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);
|
env->ReleaseStringUTFChars(text, utf_text);
|
||||||
|
|
||||||
int _baseLine;
|
int _baseLine;
|
||||||
@@ -1196,7 +1196,7 @@ extern "C" {
|
|||||||
ret = "return (jlong) _retval_;"
|
ret = "return (jlong) _retval_;"
|
||||||
elif fi.ctype.startswith('vector'): # c-tor
|
elif fi.ctype.startswith('vector'): # c-tor
|
||||||
ret = "return (jlong) _retval_;"
|
ret = "return (jlong) _retval_;"
|
||||||
elif fi.ctype == "string":
|
elif fi.ctype == "String":
|
||||||
ret = "return env->NewStringUTF(_retval_.c_str());"
|
ret = "return env->NewStringUTF(_retval_.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:
|
||||||
@@ -1218,8 +1218,8 @@ extern "C" {
|
|||||||
retval = fi.ctype + " _retval_ = "
|
retval = fi.ctype + " _retval_ = "
|
||||||
if fi.ctype == "void":
|
if fi.ctype == "void":
|
||||||
retval = ""
|
retval = ""
|
||||||
elif fi.ctype == "string":
|
elif fi.ctype == "String":
|
||||||
retval = "std::" + retval
|
retval = "cv::" + retval
|
||||||
elif fi.ctype.startswith('vector'):
|
elif fi.ctype.startswith('vector'):
|
||||||
retval = type_dict[fi.ctype]['jni_var'] % {"n" : '_ret_val_vector_'} + " = "
|
retval = type_dict[fi.ctype]['jni_var'] % {"n" : '_ret_val_vector_'} + " = "
|
||||||
c_epilogue.append("Mat* _retval_ = new Mat();")
|
c_epilogue.append("Mat* _retval_ = new Mat();")
|
||||||
|
@@ -84,7 +84,7 @@ public:
|
|||||||
//not supported: SimpleBlob, Dense
|
//not supported: SimpleBlob, Dense
|
||||||
CV_WRAP static javaFeatureDetector* create( int detectorType )
|
CV_WRAP static javaFeatureDetector* create( int detectorType )
|
||||||
{
|
{
|
||||||
std::string name;
|
cv::String name;
|
||||||
if (detectorType > DYNAMICDETECTOR)
|
if (detectorType > DYNAMICDETECTOR)
|
||||||
{
|
{
|
||||||
name = "Dynamic";
|
name = "Dynamic";
|
||||||
@@ -104,37 +104,37 @@ public:
|
|||||||
switch(detectorType)
|
switch(detectorType)
|
||||||
{
|
{
|
||||||
case FAST:
|
case FAST:
|
||||||
name += "FAST";
|
name = name + "FAST";
|
||||||
break;
|
break;
|
||||||
case STAR:
|
case STAR:
|
||||||
name += "STAR";
|
name = name + "STAR";
|
||||||
break;
|
break;
|
||||||
case SIFT:
|
case SIFT:
|
||||||
name += "SIFT";
|
name = name + "SIFT";
|
||||||
break;
|
break;
|
||||||
case SURF:
|
case SURF:
|
||||||
name += "SURF";
|
name = name + "SURF";
|
||||||
break;
|
break;
|
||||||
case ORB:
|
case ORB:
|
||||||
name += "ORB";
|
name = name + "ORB";
|
||||||
break;
|
break;
|
||||||
case MSER:
|
case MSER:
|
||||||
name += "MSER";
|
name = name + "MSER";
|
||||||
break;
|
break;
|
||||||
case GFTT:
|
case GFTT:
|
||||||
name += "GFTT";
|
name = name + "GFTT";
|
||||||
break;
|
break;
|
||||||
case HARRIS:
|
case HARRIS:
|
||||||
name += "HARRIS";
|
name = name + "HARRIS";
|
||||||
break;
|
break;
|
||||||
case SIMPLEBLOB:
|
case SIMPLEBLOB:
|
||||||
name += "SimpleBlob";
|
name = name + "SimpleBlob";
|
||||||
break;
|
break;
|
||||||
case DENSE:
|
case DENSE:
|
||||||
name += "Dense";
|
name = name + "Dense";
|
||||||
break;
|
break;
|
||||||
case BRISK:
|
case BRISK:
|
||||||
name += "BRISK";
|
name = name + "BRISK";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CV_Error( CV_StsBadArg, "Specified feature detector type is not supported." );
|
CV_Error( CV_StsBadArg, "Specified feature detector type is not supported." );
|
||||||
@@ -146,14 +146,14 @@ public:
|
|||||||
return (javaFeatureDetector*)((FeatureDetector*) detector);
|
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);
|
FileStorage fs(fileName, FileStorage::WRITE);
|
||||||
((FeatureDetector*)this)->write(fs);
|
((FeatureDetector*)this)->write(fs);
|
||||||
fs.release();
|
fs.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_WRAP void read( const std::string& fileName )
|
CV_WRAP void read( const cv::String& fileName )
|
||||||
{
|
{
|
||||||
FileStorage fs(fileName, FileStorage::READ);
|
FileStorage fs(fileName, FileStorage::READ);
|
||||||
((FeatureDetector*)this)->read(fs.root());
|
((FeatureDetector*)this)->read(fs.root());
|
||||||
@@ -208,7 +208,7 @@ public:
|
|||||||
//supported: FlannBased, BruteForce, BruteForce-L1, BruteForce-Hamming, BruteForce-HammingLUT
|
//supported: FlannBased, BruteForce, BruteForce-L1, BruteForce-Hamming, BruteForce-HammingLUT
|
||||||
CV_WRAP static javaDescriptorMatcher* create( int matcherType )
|
CV_WRAP static javaDescriptorMatcher* create( int matcherType )
|
||||||
{
|
{
|
||||||
std::string name;
|
cv::String name;
|
||||||
|
|
||||||
switch(matcherType)
|
switch(matcherType)
|
||||||
{
|
{
|
||||||
@@ -240,14 +240,14 @@ public:
|
|||||||
return (javaDescriptorMatcher*)((DescriptorMatcher*) matcher);
|
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);
|
FileStorage fs(fileName, FileStorage::WRITE);
|
||||||
((DescriptorMatcher*)this)->write(fs);
|
((DescriptorMatcher*)this)->write(fs);
|
||||||
fs.release();
|
fs.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_WRAP void read( const std::string& fileName )
|
CV_WRAP void read( const cv::String& fileName )
|
||||||
{
|
{
|
||||||
FileStorage fs(fileName, FileStorage::READ);
|
FileStorage fs(fileName, FileStorage::READ);
|
||||||
((DescriptorMatcher*)this)->read(fs.root());
|
((DescriptorMatcher*)this)->read(fs.root());
|
||||||
@@ -294,7 +294,7 @@ public:
|
|||||||
//not supported: Calonder
|
//not supported: Calonder
|
||||||
CV_WRAP static javaDescriptorExtractor* create( int extractorType )
|
CV_WRAP static javaDescriptorExtractor* create( int extractorType )
|
||||||
{
|
{
|
||||||
std::string name;
|
cv::String name;
|
||||||
|
|
||||||
if (extractorType > OPPONENTEXTRACTOR)
|
if (extractorType > OPPONENTEXTRACTOR)
|
||||||
{
|
{
|
||||||
@@ -305,22 +305,22 @@ public:
|
|||||||
switch(extractorType)
|
switch(extractorType)
|
||||||
{
|
{
|
||||||
case SIFT:
|
case SIFT:
|
||||||
name += "SIFT";
|
name = name + "SIFT";
|
||||||
break;
|
break;
|
||||||
case SURF:
|
case SURF:
|
||||||
name += "SURF";
|
name = name + "SURF";
|
||||||
break;
|
break;
|
||||||
case ORB:
|
case ORB:
|
||||||
name += "ORB";
|
name = name + "ORB";
|
||||||
break;
|
break;
|
||||||
case BRIEF:
|
case BRIEF:
|
||||||
name += "BRIEF";
|
name = name + "BRIEF";
|
||||||
break;
|
break;
|
||||||
case BRISK:
|
case BRISK:
|
||||||
name += "BRISK";
|
name = name + "BRISK";
|
||||||
break;
|
break;
|
||||||
case FREAK:
|
case FREAK:
|
||||||
name += "FREAK";
|
name = name + "FREAK";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CV_Error( CV_StsBadArg, "Specified descriptor extractor type is not supported." );
|
CV_Error( CV_StsBadArg, "Specified descriptor extractor type is not supported." );
|
||||||
@@ -332,14 +332,14 @@ public:
|
|||||||
return (javaDescriptorExtractor*)((DescriptorExtractor*) extractor);
|
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);
|
FileStorage fs(fileName, FileStorage::WRITE);
|
||||||
((DescriptorExtractor*)this)->write(fs);
|
((DescriptorExtractor*)this)->write(fs);
|
||||||
fs.release();
|
fs.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_WRAP void read( const std::string& fileName )
|
CV_WRAP void read( const cv::String& fileName )
|
||||||
{
|
{
|
||||||
FileStorage fs(fileName, FileStorage::READ);
|
FileStorage fs(fileName, FileStorage::READ);
|
||||||
((DescriptorExtractor*)this)->read(fs.root());
|
((DescriptorExtractor*)this)->read(fs.root());
|
||||||
@@ -401,7 +401,7 @@ public:
|
|||||||
//unsupported: Vector
|
//unsupported: Vector
|
||||||
CV_WRAP static javaGenericDescriptorMatcher* create( int matcherType )
|
CV_WRAP static javaGenericDescriptorMatcher* create( int matcherType )
|
||||||
{
|
{
|
||||||
std::string name;
|
cv::String name;
|
||||||
|
|
||||||
switch(matcherType)
|
switch(matcherType)
|
||||||
{
|
{
|
||||||
@@ -421,14 +421,14 @@ public:
|
|||||||
return (javaGenericDescriptorMatcher*)((GenericDescriptorMatcher*) matcher);
|
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);
|
FileStorage fs(fileName, FileStorage::WRITE);
|
||||||
((GenericDescriptorMatcher*)this)->write(fs);
|
((GenericDescriptorMatcher*)this)->write(fs);
|
||||||
fs.release();
|
fs.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_WRAP void read( const std::string& fileName )
|
CV_WRAP void read( const cv::String& fileName )
|
||||||
{
|
{
|
||||||
FileStorage fs(fileName, FileStorage::READ);
|
FileStorage fs(fileName, FileStorage::READ);
|
||||||
((GenericDescriptorMatcher*)this)->read(fs.root());
|
((GenericDescriptorMatcher*)this)->read(fs.root());
|
||||||
|
Reference in New Issue
Block a user