add part of opencv

This commit is contained in:
Tang1705
2020-01-27 20:20:56 +08:00
parent 0c4ac1d8bb
commit a71fa47620
6518 changed files with 3122580 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
include/opencv2/core/base.hpp
include/opencv2/core.hpp
include/opencv2/core/utility.hpp
misc/java/src/cpp/core_manual.hpp

View File

@@ -0,0 +1,907 @@
{
"module_imports": [ "java.lang.String" ],
"module_j_code": "src/java/core+Core.jcode.in",
"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() caught 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() caught 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_RotatedRect": {
"j_type": "MatOfRotatedRect",
"jn_type": "long",
"jni_type": "jlong",
"jni_var": "std::vector< RotatedRect > %(n)s",
"suffix": "J",
"v_type": "Mat",
"j_import": "org.opencv.core.MatOfRotatedRect"
},
"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"
}
}
}

View File

@@ -0,0 +1,21 @@
#define LOG_TAG "org.opencv.core.Core"
#include "common.h"
#include "core_manual.hpp"
#include "opencv2/core/utility.hpp"
static int quietCallback( int, const char*, const char*, const char*, int, void* )
{
return 0;
}
namespace cv {
void setErrorVerbosity(bool verbose)
{
if(verbose)
cv::redirectError(0);
else
cv::redirectError((cv::ErrorCallback)quietCallback);
}
}

View File

@@ -0,0 +1,33 @@
#pragma once
#include "opencv2/core.hpp"
namespace cv
{
CV_EXPORTS_W void setErrorVerbosity(bool verbose);
}
#ifdef OPENCV_BINDINGS_PARSER
namespace cv
{
CV_EXPORTS_W void add(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1);
CV_EXPORTS_W void subtract(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1);
CV_EXPORTS_W void multiply(InputArray src1, Scalar src2, OutputArray dst, double scale=1, int dtype=-1);
CV_EXPORTS_W void divide(InputArray src1, Scalar src2, OutputArray dst, double scale=1, int dtype=-1);
CV_EXPORTS_W void absdiff(InputArray src1, Scalar src2, OutputArray dst);
CV_EXPORTS_W void compare(InputArray src1, Scalar src2, OutputArray dst, int cmpop);
CV_EXPORTS_W void min(InputArray src1, Scalar src2, OutputArray dst);
CV_EXPORTS_W void max(InputArray src1, Scalar src2, OutputArray dst);
}
#endif

View File

@@ -0,0 +1,14 @@
// these constants are wrapped inside functions to prevent inlining
private static String getVersion() { return "@OPENCV_VERSION@"; }
private static String getNativeLibraryName() { return "opencv_java@OPENCV_VERSION_MAJOR@@OPENCV_VERSION_MINOR@@OPENCV_VERSION_PATCH@"; }
private static int getVersionMajorJ() { return @OPENCV_VERSION_MAJOR@; }
private static int getVersionMinorJ() { return @OPENCV_VERSION_MINOR@; }
private static int getVersionRevisionJ() { return @OPENCV_VERSION_PATCH@; }
private static String getVersionStatusJ() { return "@OPENCV_VERSION_STATUS@"; }
public static final String VERSION = getVersion();
public static final String NATIVE_LIBRARY_NAME = getNativeLibraryName();
public static final int VERSION_MAJOR = getVersionMajorJ();
public static final int VERSION_MINOR = getVersionMinorJ();
public static final int VERSION_REVISION = getVersionRevisionJ();
public static final String VERSION_STATUS = getVersionStatusJ();

View File

@@ -0,0 +1,15 @@
package org.opencv.core;
public class CvException extends RuntimeException {
private static final long serialVersionUID = 1L;
public CvException(String msg) {
super(msg);
}
@Override
public String toString() {
return "CvException [" + super.toString() + "]";
}
}

View File

@@ -0,0 +1,150 @@
package org.opencv.core;
public final class CvType {
// type depth constants
public static final int
CV_8U = 0,
CV_8S = 1,
CV_16U = 2,
CV_16S = 3,
CV_32S = 4,
CV_32F = 5,
CV_64F = 6,
CV_16F = 7;
/**
* @deprecated please use {@link #CV_16F}
*/
@Deprecated
public static final int CV_USRTYPE1 = CV_16F;
// predefined type constants
public static final int
CV_8UC1 = CV_8UC(1), CV_8UC2 = CV_8UC(2), CV_8UC3 = CV_8UC(3), CV_8UC4 = CV_8UC(4),
CV_8SC1 = CV_8SC(1), CV_8SC2 = CV_8SC(2), CV_8SC3 = CV_8SC(3), CV_8SC4 = CV_8SC(4),
CV_16UC1 = CV_16UC(1), CV_16UC2 = CV_16UC(2), CV_16UC3 = CV_16UC(3), CV_16UC4 = CV_16UC(4),
CV_16SC1 = CV_16SC(1), CV_16SC2 = CV_16SC(2), CV_16SC3 = CV_16SC(3), CV_16SC4 = CV_16SC(4),
CV_32SC1 = CV_32SC(1), CV_32SC2 = CV_32SC(2), CV_32SC3 = CV_32SC(3), CV_32SC4 = CV_32SC(4),
CV_32FC1 = CV_32FC(1), CV_32FC2 = CV_32FC(2), CV_32FC3 = CV_32FC(3), CV_32FC4 = CV_32FC(4),
CV_64FC1 = CV_64FC(1), CV_64FC2 = CV_64FC(2), CV_64FC3 = CV_64FC(3), CV_64FC4 = CV_64FC(4),
CV_16FC1 = CV_16FC(1), CV_16FC2 = CV_16FC(2), CV_16FC3 = CV_16FC(3), CV_16FC4 = CV_16FC(4);
private static final int CV_CN_MAX = 512, CV_CN_SHIFT = 3, CV_DEPTH_MAX = (1 << CV_CN_SHIFT);
public static final int makeType(int depth, int channels) {
if (channels <= 0 || channels >= CV_CN_MAX) {
throw new UnsupportedOperationException(
"Channels count should be 1.." + (CV_CN_MAX - 1));
}
if (depth < 0 || depth >= CV_DEPTH_MAX) {
throw new UnsupportedOperationException(
"Data type depth should be 0.." + (CV_DEPTH_MAX - 1));
}
return (depth & (CV_DEPTH_MAX - 1)) + ((channels - 1) << CV_CN_SHIFT);
}
public static final int CV_8UC(int ch) {
return makeType(CV_8U, ch);
}
public static final int CV_8SC(int ch) {
return makeType(CV_8S, ch);
}
public static final int CV_16UC(int ch) {
return makeType(CV_16U, ch);
}
public static final int CV_16SC(int ch) {
return makeType(CV_16S, ch);
}
public static final int CV_32SC(int ch) {
return makeType(CV_32S, ch);
}
public static final int CV_32FC(int ch) {
return makeType(CV_32F, ch);
}
public static final int CV_64FC(int ch) {
return makeType(CV_64F, ch);
}
public static final int CV_16FC(int ch) {
return makeType(CV_16F, ch);
}
public static final int channels(int type) {
return (type >> CV_CN_SHIFT) + 1;
}
public static final int depth(int type) {
return type & (CV_DEPTH_MAX - 1);
}
public static final boolean isInteger(int type) {
return depth(type) < CV_32F;
}
public static final int ELEM_SIZE(int type) {
switch (depth(type)) {
case CV_8U:
case CV_8S:
return channels(type);
case CV_16U:
case CV_16S:
case CV_16F:
return 2 * channels(type);
case CV_32S:
case CV_32F:
return 4 * channels(type);
case CV_64F:
return 8 * channels(type);
default:
throw new UnsupportedOperationException(
"Unsupported CvType value: " + type);
}
}
public static final String typeToString(int type) {
String s;
switch (depth(type)) {
case CV_8U:
s = "CV_8U";
break;
case CV_8S:
s = "CV_8S";
break;
case CV_16U:
s = "CV_16U";
break;
case CV_16S:
s = "CV_16S";
break;
case CV_32S:
s = "CV_32S";
break;
case CV_32F:
s = "CV_32F";
break;
case CV_64F:
s = "CV_64F";
break;
case CV_16F:
s = "CV_16F";
break;
default:
throw new UnsupportedOperationException(
"Unsupported CvType value: " + type);
}
int ch = channels(type);
if (ch <= 4)
return s + "C" + ch;
else
return s + "C(" + ch + ")";
}
}

View File

@@ -0,0 +1,58 @@
package org.opencv.core;
//C++: class DMatch
/**
* Structure for matching: query descriptor index, train descriptor index, train
* image index and distance between descriptors.
*/
public class DMatch {
/**
* Query descriptor index.
*/
public int queryIdx;
/**
* Train descriptor index.
*/
public int trainIdx;
/**
* Train image index.
*/
public int imgIdx;
// javadoc: DMatch::distance
public float distance;
// javadoc: DMatch::DMatch()
public DMatch() {
this(-1, -1, Float.MAX_VALUE);
}
// javadoc: DMatch::DMatch(_queryIdx, _trainIdx, _distance)
public DMatch(int _queryIdx, int _trainIdx, float _distance) {
queryIdx = _queryIdx;
trainIdx = _trainIdx;
imgIdx = -1;
distance = _distance;
}
// javadoc: DMatch::DMatch(_queryIdx, _trainIdx, _imgIdx, _distance)
public DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance) {
queryIdx = _queryIdx;
trainIdx = _trainIdx;
imgIdx = _imgIdx;
distance = _distance;
}
public boolean lessThan(DMatch it) {
return distance < it.distance;
}
@Override
public String toString() {
return "DMatch [queryIdx=" + queryIdx + ", trainIdx=" + trainIdx
+ ", imgIdx=" + imgIdx + ", distance=" + distance + "]";
}
}

View File

@@ -0,0 +1,77 @@
package org.opencv.core;
import org.opencv.core.Point;
//javadoc: KeyPoint
public class KeyPoint {
/**
* Coordinates of the keypoint.
*/
public Point pt;
/**
* Diameter of the useful keypoint adjacent area.
*/
public float size;
/**
* Computed orientation of the keypoint (-1 if not applicable).
*/
public float angle;
/**
* The response, by which the strongest keypoints have been selected. Can
* be used for further sorting or subsampling.
*/
public float response;
/**
* Octave (pyramid layer), from which the keypoint has been extracted.
*/
public int octave;
/**
* Object ID, that can be used to cluster keypoints by an object they
* belong to.
*/
public int class_id;
// javadoc:KeyPoint::KeyPoint(x,y,_size,_angle,_response,_octave,_class_id)
public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id) {
pt = new Point(x, y);
size = _size;
angle = _angle;
response = _response;
octave = _octave;
class_id = _class_id;
}
// javadoc: KeyPoint::KeyPoint()
public KeyPoint() {
this(0, 0, 0, -1, 0, 0, -1);
}
// javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response, _octave)
public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave) {
this(x, y, _size, _angle, _response, _octave, -1);
}
// javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response)
public KeyPoint(float x, float y, float _size, float _angle, float _response) {
this(x, y, _size, _angle, _response, 0, -1);
}
// javadoc: KeyPoint::KeyPoint(x, y, _size, _angle)
public KeyPoint(float x, float y, float _size, float _angle) {
this(x, y, _size, _angle, 0, 0, -1);
}
// javadoc: KeyPoint::KeyPoint(x, y, _size)
public KeyPoint(float x, float y, float _size) {
this(x, y, _size, -1, 0, 0, -1);
}
@Override
public String toString() {
return "KeyPoint [pt=" + pt + ", size=" + size + ", angle=" + angle
+ ", response=" + response + ", octave=" + octave
+ ", class_id=" + class_id + "]";
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,98 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
public class MatOfByte extends Mat {
// 8UC(x)
private static final int _depth = CvType.CV_8U;
private static final int _channels = 1;
public MatOfByte() {
super();
}
protected MatOfByte(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfByte fromNativeAddr(long addr) {
return new MatOfByte(addr);
}
public MatOfByte(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfByte(byte...a) {
super();
fromArray(a);
}
public MatOfByte(int offset, int length, byte...a) {
super();
fromArray(offset, length, a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(byte...a) {
if(a==null || a.length==0)
return;
int num = a.length / _channels;
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public void fromArray(int offset, int length, byte...a) {
if (offset < 0)
throw new IllegalArgumentException("offset < 0");
if (a == null)
throw new NullPointerException();
if (length < 0 || length + offset > a.length)
throw new IllegalArgumentException("invalid 'length' parameter: " + Integer.toString(length));
if (a.length == 0)
return;
int num = length / _channels;
alloc(num);
put(0, 0, a, offset, length); //TODO: check ret val!
}
public byte[] toArray() {
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
byte[] a = new byte[num * _channels];
if(num == 0)
return a;
get(0, 0, a); //TODO: check ret val!
return a;
}
public void fromList(List<Byte> lb) {
if(lb==null || lb.size()==0)
return;
Byte ab[] = lb.toArray(new Byte[0]);
byte a[] = new byte[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Byte> toList() {
byte[] a = toArray();
Byte ab[] = new Byte[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}

View File

@@ -0,0 +1,83 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
import org.opencv.core.DMatch;
public class MatOfDMatch extends Mat {
// 32FC4
private static final int _depth = CvType.CV_32F;
private static final int _channels = 4;
public MatOfDMatch() {
super();
}
protected MatOfDMatch(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat: " + toString());
//FIXME: do we need release() here?
}
public static MatOfDMatch fromNativeAddr(long addr) {
return new MatOfDMatch(addr);
}
public MatOfDMatch(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat: " + toString());
//FIXME: do we need release() here?
}
public MatOfDMatch(DMatch...ap) {
super();
fromArray(ap);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(DMatch...a) {
if(a==null || a.length==0)
return;
int num = a.length;
alloc(num);
float buff[] = new float[num * _channels];
for(int i=0; i<num; i++) {
DMatch m = a[i];
buff[_channels*i+0] = m.queryIdx;
buff[_channels*i+1] = m.trainIdx;
buff[_channels*i+2] = m.imgIdx;
buff[_channels*i+3] = m.distance;
}
put(0, 0, buff); //TODO: check ret val!
}
public DMatch[] toArray() {
int num = (int) total();
DMatch[] a = new DMatch[num];
if(num == 0)
return a;
float buff[] = new float[num * _channels];
get(0, 0, buff); //TODO: check ret val!
for(int i=0; i<num; i++)
a[i] = new DMatch((int) buff[_channels*i+0], (int) buff[_channels*i+1], (int) buff[_channels*i+2], buff[_channels*i+3]);
return a;
}
public void fromList(List<DMatch> ldm) {
DMatch adm[] = ldm.toArray(new DMatch[0]);
fromArray(adm);
}
public List<DMatch> toList() {
DMatch[] adm = toArray();
return Arrays.asList(adm);
}
}

View File

@@ -0,0 +1,79 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
public class MatOfDouble extends Mat {
// 64FC(x)
private static final int _depth = CvType.CV_64F;
private static final int _channels = 1;
public MatOfDouble() {
super();
}
protected MatOfDouble(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfDouble fromNativeAddr(long addr) {
return new MatOfDouble(addr);
}
public MatOfDouble(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfDouble(double...a) {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(double...a) {
if(a==null || a.length==0)
return;
int num = a.length / _channels;
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public double[] toArray() {
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
double[] a = new double[num * _channels];
if(num == 0)
return a;
get(0, 0, a); //TODO: check ret val!
return a;
}
public void fromList(List<Double> lb) {
if(lb==null || lb.size()==0)
return;
Double ab[] = lb.toArray(new Double[0]);
double a[] = new double[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Double> toList() {
double[] a = toArray();
Double ab[] = new Double[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}

View File

@@ -0,0 +1,79 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
public class MatOfFloat extends Mat {
// 32FC1
private static final int _depth = CvType.CV_32F;
private static final int _channels = 1;
public MatOfFloat() {
super();
}
protected MatOfFloat(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfFloat fromNativeAddr(long addr) {
return new MatOfFloat(addr);
}
public MatOfFloat(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfFloat(float...a) {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(float...a) {
if(a==null || a.length==0)
return;
int num = a.length / _channels;
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public float[] toArray() {
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
float[] a = new float[num * _channels];
if(num == 0)
return a;
get(0, 0, a); //TODO: check ret val!
return a;
}
public void fromList(List<Float> lb) {
if(lb==null || lb.size()==0)
return;
Float ab[] = lb.toArray(new Float[0]);
float a[] = new float[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Float> toList() {
float[] a = toArray();
Float ab[] = new Float[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}

View File

@@ -0,0 +1,79 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
public class MatOfFloat4 extends Mat {
// 32FC4
private static final int _depth = CvType.CV_32F;
private static final int _channels = 4;
public MatOfFloat4() {
super();
}
protected MatOfFloat4(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfFloat4 fromNativeAddr(long addr) {
return new MatOfFloat4(addr);
}
public MatOfFloat4(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfFloat4(float...a) {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(float...a) {
if(a==null || a.length==0)
return;
int num = a.length / _channels;
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public float[] toArray() {
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
float[] a = new float[num * _channels];
if(num == 0)
return a;
get(0, 0, a); //TODO: check ret val!
return a;
}
public void fromList(List<Float> lb) {
if(lb==null || lb.size()==0)
return;
Float ab[] = lb.toArray(new Float[0]);
float a[] = new float[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Float> toList() {
float[] a = toArray();
Float ab[] = new Float[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}

View File

@@ -0,0 +1,79 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
public class MatOfFloat6 extends Mat {
// 32FC6
private static final int _depth = CvType.CV_32F;
private static final int _channels = 6;
public MatOfFloat6() {
super();
}
protected MatOfFloat6(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfFloat6 fromNativeAddr(long addr) {
return new MatOfFloat6(addr);
}
public MatOfFloat6(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfFloat6(float...a) {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(float...a) {
if(a==null || a.length==0)
return;
int num = a.length / _channels;
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public float[] toArray() {
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
float[] a = new float[num * _channels];
if(num == 0)
return a;
get(0, 0, a); //TODO: check ret val!
return a;
}
public void fromList(List<Float> lb) {
if(lb==null || lb.size()==0)
return;
Float ab[] = lb.toArray(new Float[0]);
float a[] = new float[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Float> toList() {
float[] a = toArray();
Float ab[] = new Float[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}

View File

@@ -0,0 +1,80 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
public class MatOfInt extends Mat {
// 32SC1
private static final int _depth = CvType.CV_32S;
private static final int _channels = 1;
public MatOfInt() {
super();
}
protected MatOfInt(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfInt fromNativeAddr(long addr) {
return new MatOfInt(addr);
}
public MatOfInt(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfInt(int...a) {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(int...a) {
if(a==null || a.length==0)
return;
int num = a.length / _channels;
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public int[] toArray() {
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
int[] a = new int[num * _channels];
if(num == 0)
return a;
get(0, 0, a); //TODO: check ret val!
return a;
}
public void fromList(List<Integer> lb) {
if(lb==null || lb.size()==0)
return;
Integer ab[] = lb.toArray(new Integer[0]);
int a[] = new int[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Integer> toList() {
int[] a = toArray();
Integer ab[] = new Integer[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}

View File

@@ -0,0 +1,80 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
public class MatOfInt4 extends Mat {
// 32SC4
private static final int _depth = CvType.CV_32S;
private static final int _channels = 4;
public MatOfInt4() {
super();
}
protected MatOfInt4(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfInt4 fromNativeAddr(long addr) {
return new MatOfInt4(addr);
}
public MatOfInt4(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfInt4(int...a) {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(int...a) {
if(a==null || a.length==0)
return;
int num = a.length / _channels;
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public int[] toArray() {
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
int[] a = new int[num * _channels];
if(num == 0)
return a;
get(0, 0, a); //TODO: check ret val!
return a;
}
public void fromList(List<Integer> lb) {
if(lb==null || lb.size()==0)
return;
Integer ab[] = lb.toArray(new Integer[0]);
int a[] = new int[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Integer> toList() {
int[] a = toArray();
Integer ab[] = new Integer[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}

View File

@@ -0,0 +1,86 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
import org.opencv.core.KeyPoint;
public class MatOfKeyPoint extends Mat {
// 32FC7
private static final int _depth = CvType.CV_32F;
private static final int _channels = 7;
public MatOfKeyPoint() {
super();
}
protected MatOfKeyPoint(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfKeyPoint fromNativeAddr(long addr) {
return new MatOfKeyPoint(addr);
}
public MatOfKeyPoint(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfKeyPoint(KeyPoint...a) {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(KeyPoint...a) {
if(a==null || a.length==0)
return;
int num = a.length;
alloc(num);
float buff[] = new float[num * _channels];
for(int i=0; i<num; i++) {
KeyPoint kp = a[i];
buff[_channels*i+0] = (float) kp.pt.x;
buff[_channels*i+1] = (float) kp.pt.y;
buff[_channels*i+2] = kp.size;
buff[_channels*i+3] = kp.angle;
buff[_channels*i+4] = kp.response;
buff[_channels*i+5] = kp.octave;
buff[_channels*i+6] = kp.class_id;
}
put(0, 0, buff); //TODO: check ret val!
}
public KeyPoint[] toArray() {
int num = (int) total();
KeyPoint[] a = new KeyPoint[num];
if(num == 0)
return a;
float buff[] = new float[num * _channels];
get(0, 0, buff); //TODO: check ret val!
for(int i=0; i<num; i++)
a[i] = new KeyPoint( buff[_channels*i+0], buff[_channels*i+1], buff[_channels*i+2], buff[_channels*i+3],
buff[_channels*i+4], (int) buff[_channels*i+5], (int) buff[_channels*i+6] );
return a;
}
public void fromList(List<KeyPoint> lkp) {
KeyPoint akp[] = lkp.toArray(new KeyPoint[0]);
fromArray(akp);
}
public List<KeyPoint> toList() {
KeyPoint[] akp = toArray();
return Arrays.asList(akp);
}
}

View File

@@ -0,0 +1,78 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
public class MatOfPoint extends Mat {
// 32SC2
private static final int _depth = CvType.CV_32S;
private static final int _channels = 2;
public MatOfPoint() {
super();
}
protected MatOfPoint(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfPoint fromNativeAddr(long addr) {
return new MatOfPoint(addr);
}
public MatOfPoint(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfPoint(Point...a) {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(Point...a) {
if(a==null || a.length==0)
return;
int num = a.length;
alloc(num);
int buff[] = new int[num * _channels];
for(int i=0; i<num; i++) {
Point p = a[i];
buff[_channels*i+0] = (int) p.x;
buff[_channels*i+1] = (int) p.y;
}
put(0, 0, buff); //TODO: check ret val!
}
public Point[] toArray() {
int num = (int) total();
Point[] ap = new Point[num];
if(num == 0)
return ap;
int buff[] = new int[num * _channels];
get(0, 0, buff); //TODO: check ret val!
for(int i=0; i<num; i++)
ap[i] = new Point(buff[i*_channels], buff[i*_channels+1]);
return ap;
}
public void fromList(List<Point> lp) {
Point ap[] = lp.toArray(new Point[0]);
fromArray(ap);
}
public List<Point> toList() {
Point[] ap = toArray();
return Arrays.asList(ap);
}
}

View File

@@ -0,0 +1,78 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
public class MatOfPoint2f extends Mat {
// 32FC2
private static final int _depth = CvType.CV_32F;
private static final int _channels = 2;
public MatOfPoint2f() {
super();
}
protected MatOfPoint2f(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfPoint2f fromNativeAddr(long addr) {
return new MatOfPoint2f(addr);
}
public MatOfPoint2f(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfPoint2f(Point...a) {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(Point...a) {
if(a==null || a.length==0)
return;
int num = a.length;
alloc(num);
float buff[] = new float[num * _channels];
for(int i=0; i<num; i++) {
Point p = a[i];
buff[_channels*i+0] = (float) p.x;
buff[_channels*i+1] = (float) p.y;
}
put(0, 0, buff); //TODO: check ret val!
}
public Point[] toArray() {
int num = (int) total();
Point[] ap = new Point[num];
if(num == 0)
return ap;
float buff[] = new float[num * _channels];
get(0, 0, buff); //TODO: check ret val!
for(int i=0; i<num; i++)
ap[i] = new Point(buff[i*_channels], buff[i*_channels+1]);
return ap;
}
public void fromList(List<Point> lp) {
Point ap[] = lp.toArray(new Point[0]);
fromArray(ap);
}
public List<Point> toList() {
Point[] ap = toArray();
return Arrays.asList(ap);
}
}

View File

@@ -0,0 +1,79 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
public class MatOfPoint3 extends Mat {
// 32SC3
private static final int _depth = CvType.CV_32S;
private static final int _channels = 3;
public MatOfPoint3() {
super();
}
protected MatOfPoint3(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfPoint3 fromNativeAddr(long addr) {
return new MatOfPoint3(addr);
}
public MatOfPoint3(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfPoint3(Point3...a) {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(Point3...a) {
if(a==null || a.length==0)
return;
int num = a.length;
alloc(num);
int buff[] = new int[num * _channels];
for(int i=0; i<num; i++) {
Point3 p = a[i];
buff[_channels*i+0] = (int) p.x;
buff[_channels*i+1] = (int) p.y;
buff[_channels*i+2] = (int) p.z;
}
put(0, 0, buff); //TODO: check ret val!
}
public Point3[] toArray() {
int num = (int) total();
Point3[] ap = new Point3[num];
if(num == 0)
return ap;
int buff[] = new int[num * _channels];
get(0, 0, buff); //TODO: check ret val!
for(int i=0; i<num; i++)
ap[i] = new Point3(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2]);
return ap;
}
public void fromList(List<Point3> lp) {
Point3 ap[] = lp.toArray(new Point3[0]);
fromArray(ap);
}
public List<Point3> toList() {
Point3[] ap = toArray();
return Arrays.asList(ap);
}
}

View File

@@ -0,0 +1,79 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
public class MatOfPoint3f extends Mat {
// 32FC3
private static final int _depth = CvType.CV_32F;
private static final int _channels = 3;
public MatOfPoint3f() {
super();
}
protected MatOfPoint3f(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfPoint3f fromNativeAddr(long addr) {
return new MatOfPoint3f(addr);
}
public MatOfPoint3f(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfPoint3f(Point3...a) {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(Point3...a) {
if(a==null || a.length==0)
return;
int num = a.length;
alloc(num);
float buff[] = new float[num * _channels];
for(int i=0; i<num; i++) {
Point3 p = a[i];
buff[_channels*i+0] = (float) p.x;
buff[_channels*i+1] = (float) p.y;
buff[_channels*i+2] = (float) p.z;
}
put(0, 0, buff); //TODO: check ret val!
}
public Point3[] toArray() {
int num = (int) total();
Point3[] ap = new Point3[num];
if(num == 0)
return ap;
float buff[] = new float[num * _channels];
get(0, 0, buff); //TODO: check ret val!
for(int i=0; i<num; i++)
ap[i] = new Point3(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2]);
return ap;
}
public void fromList(List<Point3> lp) {
Point3 ap[] = lp.toArray(new Point3[0]);
fromArray(ap);
}
public List<Point3> toList() {
Point3[] ap = toArray();
return Arrays.asList(ap);
}
}

View File

@@ -0,0 +1,81 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
public class MatOfRect extends Mat {
// 32SC4
private static final int _depth = CvType.CV_32S;
private static final int _channels = 4;
public MatOfRect() {
super();
}
protected MatOfRect(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfRect fromNativeAddr(long addr) {
return new MatOfRect(addr);
}
public MatOfRect(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfRect(Rect...a) {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(Rect...a) {
if(a==null || a.length==0)
return;
int num = a.length;
alloc(num);
int buff[] = new int[num * _channels];
for(int i=0; i<num; i++) {
Rect r = a[i];
buff[_channels*i+0] = (int) r.x;
buff[_channels*i+1] = (int) r.y;
buff[_channels*i+2] = (int) r.width;
buff[_channels*i+3] = (int) r.height;
}
put(0, 0, buff); //TODO: check ret val!
}
public Rect[] toArray() {
int num = (int) total();
Rect[] a = new Rect[num];
if(num == 0)
return a;
int buff[] = new int[num * _channels];
get(0, 0, buff); //TODO: check ret val!
for(int i=0; i<num; i++)
a[i] = new Rect(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2], buff[i*_channels+3]);
return a;
}
public void fromList(List<Rect> lr) {
Rect ap[] = lr.toArray(new Rect[0]);
fromArray(ap);
}
public List<Rect> toList() {
Rect[] ar = toArray();
return Arrays.asList(ar);
}
}

View File

@@ -0,0 +1,81 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
public class MatOfRect2d extends Mat {
// 64FC4
private static final int _depth = CvType.CV_64F;
private static final int _channels = 4;
public MatOfRect2d() {
super();
}
protected MatOfRect2d(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfRect2d fromNativeAddr(long addr) {
return new MatOfRect2d(addr);
}
public MatOfRect2d(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfRect2d(Rect2d...a) {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(Rect2d...a) {
if(a==null || a.length==0)
return;
int num = a.length;
alloc(num);
double buff[] = new double[num * _channels];
for(int i=0; i<num; i++) {
Rect2d r = a[i];
buff[_channels*i+0] = (double) r.x;
buff[_channels*i+1] = (double) r.y;
buff[_channels*i+2] = (double) r.width;
buff[_channels*i+3] = (double) r.height;
}
put(0, 0, buff); //TODO: check ret val!
}
public Rect2d[] toArray() {
int num = (int) total();
Rect2d[] a = new Rect2d[num];
if(num == 0)
return a;
double buff[] = new double[num * _channels];
get(0, 0, buff); //TODO: check ret val!
for(int i=0; i<num; i++)
a[i] = new Rect2d(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2], buff[i*_channels+3]);
return a;
}
public void fromList(List<Rect2d> lr) {
Rect2d ap[] = lr.toArray(new Rect2d[0]);
fromArray(ap);
}
public List<Rect2d> toList() {
Rect2d[] ar = toArray();
return Arrays.asList(ar);
}
}

View File

@@ -0,0 +1,86 @@
package org.opencv.core;
import java.util.Arrays;
import java.util.List;
import org.opencv.core.RotatedRect;
public class MatOfRotatedRect extends Mat {
// 32FC5
private static final int _depth = CvType.CV_32F;
private static final int _channels = 5;
public MatOfRotatedRect() {
super();
}
protected MatOfRotatedRect(long addr) {
super(addr);
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public static MatOfRotatedRect fromNativeAddr(long addr) {
return new MatOfRotatedRect(addr);
}
public MatOfRotatedRect(Mat m) {
super(m, Range.all());
if( !empty() && checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incompatible Mat");
//FIXME: do we need release() here?
}
public MatOfRotatedRect(RotatedRect...a) {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
public void fromArray(RotatedRect...a) {
if(a==null || a.length==0)
return;
int num = a.length;
alloc(num);
float buff[] = new float[num * _channels];
for(int i=0; i<num; i++) {
RotatedRect r = a[i];
buff[_channels*i+0] = (float) r.center.x;
buff[_channels*i+1] = (float) r.center.y;
buff[_channels*i+2] = (float) r.size.width;
buff[_channels*i+3] = (float) r.size.height;
buff[_channels*i+4] = (float) r.angle;
}
put(0, 0, buff); //TODO: check ret val!
}
public RotatedRect[] toArray() {
int num = (int) total();
RotatedRect[] a = new RotatedRect[num];
if(num == 0)
return a;
float buff[] = new float[_channels];
for(int i=0; i<num; i++) {
get(i, 0, buff); //TODO: check ret val!
a[i] = new RotatedRect(new Point(buff[0],buff[1]),new Size(buff[2],buff[3]),buff[4]);
}
return a;
}
public void fromList(List<RotatedRect> lr) {
RotatedRect ap[] = lr.toArray(new RotatedRect[0]);
fromArray(ap);
}
public List<RotatedRect> toList() {
RotatedRect[] ar = toArray();
return Arrays.asList(ar);
}
}

View File

@@ -0,0 +1,68 @@
package org.opencv.core;
//javadoc:Point_
public class Point {
public double x, y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public Point() {
this(0, 0);
}
public Point(double[] vals) {
this();
set(vals);
}
public void set(double[] vals) {
if (vals != null) {
x = vals.length > 0 ? vals[0] : 0;
y = vals.length > 1 ? vals[1] : 0;
} else {
x = 0;
y = 0;
}
}
public Point clone() {
return new Point(x, y);
}
public double dot(Point p) {
return x * p.x + y * p.y;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(x);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(y);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof Point)) return false;
Point it = (Point) obj;
return x == it.x && y == it.y;
}
public boolean inside(Rect r) {
return r.contains(this);
}
@Override
public String toString() {
return "{" + x + ", " + y + "}";
}
}

View File

@@ -0,0 +1,79 @@
package org.opencv.core;
//javadoc:Point3_
public class Point3 {
public double x, y, z;
public Point3(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
public Point3() {
this(0, 0, 0);
}
public Point3(Point p) {
x = p.x;
y = p.y;
z = 0;
}
public Point3(double[] vals) {
this();
set(vals);
}
public void set(double[] vals) {
if (vals != null) {
x = vals.length > 0 ? vals[0] : 0;
y = vals.length > 1 ? vals[1] : 0;
z = vals.length > 2 ? vals[2] : 0;
} else {
x = 0;
y = 0;
z = 0;
}
}
public Point3 clone() {
return new Point3(x, y, z);
}
public double dot(Point3 p) {
return x * p.x + y * p.y + z * p.z;
}
public Point3 cross(Point3 p) {
return new Point3(y * p.z - z * p.y, z * p.x - x * p.z, x * p.y - y * p.x);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(x);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(y);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(z);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof Point3)) return false;
Point3 it = (Point3) obj;
return x == it.x && y == it.y && z == it.z;
}
@Override
public String toString() {
return "{" + x + ", " + y + ", " + z + "}";
}
}

View File

@@ -0,0 +1,82 @@
package org.opencv.core;
//javadoc:Range
public class Range {
public int start, end;
public Range(int s, int e) {
this.start = s;
this.end = e;
}
public Range() {
this(0, 0);
}
public Range(double[] vals) {
set(vals);
}
public void set(double[] vals) {
if (vals != null) {
start = vals.length > 0 ? (int) vals[0] : 0;
end = vals.length > 1 ? (int) vals[1] : 0;
} else {
start = 0;
end = 0;
}
}
public int size() {
return empty() ? 0 : end - start;
}
public boolean empty() {
return end <= start;
}
public static Range all() {
return new Range(Integer.MIN_VALUE, Integer.MAX_VALUE);
}
public Range intersection(Range r1) {
Range r = new Range(Math.max(r1.start, this.start), Math.min(r1.end, this.end));
r.end = Math.max(r.end, r.start);
return r;
}
public Range shift(int delta) {
return new Range(start + delta, end + delta);
}
public Range clone() {
return new Range(start, end);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(start);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(end);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof Range)) return false;
Range it = (Range) obj;
return start == it.start && end == it.end;
}
@Override
public String toString() {
return "[" + start + ", " + end + ")";
}
}

View File

@@ -0,0 +1,104 @@
package org.opencv.core;
//javadoc:Rect_
public class Rect {
public int x, y, width, height;
public Rect(int x, int y, int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public Rect() {
this(0, 0, 0, 0);
}
public Rect(Point p1, Point p2) {
x = (int) (p1.x < p2.x ? p1.x : p2.x);
y = (int) (p1.y < p2.y ? p1.y : p2.y);
width = (int) (p1.x > p2.x ? p1.x : p2.x) - x;
height = (int) (p1.y > p2.y ? p1.y : p2.y) - y;
}
public Rect(Point p, Size s) {
this((int) p.x, (int) p.y, (int) s.width, (int) s.height);
}
public Rect(double[] vals) {
set(vals);
}
public void set(double[] vals) {
if (vals != null) {
x = vals.length > 0 ? (int) vals[0] : 0;
y = vals.length > 1 ? (int) vals[1] : 0;
width = vals.length > 2 ? (int) vals[2] : 0;
height = vals.length > 3 ? (int) vals[3] : 0;
} else {
x = 0;
y = 0;
width = 0;
height = 0;
}
}
public Rect clone() {
return new Rect(x, y, width, height);
}
public Point tl() {
return new Point(x, y);
}
public Point br() {
return new Point(x + width, y + height);
}
public Size size() {
return new Size(width, height);
}
public double area() {
return width * height;
}
public boolean empty() {
return width <= 0 || height <= 0;
}
public boolean contains(Point p) {
return x <= p.x && p.x < x + width && y <= p.y && p.y < y + height;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(height);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(width);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(x);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(y);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof Rect)) return false;
Rect it = (Rect) obj;
return x == it.x && y == it.y && width == it.width && height == it.height;
}
@Override
public String toString() {
return "{" + x + ", " + y + ", " + width + "x" + height + "}";
}
}

View File

@@ -0,0 +1,104 @@
package org.opencv.core;
//javadoc:Rect2d_
public class Rect2d {
public double x, y, width, height;
public Rect2d(double x, double y, double width, double height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public Rect2d() {
this(0, 0, 0, 0);
}
public Rect2d(Point p1, Point p2) {
x = (double) (p1.x < p2.x ? p1.x : p2.x);
y = (double) (p1.y < p2.y ? p1.y : p2.y);
width = (double) (p1.x > p2.x ? p1.x : p2.x) - x;
height = (double) (p1.y > p2.y ? p1.y : p2.y) - y;
}
public Rect2d(Point p, Size s) {
this((double) p.x, (double) p.y, (double) s.width, (double) s.height);
}
public Rect2d(double[] vals) {
set(vals);
}
public void set(double[] vals) {
if (vals != null) {
x = vals.length > 0 ? (double) vals[0] : 0;
y = vals.length > 1 ? (double) vals[1] : 0;
width = vals.length > 2 ? (double) vals[2] : 0;
height = vals.length > 3 ? (double) vals[3] : 0;
} else {
x = 0;
y = 0;
width = 0;
height = 0;
}
}
public Rect2d clone() {
return new Rect2d(x, y, width, height);
}
public Point tl() {
return new Point(x, y);
}
public Point br() {
return new Point(x + width, y + height);
}
public Size size() {
return new Size(width, height);
}
public double area() {
return width * height;
}
public boolean empty() {
return width <= 0 || height <= 0;
}
public boolean contains(Point p) {
return x <= p.x && p.x < x + width && y <= p.y && p.y < y + height;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(height);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(width);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(x);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(y);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof Rect2d)) return false;
Rect2d it = (Rect2d) obj;
return x == it.x && y == it.y && width == it.width && height == it.height;
}
@Override
public String toString() {
return "{" + x + ", " + y + ", " + width + "x" + height + "}";
}
}

View File

@@ -0,0 +1,113 @@
package org.opencv.core;
//javadoc:RotatedRect_
public class RotatedRect {
public Point center;
public Size size;
public double angle;
public RotatedRect() {
this.center = new Point();
this.size = new Size();
this.angle = 0;
}
public RotatedRect(Point c, Size s, double a) {
this.center = c.clone();
this.size = s.clone();
this.angle = a;
}
public RotatedRect(double[] vals) {
this();
set(vals);
}
public void set(double[] vals) {
if (vals != null) {
center.x = vals.length > 0 ? (double) vals[0] : 0;
center.y = vals.length > 1 ? (double) vals[1] : 0;
size.width = vals.length > 2 ? (double) vals[2] : 0;
size.height = vals.length > 3 ? (double) vals[3] : 0;
angle = vals.length > 4 ? (double) vals[4] : 0;
} else {
center.x = 0;
center.y = 0;
size.width = 0;
size.height = 0;
angle = 0;
}
}
public void points(Point pt[])
{
double _angle = angle * Math.PI / 180.0;
double b = (double) Math.cos(_angle) * 0.5f;
double a = (double) Math.sin(_angle) * 0.5f;
pt[0] = new Point(
center.x - a * size.height - b * size.width,
center.y + b * size.height - a * size.width);
pt[1] = new Point(
center.x + a * size.height - b * size.width,
center.y - b * size.height - a * size.width);
pt[2] = new Point(
2 * center.x - pt[0].x,
2 * center.y - pt[0].y);
pt[3] = new Point(
2 * center.x - pt[1].x,
2 * center.y - pt[1].y);
}
public Rect boundingRect()
{
Point pt[] = new Point[4];
points(pt);
Rect r = new Rect((int) Math.floor(Math.min(Math.min(Math.min(pt[0].x, pt[1].x), pt[2].x), pt[3].x)),
(int) Math.floor(Math.min(Math.min(Math.min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)),
(int) Math.ceil(Math.max(Math.max(Math.max(pt[0].x, pt[1].x), pt[2].x), pt[3].x)),
(int) Math.ceil(Math.max(Math.max(Math.max(pt[0].y, pt[1].y), pt[2].y), pt[3].y)));
r.width -= r.x - 1;
r.height -= r.y - 1;
return r;
}
public RotatedRect clone() {
return new RotatedRect(center, size, angle);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(center.x);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(center.y);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(size.width);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(size.height);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(angle);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof RotatedRect)) return false;
RotatedRect it = (RotatedRect) obj;
return center.equals(it.center) && size.equals(it.size) && angle == it.angle;
}
@Override
public String toString() {
return "{ " + center + " " + size + " * " + angle + " }";
}
}

View File

@@ -0,0 +1,90 @@
package org.opencv.core;
//javadoc:Scalar_
public class Scalar {
public double val[];
public Scalar(double v0, double v1, double v2, double v3) {
val = new double[] { v0, v1, v2, v3 };
}
public Scalar(double v0, double v1, double v2) {
val = new double[] { v0, v1, v2, 0 };
}
public Scalar(double v0, double v1) {
val = new double[] { v0, v1, 0, 0 };
}
public Scalar(double v0) {
val = new double[] { v0, 0, 0, 0 };
}
public Scalar(double[] vals) {
if (vals != null && vals.length == 4)
val = vals.clone();
else {
val = new double[4];
set(vals);
}
}
public void set(double[] vals) {
if (vals != null) {
val[0] = vals.length > 0 ? vals[0] : 0;
val[1] = vals.length > 1 ? vals[1] : 0;
val[2] = vals.length > 2 ? vals[2] : 0;
val[3] = vals.length > 3 ? vals[3] : 0;
} else
val[0] = val[1] = val[2] = val[3] = 0;
}
public static Scalar all(double v) {
return new Scalar(v, v, v, v);
}
public Scalar clone() {
return new Scalar(val);
}
public Scalar mul(Scalar it, double scale) {
return new Scalar(val[0] * it.val[0] * scale, val[1] * it.val[1] * scale,
val[2] * it.val[2] * scale, val[3] * it.val[3] * scale);
}
public Scalar mul(Scalar it) {
return mul(it, 1);
}
public Scalar conj() {
return new Scalar(val[0], -val[1], -val[2], -val[3]);
}
public boolean isReal() {
return val[1] == 0 && val[2] == 0 && val[3] == 0;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + java.util.Arrays.hashCode(val);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof Scalar)) return false;
Scalar it = (Scalar) obj;
if (!java.util.Arrays.equals(val, it.val)) return false;
return true;
}
@Override
public String toString() {
return "[" + val[0] + ", " + val[1] + ", " + val[2] + ", " + val[3] + "]";
}
}

View File

@@ -0,0 +1,73 @@
package org.opencv.core;
//javadoc:Size_
public class Size {
public double width, height;
public Size(double width, double height) {
this.width = width;
this.height = height;
}
public Size() {
this(0, 0);
}
public Size(Point p) {
width = p.x;
height = p.y;
}
public Size(double[] vals) {
set(vals);
}
public void set(double[] vals) {
if (vals != null) {
width = vals.length > 0 ? vals[0] : 0;
height = vals.length > 1 ? vals[1] : 0;
} else {
width = 0;
height = 0;
}
}
public double area() {
return width * height;
}
public boolean empty() {
return width <= 0 || height <= 0;
}
public Size clone() {
return new Size(width, height);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(height);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(width);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof Size)) return false;
Size it = (Size) obj;
return width == it.width && height == it.height;
}
@Override
public String toString() {
return (int)width + "x" + (int)height;
}
}

View File

@@ -0,0 +1,92 @@
package org.opencv.core;
//javadoc:TermCriteria
public class TermCriteria {
/**
* The maximum number of iterations or elements to compute
*/
public static final int COUNT = 1;
/**
* The maximum number of iterations or elements to compute
*/
public static final int MAX_ITER = COUNT;
/**
* The desired accuracy threshold or change in parameters at which the iterative algorithm is terminated.
*/
public static final int EPS = 2;
public int type;
public int maxCount;
public double epsilon;
/**
* Termination criteria for iterative algorithms.
*
* @param type
* the type of termination criteria: COUNT, EPS or COUNT + EPS.
* @param maxCount
* the maximum number of iterations/elements.
* @param epsilon
* the desired accuracy.
*/
public TermCriteria(int type, int maxCount, double epsilon) {
this.type = type;
this.maxCount = maxCount;
this.epsilon = epsilon;
}
/**
* Termination criteria for iterative algorithms.
*/
public TermCriteria() {
this(0, 0, 0.0);
}
public TermCriteria(double[] vals) {
set(vals);
}
public void set(double[] vals) {
if (vals != null) {
type = vals.length > 0 ? (int) vals[0] : 0;
maxCount = vals.length > 1 ? (int) vals[1] : 0;
epsilon = vals.length > 2 ? (double) vals[2] : 0;
} else {
type = 0;
maxCount = 0;
epsilon = 0;
}
}
public TermCriteria clone() {
return new TermCriteria(type, maxCount, epsilon);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(type);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(maxCount);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(epsilon);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof TermCriteria)) return false;
TermCriteria it = (TermCriteria) obj;
return type == it.type && maxCount == it.maxCount && epsilon == it.epsilon;
}
@Override
public String toString() {
return "{ type: " + type + ", maxCount: " + maxCount + ", epsilon: " + epsilon + "}";
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,71 @@
package org.opencv.test.core;
import org.opencv.core.CvType;
import org.opencv.test.OpenCVTestCase;
public class CvTypeTest extends OpenCVTestCase {
public void testMakeType() {
assertEquals(CvType.CV_8UC4, CvType.makeType(CvType.CV_8U, 4));
}
public void testCV_8UC() {
assertEquals(CvType.CV_8UC4, CvType.CV_8UC(4));
}
public void testCV_8SC() {
assertEquals(CvType.CV_8SC4, CvType.CV_8SC(4));
}
public void testCV_16UC() {
assertEquals(CvType.CV_16UC4, CvType.CV_16UC(4));
}
public void testCV_16SC() {
assertEquals(CvType.CV_16SC4, CvType.CV_16SC(4));
}
public void testCV_32SC() {
assertEquals(CvType.CV_32SC4, CvType.CV_32SC(4));
}
public void testCV_32FC() {
assertEquals(CvType.CV_32FC4, CvType.CV_32FC(4));
}
public void testCV_64FC() {
assertEquals(CvType.CV_64FC4, CvType.CV_64FC(4));
}
public void testCV_16FC() {
assertEquals(CvType.CV_16FC1, CvType.CV_16FC(1));
assertEquals(CvType.CV_16FC2, CvType.CV_16FC(2));
assertEquals(CvType.CV_16FC3, CvType.CV_16FC(3));
assertEquals(CvType.CV_16FC4, CvType.CV_16FC(4));
}
public void testChannels() {
assertEquals(1, CvType.channels(CvType.CV_64F));
}
public void testDepth() {
assertEquals(CvType.CV_64F, CvType.depth(CvType.CV_64FC3));
}
public void testIsInteger() {
assertFalse(CvType.isInteger(CvType.CV_32FC3));
assertTrue(CvType.isInteger(CvType.CV_16S));
}
public void testELEM_SIZE() {
assertEquals(3 * 8, CvType.ELEM_SIZE(CvType.CV_64FC3));
assertEquals(3 * 2, CvType.ELEM_SIZE(CvType.CV_16FC3));
}
public void testTypeToString() {
assertEquals("CV_32FC1", CvType.typeToString(CvType.CV_32F));
assertEquals("CV_32FC3", CvType.typeToString(CvType.CV_32FC3));
assertEquals("CV_32FC(128)", CvType.typeToString(CvType.CV_32FC(128)));
}
}

View File

@@ -0,0 +1,44 @@
package org.opencv.test.core;
import org.opencv.core.DMatch;
import junit.framework.TestCase;
public class DMatchTest extends TestCase {
public void testDMatch() {
new DMatch();
}
public void testDMatchIntIntFloat() {
DMatch dm1 = new DMatch(1, 4, 4.0f);
assertEquals(1, dm1.queryIdx);
assertEquals(4, dm1.trainIdx);
assertEquals(4.0f, dm1.distance);
}
public void testDMatchIntIntIntFloat() {
DMatch dm2 = new DMatch(2, 6, -1, 8.0f);
assertEquals(2, dm2.queryIdx);
assertEquals(6, dm2.trainIdx);
assertEquals(-1, dm2.imgIdx);
assertEquals(8.0f, dm2.distance);
}
public void testLessThan() {
DMatch dm1 = new DMatch(1, 4, 4.0f);
DMatch dm2 = new DMatch(2, 6, -1, 8.0f);
assertTrue(dm1.lessThan(dm2));
}
public void testToString() {
DMatch dm2 = new DMatch(2, 6, -1, 8.0f);
String actual = dm2.toString();
String expected = "DMatch [queryIdx=2, trainIdx=6, imgIdx=-1, distance=8.0]";
assertEquals(expected, actual);
}
}

View File

@@ -0,0 +1,71 @@
package org.opencv.test.core;
import org.opencv.core.Point;
import org.opencv.core.KeyPoint;
import org.opencv.test.OpenCVTestCase;
public class KeyPointTest extends OpenCVTestCase {
private float angle;
private int classId;
private KeyPoint keyPoint;
private int octave;
private float response;
private float size;
private float x;
private float y;
@Override
protected void setUp() throws Exception {
super.setUp();
keyPoint = null;
x = 1.0f;
y = 2.0f;
size = 3.0f;
angle = 30.0f;
response = 2.0f;
octave = 1;
classId = 1;
}
public void testKeyPoint() {
keyPoint = new KeyPoint();
assertPointEquals(new Point(0, 0), keyPoint.pt, EPS);
}
public void testKeyPointFloatFloatFloat() {
keyPoint = new KeyPoint(x, y, size);
assertPointEquals(new Point(1, 2), keyPoint.pt, EPS);
}
public void testKeyPointFloatFloatFloatFloat() {
keyPoint = new KeyPoint(x, y, size, 10.0f);
assertEquals(10.0f, keyPoint.angle);
}
public void testKeyPointFloatFloatFloatFloatFloat() {
keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f);
assertEquals(1.0f, keyPoint.response);
}
public void testKeyPointFloatFloatFloatFloatFloatInt() {
keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f, 1);
assertEquals(1, keyPoint.octave);
}
public void testKeyPointFloatFloatFloatFloatFloatIntInt() {
keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f, 1, 1);
assertEquals(1, keyPoint.class_id);
}
public void testToString() {
keyPoint = new KeyPoint(x, y, size, angle, response, octave, classId);
String actual = keyPoint.toString();
String expected = "KeyPoint [pt={1.0, 2.0}, size=3.0, angle=30.0, response=2.0, octave=1, class_id=1]";
assertEquals(expected, actual);
}
}

View File

@@ -0,0 +1,70 @@
package org.opencv.test.core;
import java.util.Arrays;
import org.opencv.core.Core;
import org.opencv.core.CvException;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.MatOfByte;
import org.opencv.core.MatOfDouble;
import org.opencv.test.OpenCVTestCase;
import org.opencv.imgcodecs.Imgcodecs;
public class MatOfByteTest extends OpenCVTestCase {
public void testMatOfSubByteArray() {
byte[] inputBytes = { 1,2,3,4,5 };
MatOfByte m0 = new MatOfByte(inputBytes);
MatOfByte m1 = new MatOfByte(0, inputBytes.length, inputBytes);
MatOfByte m2 = new MatOfByte(1, inputBytes.length - 2, inputBytes);
assertEquals(5.0, m0.size().height);
assertEquals(1.0, m0.size().width);
assertEquals(m0.get(0, 0)[0], m1.get(0, 0)[0]);
assertEquals(m0.get((int) m0.size().height - 1, 0)[0], m1.get((int) m1.size().height - 1, 0)[0]);
assertEquals(3.0, m2.size().height);
assertEquals(1.0, m2.size().width);
assertEquals(2.0, m2.get(0, 0)[0]);
assertEquals(3.0, m2.get(1, 0)[0]);
assertEquals(4.0, m2.get(2, 0)[0]);
}
public void testMatOfSubByteArray_BadArg() {
byte[] inputBytes = { 1,2,3,4,5 };
try {
MatOfByte m1 = new MatOfByte(-1, inputBytes.length, inputBytes);
fail("Missing check: offset < 0");
} catch (IllegalArgumentException e) {
// pass
}
try {
MatOfByte m1 = new MatOfByte(0, inputBytes.length, null);
fail("Missing check: NullPointerException");
} catch (NullPointerException e) {
// pass
}
try {
MatOfByte m1 = new MatOfByte(0, -1, inputBytes);
fail("Missing check: length < 0");
} catch (IllegalArgumentException e) {
// pass
}
try {
MatOfByte m1 = new MatOfByte(1, inputBytes.length, inputBytes);
fail("Missing check: buffer bounds");
} catch (IllegalArgumentException e) {
// pass
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,107 @@
package org.opencv.test.core;
import org.opencv.core.Point;
import org.opencv.core.Point3;
import org.opencv.test.OpenCVTestCase;
public class Point3Test extends OpenCVTestCase {
private Point3 p1;
private Point3 p2;
@Override
protected void setUp() throws Exception {
super.setUp();
p1 = new Point3(2, 2, 2);
p2 = new Point3(1, 1, 1);
}
public void testClone() {
Point3 truth = new Point3(1, 1, 1);
p1 = truth.clone();
assertEquals(truth, p1);
}
public void testCross() {
Point3 dstPoint = p1.cross(p2);
Point3 truth = new Point3(0, 0, 0);
assertEquals(truth, dstPoint);
}
public void testDot() {
double result = p1.dot(p2);
assertEquals(6.0, result);
}
public void testEqualsObject() {
boolean flag = p1.equals(p1);
assertTrue(flag);
flag = p1.equals(p2);
assertFalse(flag);
}
public void testHashCode() {
assertEquals(p1.hashCode(), p1.hashCode());
}
public void testPoint3() {
p1 = new Point3();
assertNotNull(p1);
assertTrue(0 == p1.x);
assertTrue(0 == p1.y);
assertTrue(0 == p1.z);
}
public void testPoint3DoubleArray() {
double[] vals = { 1, 2, 3 };
p1 = new Point3(vals);
assertTrue(1 == p1.x);
assertTrue(2 == p1.y);
assertTrue(3 == p1.z);
}
public void testPoint3DoubleDoubleDouble() {
p1 = new Point3(1, 2, 3);
assertEquals(1., p1.x);
assertEquals(2., p1.y);
assertEquals(3., p1.z);
}
public void testPoint3Point() {
Point p = new Point(2, 3);
p1 = new Point3(p);
assertEquals(2., p1.x);
assertEquals(3., p1.y);
assertEquals(0., p1.z);
}
public void testSet() {
double[] vals1 = {};
p1.set(vals1);
assertEquals(0., p1.x);
assertEquals(0., p1.y);
assertEquals(0., p1.z);
double[] vals2 = { 3, 6, 10 };
p1.set(vals2);
assertEquals(3., p1.x);
assertEquals(6., p1.y);
assertEquals(10., p1.z);
}
public void testToString() {
String actual = p1.toString();
String expected = "{2.0, 2.0, 2.0}";
assertEquals(expected, actual);
}
}

View File

@@ -0,0 +1,93 @@
package org.opencv.test.core;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.test.OpenCVTestCase;
public class PointTest extends OpenCVTestCase {
private Point p1;
private Point p2;
@Override
protected void setUp() throws Exception {
super.setUp();
p1 = new Point(2, 2);
p2 = new Point(1, 1);
}
public void testClone() {
Point truth = new Point(1, 1);
Point dstPoint = truth.clone();
assertEquals(truth, dstPoint);
}
public void testDot() {
double result = p1.dot(p2);
assertEquals(4.0, result);
}
public void testEqualsObject() {
boolean flag = p1.equals(p1);
assertTrue(flag);
flag = p1.equals(p2);
assertFalse(flag);
}
public void testHashCode() {
assertEquals(p1.hashCode(), p1.hashCode());
}
public void testInside() {
Rect rect = new Rect(0, 0, 5, 3);
assertTrue(p1.inside(rect));
Point p2 = new Point(3, 3);
assertFalse(p2.inside(rect));
}
public void testPoint() {
Point p = new Point();
assertNotNull(p);
assertEquals(0.0, p.x);
assertEquals(0.0, p.y);
}
public void testPointDoubleArray() {
double[] vals = { 2, 4 };
Point p = new Point(vals);
assertEquals(2.0, p.x);
assertEquals(4.0, p.y);
}
public void testPointDoubleDouble() {
p1 = new Point(7, 5);
assertNotNull(p1);
assertEquals(7.0, p1.x);
assertEquals(5.0, p1.y);
}
public void testSet() {
double[] vals1 = {};
p1.set(vals1);
assertEquals(0.0, p1.x);
assertEquals(0.0, p1.y);
double[] vals2 = { 6, 10 };
p2.set(vals2);
assertEquals(6.0, p2.x);
assertEquals(10.0, p2.y);
}
public void testToString() {
String actual = p1.toString();
String expected = "{2.0, 2.0}";
assertEquals(expected, actual);
}
}

View File

@@ -0,0 +1,113 @@
package org.opencv.test.core;
import org.opencv.core.Range;
import org.opencv.test.OpenCVTestCase;
public class RangeTest extends OpenCVTestCase {
Range r1;
Range r2;
Range range;
@Override
protected void setUp() throws Exception {
super.setUp();
range = new Range();
r1 = new Range(1, 11);
r2 = new Range(1, 1);
}
public void testAll() {
range = Range.all();
assertEquals(Integer.MIN_VALUE, range.start);
assertEquals(Integer.MAX_VALUE, range.end);
}
public void testClone() {
Range dstRange = new Range();
dstRange = r1.clone();
assertEquals(r1, dstRange);
}
public void testEmpty() {
boolean flag;
flag = r1.empty();
assertFalse(flag);
flag = r2.empty();
assertTrue(flag);
}
public void testEqualsObject() {
assertFalse(r2.equals(r1));
range = r1.clone();
assertTrue(r1.equals(range));
}
public void testHashCode() {
assertEquals(r1.hashCode(), r1.hashCode());
}
public void testIntersection() {
range = r1.intersection(r2);
assertEquals(r2, range);
}
public void testRange() {
range = new Range();
assertNotNull(range);
assertEquals(0, range.start);
assertEquals(0, range.end);
}
public void testRangeDoubleArray() {
double[] vals = { 2, 4 };
Range r = new Range(vals);
assertTrue(2 == r.start);
assertTrue(4 == r.end);
}
public void testRangeIntInt() {
r1 = new Range(12, 13);
assertNotNull(r1);
assertEquals(12, r1.start);
assertEquals(13, r1.end);
}
public void testSet() {
double[] vals1 = {};
r1.set(vals1);
assertEquals(0, r1.start);
assertEquals(0, r1.end);
double[] vals2 = { 6, 10 };
r2.set(vals2);
assertEquals(6, r2.start);
assertEquals(10, r2.end);
}
public void testShift() {
int delta = 1;
range = range.shift(delta);
assertEquals(r2, range);
}
public void testSize() {
assertEquals(10, r1.size());
assertEquals(0, r2.size());
}
public void testToString() {
String actual = r1.toString();
String expected = "[1, 11)";
assertEquals(expected, actual);
}
}

View File

@@ -0,0 +1,163 @@
package org.opencv.test.core;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Size;
import org.opencv.test.OpenCVTestCase;
public class RectTest extends OpenCVTestCase {
private Rect r;
private Rect rect;
@Override
protected void setUp() throws Exception {
super.setUp();
r = new Rect();
rect = new Rect(0, 0, 10, 10);
}
public void testArea() {
double area;
area = rect.area();
assertEquals(100.0, area);
}
public void testBr() {
Point p_br = new Point();
p_br = rect.br();
Point truth = new Point(10, 10);
assertEquals(truth, p_br);
}
public void testClone() {
r = rect.clone();
assertEquals(rect, r);
}
public void testContains() {
Rect rect = new Rect(0, 0, 10, 10);
Point p_inner = new Point(5, 5);
Point p_outer = new Point(5, 55);
Point p_bl = new Point(0, 0);
Point p_br = new Point(10, 0);
Point p_tl = new Point(0, 10);
Point p_tr = new Point(10, 10);
assertTrue(rect.contains(p_inner));
assertTrue(rect.contains(p_bl));
assertFalse(rect.contains(p_outer));
assertFalse(rect.contains(p_br));
assertFalse(rect.contains(p_tl));
assertFalse(rect.contains(p_tr));
}
public void testEqualsObject() {
boolean flag;
flag = rect.equals(r);
assertFalse(flag);
r = rect.clone();
flag = rect.equals(r);
assertTrue(flag);
}
public void testHashCode() {
assertEquals(rect.hashCode(), rect.hashCode());
}
public void testRect() {
r = new Rect();
assertEquals(0, r.x);
assertEquals(0, r.y);
assertEquals(0, r.width);
assertEquals(0, r.height);
}
public void testRectDoubleArray() {
double[] vals = { 1, 3, 5, 2 };
r = new Rect(vals);
assertEquals(1, r.x);
assertEquals(3, r.y);
assertEquals(5, r.width);
assertEquals(2, r.height);
}
public void testRectIntIntIntInt() {
r = new Rect(1, 3, 5, 2);
assertNotNull(rect);
assertEquals(0, rect.x);
assertEquals(0, rect.y);
assertEquals(10, rect.width);
assertEquals(10, rect.height);
}
public void testRectPointPoint() {
Point p1 = new Point(4, 4);
Point p2 = new Point(2, 3);
r = new Rect(p1, p2);
assertNotNull(r);
assertEquals(2, r.x);
assertEquals(3, r.y);
assertEquals(2, r.width);
assertEquals(1, r.height);
}
public void testRectPointSize() {
Point p1 = new Point(4, 4);
Size sz = new Size(3, 1);
r = new Rect(p1, sz);
assertEquals(4, r.x);
assertEquals(4, r.y);
assertEquals(3, r.width);
assertEquals(1, r.height);
}
public void testSet() {
double[] vals1 = {};
Rect r1 = new Rect(vals1);
assertEquals(0, r1.x);
assertEquals(0, r1.y);
assertEquals(0, r1.width);
assertEquals(0, r1.height);
double[] vals2 = { 2, 2, 10, 5 };
r = new Rect(vals2);
assertEquals(2, r.x);
assertEquals(2, r.y);
assertEquals(10, r.width);
assertEquals(5, r.height);
}
public void testSize() {
Size s1 = new Size(0, 0);
assertEquals(s1, r.size());
Size s2 = new Size(10, 10);
assertEquals(s2, rect.size());
}
public void testTl() {
Point p_tl = new Point();
p_tl = rect.tl();
Point truth = new Point(0, 0);
assertEquals(truth, p_tl);
}
public void testToString() {
String actual = rect.toString();
String expected = "{0, 0, 10x10}";
assertEquals(expected, actual);
}
}

View File

@@ -0,0 +1,213 @@
package org.opencv.test.core;
import org.opencv.core.CvType;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.RotatedRect;
import org.opencv.core.MatOfRotatedRect;
import org.opencv.core.Size;
import org.opencv.test.OpenCVTestCase;
import java.util.Arrays;
import java.util.List;
public class RotatedRectTest extends OpenCVTestCase {
private double angle;
private Point center;
private Size size;
@Override
protected void setUp() throws Exception {
super.setUp();
center = new Point(matSize / 2, matSize / 2);
size = new Size(matSize / 4, matSize / 2);
angle = 40;
}
public void testBoundingRect() {
size = new Size(matSize / 2, matSize / 2);
assertEquals(size.height, size.width);
double length = size.height;
angle = 45;
RotatedRect rr = new RotatedRect(center, size, angle);
Rect r = rr.boundingRect();
double halfDiagonal = length * Math.sqrt(2) / 2;
assertTrue((r.x == Math.floor(center.x - halfDiagonal)) && (r.y == Math.floor(center.y - halfDiagonal)));
assertTrue((r.br().x >= Math.ceil(center.x + halfDiagonal)) && (r.br().y >= Math.ceil(center.y + halfDiagonal)));
assertTrue((r.br().x - Math.ceil(center.x + halfDiagonal)) <= 1 && (r.br().y - Math.ceil(center.y + halfDiagonal)) <= 1);
}
public void testClone() {
RotatedRect rrect = new RotatedRect(center, size, angle);
RotatedRect clone = rrect.clone();
assertNotNull(clone);
assertTrue(rrect.center.equals(clone.center));
assertTrue(rrect.size.equals(clone.size));
assertTrue(rrect.angle == clone.angle);
}
public void testEqualsObject() {
Point center2 = new Point(matSize / 3, matSize / 1.5);
Size size2 = new Size(matSize / 2, matSize / 4);
double angle2 = 0;
RotatedRect rrect1 = new RotatedRect(center, size, angle);
RotatedRect rrect2 = new RotatedRect(center2, size2, angle2);
RotatedRect rrect3 = rrect1;
RotatedRect clone1 = rrect1.clone();
RotatedRect clone2 = rrect2.clone();
assertTrue(rrect1.equals(rrect3));
assertFalse(rrect1.equals(rrect2));
assertTrue(rrect2.equals(clone2));
clone2.angle = 10;
assertFalse(rrect2.equals(clone2));
assertTrue(rrect1.equals(clone1));
clone1.center.x += 1;
assertFalse(rrect1.equals(clone1));
clone1.center.x -= 1;
assertTrue(rrect1.equals(clone1));
clone1.size.width += 1;
assertFalse(rrect1.equals(clone1));
assertFalse(rrect1.equals(size));
}
public void testHashCode() {
RotatedRect rr = new RotatedRect(center, size, angle);
assertEquals(rr.hashCode(), rr.hashCode());
}
public void testPoints() {
RotatedRect rrect = new RotatedRect(center, size, angle);
Point p[] = new Point[4];
rrect.points(p);
boolean is_p0_irrational = (100 * p[0].x != (int) (100 * p[0].x)) && (100 * p[0].y != (int) (100 * p[0].y));
boolean is_p1_irrational = (100 * p[1].x != (int) (100 * p[1].x)) && (100 * p[1].y != (int) (100 * p[1].y));
boolean is_p2_irrational = (100 * p[2].x != (int) (100 * p[2].x)) && (100 * p[2].y != (int) (100 * p[2].y));
boolean is_p3_irrational = (100 * p[3].x != (int) (100 * p[3].x)) && (100 * p[3].y != (int) (100 * p[3].y));
assertTrue(is_p0_irrational && is_p1_irrational && is_p2_irrational && is_p3_irrational);
assertTrue("Symmetric points 0 and 2",
Math.abs((p[0].x + p[2].x) / 2 - center.x) + Math.abs((p[0].y + p[2].y) / 2 - center.y) < EPS);
assertTrue("Symmetric points 1 and 3",
Math.abs((p[1].x + p[3].x) / 2 - center.x) + Math.abs((p[1].y + p[3].y) / 2 - center.y) < EPS);
assertTrue("Orthogonal vectors 01 and 12",
Math.abs((p[1].x - p[0].x) * (p[2].x - p[1].x) +
(p[1].y - p[0].y) * (p[2].y - p[1].y)) < EPS);
assertTrue("Orthogonal vectors 12 and 23",
Math.abs((p[2].x - p[1].x) * (p[3].x - p[2].x) +
(p[2].y - p[1].y) * (p[3].y - p[2].y)) < EPS);
assertTrue("Orthogonal vectors 23 and 30",
Math.abs((p[3].x - p[2].x) * (p[0].x - p[3].x) +
(p[3].y - p[2].y) * (p[0].y - p[3].y)) < EPS);
assertTrue("Orthogonal vectors 30 and 01",
Math.abs((p[0].x - p[3].x) * (p[1].x - p[0].x) +
(p[0].y - p[3].y) * (p[1].y - p[0].y)) < EPS);
assertTrue("Length of the vector 01",
Math.abs((p[1].x - p[0].x) * (p[1].x - p[0].x) +
(p[1].y - p[0].y) * (p[1].y - p[0].y) - size.height * size.height) < EPS);
assertTrue("Length of the vector 21",
Math.abs((p[1].x - p[2].x) * (p[1].x - p[2].x) +
(p[1].y - p[2].y) * (p[1].y - p[2].y) - size.width * size.width) < EPS);
assertTrue("Angle of the vector 21 with the axes", Math.abs((p[2].x - p[1].x) / size.width - Math.cos(angle * Math.PI / 180)) < EPS);
}
public void testRotatedRect() {
RotatedRect rr = new RotatedRect();
assertNotNull(rr);
assertNotNull(rr.center);
assertNotNull(rr.size);
assertEquals(0.0, rr.angle);
}
public void testRotatedRectDoubleArray() {
double[] vals = { 1.5, 2.6, 3.7, 4.2, 5.1 };
RotatedRect rr = new RotatedRect(vals);
assertNotNull(rr);
assertEquals(1.5, rr.center.x);
assertEquals(2.6, rr.center.y);
assertEquals(3.7, rr.size.width);
assertEquals(4.2, rr.size.height);
assertEquals(5.1, rr.angle);
}
public void testRotatedRectPointSizeDouble() {
RotatedRect rr = new RotatedRect(center, size, 40);
assertNotNull(rr);
assertNotNull(rr.center);
assertNotNull(rr.size);
assertEquals(40.0, rr.angle);
}
public void testSet() {
double[] vals1 = {};
RotatedRect r1 = new RotatedRect(center, size, 40);
r1.set(vals1);
assertEquals(0., r1.angle);
assertPointEquals(new Point(0, 0), r1.center, EPS);
assertSizeEquals(new Size(0, 0), r1.size, EPS);
double[] vals2 = { 1, 2, 3, 4, 5 };
RotatedRect r2 = new RotatedRect(center, size, 40);
r2.set(vals2);
assertEquals(5., r2.angle);
assertPointEquals(new Point(1, 2), r2.center, EPS);
assertSizeEquals(new Size(3, 4), r2.size, EPS);
}
public void testToString() {
String actual = new RotatedRect(new Point(1, 2), new Size(10, 12), 4.5).toString();
String expected = "{ {1.0, 2.0} 10x12 * 4.5 }";
assertEquals(expected, actual);
}
public void testMatOfRotatedRect() {
RotatedRect a = new RotatedRect(new Point(1,2),new Size(3,4),5.678);
RotatedRect b = new RotatedRect(new Point(9,8),new Size(7,6),5.432);
MatOfRotatedRect m = new MatOfRotatedRect(a,b,a,b,a,b,a,b);
assertEquals(m.rows(), 8);
assertEquals(m.cols(), 1);
assertEquals(m.type(), CvType.CV_32FC(5));
RotatedRect[] arr = m.toArray();
assertEquals(arr[2].angle, a.angle, EPS);
assertEquals(arr[3].center.x, b.center.x);
assertEquals(arr[3].size.width, b.size.width);
List<RotatedRect> li = m.toList();
assertEquals(li.size(), 8);
RotatedRect rr = li.get(7);
assertEquals(rr.angle, b.angle, EPS);
assertEquals(rr.center.y, b.center.y);
}
}

View File

@@ -0,0 +1,110 @@
package org.opencv.test.core;
import org.opencv.core.Scalar;
import org.opencv.test.OpenCVTestCase;
public class ScalarTest extends OpenCVTestCase {
private Scalar dstScalar;
private Scalar s1;
private Scalar s2;
@Override
protected void setUp() throws Exception {
super.setUp();
s1 = new Scalar(1.0);
s2 = Scalar.all(1.0);
dstScalar = null;
}
public void testAll() {
dstScalar = Scalar.all(2.0);
Scalar truth = new Scalar(2.0, 2.0, 2.0, 2.0);
assertEquals(truth, dstScalar);
}
public void testClone() {
dstScalar = s2.clone();
assertEquals(s2, dstScalar);
}
public void testConj() {
dstScalar = s2.conj();
Scalar truth = new Scalar(1, -1, -1, -1);
assertEquals(truth, dstScalar);
}
public void testEqualsObject() {
dstScalar = s2.clone();
assertTrue(s2.equals(dstScalar));
assertFalse(s2.equals(s1));
}
public void testHashCode() {
assertEquals(s2.hashCode(), s2.hashCode());
}
public void testIsReal() {
assertTrue(s1.isReal());
assertFalse(s2.isReal());
}
public void testMulScalar() {
dstScalar = s2.mul(s1);
assertEquals(s1, dstScalar);
}
public void testMulScalarDouble() {
double multiplier = 2.0;
dstScalar = s2.mul(s1, multiplier);
Scalar truth = new Scalar(2);
assertEquals(truth, dstScalar);
}
public void testScalarDouble() {
Scalar truth = new Scalar(1);
assertEquals(truth, s1);
}
public void testScalarDoubleArray() {
double[] vals = { 2.0, 4.0, 5.0, 3.0 };
dstScalar = new Scalar(vals);
Scalar truth = new Scalar(2.0, 4.0, 5.0, 3.0);
assertEquals(truth, dstScalar);
}
public void testScalarDoubleDouble() {
dstScalar = new Scalar(2, 5);
Scalar truth = new Scalar(2.0, 5.0, 0.0, 0.0);
assertEquals(truth, dstScalar);
}
public void testScalarDoubleDoubleDouble() {
dstScalar = new Scalar(2.0, 5.0, 5.0);
Scalar truth = new Scalar(2.0, 5.0, 5.0, 0.0);
assertEquals(truth, dstScalar);
}
public void testScalarDoubleDoubleDoubleDouble() {
dstScalar = new Scalar(2.0, 5.0, 5.0, 9.0);
Scalar truth = new Scalar(2.0, 5.0, 5.0, 9.0);
assertEquals(truth, dstScalar);
}
public void testSet() {
double[] vals = { 1.0, 1.0, 1.0, 1.0 };
s1.set(vals);
assertEquals(s2, s1);
}
public void testToString() {
String actual = s2.toString();
String expected = "[1.0, 1.0, 1.0, 1.0]";
assertEquals(expected, actual);
}
}

View File

@@ -0,0 +1,93 @@
package org.opencv.test.core;
import org.opencv.core.Point;
import org.opencv.core.Size;
import org.opencv.test.OpenCVTestCase;
public class SizeTest extends OpenCVTestCase {
Size dstSize;
Size sz1;
Size sz2;
@Override
protected void setUp() throws Exception {
super.setUp();
sz1 = new Size(10.0, 10.0);
sz2 = new Size(-1, -1);
dstSize = null;
}
public void testArea() {
double area = sz1.area();
assertEquals(100.0, area);
}
public void testClone() {
dstSize = sz1.clone();
assertEquals(sz1, dstSize);
}
public void testEqualsObject() {
assertFalse(sz1.equals(sz2));
sz2 = sz1.clone();
assertTrue(sz1.equals(sz2));
}
public void testHashCode() {
assertEquals(sz1.hashCode(), sz1.hashCode());
}
public void testSet() {
double[] vals1 = {};
sz2.set(vals1);
assertEquals(0., sz2.width);
assertEquals(0., sz2.height);
double[] vals2 = { 9, 12 };
sz1.set(vals2);
assertEquals(9., sz1.width);
assertEquals(12., sz1.height);
}
public void testSize() {
dstSize = new Size();
assertNotNull(dstSize);
assertEquals(0., dstSize.width);
assertEquals(0., dstSize.height);
}
public void testSizeDoubleArray() {
double[] vals = { 10, 20 };
sz2 = new Size(vals);
assertEquals(10., sz2.width);
assertEquals(20., sz2.height);
}
public void testSizeDoubleDouble() {
assertNotNull(sz1);
assertEquals(10.0, sz1.width);
assertEquals(10.0, sz1.height);
}
public void testSizePoint() {
Point p = new Point(2, 4);
sz1 = new Size(p);
assertNotNull(sz1);
assertEquals(2.0, sz1.width);
assertEquals(4.0, sz1.height);
}
public void testToString() {
String actual = sz1.toString();
String expected = "10x10";
assertEquals(expected, actual);
}
}

View File

@@ -0,0 +1,86 @@
package org.opencv.test.core;
import org.opencv.core.TermCriteria;
import org.opencv.test.OpenCVTestCase;
public class TermCriteriaTest extends OpenCVTestCase {
private TermCriteria tc1;
private TermCriteria tc2;
@Override
protected void setUp() throws Exception {
super.setUp();
tc1 = new TermCriteria();
tc2 = new TermCriteria(2, 4, EPS);
}
public void testClone() {
tc1 = tc2.clone();
assertEquals(tc2, tc1);
}
public void testEqualsObject() {
assertFalse(tc2.equals(tc1));
tc1 = tc2.clone();
assertTrue(tc2.equals(tc1));
}
public void testHashCode() {
assertEquals(tc2.hashCode(), tc2.hashCode());
}
public void testSet() {
double[] vals1 = {};
tc1.set(vals1);
assertEquals(0, tc1.type);
assertEquals(0, tc1.maxCount);
assertEquals(0.0, tc1.epsilon);
double[] vals2 = { 9, 8, 0.002 };
tc2.set(vals2);
assertEquals(9, tc2.type);
assertEquals(8, tc2.maxCount);
assertEquals(0.002, tc2.epsilon);
}
public void testTermCriteria() {
tc1 = new TermCriteria();
assertNotNull(tc1);
assertEquals(0, tc1.type);
assertEquals(0, tc1.maxCount);
assertEquals(0.0, tc1.epsilon);
}
public void testTermCriteriaDoubleArray() {
double[] vals = { 3, 2, 0.007 };
tc1 = new TermCriteria(vals);
assertEquals(3, tc1.type);
assertEquals(2, tc1.maxCount);
assertEquals(0.007, tc1.epsilon);
}
public void testTermCriteriaIntIntDouble() {
tc1 = new TermCriteria(2, 4, EPS);
assertNotNull(tc2);
assertEquals(2, tc2.type);
assertEquals(4, tc2.maxCount);
assertEquals(EPS, tc2.epsilon);
}
public void testToString() {
String actual = tc2.toString();
double eps = EPS;
String expected = "{ type: 2, maxCount: 4, epsilon: " + eps + "}";
assertEquals(expected, actual);
}
}

View File

@@ -0,0 +1,8 @@
#ifdef HAVE_OPENCV_CORE
#include "opencv2/core/async.hpp"
CV_PY_TO_CLASS(AsyncArray);
CV_PY_FROM_CLASS(AsyncArray);
#endif

View File

@@ -0,0 +1,37 @@
#ifdef HAVE_OPENCV_CORE
#include "opencv2/core/cuda.hpp"
typedef std::vector<cuda::GpuMat> vector_GpuMat;
typedef cuda::GpuMat::Allocator GpuMat_Allocator;
typedef cuda::HostMem::AllocType HostMem_AllocType;
typedef cuda::Event::CreateFlags Event_CreateFlags;
template<> struct pyopencvVecConverter<cuda::GpuMat>
{
static bool to(PyObject* obj, std::vector<cuda::GpuMat>& value, const ArgInfo& info)
{
return pyopencv_to_generic_vec(obj, value, info);
}
static PyObject* from(const std::vector<cuda::GpuMat>& value)
{
return pyopencv_from_generic_vec(value);
}
};
CV_PY_TO_CLASS(cuda::GpuMat);
CV_PY_TO_CLASS(cuda::Stream);
CV_PY_TO_CLASS(cuda::Event);
CV_PY_TO_CLASS(cuda::HostMem);
CV_PY_TO_CLASS_PTR(cuda::GpuMat);
CV_PY_TO_CLASS_PTR(cuda::GpuMat::Allocator);
CV_PY_FROM_CLASS(cuda::GpuMat);
CV_PY_FROM_CLASS(cuda::Stream);
CV_PY_FROM_CLASS(cuda::HostMem);
CV_PY_FROM_CLASS_PTR(cuda::GpuMat::Allocator);
#endif

View File

@@ -0,0 +1,36 @@
#ifdef HAVE_OPENCV_CORE
#include "opencv2/core/mat.hpp"
typedef std::vector<Range> vector_Range;
CV_PY_TO_CLASS(UMat);
CV_PY_FROM_CLASS(UMat);
static bool cv_mappable_to(const Ptr<Mat>& src, Ptr<UMat>& dst)
{
//dst.reset(new UMat(src->getUMat(ACCESS_RW)));
dst.reset(new UMat());
src->copyTo(*dst);
return true;
}
static void* cv_UMat_queue()
{
return cv::ocl::Queue::getDefault().ptr();
}
static void* cv_UMat_context()
{
return cv::ocl::Context::getDefault().ptr();
}
static Mat cv_UMat_get(const UMat* _self)
{
Mat m;
m.allocator = &g_numpyAllocator;
_self->copyTo(m);
return m;
}
#endif

View File

@@ -0,0 +1,59 @@
#error This is a shadow header file, which is not intended for processing by any compiler. \
Only bindings parser should handle this file.
namespace cv
{
class CV_EXPORTS_W UMat
{
public:
//! default constructor
CV_WRAP UMat(UMatUsageFlags usageFlags = USAGE_DEFAULT);
//! constructs 2D matrix of the specified size and type
// (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.)
CV_WRAP UMat(int rows, int cols, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT);
CV_WRAP UMat(Size size, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT);
//! constructs 2D matrix and fills it with the specified value _s.
CV_WRAP UMat(int rows, int cols, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT);
CV_WRAP UMat(Size size, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT);
//! Mat is mappable to UMat
CV_WRAP_MAPPABLE(Ptr<Mat>);
//! returns the OpenCL queue used by OpenCV UMat
CV_WRAP_PHANTOM(static void* queue());
//! returns the OpenCL context used by OpenCV UMat
CV_WRAP_PHANTOM(static void* context());
//! copy constructor
CV_WRAP UMat(const UMat& m);
//! creates a matrix header for a part of the bigger matrix
CV_WRAP UMat(const UMat& m, const Range& rowRange, const Range& colRange = Range::all());
CV_WRAP UMat(const UMat& m, const Rect& roi);
CV_WRAP UMat(const UMat& m, const std::vector<Range>& ranges);
//CV_WRAP_AS(get) Mat getMat(int flags CV_WRAP_DEFAULT(ACCESS_RW)) const;
//! returns a numpy matrix
CV_WRAP_PHANTOM(Mat get() const);
//! returns true iff the matrix data is continuous
// (i.e. when there are no gaps between successive rows).
// similar to CV_IS_MAT_CONT(cvmat->type)
CV_WRAP bool isContinuous() const;
//! returns true if the matrix is a submatrix of another matrix
CV_WRAP bool isSubmatrix() const;
/*! Returns the OpenCL buffer handle on which UMat operates on.
The UMat instance should be kept alive during the use of the handle to prevent the buffer to be
returned to the OpenCV buffer pool.
*/
CV_WRAP void* handle(AccessFlag accessFlags) const;
// offset of the submatrix (or 0)
CV_PROP_RW size_t offset;
};
} // namespace cv