Added class TermCriteria.
authorLeonid Beynenson <no@email>
Thu, 14 Jul 2011 14:52:58 +0000 (14:52 +0000)
committerLeonid Beynenson <no@email>
Thu, 14 Jul 2011 14:52:58 +0000 (14:52 +0000)
modules/java/gen_java.py
modules/java/src/java/TermCriteria.java [new file with mode: 0644]

index 847f256..44b8959 100644 (file)
@@ -78,7 +78,7 @@ type_dict = {
     "Range"   : { "j_type" : "Range",  "jn_args" : (("int", ".start"), ("int", ".end")),\r
                   "jni_var" : "cv::Range %(n)s(%(n)s_start, %(n)s_end)",\r
                   "suffix" : "II"},\r
-    "CvSlice"   : { "j_type" : "Range",  "jn_args" : (("int", ".start"), ("int", ".end")),\r
+    "CvSlice" : { "j_type" : "Range",  "jn_args" : (("int", ".start"), ("int", ".end")),\r
                   "jni_var" : "cv::Range %(n)s(%(n)s_start, %(n)s_end)",\r
                   "suffix" : "II"},\r
     "string"  : { "j_type" : "java.lang.String",  "jn_type" : "java.lang.String",\r
@@ -93,6 +93,9 @@ type_dict = {
                   "jni_type" : "jstring", "jni_name" : "n_%(n)s.c_str()",\r
                   "jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); std::string n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)',\r
                   "suffix" : "Ljava_lang_String_2"},\r
+"TermCriteria": { "j_type" : "TermCriteria",  "jn_args" : (("int", ".type"), ("int", ".maxCount"), ("double", ".epsilon")),\r
+                  "jni_var" : "TermCriteria %(n)s(%(n)s_type, %(n)s_maxCount, %(n)s_epsilon)",\r
+                  "suffix" : "IID"},\r
 \r
 }\r
 \r
@@ -320,7 +323,7 @@ class JavaWrapperGenerator(object):
         if (mask != null) {\r
                 maskNativeObj=mask.nativeObj;\r
         }\r
-        double resarr[] = n_minMaxLoc(src.nativeObj, maskNativeObj);\r
+        double resarr[] = n_minMaxLocManual(src.nativeObj, maskNativeObj);\r
         res.minVal=resarr[0];\r
         res.maxVal=resarr[1];\r
         res.minLoc.x=resarr[2];\r
@@ -332,7 +335,7 @@ class JavaWrapperGenerator(object):
     public static MinMaxLocResult minMaxLoc(Mat src) {\r
         return minMaxLoc(src, null);\r
     }\r
-    private static native double[] n_minMaxLoc(long src_nativeObj, long mask_nativeObj);\r
+    private static native double[] n_minMaxLocManual(long src_nativeObj, long mask_nativeObj);\r
 \r
 \r
 """ )\r
@@ -420,7 +423,7 @@ class JavaWrapperGenerator(object):
         if module == "core":\r
             self.cpp_code.write(\\r
 """\r
-JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_n_1minMaxLoc\r
+JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_n_1minMaxLocManual\r
   (JNIEnv* env, jclass cls, jlong src_nativeObj, jlong mask_nativeObj)\r
 {\r
     try {\r
diff --git a/modules/java/src/java/TermCriteria.java b/modules/java/src/java/TermCriteria.java
new file mode 100644 (file)
index 0000000..855137e
--- /dev/null
@@ -0,0 +1,60 @@
+package org.opencv;\r
+\r
+//javadoc:TermCriteria\r
+public class TermCriteria {\r
+\r
+    public int type;\r
+    public int maxCount;\r
+    public double epsilon;\r
+\r
+    public TermCriteria(int t, int c, double e) {\r
+        this.type = t;\r
+        this.maxCount = c;\r
+        this.epsilon = e;\r
+    }\r
+\r
+    public TermCriteria() {\r
+        this(0, 0, 0.0);\r
+    }\r
+\r
+    public TermCriteria(double[] vals) {\r
+       this();\r
+       if(vals!=null) {\r
+               type      = vals.length>0 ? (int)vals[0]    : 0;\r
+               maxCount  = vals.length>1 ? (int)vals[1]    : 0;\r
+               epsilon   = vals.length>2 ? (double)vals[2] : 0;\r
+       }\r
+    }\r
+\r
+    public TermCriteria clone() {\r
+        return new TermCriteria(type, maxCount, epsilon);\r
+    }\r
+\r
+    @Override\r
+    public int hashCode() {\r
+        final int prime = 31;\r
+        int result = 1;\r
+        long temp;\r
+        temp = Double.doubleToLongBits(type);\r
+        result = prime * result + (int) (temp ^ (temp >>> 32));\r
+        temp = Double.doubleToLongBits(maxCount);\r
+        result = prime * result + (int) (temp ^ (temp >>> 32));\r
+        temp = Double.doubleToLongBits(epsilon);\r
+        result = prime * result + (int) (temp ^ (temp >>> 32));\r
+        return result;\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(Object obj) {\r
+        if (this == obj) return true;\r
+        if (!(obj instanceof TermCriteria)) return false;\r
+        TermCriteria it = (TermCriteria) obj;\r
+        return type == it.type && maxCount == it.maxCount && epsilon== it.epsilon;\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        if (this == null) return "null";\r
+        return "{ type: " + type + ", maxCount: " + maxCount + ", epsilon: " + epsilon + "}";\r
+    }\r
+}\r