adding method dims() to core.Mat
authorJan Starzynski <jan@2009.starzy.de>
Wed, 17 Jul 2013 13:04:34 +0000 (15:04 +0200)
committerJan Starzynski <jan@2009.starzy.de>
Wed, 17 Jul 2013 13:04:34 +0000 (15:04 +0200)
modules/java/generator/src/cpp/Mat.cpp
modules/java/generator/src/java/core+Mat.java

index 726dcaf..a869900 100644 (file)
@@ -524,6 +524,37 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1colRange
 
 
 //
+//  int Mat::dims()
+//
+
+JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1dims
+  (JNIEnv* env, jclass, jlong self);
+
+JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1dims
+  (JNIEnv* env, jclass, jlong self)
+{
+    try {
+        LOGD("Mat::n_1dims()");
+        Mat* me = (Mat*) self; //TODO: check for NULL
+        int _retval_ = me->dims;
+
+        return _retval_;
+    } catch(cv::Exception e) {
+        LOGD("Mat::n_1cols() catched cv::Exception: %s", e.what());
+        jclass je = env->FindClass("org/opencv/core/CvException");
+        if(!je) je = env->FindClass("java/lang/Exception");
+        env->ThrowNew(je, e.what());
+        return 0;
+    } catch (...) {
+        LOGD("Mat::n_1cols() catched unknown exception (...)");
+        jclass je = env->FindClass("java/lang/Exception");
+        env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1cols()}");
+        return 0;
+    }
+}
+
+
+//
 //  int Mat::cols()
 //
 
index 8dd72fb..6db2554 100644 (file)
@@ -246,6 +246,19 @@ public class Mat {
     }
 
     //
+    // C++: int Mat::dims()
+    //
+
+    // javadoc: Mat::dims()
+    public int dims()
+    {
+
+        int retVal = n_dims(nativeObj);
+
+        return retVal;
+    }
+
+    //
     // C++: int Mat::cols()
     //
 
@@ -1130,6 +1143,9 @@ public class Mat {
     // C++: Mat Mat::colRange(int startcol, int endcol)
     private static native long n_colRange(long nativeObj, int startcol, int endcol);
 
+    // C++: int Mat::dims()
+    private static native int n_dims(long nativeObj);
+
     // C++: int Mat::cols()
     private static native int n_cols(long nativeObj);