JavaAPI: implemented Mat.dump method (analog for C++ stream <<)

This commit is contained in:
Kirill Kornyakov 2011-07-05 08:37:49 +00:00
parent ff8fe39e23
commit 5688b014e9
3 changed files with 25 additions and 2 deletions

View 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() {

View File

@ -240,6 +240,14 @@ JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nInv
JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nEye
(JNIEnv *, jclass, jint, jint, jint);
/*
* Class: org_opencv_Mat
* Method: nDump
* Signature: (J)S
*/
JNIEXPORT jstring JNICALL Java_org_opencv_Mat_nDump
(JNIEnv *, jclass, jlong);
#ifdef __cplusplus
}
#endif
@ -619,6 +627,15 @@ JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nEye
return (jlong) new cv::Mat(cv::Mat::eye( _rows, _cols, _type ));
}
JNIEXPORT jstring JNICALL Java_org_opencv_Mat_nDump
(JNIEnv *env, jclass cls, jlong self)
{
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
std::stringstream s;
s << *me;
return env->NewStringUTF(s.str().c_str());
}
JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nCreateMat__III
(JNIEnv* env, jclass cls, jint _rows, jint _cols, jint _type)
{

View File

@ -180,10 +180,14 @@ public class Mat {
rows() + "*" + cols() + "*" + type() +
", isCont=" + isContinuous() + ", isSubmat=" + isSubmatrix() +
", nativeObj=0x" + Long.toHexString(nativeObj) +
", dataAddr=0x" + Long.toHexString(dataAddr()) +
", dataAddr=0x" + Long.toHexString(dataAddr()) +
" ]";
}
public String dump() {
return nDump(nativeObj);
}
public boolean empty() {
if(nativeObj == 0) return true;
return nIsEmpty(nativeObj);
@ -426,5 +430,6 @@ public class Mat {
private static native long nCross(long self, long mat);
private static native long nInv(long self);
private static native long nEye(int rows, int cols, int type);
private static native String nDump(long self);
}