Commit 68d01972 authored by Maksim Shabunin's avatar Maksim Shabunin

Merge pull request #8883 from abratchik:DNN.java.wrappers.fix

parents 1f406711 037d8fbd
{
"class_ignore_list": [
"CirclesGridFinderParameters"
],
"missing_consts" : {
"Calib3d": {
"public" : [
["CALIB_USE_INTRINSIC_GUESS", "1"],
["CALIB_RECOMPUTE_EXTRINSIC", "2"],
["CALIB_CHECK_COND", "4"],
["CALIB_FIX_SKEW", "8"],
["CALIB_FIX_K1", "16"],
["CALIB_FIX_K2", "32"],
["CALIB_FIX_K3", "64"],
["CALIB_FIX_K4", "128"],
["CALIB_FIX_INTRINSIC", "256"]
]
}
},
"func_arg_fix" : {
"findFundamentalMat" : { "points1" : {"ctype" : "vector_Point2f"},
"points2" : {"ctype" : "vector_Point2f"} },
"cornerSubPix" : { "corners" : {"ctype" : "vector_Point2f"} },
"findHomography" : { "srcPoints" : {"ctype" : "vector_Point2f"},
"dstPoints" : {"ctype" : "vector_Point2f"} },
"solvePnP" : { "objectPoints" : {"ctype" : "vector_Point3f"},
"imagePoints" : {"ctype" : "vector_Point2f"},
"distCoeffs" : {"ctype" : "vector_double" } },
"solvePnPRansac" : { "objectPoints" : {"ctype" : "vector_Point3f"},
"imagePoints" : {"ctype" : "vector_Point2f"},
"distCoeffs" : {"ctype" : "vector_double" } },
"undistortPoints" : { "src" : {"ctype" : "vector_Point2f"},
"dst" : {"ctype" : "vector_Point2f"} },
"projectPoints" : { "objectPoints" : {"ctype" : "vector_Point3f"},
"imagePoints" : {"ctype" : "vector_Point2f"},
"distCoeffs" : {"ctype" : "vector_double" } },
"initCameraMatrix2D" : { "objectPoints" : {"ctype" : "vector_vector_Point3f"},
"imagePoints" : {"ctype" : "vector_vector_Point2f"} },
"findChessboardCorners" : { "corners" : {"ctype" : "vector_Point2f"} },
"drawChessboardCorners" : { "corners" : {"ctype" : "vector_Point2f"} }
}
}
{
"class_ignore_list" : [
"FileNode",
"FileStorage",
"KDTree",
"KeyPoint",
"DMatch"
],
"missing_consts" : {
"Core" : {
"private" : [
["CV_8U", 0 ], ["CV_8S", 1 ],
["CV_16U", 2 ], ["CV_16S", 3 ],
["CV_32S", 4 ],
["CV_32F", 5 ], ["CV_64F", 6 ],
["CV_USRTYPE1", 7 ]
],
"public" : [
["SVD_MODIFY_A", 1], ["SVD_NO_UV", 2], ["SVD_FULL_UV", 4],
["FILLED", -1],
["REDUCE_SUM", 0], ["REDUCE_AVG", 1], ["REDUCE_MAX", 2], ["REDUCE_MIN", 3]
]
}
},
"ManualFuncs" : {
"Core" : {
"minMaxLoc" : {
"j_code" : [
"// manual port",
"public static class MinMaxLocResult {",
" public double minVal;",
" public double maxVal;",
" public Point minLoc;",
" public Point maxLoc;",
"\n",
" public MinMaxLocResult() {",
" minVal=0; maxVal=0;",
" minLoc=new Point();",
" maxLoc=new Point();",
" }",
"}",
"\n",
"// C++: minMaxLoc(Mat src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, InputArray mask=noArray())",
"\n",
"//javadoc: minMaxLoc(src, mask)",
"public static MinMaxLocResult minMaxLoc(Mat src, Mat mask) {",
" MinMaxLocResult res = new MinMaxLocResult();",
" long maskNativeObj=0;",
" if (mask != null) {",
" maskNativeObj=mask.nativeObj;",
" }",
" double resarr[] = n_minMaxLocManual(src.nativeObj, maskNativeObj);",
" res.minVal=resarr[0];",
" res.maxVal=resarr[1];",
" res.minLoc.x=resarr[2];",
" res.minLoc.y=resarr[3];",
" res.maxLoc.x=resarr[4];",
" res.maxLoc.y=resarr[5];",
" return res;",
"}",
"\n",
"//javadoc: minMaxLoc(src)",
"public static MinMaxLocResult minMaxLoc(Mat src) {",
" return minMaxLoc(src, null);",
"}"
],
"jn_code" : [
"private static native double[] n_minMaxLocManual(long src_nativeObj, long mask_nativeObj);\n"
],
"cpp_code" : [
"// C++: minMaxLoc(Mat src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, InputArray mask=noArray())",
"JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual (JNIEnv*, jclass, jlong, jlong);",
"\n",
"JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual",
" (JNIEnv* env, jclass, jlong src_nativeObj, jlong mask_nativeObj)",
"{",
" try {",
" LOGD(\"Core::n_1minMaxLoc()\");",
" jdoubleArray result;",
" result = env->NewDoubleArray(6);",
" if (result == NULL) {",
" return NULL; /* out of memory error thrown */",
" }",
"\n",
" Mat& src = *((Mat*)src_nativeObj);",
"\n",
" double minVal, maxVal;",
" Point minLoc, maxLoc;",
" if (mask_nativeObj != 0) {",
" Mat& mask = *((Mat*)mask_nativeObj);",
" minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc, mask);",
" } else {",
" minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc);",
" }",
"\n",
" jdouble fill[6];",
" fill[0]=minVal;",
" fill[1]=maxVal;",
" fill[2]=minLoc.x;",
" fill[3]=minLoc.y;",
" fill[4]=maxLoc.x;",
" fill[5]=maxLoc.y;",
"\n",
" env->SetDoubleArrayRegion(result, 0, 6, fill);",
"\n",
" return result;",
"\n",
" } catch(const cv::Exception& e) {",
" LOGD(\"Core::n_1minMaxLoc() catched cv::Exception: %s\", e.what());",
" jclass je = env->FindClass(\"org/opencv/core/CvException\");",
" if(!je) je = env->FindClass(\"java/lang/Exception\");",
" env->ThrowNew(je, e.what());",
" return NULL;",
" } catch (...) {",
" LOGD(\"Core::n_1minMaxLoc() catched unknown exception (...)\");",
" jclass je = env->FindClass(\"java/lang/Exception\");",
" env->ThrowNew(je, \"Unknown exception in JNI code {core::minMaxLoc()}\");",
" return NULL;",
" }",
"}",
"\n"
]
},
"checkHardwareSupport" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"setUseOptimized" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"useOptimized" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] }
}
},
"func_arg_fix" : {
"randu" : { "low" : {"ctype" : "double"},
"high" : {"ctype" : "double"} },
"randn" : { "mean" : {"ctype" : "double"},
"stddev" : {"ctype" : "double"} },
"inRange" : { "lowerb" : {"ctype" : "Scalar"},
"upperb" : {"ctype" : "Scalar"} },
"boundingRect" : { "points" : {"ctype" : "vector_Point"} },
"hconcat" : { "src" : {"ctype" : "vector_Mat"} },
"vconcat" : { "src" : {"ctype" : "vector_Mat"} },
"checkRange" : {"pos" : {"ctype" : "*"} },
"meanStdDev" : { "mean" : {"ctype" : "vector_double"},
"stddev" : {"ctype" : "vector_double"} },
"mixChannels" : { "dst" : {"attrib" : []} }
},
"type_dict" : {
"Algorithm": {
"j_type": "Feature2D",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "Feature2D %(n)s",
"suffix": "J",
"j_import": "org.opencv.core.Algorithm"
},
"CvSlice": {
"j_type": "Range",
"jn_args": [
[
"int",
".start"
],
[
"int",
".end"
]
],
"jni_type": "jdoubleArray",
"jni_var": "Range %(n)s(%(n)s_start, %(n)s_end)",
"suffix": "II",
"j_import": "org.opencv.core.Range"
},
"CvTermCriteria": {
"j_type": "TermCriteria",
"jn_args": [
[
"int",
".type"
],
[
"int",
".maxCount"
],
[
"double",
".epsilon"
]
],
"jni_type": "jdoubleArray",
"jni_var": "TermCriteria %(n)s(%(n)s_type, %(n)s_maxCount, %(n)s_epsilon)",
"suffix": "IID",
"j_import": "org.opencv.core.TermCriteria"
},
"DMatch": {
"j_type": "DMatch",
"jn_args": [
[
"int",
"queryIdx"
],
[
"int",
"trainIdx"
],
[
"int",
"imgIdx"
],
[
"float",
"distance"
]
],
"jni_type": "jdoubleArray",
"jni_var": "DMatch %(n)s(%(n)s_queryIdx, %(n)s_trainIdx, %(n)s_imgIdx, %(n)s_distance)",
"suffix": "IIIF",
"j_import": "org.opencv.core.DMatch"
},
"KeyPoint": {
"j_type": "KeyPoint",
"jn_args": [
[
"float",
".x"
],
[
"float",
".y"
],
[
"float",
".size"
],
[
"float",
".angle"
],
[
"float",
".response"
],
[
"int",
".octave"
],
[
"int",
".class_id"
]
],
"jni_type": "jdoubleArray",
"jni_var": "KeyPoint %(n)s(%(n)s_x, %(n)s_y, %(n)s_size, %(n)s_angle, %(n)s_response, %(n)s_octave, %(n)s_class_id)",
"suffix": "FFFFFII",
"j_import": "org.opencv.core.KeyPoint"
},
"Mat": {
"j_type": "Mat",
"jn_args": [
[
"__int64",
".nativeObj"
]
],
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "Mat& %(n)s = *((Mat*)%(n)s_nativeObj)",
"suffix": "J",
"j_import": "org.opencv.core.Mat"
},
"Moments": {
"j_type": "Moments",
"jn_args": [
[
"double",
".m00"
],
[
"double",
".m10"
],
[
"double",
".m01"
],
[
"double",
".m20"
],
[
"double",
".m11"
],
[
"double",
".m02"
],
[
"double",
".m30"
],
[
"double",
".m21"
],
[
"double",
".m12"
],
[
"double",
".m03"
]
],
"jni_type": "jdoubleArray",
"jni_var": "Moments %(n)s(%(n)s_m00, %(n)s_m10, %(n)s_m01, %(n)s_m20, %(n)s_m11, %(n)s_m02, %(n)s_m30, %(n)s_m21, %(n)s_m12, %(n)s_m03)",
"suffix": "DDDDDDDDDD"
},
"Point": {
"j_type": "Point",
"jn_args": [
[
"double",
".x"
],
[
"double",
".y"
]
],
"jni_type": "jdoubleArray",
"jni_var": "Point %(n)s((int)%(n)s_x, (int)%(n)s_y)",
"suffix": "DD",
"j_import": "org.opencv.core.Point"
},
"Point2d": {
"j_type": "Point",
"jn_args": [
[
"double",
".x"
],
[
"double",
".y"
]
],
"jni_type": "jdoubleArray",
"jni_var": "Point2d %(n)s(%(n)s_x, %(n)s_y)",
"suffix": "DD",
"j_import": "org.opencv.core.Point"
},
"Point2f": {
"j_type": "Point",
"jn_args": [
[
"double",
".x"
],
[
"double",
".y"
]
],
"jni_type": "jdoubleArray",
"jni_var": "Point2f %(n)s((float)%(n)s_x, (float)%(n)s_y)",
"suffix": "DD",
"j_import": "org.opencv.core.Point"
},
"Point3d": {
"j_type": "Point3",
"jn_args": [
[
"double",
".x"
],
[
"double",
".y"
],
[
"double",
".z"
]
],
"jni_type": "jdoubleArray",
"jni_var": "Point3d %(n)s(%(n)s_x, %(n)s_y, %(n)s_z)",
"suffix": "DDD",
"j_import": "org.opencv.core.Point3"
},
"Point3f": {
"j_type": "Point3",
"jn_args": [
[
"double",
".x"
],
[
"double",
".y"
],
[
"double",
".z"
]
],
"jni_type": "jdoubleArray",
"jni_var": "Point3f %(n)s((float)%(n)s_x, (float)%(n)s_y, (float)%(n)s_z)",
"suffix": "DDD",
"j_import": "org.opencv.core.Point3"
},
"Point3i": {
"j_type": "Point3",
"jn_args": [
[
"double",
".x"
],
[
"double",
".y"
],
[
"double",
".z"
]
],
"jni_type": "jdoubleArray",
"jni_var": "Point3i %(n)s((int)%(n)s_x, (int)%(n)s_y, (int)%(n)s_z)",
"suffix": "DDD",
"j_import": "org.opencv.core.Point3"
},
"Range": {
"j_type": "Range",
"jn_args": [
[
"int",
".start"
],
[
"int",
".end"
]
],
"jni_type": "jdoubleArray",
"jni_var": "Range %(n)s(%(n)s_start, %(n)s_end)",
"suffix": "II",
"j_import": "org.opencv.core.Range"
},
"Rect": {
"j_type": "Rect",
"jn_args": [
[
"int",
".x"
],
[
"int",
".y"
],
[
"int",
".width"
],
[
"int",
".height"
]
],
"jni_type": "jdoubleArray",
"jni_var": "Rect %(n)s(%(n)s_x, %(n)s_y, %(n)s_width, %(n)s_height)",
"suffix": "IIII",
"j_import": "org.opencv.core.Rect"
},
"Rect2d": {
"j_type": "Rect2d",
"jn_args": [
[
"double",
".x"
],
[
"double",
".y"
],
[
"double",
".width"
],
[
"double",
".height"
]
],
"jni_type": "jdoubleArray",
"jni_var": "Rect %(n)s(%(n)s_x, %(n)s_y, %(n)s_width, %(n)s_height)",
"suffix": "DDDD",
"j_import": "org.opencv.core.Rect2d"
},
"RotatedRect": {
"j_type": "RotatedRect",
"jn_args": [
[
"double",
".center.x"
],
[
"double",
".center.y"
],
[
"double",
".size.width"
],
[
"double",
".size.height"
],
[
"double",
".angle"
]
],
"jni_type": "jdoubleArray",
"jni_var": "RotatedRect %(n)s(cv::Point2f(%(n)s_center_x, %(n)s_center_y), cv::Size2f(%(n)s_size_width, %(n)s_size_height), %(n)s_angle)",
"suffix": "DDDDD",
"j_import": "org.opencv.core.RotatedRect"
},
"Scalar": {
"j_type": "Scalar",
"jn_args": [
[
"double",
".val[0]"
],
[
"double",
".val[1]"
],
[
"double",
".val[2]"
],
[
"double",
".val[3]"
]
],
"jni_type": "jdoubleArray",
"jni_var": "Scalar %(n)s(%(n)s_val0, %(n)s_val1, %(n)s_val2, %(n)s_val3)",
"suffix": "DDDD",
"j_import": "org.opencv.core.Scalar"
},
"Size": {
"j_type": "Size",
"jn_args": [
[
"double",
".width"
],
[
"double",
".height"
]
],
"jni_type": "jdoubleArray",
"jni_var": "Size %(n)s((int)%(n)s_width, (int)%(n)s_height)",
"suffix": "DD",
"j_import": "org.opencv.core.Size"
},
"Size2f": {
"j_type": "Size",
"jn_args": [
[
"double",
".width"
],
[
"double",
".height"
]
],
"jni_type": "jdoubleArray",
"jni_var": "Size2f %(n)s((float)%(n)s_width, (float)%(n)s_height)",
"suffix": "DD",
"j_import": "org.opencv.core.Size"
},
"String": {
"j_type": "String",
"jn_type": "String",
"jni_name": "n_%(n)s",
"jni_type": "jstring",
"jni_var": "const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); String n_%(n)s( utf_%(n)s ? utf_%(n)s : \"\" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)",
"suffix": "Ljava_lang_String_2",
"j_import": "java.lang.String"
},
"TermCriteria": {
"j_type": "TermCriteria",
"jn_args": [
[
"int",
".type"
],
[
"int",
".maxCount"
],
[
"double",
".epsilon"
]
],
"jni_type": "jdoubleArray",
"jni_var": "TermCriteria %(n)s(%(n)s_type, %(n)s_maxCount, %(n)s_epsilon)",
"suffix": "IID",
"j_import": "org.opencv.core.TermCriteria"
},
"Vec2d": {
"j_type": "double[]",
"jn_args": [
[
"double",
".val[0]"
],
[
"double",
".val[1]"
]
],
"jn_type": "double[]",
"jni_type": "jdoubleArray",
"jni_var": "Vec2d %(n)s(%(n)s_val0, %(n)s_val1)",
"suffix": "DD"
},
"Vec3d": {
"j_type": "double[]",
"jn_args": [
[
"double",
".val[0]"
],
[
"double",
".val[1]"
],
[
"double",
".val[2]"
]
],
"jn_type": "double[]",
"jni_type": "jdoubleArray",
"jni_var": "Vec3d %(n)s(%(n)s_val0, %(n)s_val1, %(n)s_val2)",
"suffix": "DDD"
},
"c_string": {
"j_type": "String",
"jn_type": "String",
"jni_name": "n_%(n)s.c_str()",
"jni_type": "jstring",
"jni_var": "const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); String n_%(n)s( utf_%(n)s ? utf_%(n)s : \"\" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)",
"suffix": "Ljava_lang_String_2",
"j_import": "java.lang.String"
},
"size_t": {
"j_type": "long",
"jn_type": "long",
"jni_type": "jlong",
"suffix": "J"
},
"vector_DMatch": {
"j_type": "MatOfDMatch",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<DMatch> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfDMatch"
},
"vector_KeyPoint": {
"j_type": "MatOfKeyPoint",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<KeyPoint> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfKeyPoint"
},
"vector_Mat": {
"j_type": "List<Mat>",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<Mat> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.Mat"
},
"vector_Point": {
"j_type": "MatOfPoint",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<Point> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfPoint"
},
"vector_Point2f": {
"j_type": "MatOfPoint2f",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<Point2f> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfPoint2f"
},
"vector_Point3f": {
"j_type": "MatOfPoint3f",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<Point3f> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfPoint3f"
},
"vector_Point2d": {
"j_type": "MatOfPoint2f",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<Point2f> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfPoint2f"
},
"vector_Point3d": {
"j_type": "MatOfPoint3f",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<Point3f> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfPoint3f"
},
"vector_Point3i": {
"j_type": "MatOfPoint3",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<Point3i> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfPoint3"
},
"vector_Rect": {
"j_type": "MatOfRect",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<Rect> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfRect"
},
"vector_Rect2d": {
"j_type": "MatOfRect2d",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<Rect2d> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfRect2d"
},
"vector_String": {
"j_type": "List<String>",
"jn_type": "List<String>",
"jni_type": "jobject",
"jni_var": "std::vector< String > %(n)s",
"suffix": "Ljava_util_List",
"v_type": "String",
"j_import": "java.lang.String"
},
"vector_Vec4f": {
"j_type": "MatOfFloat4",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<Vec4f> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfFloat4"
},
"vector_Vec4i": {
"j_type": "MatOfInt4",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<Vec4i> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfInt4"
},
"vector_Vec6f": {
"j_type": "MatOfFloat6",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<Vec6f> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfFloat6"
},
"vector_char": {
"j_type": "MatOfByte",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<char> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfByte"
},
"vector_double": {
"j_type": "MatOfDouble",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<double> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfDouble"
},
"vector_float": {
"j_type": "MatOfFloat",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<float> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfFloat"
},
"vector_int": {
"j_type": "MatOfInt",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<int> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfInt"
},
"vector_uchar": {
"j_type": "MatOfByte",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector<uchar> %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfByte"
},
"vector_vector_DMatch": {
"j_type": "List<MatOfDMatch>",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector< std::vector<DMatch> > %(n)s",
"v_type": "vector_Mat",
"j_import": "org.opencv.core.MatOfDMatch"
},
"vector_vector_KeyPoint": {
"j_type": "List<MatOfKeyPoint>",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector< std::vector<KeyPoint> > %(n)s",
"v_type": "vector_Mat",
"j_import": "org.opencv.core.MatOfKeyPoint"
},
"vector_vector_Point": {
"j_type": "List<MatOfPoint>",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector< std::vector<Point> > %(n)s",
"v_type": "vector_Mat",
"j_import": "org.opencv.core.MatOfPoint"
},
"vector_vector_Point2f": {
"j_type": "List<MatOfPoint2f>",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector< std::vector<Point2f> > %(n)s",
"v_type": "vector_Mat",
"j_import": "org.opencv.core.MatOfPoint2f"
},
"vector_vector_Point3f": {
"j_type": "List<MatOfPoint3f>",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector< std::vector<Point3f> > %(n)s",
"v_type": "vector_Mat",
"j_import": "org.opencv.core.MatOfPoint3f"
},
"vector_vector_char": {
"j_type": "List<MatOfByte>",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector< std::vector<char> > %(n)s",
"v_type": "vector_Mat",
"j_import": "org.opencv.core.MatOfByte"
}
}
}
{
"class_ignore_list" : [
"SimpleBlobDetector"
],
"const_private_list" : [
"OPPONENTEXTRACTOR",
"GRIDDETECTOR",
"PYRAMIDDETECTOR",
"DYNAMICDETECTOR"
],
"type_dict" : {
"Feature2D": {
"j_type": "Feature2D",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "Feature2D %(n)s",
"suffix": "J",
"j_import": "org.opencv.features2d.Feature2D"
}
}
}
{
"const_ignore_list": [
"EVENT_.*",
"WINDOW_AUTOSIZE",
"CV_WND_PROP_",
"CV_WINDOW_",
"CV_EVENT_",
"CV_GUI_",
"CV_PUSH_BUTTON",
"CV_CHECKBOX",
"CV_RADIOBOX",
"WINDOW_.+",
"WND_PROP_.+"
],
"ManualFuncs" : {
"Highgui" : {
"namedWindow" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"destroyWindow" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"destroyAllWindows" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"startWindowThread" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"setWindowProperty" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"getWindowProperty" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"getTrackbarPos" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"setTrackbarPos" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"imshow" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"waitKey" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"moveWindow" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
"resizeWindow" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] }
}
}
}
{
"const_ignore_list": [
"CV_TM_.+",
"CV_COLORCVT_MAX",
"CV_.*Bayer.*",
"CV_YUV420(i|sp|p)2.+",
"CV_L?(BGRA?|RGBA?|GRAY|XYZ|YCrCb|Luv|Lab|HLS|YUV|HSV)\\d*2L?(BGRA?|RGBA?|GRAY|XYZ|YCrCb|Luv|Lab|HLS|YUV|HSV).*",
"CV_FLOODFILL_.+",
"CV_ADAPTIVE_THRESH_.+"
],
"const_private_list" : [
"CV_MOP_.+",
"CV_INTER_.+",
"CV_THRESH_.+",
"CV_INPAINT_.+",
"CV_RETR_.+",
"CV_CHAIN_APPROX_.+"
],
"missing_consts" : {
"Imgproc" : {
"private" : [
["IPL_BORDER_CONSTANT", 0 ],
["IPL_BORDER_REPLICATE", 1 ],
["IPL_BORDER_REFLECT", 2 ],
["IPL_BORDER_WRAP", 3 ],
["IPL_BORDER_REFLECT_101", 4 ],
["IPL_BORDER_TRANSPARENT", 5 ]
],
"public" : [
["LINE_AA", 16], ["LINE_8", 8], ["LINE_4", 4]
]
}
},
"ManualFuncs" : {
"Imgproc" : {
"getTextSize" : {
"j_code" : [
"\n",
"// C++: Size getTextSize(const 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)",
" throw new java.lang.IllegalArgumentException(\"'baseLine' must be 'int[1]' or 'null'.\");",
" Size retVal = new Size(n_getTextSize(text, fontFace, fontScale, thickness, baseLine));",
" return retVal;",
"}",
"\n"
],
"jn_code" : [
"private static native double[] n_getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine);\n"
],
"cpp_code" : [
"\n",
" // C++: Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, int* baseLine);",
" JNIEXPORT jdoubleArray JNICALL Java_org_opencv_imgproc_Imgproc_n_1getTextSize (JNIEnv*, jclass, jstring, jint, jdouble, jint, jintArray);",
"\n",
" JNIEXPORT jdoubleArray JNICALL Java_org_opencv_imgproc_Imgproc_n_1getTextSize",
" (JNIEnv* env, jclass, jstring text, jint fontFace, jdouble fontScale, jint thickness, jintArray baseLine)",
" {",
" try {",
" LOGD(\"Core::n_1getTextSize()\");",
" jdoubleArray result;",
" result = env->NewDoubleArray(2);",
" if (result == NULL) {",
" return NULL; /* out of memory error thrown */",
" }",
"\n",
" const char* utf_text = env->GetStringUTFChars(text, 0);",
" String n_text( utf_text ? utf_text : \"\" );",
" env->ReleaseStringUTFChars(text, utf_text);",
"\n",
" int _baseLine;",
" int* pbaseLine = 0;",
"\n",
" if (baseLine != NULL)",
" pbaseLine = &_baseLine;",
"\n",
" cv::Size rsize = cv::getTextSize(n_text, (int)fontFace, (double)fontScale, (int)thickness, pbaseLine);",
"\n",
" jdouble fill[2];",
" fill[0]=rsize.width;",
" fill[1]=rsize.height;",
"\n",
" env->SetDoubleArrayRegion(result, 0, 2, fill);",
"\n",
" if (baseLine != NULL) {",
" jint jbaseLine = (jint)(*pbaseLine);",
" env->SetIntArrayRegion(baseLine, 0, 1, &jbaseLine);",
" }",
"\n",
" return result;",
"\n",
" } catch(const cv::Exception& e) {",
" LOGD(\"Imgproc::n_1getTextSize() catched cv::Exception: %s\", e.what());",
" jclass je = env->FindClass(\"org/opencv/core/CvException\");",
" if(!je) je = env->FindClass(\"java/lang/Exception\");",
" env->ThrowNew(je, e.what());",
" return NULL;",
" } catch (...) {",
" LOGD(\"Imgproc::n_1getTextSize() catched unknown exception (...)\");",
" jclass je = env->FindClass(\"java/lang/Exception\");",
" env->ThrowNew(je, \"Unknown exception in JNI code {core::getTextSize()}\");",
" return NULL;",
" }",
" }"
]
}
}
},
"func_arg_fix" : {
"goodFeaturesToTrack" : { "corners" : {"ctype" : "vector_Point"} },
"minEnclosingCircle" : { "points" : {"ctype" : "vector_Point2f"} },
"fitEllipse" : { "points" : {"ctype" : "vector_Point2f"} },
"fillPoly" : { "pts" : {"ctype" : "vector_vector_Point"} },
"polylines" : { "pts" : {"ctype" : "vector_vector_Point"} },
"fillConvexPoly" : { "points" : {"ctype" : "vector_Point"} },
"approxPolyDP" : { "curve" : {"ctype" : "vector_Point2f"},
"approxCurve" : {"ctype" : "vector_Point2f"} },
"arcLength" : { "curve" : {"ctype" : "vector_Point2f"} },
"pointPolygonTest" : { "contour" : {"ctype" : "vector_Point2f"} },
"minAreaRect" : { "points" : {"ctype" : "vector_Point2f"} },
"getAffineTransform" : { "src" : {"ctype" : "vector_Point2f"},
"dst" : {"ctype" : "vector_Point2f"} },
"drawContours" : {"contours" : {"ctype" : "vector_vector_Point"} },
"findContours" : {"contours" : {"ctype" : "vector_vector_Point"} },
"convexityDefects" : { "contour" : {"ctype" : "vector_Point"},
"convexhull" : {"ctype" : "vector_int"},
"convexityDefects" : {"ctype" : "vector_Vec4i"} },
"isContourConvex" : { "contour" : {"ctype" : "vector_Point"} },
"convexHull" : { "points" : {"ctype" : "vector_Point"},
"hull" : {"ctype" : "vector_int"},
"returnPoints" : {"ctype" : ""} }
}
}
...@@ -140,10 +140,17 @@ glob_more_specific_sources(AIDL "${CMAKE_CURRENT_SOURCE_DIR}/generator" handwrit ...@@ -140,10 +140,17 @@ glob_more_specific_sources(AIDL "${CMAKE_CURRENT_SOURCE_DIR}/generator" handwrit
# headers of OpenCV modules # headers of OpenCV modules
set(opencv_public_headers "") set(opencv_public_headers "")
set(opencv_type_dicts "")
set(generated_cpp_sources "") set(generated_cpp_sources "")
set(generated_java_sources "") set(generated_java_sources "")
foreach(module ${OPENCV_JAVA_MODULES}) foreach(module ${OPENCV_JAVA_MODULES})
set(module_java_dir "${OPENCV_MODULE_opencv_${module}_LOCATION}/misc/java") set(module_java_dir "${OPENCV_MODULE_opencv_${module}_LOCATION}/misc/java")
# custom mappings between c and java/JNI types
set(custom_type_dict "${module_java_dir}/gen_dict.json")
if(EXISTS "${custom_type_dict}")
list(APPEND opencv_java_type_dict_${module} ${custom_type_dict})
endif()
set(custom_header_list "${module_java_dir}/filelist") set(custom_header_list "${module_java_dir}/filelist")
if(EXISTS "${custom_header_list}") if(EXISTS "${custom_header_list}")
file(STRINGS "${custom_header_list}" module_headers) file(STRINGS "${custom_header_list}" module_headers)
...@@ -171,6 +178,13 @@ foreach(module ${OPENCV_JAVA_MODULES}) ...@@ -171,6 +178,13 @@ foreach(module ${OPENCV_JAVA_MODULES})
include_directories("${module_java_dir}/src/cpp") include_directories("${module_java_dir}/src/cpp")
set(common_header_list "${module_java_dir}/filelist_common")
if(EXISTS "${common_header_list}")
file(STRINGS "${common_header_list}" __headers)
ocv_list_add_prefix(__headers "${OPENCV_MODULE_opencv_${module}_LOCATION}/")
list(APPEND opencv_java_common_headers_${module} ${__headers})
endif()
foreach(m ${OPENCV_MODULE_opencv_${module}_DEPS}) foreach(m ${OPENCV_MODULE_opencv_${module}_DEPS})
set(common_header_list "${OPENCV_MODULE_${m}_LOCATION}/misc/java/filelist_common") set(common_header_list "${OPENCV_MODULE_${m}_LOCATION}/misc/java/filelist_common")
if(EXISTS "${common_header_list}") if(EXISTS "${common_header_list}")
...@@ -178,6 +192,11 @@ foreach(module ${OPENCV_JAVA_MODULES}) ...@@ -178,6 +192,11 @@ foreach(module ${OPENCV_JAVA_MODULES})
ocv_list_add_prefix(__headers "${OPENCV_MODULE_${m}_LOCATION}/") ocv_list_add_prefix(__headers "${OPENCV_MODULE_${m}_LOCATION}/")
list(APPEND opencv_java_common_headers_${module} ${__headers}) list(APPEND opencv_java_common_headers_${module} ${__headers})
endif() endif()
set(custom_type_dict "${OPENCV_MODULE_${m}_LOCATION}/misc/java/gen_dict.json")
if(EXISTS "${custom_type_dict}")
list(APPEND opencv_java_type_dict_${module} ${custom_type_dict})
list(APPEND opencv_type_dicts ${custom_type_dicts})
endif()
endforeach() endforeach()
glob_more_specific_sources(H "${module_java_dir}" handwritten_h_sources) glob_more_specific_sources(H "${module_java_dir}" handwritten_h_sources)
...@@ -188,7 +207,7 @@ foreach(module ${OPENCV_JAVA_MODULES}) ...@@ -188,7 +207,7 @@ foreach(module ${OPENCV_JAVA_MODULES})
# first run of gen_java.py (to get list of generated files) # first run of gen_java.py (to get list of generated files)
file(REMOVE_RECURSE "${probe_dir}") file(REMOVE_RECURSE "${probe_dir}")
file(MAKE_DIRECTORY "${probe_dir}") file(MAKE_DIRECTORY "${probe_dir}")
execute_process(COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${scripts_gen_java}" "${scripts_hdr_parser}" ${module} ${opencv_public_headers_${module}} "--common" ${opencv_java_common_headers_${module}} execute_process(COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${scripts_gen_java}" "-p" "${scripts_hdr_parser}" "-m" ${module} "-s" ${opencv_public_headers_${module}} "-c" ${opencv_java_common_headers_${module}} "-t" ${opencv_java_type_dict_${module}}
WORKING_DIRECTORY "${probe_dir}" WORKING_DIRECTORY "${probe_dir}"
OUTPUT_QUIET ERROR_QUIET) OUTPUT_QUIET ERROR_QUIET)
file(GLOB_RECURSE generated_java_sources_${module} RELATIVE "${probe_dir}" "${probe_dir}/*.java") file(GLOB_RECURSE generated_java_sources_${module} RELATIVE "${probe_dir}" "${probe_dir}/*.java")
...@@ -216,20 +235,20 @@ else() ...@@ -216,20 +235,20 @@ else()
endif() endif()
endif() endif()
# IMPORTANT: add dependencies to cmake (we should rerun cmake if any of these files is modified) # IMPORTANT: add dependencies to cmake (we should rerun cmake if any of these files are modified)
add_cmake_dependencies(${scripts_gen_java} ${scripts_hdr_parser} ${opencv_public_headers}) add_cmake_dependencies(${scripts_gen_java} ${scripts_hdr_parser} ${opencv_public_headers} ${opencv_type_dicts})
###################################################################################################################################### ######################################################################################################################################
# step 1: generate .cpp/.java from OpenCV headers # step 1: generate .cpp/.java from OpenCV headers
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/gen") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/gen")
set(step1_depends "${scripts_gen_java}" "${scripts_hdr_parser}" ${opencv_public_headers}) set(step1_depends "${scripts_gen_java}" "${scripts_hdr_parser}" ${opencv_public_headers} ${opencv_type_dicts})
foreach(module ${OPENCV_JAVA_MODULES}) foreach(module ${OPENCV_JAVA_MODULES})
# second run of gen_java.py (at build time) # second run of gen_java.py (at build time)
add_custom_command(OUTPUT ${generated_java_sources_${module}} "${CMAKE_CURRENT_BINARY_DIR}/gen/${module}.cpp" add_custom_command(OUTPUT ${generated_java_sources_${module}} "${CMAKE_CURRENT_BINARY_DIR}/gen/${module}.cpp"
COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${scripts_gen_java}" "${scripts_hdr_parser}" ${module} ${opencv_public_headers_${module}} "--common" ${opencv_java_common_headers_${module}} COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${scripts_gen_java}" "-p" "${scripts_hdr_parser}" "-m" ${module} "-s" ${opencv_public_headers_${module}} "-c" ${opencv_java_common_headers_${module}} "-t" ${opencv_java_type_dict_${module}}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/gen/" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/gen/"
DEPENDS "${scripts_gen_java}" "${scripts_hdr_parser}" ${opencv_public_headers_${module}} ${opencv_java_common_headers_${module}} DEPENDS "${scripts_gen_java}" "${scripts_hdr_parser}" ${opencv_public_headers_${module}} ${opencv_java_common_headers_${module}} ${opencv_java_type_dict_${module}}
) )
endforeach() endforeach()
......
#!/usr/bin/env python #!/usr/bin/env python
import sys, re, os.path import sys, re, os.path
import json
import logging import logging
from pprint import pformat from pprint import pformat
from string import Template from string import Template
...@@ -10,176 +11,23 @@ if sys.version_info[0] >= 3: ...@@ -10,176 +11,23 @@ if sys.version_info[0] >= 3:
else: else:
from cStringIO import StringIO from cStringIO import StringIO
class_ignore_list = ( # list of class names, which should be skipped by wrapper generator
#core # the list is loaded from misc/java/gen_dict.json defined for the module and its dependencies
"FileNode", "FileStorage", "KDTree", "KeyPoint", "DMatch", class_ignore_list = []
#features2d
"SimpleBlobDetector",
"CirclesGridFinderParameters"
)
const_ignore_list = (
"CV_CAP_OPENNI",
"CV_CAP_PROP_OPENNI_",
"CV_CAP_INTELPERC",
"CV_CAP_PROP_INTELPERC_"
"WINDOW_AUTOSIZE",
"CV_WND_PROP_",
"CV_WINDOW_",
"CV_EVENT_",
"CV_GUI_",
"CV_PUSH_BUTTON",
"CV_CHECKBOX",
"CV_RADIOBOX",
#attention!
#the following constants are added to this list using code automatic generation
#TODO: should be checked
"CV_CAP_ANY",
"CV_CAP_MIL",
"CV_CAP_VFW",
"CV_CAP_V4L",
"CV_CAP_V4L2",
"CV_CAP_FIREWARE",
"CV_CAP_FIREWIRE",
"CV_CAP_IEEE1394",
"CV_CAP_DC1394",
"CV_CAP_CMU1394",
"CV_CAP_STEREO",
"CV_CAP_TYZX",
"CV_TYZX_LEFT",
"CV_TYZX_RIGHT",
"CV_TYZX_COLOR",
"CV_TYZX_Z",
"CV_CAP_QT",
"CV_CAP_UNICAP",
"CV_CAP_DSHOW",
"CV_CAP_PVAPI",
"CV_CAP_PROP_DC1394_OFF",
"CV_CAP_PROP_DC1394_MODE_MANUAL",
"CV_CAP_PROP_DC1394_MODE_AUTO",
"CV_CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO",
"CV_CAP_PROP_POS_MSEC",
"CV_CAP_PROP_POS_FRAMES",
"CV_CAP_PROP_POS_AVI_RATIO",
"CV_CAP_PROP_FPS",
"CV_CAP_PROP_FOURCC",
"CV_CAP_PROP_FRAME_COUNT",
"CV_CAP_PROP_FORMAT",
"CV_CAP_PROP_MODE",
"CV_CAP_PROP_BRIGHTNESS",
"CV_CAP_PROP_CONTRAST",
"CV_CAP_PROP_SATURATION",
"CV_CAP_PROP_HUE",
"CV_CAP_PROP_GAIN",
"CV_CAP_PROP_EXPOSURE",
"CV_CAP_PROP_CONVERT_RGB",
"CV_CAP_PROP_WHITE_BALANCE_BLUE_U",
"CV_CAP_PROP_RECTIFICATION",
"CV_CAP_PROP_MONOCHROME",
"CV_CAP_PROP_SHARPNESS",
"CV_CAP_PROP_AUTO_EXPOSURE",
"CV_CAP_PROP_GAMMA",
"CV_CAP_PROP_TEMPERATURE",
"CV_CAP_PROP_TRIGGER",
"CV_CAP_PROP_TRIGGER_DELAY",
"CV_CAP_PROP_WHITE_BALANCE_RED_V",
"CV_CAP_PROP_MAX_DC1394",
"CV_CAP_GSTREAMER_QUEUE_LENGTH",
"CV_CAP_PROP_PVAPI_MULTICASTIP",
"CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING",
"EVENT_.*",
"CV_L?(BGRA?|RGBA?|GRAY|XYZ|YCrCb|Luv|Lab|HLS|YUV|HSV)\d*2L?(BGRA?|RGBA?|GRAY|XYZ|YCrCb|Luv|Lab|HLS|YUV|HSV).*",
"CV_COLORCVT_MAX",
"CV_.*Bayer.*",
"CV_YUV420(i|sp|p)2.+",
"CV_TM_.+",
"CV_FLOODFILL_.+",
"CV_ADAPTIVE_THRESH_.+",
"WINDOW_.+",
"WND_PROP_.+",
)
const_private_list = (
"CV_MOP_.+",
"CV_INTER_.+",
"CV_THRESH_.+",
"CV_INPAINT_.+",
"CV_RETR_.+",
"CV_CHAIN_APPROX_.+",
"OPPONENTEXTRACTOR",
"GRIDDETECTOR",
"PYRAMIDDETECTOR",
"DYNAMICDETECTOR",
)
# { Module : { public : [[name, val],...], private : [[]...] } } # list of constant names, which should be skipped by wrapper generator
missing_consts = \ # ignored constants can be defined using regular expressions
{ const_ignore_list = []
'Core' :
{
'private' :
(
('CV_8U', 0 ), ('CV_8S', 1 ),
('CV_16U', 2 ), ('CV_16S', 3 ),
('CV_32S', 4 ),
('CV_32F', 5 ), ('CV_64F', 6 ),
('CV_USRTYPE1', 7 ),
), # private
'public' :
(
('SVD_MODIFY_A', 1), ('SVD_NO_UV', 2), ('SVD_FULL_UV', 4),
('FILLED', -1),
('REDUCE_SUM', 0), ('REDUCE_AVG', 1), ('REDUCE_MAX', 2), ('REDUCE_MIN', 3),
) #public
}, # Core
"Imgproc":
{
'private' :
(
('IPL_BORDER_CONSTANT', 0 ),
('IPL_BORDER_REPLICATE', 1 ),
('IPL_BORDER_REFLECT', 2 ),
('IPL_BORDER_WRAP', 3 ),
('IPL_BORDER_REFLECT_101', 4 ),
('IPL_BORDER_TRANSPARENT', 5 ),
), # private
'public' :
(
('LINE_AA', 16), ('LINE_8', 8), ('LINE_4', 4),
) #public
}, # Imgproc
"Calib3d":
{
'public' :
(
('CALIB_USE_INTRINSIC_GUESS', '1'),
('CALIB_RECOMPUTE_EXTRINSIC', '2'),
('CALIB_CHECK_COND', '4'),
('CALIB_FIX_SKEW', '8'),
('CALIB_FIX_K1', '16'),
('CALIB_FIX_K2', '32'),
('CALIB_FIX_K3', '64'),
('CALIB_FIX_K4', '128'),
('CALIB_FIX_INTRINSIC', '256')
)
}, # Calib3d
"Video":
{
'private' :
(
('CV_LKFLOW_INITIAL_GUESSES', 4 ),
('CV_LKFLOW_GET_MIN_EIGENVALS', 8 ),
) # private
}, # Video
} # list of private constants
const_private_list = []
# { Module : { public : [[name, val],...], private : [[]...] } }
missing_consts = {}
# c_type : { java/jni correspondence } # c_type : { java/jni correspondence }
# Complex data types are configured for each module using misc/java/gen_dict.json
type_dict = { type_dict = {
# "simple" : { j_type : "?", jn_type : "?", jni_type : "?", suffix : "?" }, # "simple" : { j_type : "?", jn_type : "?", jni_type : "?", suffix : "?" },
"" : { "j_type" : "", "jn_type" : "long", "jni_type" : "jlong" }, # c-tor ret_type "" : { "j_type" : "", "jn_type" : "long", "jni_type" : "jlong" }, # c-tor ret_type
...@@ -195,397 +43,14 @@ type_dict = { ...@@ -195,397 +43,14 @@ type_dict = {
"size_t" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" }, "size_t" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" },
"__int64" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" }, "__int64" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" },
"int64" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" }, "int64" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" },
"double[]": { "j_type" : "double[]", "jn_type" : "double[]", "jni_type" : "jdoubleArray", "suffix" : "_3D" }, "double[]": { "j_type" : "double[]", "jn_type" : "double[]", "jni_type" : "jdoubleArray", "suffix" : "_3D" }
# "complex" : { j_type : "?", jn_args : (("", ""),), jn_name : "", jni_var : "", jni_name : "", "suffix" : "?" },
"vector_Point" : { "j_type" : "MatOfPoint", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Point> %(n)s", "suffix" : "J" },
"vector_Point2f" : { "j_type" : "MatOfPoint2f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Point2f> %(n)s", "suffix" : "J" },
#"vector_Point2d" : { "j_type" : "MatOfPoint2d", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Point2d> %(n)s", "suffix" : "J" },
"vector_Point3i" : { "j_type" : "MatOfPoint3", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Point3i> %(n)s", "suffix" : "J" },
"vector_Point3f" : { "j_type" : "MatOfPoint3f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Point3f> %(n)s", "suffix" : "J" },
#"vector_Point3d" : { "j_type" : "MatOfPoint3d", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Point3d> %(n)s", "suffix" : "J" },
"vector_KeyPoint" : { "j_type" : "MatOfKeyPoint", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<KeyPoint> %(n)s", "suffix" : "J" },
"vector_DMatch" : { "j_type" : "MatOfDMatch", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<DMatch> %(n)s", "suffix" : "J" },
"vector_Rect" : { "j_type" : "MatOfRect", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Rect> %(n)s", "suffix" : "J" },
"vector_Rect2d" : { "j_type" : "MatOfRect2d", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Rect2d> %(n)s", "suffix" : "J" },
"vector_uchar" : { "j_type" : "MatOfByte", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<uchar> %(n)s", "suffix" : "J" },
"vector_char" : { "j_type" : "MatOfByte", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<char> %(n)s", "suffix" : "J" },
"vector_int" : { "j_type" : "MatOfInt", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<int> %(n)s", "suffix" : "J" },
"vector_float" : { "j_type" : "MatOfFloat", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<float> %(n)s", "suffix" : "J" },
"vector_double" : { "j_type" : "MatOfDouble", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<double> %(n)s", "suffix" : "J" },
"vector_Vec4i" : { "j_type" : "MatOfInt4", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Vec4i> %(n)s", "suffix" : "J" },
"vector_Vec4f" : { "j_type" : "MatOfFloat4", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Vec4f> %(n)s", "suffix" : "J" },
"vector_Vec6f" : { "j_type" : "MatOfFloat6", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Vec6f> %(n)s", "suffix" : "J" },
"vector_Mat" : { "j_type" : "List<Mat>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Mat> %(n)s", "suffix" : "J" },
"vector_vector_KeyPoint": { "j_type" : "List<MatOfKeyPoint>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector<KeyPoint> > %(n)s" },
"vector_vector_DMatch" : { "j_type" : "List<MatOfDMatch>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector<DMatch> > %(n)s" },
"vector_vector_char" : { "j_type" : "List<MatOfByte>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector<char> > %(n)s" },
"vector_vector_Point" : { "j_type" : "List<MatOfPoint>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector<Point> > %(n)s" },
"vector_vector_Point2f" : { "j_type" : "List<MatOfPoint2f>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector<Point2f> > %(n)s" },
"vector_vector_Point3f" : { "j_type" : "List<MatOfPoint3f>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector<Point3f> > %(n)s" },
"Mat" : { "j_type" : "Mat", "jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),),
"jni_var" : "Mat& %(n)s = *((Mat*)%(n)s_nativeObj)",
"jni_type" : "jlong", #"jni_name" : "*%(n)s",
"suffix" : "J" },
"Point" : { "j_type" : "Point", "jn_args" : (("double", ".x"), ("double", ".y")),
"jni_var" : "Point %(n)s((int)%(n)s_x, (int)%(n)s_y)", "jni_type" : "jdoubleArray",
"suffix" : "DD"},
"Point2f" : { "j_type" : "Point", "jn_args" : (("double", ".x"), ("double", ".y")),
"jni_var" : "Point2f %(n)s((float)%(n)s_x, (float)%(n)s_y)", "jni_type" : "jdoubleArray",
"suffix" : "DD"},
"Point2d" : { "j_type" : "Point", "jn_args" : (("double", ".x"), ("double", ".y")),
"jni_var" : "Point2d %(n)s(%(n)s_x, %(n)s_y)", "jni_type" : "jdoubleArray",
"suffix" : "DD"},
"Point3i" : { "j_type" : "Point3", "jn_args" : (("double", ".x"), ("double", ".y"), ("double", ".z")),
"jni_var" : "Point3i %(n)s((int)%(n)s_x, (int)%(n)s_y, (int)%(n)s_z)", "jni_type" : "jdoubleArray",
"suffix" : "DDD"},
"Point3f" : { "j_type" : "Point3", "jn_args" : (("double", ".x"), ("double", ".y"), ("double", ".z")),
"jni_var" : "Point3f %(n)s((float)%(n)s_x, (float)%(n)s_y, (float)%(n)s_z)", "jni_type" : "jdoubleArray",
"suffix" : "DDD"},
"Point3d" : { "j_type" : "Point3", "jn_args" : (("double", ".x"), ("double", ".y"), ("double", ".z")),
"jni_var" : "Point3d %(n)s(%(n)s_x, %(n)s_y, %(n)s_z)", "jni_type" : "jdoubleArray",
"suffix" : "DDD"},
"KeyPoint": { "j_type" : "KeyPoint", "jn_args" : (("float", ".x"), ("float", ".y"), ("float", ".size"),
("float", ".angle"), ("float", ".response"), ("int", ".octave"), ("int", ".class_id")),
"jni_var" : "KeyPoint %(n)s(%(n)s_x, %(n)s_y, %(n)s_size, %(n)s_angle, %(n)s_response, %(n)s_octave, %(n)s_class_id)",
"jni_type" : "jdoubleArray",
"suffix" : "FFFFFII"},
"DMatch" : { "j_type" : "DMatch", "jn_args" : ( ('int', 'queryIdx'), ('int', 'trainIdx'),
('int', 'imgIdx'), ('float', 'distance'), ),
"jni_var" : "DMatch %(n)s(%(n)s_queryIdx, %(n)s_trainIdx, %(n)s_imgIdx, %(n)s_distance)",
"jni_type" : "jdoubleArray",
"suffix" : "IIIF"},
"Rect" : { "j_type" : "Rect", "jn_args" : (("int", ".x"), ("int", ".y"), ("int", ".width"), ("int", ".height")),
"jni_var" : "Rect %(n)s(%(n)s_x, %(n)s_y, %(n)s_width, %(n)s_height)", "jni_type" : "jdoubleArray",
"suffix" : "IIII"},
"Rect2d" : { "j_type" : "Rect2d", "jn_args" : (("double", ".x"), ("double", ".y"), ("double", ".width"), ("double", ".height")),
"jni_var" : "Rect %(n)s(%(n)s_x, %(n)s_y, %(n)s_width, %(n)s_height)", "jni_type" : "jdoubleArray",
"suffix" : "DDDD"},
"Size" : { "j_type" : "Size", "jn_args" : (("double", ".width"), ("double", ".height")),
"jni_var" : "Size %(n)s((int)%(n)s_width, (int)%(n)s_height)", "jni_type" : "jdoubleArray",
"suffix" : "DD"},
"Size2f" : { "j_type" : "Size", "jn_args" : (("double", ".width"), ("double", ".height")),
"jni_var" : "Size2f %(n)s((float)%(n)s_width, (float)%(n)s_height)", "jni_type" : "jdoubleArray",
"suffix" : "DD"},
"RotatedRect": { "j_type" : "RotatedRect", "jn_args" : (("double", ".center.x"), ("double", ".center.y"), ("double", ".size.width"), ("double", ".size.height"), ("double", ".angle")),
"jni_var" : "RotatedRect %(n)s(cv::Point2f(%(n)s_center_x, %(n)s_center_y), cv::Size2f(%(n)s_size_width, %(n)s_size_height), %(n)s_angle)",
"jni_type" : "jdoubleArray", "suffix" : "DDDDD"},
"Scalar" : { "j_type" : "Scalar", "jn_args" : (("double", ".val[0]"), ("double", ".val[1]"), ("double", ".val[2]"), ("double", ".val[3]")),
"jni_var" : "Scalar %(n)s(%(n)s_val0, %(n)s_val1, %(n)s_val2, %(n)s_val3)", "jni_type" : "jdoubleArray",
"suffix" : "DDDD"},
"Range" : { "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"},
"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",
"jni_type" : "jstring", "jni_name" : "n_%(n)s",
"jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); 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); 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",
"suffix" : "IID"},
"CvTermCriteria": { "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",
"suffix" : "IID"},
"Vec2d" : { "j_type" : "double[]", "jn_args" : (("double", ".val[0]"), ("double", ".val[1]")),
"jn_type" : "double[]",
"jni_var" : "Vec2d %(n)s(%(n)s_val0, %(n)s_val1)", "jni_type" : "jdoubleArray",
"suffix" : "DD"},
"Vec3d" : { "j_type" : "double[]", "jn_args" : (("double", ".val[0]"), ("double", ".val[1]"), ("double", ".val[2]")),
"jn_type" : "double[]",
"jni_var" : "Vec3d %(n)s(%(n)s_val0, %(n)s_val1, %(n)s_val2)", "jni_type" : "jdoubleArray",
"suffix" : "DDD"},
"Moments" : {
"j_type" : "Moments",
"jn_args" : (("double", ".m00"), ("double", ".m10"), ("double", ".m01"), ("double", ".m20"), ("double", ".m11"),
("double", ".m02"), ("double", ".m30"), ("double", ".m21"), ("double", ".m12"), ("double", ".m03")),
"jni_var" : "Moments %(n)s(%(n)s_m00, %(n)s_m10, %(n)s_m01, %(n)s_m20, %(n)s_m11, %(n)s_m02, %(n)s_m30, %(n)s_m21, %(n)s_m12, %(n)s_m03)",
"jni_type" : "jdoubleArray",
"suffix" : "DDDDDDDDDD"},
} }
# { class : { func : {j_code, jn_code, cpp_code} } } # { class : { func : {j_code, jn_code, cpp_code} } }
ManualFuncs = { ManualFuncs = {}
'Core' :
{
'minMaxLoc' : {
'j_code' : """
// manual port
public static class MinMaxLocResult {
public double minVal;
public double maxVal;
public Point minLoc;
public Point maxLoc;
public MinMaxLocResult() {
minVal=0; maxVal=0;
minLoc=new Point();
maxLoc=new Point();
}
}
// C++: minMaxLoc(Mat src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, InputArray mask=noArray())
//javadoc: minMaxLoc(src, mask)
public static MinMaxLocResult minMaxLoc(Mat src, Mat mask) {
MinMaxLocResult res = new MinMaxLocResult();
long maskNativeObj=0;
if (mask != null) {
maskNativeObj=mask.nativeObj;
}
double resarr[] = n_minMaxLocManual(src.nativeObj, maskNativeObj);
res.minVal=resarr[0];
res.maxVal=resarr[1];
res.minLoc.x=resarr[2];
res.minLoc.y=resarr[3];
res.maxLoc.x=resarr[4];
res.maxLoc.y=resarr[5];
return res;
}
//javadoc: minMaxLoc(src)
public static MinMaxLocResult minMaxLoc(Mat src) {
return minMaxLoc(src, null);
}
""",
'jn_code' :
""" private static native double[] n_minMaxLocManual(long src_nativeObj, long mask_nativeObj);\n""",
'cpp_code' :
"""
// C++: minMaxLoc(Mat src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, InputArray mask=noArray())
JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual (JNIEnv*, jclass, jlong, jlong);
JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual
(JNIEnv* env, jclass, jlong src_nativeObj, jlong mask_nativeObj)
{
try {
LOGD("Core::n_1minMaxLoc()");
jdoubleArray result;
result = env->NewDoubleArray(6);
if (result == NULL) {
return NULL; /* out of memory error thrown */
}
Mat& src = *((Mat*)src_nativeObj);
double minVal, maxVal;
Point minLoc, maxLoc;
if (mask_nativeObj != 0) {
Mat& mask = *((Mat*)mask_nativeObj);
minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc, mask);
} else {
minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc);
}
jdouble fill[6];
fill[0]=minVal;
fill[1]=maxVal;
fill[2]=minLoc.x;
fill[3]=minLoc.y;
fill[4]=maxLoc.x;
fill[5]=maxLoc.y;
env->SetDoubleArrayRegion(result, 0, 6, fill);
return result;
} catch(const cv::Exception& e) {
LOGD("Core::n_1minMaxLoc() catched cv::Exception: %s", e.what());
jclass je = env->FindClass("org/opencv/core/CvException");
if(!je) je = env->FindClass("java/lang/Exception");
env->ThrowNew(je, e.what());
return NULL;
} catch (...) {
LOGD("Core::n_1minMaxLoc() catched unknown exception (...)");
jclass je = env->FindClass("java/lang/Exception");
env->ThrowNew(je, "Unknown exception in JNI code {core::minMaxLoc()}");
return NULL;
}
}
""",
}, # minMaxLoc
## "checkRange" : #TBD
## {'j_code' : '/* TBD: checkRange() */', 'jn_code' : '', 'cpp_code' : '' },
"checkHardwareSupport" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"setUseOptimized" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"useOptimized" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
}, # Core
'Imgproc' :
{
'getTextSize' :
{
'j_code' :
"""
// C++: Size getTextSize(const 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)
throw new java.lang.IllegalArgumentException("'baseLine' must be 'int[1]' or 'null'.");
Size retVal = new Size(n_getTextSize(text, fontFace, fontScale, thickness, baseLine));
return retVal;
}
""",
'jn_code' :
""" private static native double[] n_getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine);\n""",
'cpp_code' :
"""
// C++: Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, int* baseLine);
JNIEXPORT jdoubleArray JNICALL Java_org_opencv_imgproc_Imgproc_n_1getTextSize (JNIEnv*, jclass, jstring, jint, jdouble, jint, jintArray);
JNIEXPORT jdoubleArray JNICALL Java_org_opencv_imgproc_Imgproc_n_1getTextSize
(JNIEnv* env, jclass, jstring text, jint fontFace, jdouble fontScale, jint thickness, jintArray baseLine)
{
try {
LOGD("Core::n_1getTextSize()");
jdoubleArray result;
result = env->NewDoubleArray(2);
if (result == NULL) {
return NULL; /* out of memory error thrown */
}
const char* utf_text = env->GetStringUTFChars(text, 0);
String n_text( utf_text ? utf_text : "" );
env->ReleaseStringUTFChars(text, utf_text);
int _baseLine;
int* pbaseLine = 0;
if (baseLine != NULL)
pbaseLine = &_baseLine;
cv::Size rsize = cv::getTextSize(n_text, (int)fontFace, (double)fontScale, (int)thickness, pbaseLine);
jdouble fill[2];
fill[0]=rsize.width;
fill[1]=rsize.height;
env->SetDoubleArrayRegion(result, 0, 2, fill);
if (baseLine != NULL) {
jint jbaseLine = (jint)(*pbaseLine);
env->SetIntArrayRegion(baseLine, 0, 1, &jbaseLine);
}
return result;
} catch(const cv::Exception& e) {
LOGD("Imgproc::n_1getTextSize() catched cv::Exception: %s", e.what());
jclass je = env->FindClass("org/opencv/core/CvException");
if(!je) je = env->FindClass("java/lang/Exception");
env->ThrowNew(je, e.what());
return NULL;
} catch (...) {
LOGD("Imgproc::n_1getTextSize() catched unknown exception (...)");
jclass je = env->FindClass("java/lang/Exception");
env->ThrowNew(je, "Unknown exception in JNI code {core::getTextSize()}");
return NULL;
}
}
""",
}, # getTextSize
}, # Imgproc
'Highgui' :
{
"namedWindow" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"destroyWindow" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"destroyAllWindows" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"startWindowThread" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"setWindowProperty" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"getWindowProperty" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"getTrackbarPos" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"setTrackbarPos" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"imshow" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"waitKey" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"moveWindow" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"resizeWindow" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
}, # Highgui
}
# { class : { func : { arg_name : {"ctype" : ctype, "attrib" : [attrib]} } } } # { class : { func : { arg_name : {"ctype" : ctype, "attrib" : [attrib]} } } }
func_arg_fix = { func_arg_fix = {}
'' : {
'randu' : { 'low' : {"ctype" : 'double'},
'high' : {"ctype" : 'double'} },
'randn' : { 'mean' : {"ctype" : 'double'},
'stddev' : {"ctype" : 'double'} },
'inRange' : { 'lowerb' : {"ctype" : 'Scalar'},
'upperb' : {"ctype" : 'Scalar'} },
'goodFeaturesToTrack' : { 'corners' : {"ctype" : 'vector_Point'} },
'findFundamentalMat' : { 'points1' : {"ctype" : 'vector_Point2f'},
'points2' : {"ctype" : 'vector_Point2f'} },
'cornerSubPix' : { 'corners' : {"ctype" : 'vector_Point2f'} },
'minEnclosingCircle' : { 'points' : {"ctype" : 'vector_Point2f'} },
'findHomography' : { 'srcPoints' : {"ctype" : 'vector_Point2f'},
'dstPoints' : {"ctype" : 'vector_Point2f'} },
'solvePnP' : { 'objectPoints' : {"ctype" : 'vector_Point3f'},
'imagePoints' : {"ctype" : 'vector_Point2f'},
'distCoeffs' : {"ctype" : 'vector_double' } },
'solvePnPRansac' : { 'objectPoints' : {"ctype" : 'vector_Point3f'},
'imagePoints' : {"ctype" : 'vector_Point2f'},
'distCoeffs' : {"ctype" : 'vector_double' } },
'calcOpticalFlowPyrLK' : { 'prevPts' : {"ctype" : 'vector_Point2f'},
'nextPts' : {"ctype" : 'vector_Point2f'},
'status' : {"ctype" : 'vector_uchar'},
'err' : {"ctype" : 'vector_float'} },
'fitEllipse' : { 'points' : {"ctype" : 'vector_Point2f'} },
'fillPoly' : { 'pts' : {"ctype" : 'vector_vector_Point'} },
'polylines' : { 'pts' : {"ctype" : 'vector_vector_Point'} },
'fillConvexPoly' : { 'points' : {"ctype" : 'vector_Point'} },
'boundingRect' : { 'points' : {"ctype" : 'vector_Point'} },
'approxPolyDP' : { 'curve' : {"ctype" : 'vector_Point2f'},
'approxCurve' : {"ctype" : 'vector_Point2f'} },
'arcLength' : { 'curve' : {"ctype" : 'vector_Point2f'} },
'pointPolygonTest' : { 'contour' : {"ctype" : 'vector_Point2f'} },
'minAreaRect' : { 'points' : {"ctype" : 'vector_Point2f'} },
'getAffineTransform' : { 'src' : {"ctype" : 'vector_Point2f'},
'dst' : {"ctype" : 'vector_Point2f'} },
'hconcat' : { 'src' : {"ctype" : 'vector_Mat'} },
'vconcat' : { 'src' : {"ctype" : 'vector_Mat'} },
'undistortPoints' : { 'src' : {"ctype" : 'vector_Point2f'},
'dst' : {"ctype" : 'vector_Point2f'} },
'checkRange' : {'pos' : {"ctype" : '*'} },
'meanStdDev' : { 'mean' : {"ctype" : 'vector_double'},
'stddev' : {"ctype" : 'vector_double'} },
'drawContours' : {'contours' : {"ctype" : 'vector_vector_Point'} },
'findContours' : {'contours' : {"ctype" : 'vector_vector_Point'} },
'convexityDefects' : { 'contour' : {"ctype" : 'vector_Point'},
'convexhull' : {"ctype" : 'vector_int'},
'convexityDefects' : {"ctype" : 'vector_Vec4i'} },
'isContourConvex' : { 'contour' : {"ctype" : 'vector_Point'} },
'convexHull' : { 'points' : {"ctype" : 'vector_Point'},
'hull' : {"ctype" : 'vector_int'},
'returnPoints' : {"ctype" : ''} },
'projectPoints' : { 'objectPoints' : {"ctype" : 'vector_Point3f'},
'imagePoints' : {"ctype" : 'vector_Point2f'},
'distCoeffs' : {"ctype" : 'vector_double' } },
'initCameraMatrix2D' : { 'objectPoints' : {"ctype" : 'vector_vector_Point3f'},
'imagePoints' : {"ctype" : 'vector_vector_Point2f'} },
'findChessboardCorners' : { 'corners' : {"ctype" : 'vector_Point2f'} },
'drawChessboardCorners' : { 'corners' : {"ctype" : 'vector_Point2f'} },
'mixChannels' : { 'dst' : {"attrib" : []} },
}, # '', i.e. no class
} # func_arg_fix
def getLibVersion(version_hpp_path): def getLibVersion(version_hpp_path):
version_file = open(version_hpp_path, "rt").read() version_file = open(version_hpp_path, "rt").read()
...@@ -808,33 +273,15 @@ class ClassInfo(GeneralInfo): ...@@ -808,33 +273,15 @@ class ClassInfo(GeneralInfo):
return ["import %s;" % c for c in sorted(self.imports) if not c.startswith('org.opencv.'+module)] return ["import %s;" % c for c in sorted(self.imports) if not c.startswith('org.opencv.'+module)]
def addImports(self, ctype): def addImports(self, ctype):
if ctype.startswith('vector_vector'): if ctype in type_dict:
self.imports.add("org.opencv.core.Mat") if "j_import" in type_dict[ctype]:
self.imports.add("org.opencv.utils.Converters") self.imports.add(type_dict[ctype]["j_import"])
self.imports.add("java.util.List") if "v_type" in type_dict[ctype]:
self.imports.add("java.util.ArrayList")
self.addImports(ctype.replace('vector_vector', 'vector'))
elif ctype.startswith('Feature2D'):
self.imports.add("org.opencv.features2d.Feature2D")
elif ctype.startswith('vector'):
self.imports.add("org.opencv.core.Mat")
self.imports.add('java.util.ArrayList')
if type_dict[ctype]['j_type'].startswith('MatOf'):
self.imports.add("org.opencv.core." + type_dict[ctype]['j_type'])
else:
self.imports.add("java.util.List") self.imports.add("java.util.List")
self.imports.add("java.util.ArrayList")
self.imports.add("org.opencv.utils.Converters") self.imports.add("org.opencv.utils.Converters")
self.addImports(ctype.replace('vector_', '')) if type_dict[ctype]["v_type"] in ("Mat", "vector_Mat"):
else: self.imports.add("org.opencv.core.Mat")
j_type = ''
if ctype in type_dict:
j_type = type_dict[ctype]['j_type']
elif ctype in ("Algorithm"):
j_type = ctype
if j_type in ( "CvType", "Mat", "Point", "Point3", "Range", "Rect", "Rect2d", "RotatedRect", "Scalar", "Size", "TermCriteria", "Algorithm" ):
self.imports.add("org.opencv.core." + j_type)
if j_type == 'String':
self.imports.add("java.lang.String")
def getAllMethods(self): def getAllMethods(self):
result = [] result = []
...@@ -900,10 +347,6 @@ class ArgInfo(): ...@@ -900,10 +347,6 @@ class ArgInfo():
if ctype.endswith("*"): if ctype.endswith("*"):
ctype = ctype[:-1] ctype = ctype[:-1]
self.pointer = True self.pointer = True
if ctype == 'vector_Point2d':
ctype = 'vector_Point2f'
elif ctype == 'vector_Point3d':
ctype = 'vector_Point3f'
self.ctype = ctype self.ctype = ctype
self.name = arg_tuple[1] self.name = arg_tuple[1]
self.defval = arg_tuple[2] self.defval = arg_tuple[2]
...@@ -933,7 +376,7 @@ class FuncInfo(GeneralInfo): ...@@ -933,7 +376,7 @@ class FuncInfo(GeneralInfo):
self.static = ["","static"][ "/S" in decl[2] ] self.static = ["","static"][ "/S" in decl[2] ]
self.ctype = re.sub(r"^CvTermCriteria", "TermCriteria", decl[1] or "") self.ctype = re.sub(r"^CvTermCriteria", "TermCriteria", decl[1] or "")
self.args = [] self.args = []
func_fix_map = func_arg_fix.get(self.classname, {}).get(self.jname, {}) func_fix_map = func_arg_fix.get(self.jname, {})
for a in decl[3]: for a in decl[3]:
arg = a[:] arg = a[:]
arg_fix_map = func_fix_map.get(arg[1], {}) arg_fix_map = func_fix_map.get(arg[1], {})
...@@ -1199,46 +642,55 @@ class JavaWrapperGenerator(object): ...@@ -1199,46 +642,55 @@ class JavaWrapperGenerator(object):
if not a.ctype: # hidden if not a.ctype: # hidden
continue continue
ci.addImports(a.ctype) ci.addImports(a.ctype)
if "vector" in a.ctype: # pass as Mat if "v_type" in type_dict[a.ctype]: # pass as vector
jn_args.append ( ArgInfo([ "__int64", "%s_mat.nativeObj" % a.name, "", [], "" ]) ) if type_dict[a.ctype]["v_type"] in ("Mat", "vector_Mat"): #pass as Mat or vector_Mat
jni_args.append ( ArgInfo([ "__int64", "%s_mat_nativeObj" % a.name, "", [], "" ]) ) jn_args.append ( ArgInfo([ "__int64", "%s_mat.nativeObj" % a.name, "", [], "" ]) )
c_prologue.append( type_dict[a.ctype]["jni_var"] % {"n" : a.name} + ";" ) jni_args.append ( ArgInfo([ "__int64", "%s_mat_nativeObj" % a.name, "", [], "" ]) )
c_prologue.append( "Mat& %(n)s_mat = *((Mat*)%(n)s_mat_nativeObj)" % {"n" : a.name} + ";" ) c_prologue.append( type_dict[a.ctype]["jni_var"] % {"n" : a.name} + ";" )
if "I" in a.out or not a.out: c_prologue.append( "Mat& %(n)s_mat = *((Mat*)%(n)s_mat_nativeObj)" % {"n" : a.name} + ";" )
if a.ctype.startswith("vector_vector_"): if "I" in a.out or not a.out:
j_prologue.append( "List<Mat> %(n)s_tmplm = new ArrayList<Mat>((%(n)s != null) ? %(n)s.size() : 0);" % {"n" : a.name } ) if type_dict[a.ctype]["v_type"] == "vector_Mat":
j_prologue.append( "Mat %(n)s_mat = Converters.%(t)s_to_Mat(%(n)s, %(n)s_tmplm);" % {"n" : a.name, "t" : a.ctype} ) j_prologue.append( "List<Mat> %(n)s_tmplm = new ArrayList<Mat>((%(n)s != null) ? %(n)s.size() : 0);" % {"n" : a.name } )
j_prologue.append( "Mat %(n)s_mat = Converters.%(t)s_to_Mat(%(n)s, %(n)s_tmplm);" % {"n" : a.name, "t" : a.ctype} )
else:
if not type_dict[a.ctype]["j_type"].startswith("MatOf"):
j_prologue.append( "Mat %(n)s_mat = Converters.%(t)s_to_Mat(%(n)s);" % {"n" : a.name, "t" : a.ctype} )
else:
j_prologue.append( "Mat %s_mat = %s;" % (a.name, a.name) )
c_prologue.append( "Mat_to_%(t)s( %(n)s_mat, %(n)s );" % {"n" : a.name, "t" : a.ctype} )
else: else:
if not type_dict[a.ctype]["j_type"].startswith("MatOf"): if not type_dict[a.ctype]["j_type"].startswith("MatOf"):
j_prologue.append( "Mat %(n)s_mat = Converters.%(t)s_to_Mat(%(n)s);" % {"n" : a.name, "t" : a.ctype} ) j_prologue.append( "Mat %s_mat = new Mat();" % a.name )
else: else:
j_prologue.append( "Mat %s_mat = %s;" % (a.name, a.name) ) j_prologue.append( "Mat %s_mat = %s;" % (a.name, a.name) )
c_prologue.append( "Mat_to_%(t)s( %(n)s_mat, %(n)s );" % {"n" : a.name, "t" : a.ctype} ) if "O" in a.out:
else: if not type_dict[a.ctype]["j_type"].startswith("MatOf"):
if not type_dict[a.ctype]["j_type"].startswith("MatOf"): j_epilogue.append("Converters.Mat_to_%(t)s(%(n)s_mat, %(n)s);" % {"t" : a.ctype, "n" : a.name})
j_prologue.append( "Mat %s_mat = new Mat();" % a.name ) j_epilogue.append( "%s_mat.release();" % a.name )
else: c_epilogue.append( "%(t)s_to_Mat( %(n)s, %(n)s_mat );" % {"n" : a.name, "t" : a.ctype} )
j_prologue.append( "Mat %s_mat = %s;" % (a.name, a.name) ) else: #pass as list
if "O" in a.out: jn_args.append ( ArgInfo([ a.ctype, a.name, "", [], "" ]) )
if not type_dict[a.ctype]["j_type"].startswith("MatOf"): jni_args.append ( ArgInfo([ a.ctype, "%s_list" % a.name , "", [], "" ]) )
j_epilogue.append("Converters.Mat_to_%(t)s(%(n)s_mat, %(n)s);" % {"t" : a.ctype, "n" : a.name}) c_prologue.append(type_dict[a.ctype]["jni_var"] % {"n" : a.name} + ";")
j_epilogue.append( "%s_mat.release();" % a.name ) if "I" in a.out or not a.out:
c_epilogue.append( "%(t)s_to_Mat( %(n)s, %(n)s_mat );" % {"n" : a.name, "t" : a.ctype} ) c_prologue.append("%(n)s = List_to_%(t)s(env, %(n)s_list);" % {"n" : a.name, "t" : a.ctype})
if "O" in a.out:
c_epilogue.append("Copy_%s_to_List(env,%s,%s_list);" % (a.ctype, a.name, a.name))
else: else:
fields = type_dict[a.ctype].get("jn_args", ((a.ctype, ""),)) fields = type_dict[a.ctype].get("jn_args", ((a.ctype, ""),))
if "I" in a.out or not a.out or self.isWrapped(a.ctype): # input arg, pass by primitive fields if "I" in a.out or not a.out or self.isWrapped(a.ctype): # input arg, pass by primitive fields
for f in fields: for f in fields:
jn_args.append ( ArgInfo([ f[0], a.name + f[1], "", [], "" ]) ) jn_args.append ( ArgInfo([ f[0], a.name + f[1], "", [], "" ]) )
jni_args.append( ArgInfo([ f[0], a.name + f[1].replace(".","_").replace("[","").replace("]","").replace("_getNativeObjAddr()","_nativeObj"), "", [], "" ]) ) jni_args.append( ArgInfo([ f[0], a.name + f[1].replace(".","_").replace("[","").replace("]","").replace("_getNativeObjAddr()","_nativeObj"), "", [], "" ]) )
if a.out and not self.isWrapped(a.ctype): # out arg, pass as double[] if "O" in a.out and not self.isWrapped(a.ctype): # out arg, pass as double[]
jn_args.append ( ArgInfo([ "double[]", "%s_out" % a.name, "", [], "" ]) ) jn_args.append ( ArgInfo([ "double[]", "%s_out" % a.name, "", [], "" ]) )
jni_args.append ( ArgInfo([ "double[]", "%s_out" % a.name, "", [], "" ]) ) jni_args.append ( ArgInfo([ "double[]", "%s_out" % a.name, "", [], "" ]) )
j_prologue.append( "double[] %s_out = new double[%i];" % (a.name, len(fields)) ) j_prologue.append( "double[] %s_out = new double[%i];" % (a.name, len(fields)) )
c_epilogue.append( \ c_epilogue.append( \
"jdouble tmp_%(n)s[%(cnt)i] = {%(args)s}; env->SetDoubleArrayRegion(%(n)s_out, 0, %(cnt)i, tmp_%(n)s);" % "jdouble tmp_%(n)s[%(cnt)i] = {%(args)s}; env->SetDoubleArrayRegion(%(n)s_out, 0, %(cnt)i, tmp_%(n)s);" %
{ "n" : a.name, "cnt" : len(fields), "args" : ", ".join(["(jdouble)" + a.name + f[1] for f in fields]) } ) { "n" : a.name, "cnt" : len(fields), "args" : ", ".join(["(jdouble)" + a.name + f[1] for f in fields]) } )
if a.ctype in ('bool', 'int', 'long', 'float', 'double'): if type_dict[a.ctype]["j_type"] in ('bool', 'int', 'long', 'float', 'double'):
j_epilogue.append('if(%(n)s!=null) %(n)s[0] = (%(t)s)%(n)s_out[0];' % {'n':a.name,'t':a.ctype}) j_epilogue.append('if(%(n)s!=null) %(n)s[0] = (%(t)s)%(n)s_out[0];' % {'n':a.name,'t':type_dict[a.ctype]["j_type"]})
else: else:
set_vals = [] set_vals = []
i = 0 i = 0
...@@ -1255,7 +707,7 @@ class JavaWrapperGenerator(object): ...@@ -1255,7 +707,7 @@ class JavaWrapperGenerator(object):
if not a.ctype: #hidden if not a.ctype: #hidden
continue continue
jt = type_dict[a.ctype]["j_type"] jt = type_dict[a.ctype]["j_type"]
if a.out and a.ctype in ('bool', 'int', 'long', 'float', 'double'): if a.out and jt in ('bool', 'int', 'long', 'float', 'double'):
jt += '[]' jt += '[]'
j_args.append( jt + ' ' + a.name ) j_args.append( jt + ' ' + a.name )
j_signature = type_dict[fi.ctype]["j_type"] + " " + \ j_signature = type_dict[fi.ctype]["j_type"] + " " + \
...@@ -1299,15 +751,16 @@ class JavaWrapperGenerator(object): ...@@ -1299,15 +751,16 @@ class JavaWrapperGenerator(object):
ret_val = type_dict[ret_type]["j_type"] + " retVal = " ret_val = type_dict[ret_type]["j_type"] + " retVal = "
tail = "" tail = ""
ret = "return retVal;" ret = "return retVal;"
if ret_type.startswith('vector'): if "v_type" in type_dict[ret_type]:
tail = ")"
j_type = type_dict[ret_type]["j_type"] j_type = type_dict[ret_type]["j_type"]
if j_type.startswith('MatOf'): if type_dict[ret_type]["v_type"] in ("Mat", "vector_Mat"):
ret_val += j_type + ".fromNativeAddr(" tail = ")"
else: if j_type.startswith('MatOf'):
ret_val = "Mat retValMat = new Mat(" ret_val += j_type + ".fromNativeAddr("
j_prologue.append( j_type + ' retVal = new Array' + j_type+'();') else:
j_epilogue.append('Converters.Mat_to_' + ret_type + '(retValMat, retVal);') ret_val = "Mat retValMat = new Mat("
j_prologue.append( j_type + ' retVal = new Array' + j_type+'();')
j_epilogue.append('Converters.Mat_to_' + ret_type + '(retValMat, retVal);')
elif ret_type.startswith("Ptr_"): elif ret_type.startswith("Ptr_"):
ret_val = type_dict[fi.ctype]["j_type"] + " retVal = new " + type_dict[ret_type]["j_type"] + "(" ret_val = type_dict[fi.ctype]["j_type"] + " retVal = new " + type_dict[ret_type]["j_type"] + "("
tail = ")" tail = ")"
...@@ -1367,8 +820,11 @@ class JavaWrapperGenerator(object): ...@@ -1367,8 +820,11 @@ class JavaWrapperGenerator(object):
default = "return;" default = "return;"
elif not fi.ctype: # c-tor elif not fi.ctype: # c-tor
ret = "return (jlong) _retval_;" ret = "return (jlong) _retval_;"
elif fi.ctype.startswith('vector'): # c-tor elif "v_type" in type_dict[fi.ctype]: # c-tor
ret = "return (jlong) _retval_;" if type_dict[fi.ctype]["v_type"] in ("Mat", "vector_Mat"):
ret = "return (jlong) _retval_;"
else: # returned as jobject
ret = "return _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("");'
...@@ -1396,10 +852,13 @@ class JavaWrapperGenerator(object): ...@@ -1396,10 +852,13 @@ class JavaWrapperGenerator(object):
retval = "" retval = ""
elif fi.ctype == "String": elif fi.ctype == "String":
retval = "cv::" + retval retval = "cv::" + retval
elif fi.ctype.startswith('vector'): elif "v_type" in type_dict[fi.ctype]: # vector is returned
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();") if type_dict[fi.ctype]["v_type"] in ("Mat", "vector_Mat"):
c_epilogue.append(fi.ctype+"_to_Mat(_ret_val_vector_, *_retval_);") c_epilogue.append("Mat* _retval_ = new Mat();")
c_epilogue.append(fi.ctype+"_to_Mat(_ret_val_vector_, *_retval_);")
else:
c_epilogue.append("jobject _retval_ = " + fi.ctype + "_to_List(env, _ret_val_vector_);")
if len(fi.classname)>0: if len(fi.classname)>0:
if not fi.ctype: # c-tor if not fi.ctype: # c-tor
retval = fi.fullClass(isCPP=True) + "* _retval_ = " retval = fi.fullClass(isCPP=True) + "* _retval_ = "
...@@ -1425,7 +884,7 @@ class JavaWrapperGenerator(object): ...@@ -1425,7 +884,7 @@ class JavaWrapperGenerator(object):
if not a.ctype: # hidden if not a.ctype: # hidden
jni_name = a.defval jni_name = a.defval
cvargs.append( type_dict[a.ctype].get("jni_name", jni_name) % {"n" : a.name}) cvargs.append( type_dict[a.ctype].get("jni_name", jni_name) % {"n" : a.name})
if "vector" not in a.ctype : if "v_type" not in type_dict[a.ctype]:
if ("I" in a.out or not a.out or self.isWrapped(a.ctype)) and "jni_var" in type_dict[a.ctype]: # complex type if ("I" in a.out or not a.out or self.isWrapped(a.ctype)) and "jni_var" in type_dict[a.ctype]: # complex type
c_prologue.append(type_dict[a.ctype]["jni_var"] % {"n" : a.name} + ";") c_prologue.append(type_dict[a.ctype]["jni_var"] % {"n" : a.name} + ";")
if a.out and "I" not in a.out and not self.isWrapped(a.ctype) and a.ctype: if a.out and "I" not in a.out and not self.isWrapped(a.ctype) and a.ctype:
...@@ -1521,9 +980,9 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_${clazz}_$fname ...@@ -1521,9 +980,9 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_${clazz}_$fname
# manual ports # manual ports
if ci.name in ManualFuncs: if ci.name in ManualFuncs:
for func in ManualFuncs[ci.name].keys(): for func in ManualFuncs[ci.name].keys():
ci.j_code.write ( ManualFuncs[ci.name][func]["j_code"] ) ci.j_code.write ( "\n".join(ManualFuncs[ci.name][func]["j_code"]) )
ci.jn_code.write( ManualFuncs[ci.name][func]["jn_code"] ) ci.jn_code.write( "\n".join(ManualFuncs[ci.name][func]["jn_code"]) )
ci.cpp_code.write( ManualFuncs[ci.name][func]["cpp_code"] ) ci.cpp_code.write( "\n".join(ManualFuncs[ci.name][func]["cpp_code"]) )
if ci.name != self.Module or ci.base: if ci.name != self.Module or ci.base:
# finalize() # finalize()
...@@ -1596,30 +1055,57 @@ JNIEXPORT void JNICALL Java_org_opencv_%(module)s_%(j_cls)s_delete ...@@ -1596,30 +1055,57 @@ JNIEXPORT void JNICALL Java_org_opencv_%(module)s_%(j_cls)s_delete
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) < 4:
print("Usage:\n", \
os.path.basename(sys.argv[0]), \
"<full path to hdr_parser.py> <module name> <C++ header> [<C++ header>...]")
print("Current args are: ", ", ".join(["'"+a+"'" for a in sys.argv]))
exit(0)
dstdir = "." # parse command line parameters
hdr_parser_path = os.path.abspath(sys.argv[1]) import argparse
arg_parser = argparse.ArgumentParser(description='OpenCV Java Wrapper Generator')
arg_parser.add_argument('-p', '--parser', required=True, help='OpenCV header parser')
arg_parser.add_argument('-m', '--module', required=True, help='OpenCV module name')
arg_parser.add_argument('-s', '--srcfiles', required=True, nargs='+', help='Source headers to be wrapped')
arg_parser.add_argument('-c', '--common', nargs='*', help='Common headers')
arg_parser.add_argument('-t', '--gendict', nargs='*', help='Custom module dictionaries for C++ to Java conversion')
args=arg_parser.parse_args()
# import header parser
hdr_parser_path = os.path.abspath(args.parser)
if hdr_parser_path.endswith(".py"): if hdr_parser_path.endswith(".py"):
hdr_parser_path = os.path.dirname(hdr_parser_path) hdr_parser_path = os.path.dirname(hdr_parser_path)
sys.path.append(hdr_parser_path) sys.path.append(hdr_parser_path)
import hdr_parser import hdr_parser
module = sys.argv[2]
srcfiles = sys.argv[3:] module = args.module
common_headers = [] srcfiles = args.srcfiles
if '--common' in srcfiles: common_headers= args.common
pos = srcfiles.index('--common') gen_dict_files = args.gendict
common_headers = srcfiles[pos+1:]
srcfiles = srcfiles[:pos] dstdir = "."
# initialize logger
logging.basicConfig(filename='%s/%s.log' % (dstdir, module), format=None, filemode='w', level=logging.INFO) logging.basicConfig(filename='%s/%s.log' % (dstdir, module), format=None, filemode='w', level=logging.INFO)
handler = logging.StreamHandler() handler = logging.StreamHandler()
handler.setLevel(logging.WARNING) handler.setLevel(logging.WARNING)
logging.getLogger().addHandler(handler) logging.getLogger().addHandler(handler)
#print("Generating module '" + module + "' from headers:\n\t" + "\n\t".join(srcfiles))
# load dictionaries
for gdf in gen_dict_files:
with open(gdf) as f:
gen_type_dict = json.load(f)
if "class_ignore_list" in gen_type_dict:
class_ignore_list += gen_type_dict["class_ignore_list"]
if "const_ignore_list" in gen_type_dict:
const_ignore_list += gen_type_dict["const_ignore_list"]
if "const_private_list" in gen_type_dict:
const_private_list += gen_type_dict["const_private_list"]
if "missing_consts" in gen_type_dict:
missing_consts.update(gen_type_dict["missing_consts"])
if "type_dict" in gen_type_dict:
type_dict.update(gen_type_dict["type_dict"])
if "ManualFuncs" in gen_type_dict:
ManualFuncs.update(gen_type_dict["ManualFuncs"])
if "func_arg_fix" in gen_type_dict:
func_arg_fix.update(gen_type_dict["func_arg_fix"])
# launch Java Wrapper generator
generator = JavaWrapperGenerator() generator = JavaWrapperGenerator()
generator.gen(srcfiles, module, dstdir, common_headers) generator.gen(srcfiles, module, dstdir, common_headers)
...@@ -7,22 +7,11 @@ ...@@ -7,22 +7,11 @@
#endif #endif
#include <jni.h> #include <jni.h>
#ifdef __ANDROID__ #include "opencv2/java.hpp"
# include <android/log.h>
# define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
# ifdef DEBUG
# define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
# else
# define LOGD(...)
# endif
#else
# define LOGE(...)
# define LOGD(...)
#endif
#include "opencv2/core/utility.hpp" #include "opencv2/core/utility.hpp"
#include "converters.h" #include "converters.h"
#include "listconverters.hpp"
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(disable:4800 4244) # pragma warning(disable:4800 4244)
......
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
using namespace cv; using namespace cv;
#define CHECK_MAT(cond) if(!(cond)){ LOGD("FAILED: " #cond); return; }
// vector_int // vector_int
void Mat_to_vector_int(Mat& mat, std::vector<int>& v_int) void Mat_to_vector_int(Mat& mat, std::vector<int>& v_int)
......
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
// Author: abratchik
#define LOG_TAG "org.opencv.utils.Converters"
#include "common.h"
jobject vector_String_to_List(JNIEnv* env, std::vector<cv::String>& vs) {
static jclass juArrayList = ARRAYLIST(env);
static jmethodID m_create = CONSTRUCTOR(env, juArrayList);
jmethodID m_add = LIST_ADD(env, juArrayList);
jobject result = env->NewObject(juArrayList, m_create, vs.size());
for (std::vector<cv::String>::iterator it = vs.begin(); it != vs.end(); ++it) {
jstring element = env->NewStringUTF((*it).c_str());
env->CallBooleanMethod(result, m_add, element);
env->DeleteLocalRef(element);
}
return result;
}
std::vector<cv::String> List_to_vector_String(JNIEnv* env, jobject list)
{
static jclass juArrayList = ARRAYLIST(env);
jmethodID m_size = LIST_SIZE(env,juArrayList);
jmethodID m_get = LIST_GET(env, juArrayList);
jint len = env->CallIntMethod(list, m_size);
std::vector<cv::String> result;
result.reserve(len);
for (jint i=0; i<len; i++)
{
jstring element = static_cast<jstring>(env->CallObjectMethod(list, m_get, i));
const char* pchars = env->GetStringUTFChars(element, NULL);
result.push_back(pchars);
env->ReleaseStringUTFChars(element, pchars);
env->DeleteLocalRef(element);
}
return result;
}
void Copy_vector_String_to_List(JNIEnv* env, std::vector<cv::String>& vs, jobject list)
{
static jclass juArrayList = ARRAYLIST(env);
jmethodID m_clear = LIST_CLEAR(env, juArrayList);
jmethodID m_add = LIST_ADD(env, juArrayList);
env->CallVoidMethod(list, m_clear);
for (std::vector<cv::String>::iterator it = vs.begin(); it != vs.end(); ++it)
{
jstring element = env->NewStringUTF((*it).c_str());
env->CallBooleanMethod(list, m_add, element);
env->DeleteLocalRef(element);
}
}
\ No newline at end of file
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
// Author: abratchik
#ifndef LISTCONVERTERS_HPP
#define LISTCONVERTERS_HPP
#include "opencv2/opencv_modules.hpp"
#include "opencv2/core.hpp"
jobject vector_String_to_List(JNIEnv* env, std::vector<cv::String>& vs);
std::vector<cv::String> List_to_vector_String(JNIEnv* env, jobject list);
void Copy_vector_String_to_List(JNIEnv* env, std::vector<cv::String>& vs, jobject list);
#endif /* LISTCONVERTERS_HPP */
\ No newline at end of file
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
// Author: abratchik
#ifndef JAVA_HPP
#define JAVA_HPP
#ifdef __ANDROID__
# include <android/log.h>
# define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
# ifdef DEBUG
# define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
# else
# define LOGD(...)
# endif
#else
# define LOGE(...)
# define LOGD(...)
#endif
#define MATOFINT(ENV) static_cast<jclass>(ENV->NewGlobalRef(ENV->FindClass("org/opencv/core/MatOfInt")))
#define GETNATIVEOBJ(ENV, CLS, MAT) ENV->GetLongField(MAT, ENV->GetFieldID(CLS, "nativeObj", "J"))
#define CONSTRUCTOR(ENV, CLS) ENV->GetMethodID(CLS, "<init>", "(I)V")
#define ARRAYLIST(ENV) static_cast<jclass>(ENV->NewGlobalRef(ENV->FindClass("java/util/ArrayList")))
#define LIST_ADD(ENV, LIST) ENV->GetMethodID(LIST, "add", "(Ljava/lang/Object;)Z")
#define LIST_GET(ENV, LIST) ENV->GetMethodID(LIST, "get", "((I)Ljava/lang/Object;")
#define LIST_SIZE(ENV, LIST) ENV->GetMethodID(LIST, "size", "()I")
#define LIST_CLEAR(ENV, LIST) ENV->GetMethodID(LIST, "clear", "()V")
#define CHECK_MAT(cond) if(!(cond)){ LOGD("FAILED: " #cond); return; }
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* JAVA_HPP */
\ No newline at end of file
{
"missing_consts": {
"Video" : {
"private" : [
["CV_LKFLOW_INITIAL_GUESSES", 4 ],
["CV_LKFLOW_GET_MIN_EIGENVALS", 8 ]
]
}
},
"func_arg_fix" : {
"calcOpticalFlowPyrLK" : { "prevPts" : {"ctype" : "vector_Point2f"},
"nextPts" : {"ctype" : "vector_Point2f"},
"status" : {"ctype" : "vector_uchar"},
"err" : {"ctype" : "vector_float"} }
}
}
{
"const_ignore_list": [
"CV_CAP_OPENNI",
"CV_CAP_PROP_OPENNI_",
"CV_CAP_INTELPERC",
"CV_CAP_PROP_INTELPERC_",
"CV_CAP_ANY",
"CV_CAP_MIL",
"CV_CAP_VFW",
"CV_CAP_V4L",
"CV_CAP_V4L2",
"CV_CAP_FIREWARE",
"CV_CAP_FIREWIRE",
"CV_CAP_IEEE1394",
"CV_CAP_DC1394",
"CV_CAP_CMU1394",
"CV_CAP_STEREO",
"CV_CAP_TYZX",
"CV_CAP_QT",
"CV_CAP_UNICAP",
"CV_CAP_DSHOW",
"CV_CAP_PVAPI",
"CV_CAP_PROP_DC1394_OFF",
"CV_CAP_PROP_DC1394_MODE_MANUAL",
"CV_CAP_PROP_DC1394_MODE_AUTO",
"CV_CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO",
"CV_CAP_PROP_POS_MSEC",
"CV_CAP_PROP_POS_FRAMES",
"CV_CAP_PROP_POS_AVI_RATIO",
"CV_CAP_PROP_FPS",
"CV_CAP_PROP_FOURCC",
"CV_CAP_PROP_FRAME_COUNT",
"CV_CAP_PROP_FORMAT",
"CV_CAP_PROP_MODE",
"CV_CAP_PROP_BRIGHTNESS",
"CV_CAP_PROP_CONTRAST",
"CV_CAP_PROP_SATURATION",
"CV_CAP_PROP_HUE",
"CV_CAP_PROP_GAIN",
"CV_CAP_PROP_EXPOSURE",
"CV_CAP_PROP_CONVERT_RGB",
"CV_CAP_PROP_WHITE_BALANCE_BLUE_U",
"CV_CAP_PROP_RECTIFICATION",
"CV_CAP_PROP_MONOCHROME",
"CV_CAP_PROP_SHARPNESS",
"CV_CAP_PROP_AUTO_EXPOSURE",
"CV_CAP_PROP_GAMMA",
"CV_CAP_PROP_TEMPERATURE",
"CV_CAP_PROP_TRIGGER",
"CV_CAP_PROP_TRIGGER_DELAY",
"CV_CAP_PROP_WHITE_BALANCE_RED_V",
"CV_CAP_PROP_MAX_DC1394",
"CV_CAP_GSTREAMER_QUEUE_LENGTH",
"CV_CAP_PROP_PVAPI_MULTICASTIP",
"CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING",
"CV_TYZX_LEFT",
"CV_TYZX_RIGHT",
"CV_TYZX_COLOR",
"CV_TYZX_Z"
]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment