JavaAPI: implemented Mat.dump method (analog for C++ stream <<)
authorKirill Kornyakov <no@email>
Tue, 5 Jul 2011 08:37:49 +0000 (08:37 +0000)
committerKirill Kornyakov <no@email>
Tue, 5 Jul 2011 08:37:49 +0000 (08:37 +0000)
modules/java/android_test/src/org/opencv/test/MatTest.java
modules/java/src/cpp/Mat.cpp
modules/java/src/java/Mat.java

index 40a43eb..3f21525 100644 (file)
@@ -9,7 +9,8 @@ public class MatTest extends OpenCVTestCase {
        }
 
        public void testChannels() {
-               fail("Not yet implemented");
+               //fail("Not yet implemented");
+               utils.Log(grayRnd.dump());
        }
 
        public void testClone() {
index 730a7a9..67bbdaf 100644 (file)
@@ -240,6 +240,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nInv
 JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nEye\r
   (JNIEnv *, jclass, jint, jint, jint);\r
 \r
+/*\r
+ * Class:     org_opencv_Mat\r
+ * Method:    nDump\r
+ * Signature: (J)S\r
+ */\r
+JNIEXPORT jstring JNICALL Java_org_opencv_Mat_nDump\r
+  (JNIEnv *, jclass, jlong);\r
+\r
 #ifdef __cplusplus\r
 }\r
 #endif\r
@@ -619,6 +627,15 @@ JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nEye
     return (jlong) new cv::Mat(cv::Mat::eye( _rows, _cols, _type ));\r
 }\r
 \r
+JNIEXPORT jstring JNICALL Java_org_opencv_Mat_nDump\r
+  (JNIEnv *env, jclass cls, jlong self)\r
+{\r
+       cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL\r
+    std::stringstream s;\r
+    s << *me;\r
+       return env->NewStringUTF(s.str().c_str());\r
+}\r
+\r
 JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nCreateMat__III\r
   (JNIEnv* env, jclass cls, jint _rows, jint _cols, jint _type)\r
 {\r
index 8669b99..122bb82 100644 (file)
@@ -180,10 +180,14 @@ public class Mat {
                                rows() + "*" + cols() + "*" + type() + \r
                                ", isCont=" + isContinuous() + ", isSubmat=" + isSubmatrix() +\r
                                ", nativeObj=0x" + Long.toHexString(nativeObj) + \r
-                               ", dataAddr=0x" + Long.toHexString(dataAddr()) + \r
+                               ", dataAddr=0x" + Long.toHexString(dataAddr()) +  \r
                                " ]";\r
        }\r
        \r
+    public String dump() {\r
+       return nDump(nativeObj);\r
+    }\r
+       \r
        public boolean empty() {\r
                if(nativeObj == 0) return true;\r
                return nIsEmpty(nativeObj); \r
@@ -426,5 +430,6 @@ public class Mat {
        private static native long nCross(long self, long mat);\r
        private static native long nInv(long self);\r
     private static native long nEye(int rows, int cols, int type);\r
+    private static native String nDump(long self);\r
 \r
 }\r