From 5041773f0d0e517e61b816b46fca5ae4fce9cd67 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Sun, 31 Jul 2011 20:23:23 +0000 Subject: [PATCH] Java API: updated Mat port --- modules/java/gen_java.py | 6 +- modules/java/src/cpp/Mat.cpp | 2045 ++++++++++++++++++++++++--- modules/java/src/java/core+Mat.java | 1249 +++++++++++++--- 3 files changed, 2973 insertions(+), 327 deletions(-) diff --git a/modules/java/gen_java.py b/modules/java/gen_java.py index a90c0547b9..23645a6d20 100644 --- a/modules/java/gen_java.py +++ b/modules/java/gen_java.py @@ -85,7 +85,7 @@ const_ignore_list = ( "CV_L?(BGRA?|RGBA?|GRAY|XYZ|YCrCb|Luv|Lab|HLS|YUV|HSV)\d*2L?(BGRA?|RGBA?|GRAY|XYZ|YCrCb|Luv|Lab|HLS|YUV|HSV).*", "CV_COLORCVT_MAX", "CV_.*Bayer.*", - "CV_YUV420i2.+", + "CV_YUV420(i|sp)2.+", "CV_TM_.+", "CV_FLOODFILL_.+", "CV_ADAPTIVE_THRESH_.+", @@ -616,11 +616,11 @@ public class %(c)s { if classinfo.name in self.classes: print "Generator error: class %s (%s) is duplicated" % \ (classinfo.name, classinfo.cname) - sys.exit(-1) + return self.classes[classinfo.name] = classinfo if classinfo.name in type_dict: print "Duplicated class: " + classinfo.name - sys.exit(-1) + return type_dict[classinfo.name] = \ { "j_type" : classinfo.name, "jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),), diff --git a/modules/java/src/cpp/Mat.cpp b/modules/java/src/cpp/Mat.cpp index 5829d7a8a2..6081deda0f 100644 --- a/modules/java/src/cpp/Mat.cpp +++ b/modules/java/src/cpp/Mat.cpp @@ -1,112 +1,1926 @@ #include -/* + +#include "converters.h" + +#ifdef DEBUG #include -#define TEGRA_LOG_TAG "MAT_CPP" -#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, TEGRA_LOG_TAG, __VA_ARGS__)) -*/ +#define MODULE_LOG_TAG "OpenCV.core.Mat" +#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, MODULE_LOG_TAG, __VA_ARGS__)) +#else //DEBUG +#define LOGD(...) +#endif //DEBUG + +#include "opencv2/core/core.hpp" + +using namespace cv; + +extern "C" { + + +// +// MatXXX::MatXXX() +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__ + (JNIEnv* env, jclass cls) +{ + LOGD("Mat::n_1Mat__()"); + return (jlong) new cv::Mat(); +} + + + +// +// Mat::Mat(int rows, int cols, int type) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__III + (JNIEnv* env, jclass cls, jint rows, jint cols, jint type) +{ + try { + LOGD("Mat::n_1Mat__III()"); + + Mat* _retval_ = new Mat( rows, cols, type ); + + return (jlong) _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1Mat__III() 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_1Mat__III() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1Mat__III()}"); + return 0; + } +} + + + +// +// Mat::Mat(Size size, int type) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDI + (JNIEnv* env, jclass cls, jdouble size_width, jdouble size_height, jint type) +{ + try { + LOGD("Mat::n_1Mat__DDI()"); + Size size((int)size_width, (int)size_height); + Mat* _retval_ = new Mat( size, type ); + + return (jlong) _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1Mat__DDI() 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_1Mat__DDI() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1Mat__DDI()}"); + return 0; + } +} + + + +// +// Mat::Mat(int rows, int cols, int type, Scalar s) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__IIIDDDD + (JNIEnv* env, jclass cls, jint rows, jint cols, jint type, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3) +{ + try { + LOGD("Mat::n_1Mat__IIIDDDD()"); + Scalar s(s_val0, s_val1, s_val2, s_val3); + Mat* _retval_ = new Mat( rows, cols, type, s ); + + return (jlong) _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1Mat__IIIDDDD() 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_1Mat__IIIDDDD() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1Mat__IIIDDDD()}"); + return 0; + } +} + + + +// +// Mat::Mat(Size size, int type, Scalar s) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__DDIDDDD + (JNIEnv* env, jclass cls, jdouble size_width, jdouble size_height, jint type, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3) +{ + try { + LOGD("Mat::n_1Mat__DDIDDDD()"); + Size size((int)size_width, (int)size_height); + Scalar s(s_val0, s_val1, s_val2, s_val3); + Mat* _retval_ = new Mat( size, type, s ); + + return (jlong) _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1Mat__DDIDDDD() 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_1Mat__DDIDDDD() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1Mat__DDIDDDD()}"); + return 0; + } +} + + + +// +// Mat::Mat(Mat m, Range rowRange, Range colRange = Range::all()) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__JIIII + (JNIEnv* env, jclass cls, jlong m_nativeObj, jint rowRange_start, jint rowRange_end, jint colRange_start, jint colRange_end) +{ + try { + LOGD("Mat::n_1Mat__JIIII()"); + Range rowRange(rowRange_start, rowRange_end); + Range colRange(colRange_start, colRange_end); + Mat* _retval_ = new Mat( (*(Mat*)m_nativeObj), rowRange, colRange ); + + return (jlong) _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1Mat__JIIII() 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_1Mat__JIIII() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1Mat__JIIII()}"); + return 0; + } +} + + + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1Mat__JII + (JNIEnv* env, jclass cls, jlong m_nativeObj, jint rowRange_start, jint rowRange_end) +{ + try { + LOGD("Mat::n_1Mat__JII()"); + Range rowRange(rowRange_start, rowRange_end); + Mat* _retval_ = new Mat( (*(Mat*)m_nativeObj), rowRange ); + + return (jlong) _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1Mat__JII() 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_1Mat__JII() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1Mat__JII()}"); + return 0; + } +} + + +// +// Mat Mat::adjustROI(int dtop, int dbottom, int dleft, int dright) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1adjustROI + (JNIEnv* env, jclass cls, jlong self, jint dtop, jint dbottom, jint dleft, jint dright) +{ + try { + LOGD("Mat::n_1adjustROI()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat _retval_ = me->adjustROI( dtop, dbottom, dleft, dright ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1adjustROI() 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_1adjustROI() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1adjustROI()}"); + return 0; + } +} + + + +// +// void Mat::assignTo(Mat m, int type = -1) +// + + +JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJI + (JNIEnv* env, jclass cls, jlong self, jlong m_nativeObj, jint type) +{ + try { + LOGD("Mat::n_1assignTo__JJI()"); + Mat* me = (Mat*) self; //TODO: check for NULL + me->assignTo( (*(Mat*)m_nativeObj), type ); + + return; + } catch(cv::Exception e) { + LOGD("Mat::n_1assignTo__JJI() 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; + } catch (...) { + LOGD("Mat::n_1assignTo__JJI() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1assignTo__JJI()}"); + return; + } +} + + + + +JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1assignTo__JJ + (JNIEnv* env, jclass cls, jlong self, jlong m_nativeObj) +{ + try { + LOGD("Mat::n_1assignTo__JJ()"); + Mat* me = (Mat*) self; //TODO: check for NULL + me->assignTo( (*(Mat*)m_nativeObj) ); + + return; + } catch(cv::Exception e) { + LOGD("Mat::n_1assignTo__JJ() 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; + } catch (...) { + LOGD("Mat::n_1assignTo__JJ() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1assignTo__JJ()}"); + return; + } +} + + + +// +// int Mat::channels() +// + + +JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1channels + (JNIEnv* env, jclass cls, jlong self) +{ + try { + LOGD("Mat::n_1channels()"); + Mat* me = (Mat*) self; //TODO: check for NULL + int _retval_ = me->channels( ); + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1channels() 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_1channels() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1channels()}"); + return 0; + } +} + + + +// +// int Mat::checkVector(int elemChannels, int depth = -1, bool requireContinuous = true) +// + + +JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JIIZ + (JNIEnv* env, jclass cls, jlong self, jint elemChannels, jint depth, jboolean requireContinuous) +{ + try { + LOGD("Mat::n_1checkVector__JIIZ()"); + Mat* me = (Mat*) self; //TODO: check for NULL + int _retval_ = me->checkVector( elemChannels, depth, requireContinuous ); + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1checkVector__JIIZ() 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_1checkVector__JIIZ() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1checkVector__JIIZ()}"); + return 0; + } +} + + + + +JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JII + (JNIEnv* env, jclass cls, jlong self, jint elemChannels, jint depth) +{ + try { + LOGD("Mat::n_1checkVector__JII()"); + Mat* me = (Mat*) self; //TODO: check for NULL + int _retval_ = me->checkVector( elemChannels, depth ); + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1checkVector__JII() 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_1checkVector__JII() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1checkVector__JII()}"); + return 0; + } +} + + + + +JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1checkVector__JI + (JNIEnv* env, jclass cls, jlong self, jint elemChannels) +{ + try { + LOGD("Mat::n_1checkVector__JI()"); + Mat* me = (Mat*) self; //TODO: check for NULL + int _retval_ = me->checkVector( elemChannels ); + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1checkVector__JI() 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_1checkVector__JI() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1checkVector__JI()}"); + return 0; + } +} + + + +// +// Mat Mat::clone() +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1clone + (JNIEnv* env, jclass cls, jlong self) +{ + try { + LOGD("Mat::n_1clone()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat _retval_ = me->clone( ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1clone() 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_1clone() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1clone()}"); + return 0; + } +} + + + +// +// Mat Mat::col(int x) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1col + (JNIEnv* env, jclass cls, jlong self, jint x) +{ + try { + LOGD("Mat::n_1col()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat _retval_ = me->col( x ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1col() 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_1col() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1col()}"); + return 0; + } +} + + + +// +// Mat Mat::colRange(int startcol, int endcol) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1colRange + (JNIEnv* env, jclass cls, jlong self, jint startcol, jint endcol) +{ + try { + LOGD("Mat::n_1colRange()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat _retval_ = me->colRange( startcol, endcol ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1colRange() 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_1colRange() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1colRange()}"); + return 0; + } +} + + + +// +// int Mat::cols() +// + + +JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1cols + (JNIEnv* env, jclass cls, jlong self) +{ + try { + LOGD("Mat::n_1cols()"); + Mat* me = (Mat*) self; //TODO: check for NULL + int _retval_ = me->cols; + + 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; + } +} + + + +// +// void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta = 0) +// + + +JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJIDD + (JNIEnv* env, jclass cls, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha, jdouble beta) +{ + try { + LOGD("Mat::n_1convertTo__JJIDD()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat& m = *((Mat*)m_nativeObj); + me->convertTo( m, rtype, alpha, beta ); + + return; + } catch(cv::Exception e) { + LOGD("Mat::n_1convertTo__JJIDD() 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; + } catch (...) { + LOGD("Mat::n_1convertTo__JJIDD() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1convertTo__JJIDD()}"); + return; + } +} + + + + +JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJID + (JNIEnv* env, jclass cls, jlong self, jlong m_nativeObj, jint rtype, jdouble alpha) +{ + try { + LOGD("Mat::n_1convertTo__JJID()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat& m = *((Mat*)m_nativeObj); + me->convertTo( m, rtype, alpha ); + + return; + } catch(cv::Exception e) { + LOGD("Mat::n_1convertTo__JJID() 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; + } catch (...) { + LOGD("Mat::n_1convertTo__JJID() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1convertTo__JJID()}"); + return; + } +} + + + + +JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1convertTo__JJI + (JNIEnv* env, jclass cls, jlong self, jlong m_nativeObj, jint rtype) +{ + try { + LOGD("Mat::n_1convertTo__JJI()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat& m = *((Mat*)m_nativeObj); + me->convertTo( m, rtype ); + + return; + } catch(cv::Exception e) { + LOGD("Mat::n_1convertTo__JJI() 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; + } catch (...) { + LOGD("Mat::n_1convertTo__JJI() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1convertTo__JJI()}"); + return; + } +} + + + +// +// void Mat::copyTo(Mat& m) +// + + +JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1copyTo__JJ + (JNIEnv* env, jclass cls, jlong self, jlong m_nativeObj) +{ + try { + LOGD("Mat::n_1copyTo__JJ()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat& m = *((Mat*)m_nativeObj); + me->copyTo( m ); + + return; + } catch(cv::Exception e) { + LOGD("Mat::n_1copyTo__JJ() 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; + } catch (...) { + LOGD("Mat::n_1copyTo__JJ() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1copyTo__JJ()}"); + return; + } +} + + + +// +// void Mat::copyTo(Mat& m, Mat mask) +// + + +JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1copyTo__JJJ + (JNIEnv* env, jclass cls, jlong self, jlong m_nativeObj, jlong mask_nativeObj) +{ + try { + LOGD("Mat::n_1copyTo__JJJ()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat& m = *((Mat*)m_nativeObj); + Mat& mask = *((Mat*)mask_nativeObj); + me->copyTo( m, mask ); + + return; + } catch(cv::Exception e) { + LOGD("Mat::n_1copyTo__JJJ() 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; + } catch (...) { + LOGD("Mat::n_1copyTo__JJJ() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1copyTo__JJJ()}"); + return; + } +} + + + +// +// void Mat::create(int rows, int cols, int type) +// + + +JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JIII + (JNIEnv* env, jclass cls, jlong self, jint rows, jint cols, jint type) +{ + try { + LOGD("Mat::n_1create__JIII()"); + Mat* me = (Mat*) self; //TODO: check for NULL + me->create( rows, cols, type ); + + return; + } catch(cv::Exception e) { + LOGD("Mat::n_1create__JIII() 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; + } catch (...) { + LOGD("Mat::n_1create__JIII() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1create__JIII()}"); + return; + } +} + + + +// +// void Mat::create(Size size, int type) +// + + +JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1create__JDDI + (JNIEnv* env, jclass cls, jlong self, jdouble size_width, jdouble size_height, jint type) +{ + try { + LOGD("Mat::n_1create__JDDI()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Size size((int)size_width, (int)size_height); + me->create( size, type ); + + return; + } catch(cv::Exception e) { + LOGD("Mat::n_1create__JDDI() 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; + } catch (...) { + LOGD("Mat::n_1create__JDDI() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1create__JDDI()}"); + return; + } +} + + + +// +// Mat Mat::cross(Mat m) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1cross + (JNIEnv* env, jclass cls, jlong self, jlong m_nativeObj) +{ + try { + LOGD("Mat::n_1cross()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat& m = *((Mat*)m_nativeObj); + Mat _retval_ = me->cross( m ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1cross() 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_1cross() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1cross()}"); + return 0; + } +} + + + +// +// long Mat::dataAddr() +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1dataAddr + (JNIEnv* env, jclass cls, jlong self) +{ + LOGD("Mat::n_1dataAddr()"); + Mat* me = (Mat*) self; //TODO: check for NULL + return (jlong) me->data; +} + + + +// +// int Mat::depth() +// + + +JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1depth + (JNIEnv* env, jclass cls, jlong self) +{ + try { + LOGD("Mat::n_1depth()"); + Mat* me = (Mat*) self; //TODO: check for NULL + int _retval_ = me->depth( ); + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1depth() 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_1depth() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1depth()}"); + return 0; + } +} + + + +// +// Mat Mat::diag(int d = 0) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1diag__JI + (JNIEnv* env, jclass cls, jlong self, jint d) +{ + try { + LOGD("Mat::n_1diag__JI()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat _retval_ = me->diag( d ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1diag__JI() 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_1diag__JI() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1diag__JI()}"); + return 0; + } +} + + + + +// +// static Mat Mat::diag(Mat d) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1diag__J + (JNIEnv* env, jclass cls, jlong d_nativeObj) +{ + try { + LOGD("Mat::n_1diag__J()"); + + Mat _retval_ = Mat::diag( (*(Mat*)d_nativeObj) ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1diag__J() 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_1diag__J() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1diag__J()}"); + return 0; + } +} + + + +// +// double Mat::dot(Mat m) +// + + +JNIEXPORT jdouble JNICALL Java_org_opencv_core_Mat_n_1dot + (JNIEnv* env, jclass cls, jlong self, jlong m_nativeObj) +{ + try { + LOGD("Mat::n_1dot()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat& m = *((Mat*)m_nativeObj); + double _retval_ = me->dot( m ); + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1dot() 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_1dot() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1dot()}"); + return 0; + } +} + + + +// +// size_t Mat::elemSize() +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1elemSize + (JNIEnv* env, jclass cls, jlong self) +{ + try { + LOGD("Mat::n_1elemSize()"); + Mat* me = (Mat*) self; //TODO: check for NULL + size_t _retval_ = me->elemSize( ); + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1elemSize() 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_1elemSize() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1elemSize()}"); + return 0; + } +} + + + +// +// size_t Mat::elemSize1() +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1elemSize1 + (JNIEnv* env, jclass cls, jlong self) +{ + try { + LOGD("Mat::n_1elemSize1()"); + Mat* me = (Mat*) self; //TODO: check for NULL + size_t _retval_ = me->elemSize1( ); + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1elemSize1() 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_1elemSize1() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1elemSize1()}"); + return 0; + } +} + + + +// +// bool Mat::empty() +// + + +JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1empty + (JNIEnv* env, jclass cls, jlong self) +{ + try { + LOGD("Mat::n_1empty()"); + Mat* me = (Mat*) self; //TODO: check for NULL + bool _retval_ = me->empty( ); + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1empty() 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_1empty() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1empty()}"); + return 0; + } +} + + + +// +// static Mat Mat::eye(int rows, int cols, int type) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__III + (JNIEnv* env, jclass cls, jint rows, jint cols, jint type) +{ + try { + LOGD("Mat::n_1eye__III()"); + + Mat _retval_ = Mat::eye( rows, cols, type ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1eye__III() 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_1eye__III() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1eye__III()}"); + return 0; + } +} + + + +// +// static Mat Mat::eye(Size size, int type) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1eye__DDI + (JNIEnv* env, jclass cls, jdouble size_width, jdouble size_height, jint type) +{ + try { + LOGD("Mat::n_1eye__DDI()"); + Size size((int)size_width, (int)size_height); + Mat _retval_ = Mat::eye( size, type ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1eye__DDI() 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_1eye__DDI() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1eye__DDI()}"); + return 0; + } +} + + + +// +// Mat Mat::inv(int method = DECOMP_LU) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1inv__JI + (JNIEnv* env, jclass cls, jlong self, jint method) +{ + try { + LOGD("Mat::n_1inv__JI()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat _retval_ = me->inv( method ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1inv__JI() 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_1inv__JI() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1inv__JI()}"); + return 0; + } +} + + + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1inv__J + (JNIEnv* env, jclass cls, jlong self) +{ + try { + LOGD("Mat::n_1inv__J()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat _retval_ = me->inv( ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1inv__J() 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_1inv__J() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1inv__J()}"); + return 0; + } +} + + + +// +// bool Mat::isContinuous() +// + + +JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isContinuous + (JNIEnv* env, jclass cls, jlong self) +{ + try { + LOGD("Mat::n_1isContinuous()"); + Mat* me = (Mat*) self; //TODO: check for NULL + bool _retval_ = me->isContinuous( ); + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1isContinuous() 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_1isContinuous() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1isContinuous()}"); + return 0; + } +} + + + +// +// bool Mat::isSubmatrix() +// + + +JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_n_1isSubmatrix + (JNIEnv* env, jclass cls, jlong self) +{ + try { + LOGD("Mat::n_1isSubmatrix()"); + Mat* me = (Mat*) self; //TODO: check for NULL + bool _retval_ = me->isSubmatrix( ); + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1isSubmatrix() 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_1isSubmatrix() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1isSubmatrix()}"); + return 0; + } +} + + + +// +// void Mat::locateROI(Size wholeSize, Point ofs) +// + + +JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1locateROI + (JNIEnv* env, jclass cls, jlong self, jdouble wholeSize_width, jdouble wholeSize_height, jdouble ofs_x, jdouble ofs_y) +{ + try { + LOGD("Mat::n_1locateROI()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Size wholeSize((int)wholeSize_width, (int)wholeSize_height); + Point ofs((int)ofs_x, (int)ofs_y); + me->locateROI( wholeSize, ofs ); + + return; + } catch(cv::Exception e) { + LOGD("Mat::n_1locateROI() 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; + } catch (...) { + LOGD("Mat::n_1locateROI() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1locateROI()}"); + return; + } +} + + + +// +// Mat Mat::mul(Mat m, double scale = 1) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJD + (JNIEnv* env, jclass cls, jlong self, jlong m_nativeObj, jdouble scale) +{ + try { + LOGD("Mat::n_1mul__JJD()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat& m = *((Mat*)m_nativeObj); + Mat _retval_ = me->mul( m, scale ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1mul__JJD() 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_1mul__JJD() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1mul__JJD()}"); + return 0; + } +} + + + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1mul__JJ + (JNIEnv* env, jclass cls, jlong self, jlong m_nativeObj) +{ + try { + LOGD("Mat::n_1mul__JJ()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat& m = *((Mat*)m_nativeObj); + Mat _retval_ = me->mul( m ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1mul__JJ() 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_1mul__JJ() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1mul__JJ()}"); + return 0; + } +} + + + +// +// static Mat Mat::ones(int rows, int cols, int type) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__III + (JNIEnv* env, jclass cls, jint rows, jint cols, jint type) +{ + try { + LOGD("Mat::n_1ones__III()"); + + Mat _retval_ = Mat::ones( rows, cols, type ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1ones__III() 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_1ones__III() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1ones__III()}"); + return 0; + } +} + + + +// +// static Mat Mat::ones(Size size, int type) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1ones__DDI + (JNIEnv* env, jclass cls, jdouble size_width, jdouble size_height, jint type) +{ + try { + LOGD("Mat::n_1ones__DDI()"); + Size size((int)size_width, (int)size_height); + Mat _retval_ = Mat::ones( size, type ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1ones__DDI() 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_1ones__DDI() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1ones__DDI()}"); + return 0; + } +} + + + +// +// void Mat::push_back(Mat m) +// + + +JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1push_1back + (JNIEnv* env, jclass cls, jlong self, jlong m_nativeObj) +{ + try { + LOGD("Mat::n_1push_1back()"); + Mat* me = (Mat*) self; //TODO: check for NULL + me->push_back( (*(Mat*)m_nativeObj) ); + + return; + } catch(cv::Exception e) { + LOGD("Mat::n_1push_1back() 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; + } catch (...) { + LOGD("Mat::n_1push_1back() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1push_1back()}"); + return; + } +} + + + +// +// void Mat::release() +// + + +JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1release + (JNIEnv* env, jclass cls, jlong self) +{ + try { + LOGD("Mat::n_1release()"); + Mat* me = (Mat*) self; //TODO: check for NULL + me->release( ); + + return; + } catch(cv::Exception e) { + LOGD("Mat::n_1release() 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; + } catch (...) { + LOGD("Mat::n_1release() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1release()}"); + return; + } +} + + + +// +// Mat Mat::reshape(int cn, int rows = 0) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JII + (JNIEnv* env, jclass cls, jlong self, jint cn, jint rows) +{ + try { + LOGD("Mat::n_1reshape__JII()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat _retval_ = me->reshape( cn, rows ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1reshape__JII() 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_1reshape__JII() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1reshape__JII()}"); + return 0; + } +} + + + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1reshape__JI + (JNIEnv* env, jclass cls, jlong self, jint cn) +{ + try { + LOGD("Mat::n_1reshape__JI()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat _retval_ = me->reshape( cn ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1reshape__JI() 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_1reshape__JI() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1reshape__JI()}"); + return 0; + } +} + + + +// +// Mat Mat::row(int y) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1row + (JNIEnv* env, jclass cls, jlong self, jint y) +{ + try { + LOGD("Mat::n_1row()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat _retval_ = me->row( y ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1row() 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_1row() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1row()}"); + return 0; + } +} + + + +// +// Mat Mat::rowRange(int startrow, int endrow) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1rowRange + (JNIEnv* env, jclass cls, jlong self, jint startrow, jint endrow) +{ + try { + LOGD("Mat::n_1rowRange()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat _retval_ = me->rowRange( startrow, endrow ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1rowRange() 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_1rowRange() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1rowRange()}"); + return 0; + } +} + + + +// +// int Mat::rows() +// + + +JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1rows + (JNIEnv* env, jclass cls, jlong self) +{ + try { + LOGD("Mat::n_1rows()"); + Mat* me = (Mat*) self; //TODO: check for NULL + int _retval_ = me->rows; + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1rows() 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_1rows() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1rows()}"); + return 0; + } +} -#include "opencv2/core/core.hpp" -#ifdef __cplusplus -extern "C" { -#endif +// +// Mat Mat::operator =(Scalar s) +// + -JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nType - (JNIEnv* env, jclass cls, jlong self) +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDD + (JNIEnv* env, jclass cls, jlong self, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3) { - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - return me->type( ); + try { + LOGD("Mat::n_1setTo__JDDDD()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Scalar s(s_val0, s_val1, s_val2, s_val3); + Mat _retval_ = me->operator =( s ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1setTo__JDDDD() 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_1setTo__JDDDD() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1setTo__JDDDD()}"); + return 0; + } } -JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nRows - (JNIEnv* env, jclass cls, jlong self) + + +// +// Mat Mat::setTo(Mat value, Mat mask = Mat()) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JJJ + (JNIEnv* env, jclass cls, jlong self, jlong value_nativeObj, jlong mask_nativeObj) { - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - return me->rows; + try { + LOGD("Mat::n_1setTo__JJJ()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat& value = *((Mat*)value_nativeObj); + Mat& mask = *((Mat*)mask_nativeObj); + Mat _retval_ = me->setTo( value, mask ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1setTo__JJJ() 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_1setTo__JJJ() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1setTo__JJJ()}"); + return 0; + } } -JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nCols - (JNIEnv* env, jclass cls, jlong self) + + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JJ + (JNIEnv* env, jclass cls, jlong self, jlong value_nativeObj) { - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - return me->cols; + try { + LOGD("Mat::n_1setTo__JJ()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat& value = *((Mat*)value_nativeObj); + Mat _retval_ = me->setTo( value ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1setTo__JJ() 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_1setTo__JJ() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1setTo__JJ()}"); + return 0; + } } -JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nData - (JNIEnv* env, jclass cls, jlong self) + + +// +// Size Mat::size() +// + + +JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_n_1size + (JNIEnv* env, jclass cls, jlong self) { - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - return (jlong) me->data; + try { + LOGD("Mat::n_1size()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Size _retval_ = me->size( ); + jdoubleArray _da_retval_ = env->NewDoubleArray(2); jdouble _tmp_retval_[2] = {_retval_.width, _retval_.height}; env->SetDoubleArrayRegion(_da_retval_, 0, 2, _tmp_retval_); + return _da_retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1size() 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_1size() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1size()}"); + return 0; + } } -JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_nIsEmpty - (JNIEnv* env, jclass cls, jlong self) + + +// +// size_t Mat::step1(int i = 0) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1step1__JI + (JNIEnv* env, jclass cls, jlong self, jint i) { - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - return me->empty(); + try { + LOGD("Mat::n_1step1__JI()"); + Mat* me = (Mat*) self; //TODO: check for NULL + size_t _retval_ = me->step1( i ); + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1step1__JI() 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_1step1__JI() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1step1__JI()}"); + return 0; + } } -JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nSize - (JNIEnv* env, jclass cls, jlong self) + + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1step1__J + (JNIEnv* env, jclass cls, jlong self) { try { -#ifdef DEBUG - LOGD("core::Mat::nSize()"); -#endif // DEBUG - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - cv::Size _retval_ = me->size(); - - jdoubleArray _da_retval_ = env->NewDoubleArray(2); - jdouble _tmp_retval_[4] = {_retval_.width, _retval_.height}; - env->SetDoubleArrayRegion(_da_retval_, 0, 2, _tmp_retval_); - return _da_retval_; + LOGD("Mat::n_1step1__J()"); + Mat* me = (Mat*) self; //TODO: check for NULL + size_t _retval_ = me->step1( ); + + return _retval_; } catch(cv::Exception e) { -#ifdef DEBUG - LOGD("core::Mat::nSize() catched cv::Exception: %s", e.what()); -#endif // DEBUG + LOGD("Mat::n_1step1__J() 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 (...) { -#ifdef DEBUG - LOGD("core::Mat::nSize() catched unknown exception (...)"); -#endif // DEBUG + LOGD("Mat::n_1step1__J() catched unknown exception (...)"); jclass je = env->FindClass("java/lang/Exception"); - env->ThrowNew(je, "Unknown exception in JNI code {core::n_1mean__JJ()}"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1step1__J()}"); return 0; } } -JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_nIsCont - (JNIEnv* env, jclass cls, jlong self) +// +// Mat Mat::operator()(Range rowRange, Range colRange) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1submat_1rr + (JNIEnv* env, jclass cls, jlong self, jint rowRange_start, jint rowRange_end, jint colRange_start, jint colRange_end) { - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - return me->isContinuous(); + try { + LOGD("Mat::n_1submat_1rr()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Range rowRange(rowRange_start, rowRange_end); + Range colRange(colRange_start, colRange_end); + Mat _retval_ = me->operator()( rowRange, colRange ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1submat_1rr() 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_1submat_1rr() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1submat_1rr()}"); + return 0; + } } -JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_nIsSubmat - (JNIEnv* env, jclass cls, jlong self) + + +// +// Mat Mat::operator()(Rect roi) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1submat + (JNIEnv* env, jclass cls, jlong self, jint roi_x, jint roi_y, jint roi_width, jint roi_height) { - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - return me->isSubmatrix(); + try { + LOGD("Mat::n_1submat()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Rect roi(roi_x, roi_y, roi_width, roi_height); + Mat _retval_ = me->operator()( roi ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1submat() 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_1submat() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1submat()}"); + return 0; + } } -JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nSubmat - (JNIEnv* env, jclass cls, jlong self, jint r1, jint r2, jint c1, jint c2) + + +// +// Mat Mat::t() +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1t + (JNIEnv* env, jclass cls, jlong self) { - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - return (jlong) new cv::Mat(*me, cv::Range(r1, r2>0 ? r2 : me->rows), cv::Range(c1, c2>0 ? c2 : me->cols)); + try { + LOGD("Mat::n_1t()"); + Mat* me = (Mat*) self; //TODO: check for NULL + Mat _retval_ = me->t( ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1t() 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_1t() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1t()}"); + return 0; + } } -JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nClone - (JNIEnv* env, jclass cls, jlong self) + + +// +// size_t Mat::total() +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1total + (JNIEnv* env, jclass cls, jlong self) { - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - cv::Mat* it = new cv::Mat(); - me->copyTo(*it); - return (jlong) it; + try { + LOGD("Mat::n_1total()"); + Mat* me = (Mat*) self; //TODO: check for NULL + size_t _retval_ = me->total( ); + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1total() 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_1total() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1total()}"); + return 0; + } +} + + + +// +// int Mat::type() +// + + +JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1type + (JNIEnv* env, jclass cls, jlong self) +{ + try { + LOGD("Mat::n_1type()"); + Mat* me = (Mat*) self; //TODO: check for NULL + int _retval_ = me->type( ); + + return _retval_; + } catch(cv::Exception e) { + LOGD("Mat::n_1type() 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_1type() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1type()}"); + return 0; + } +} + + + +// +// static Mat Mat::zeros(int rows, int cols, int type) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__III + (JNIEnv* env, jclass cls, jint rows, jint cols, jint type) +{ + try { + LOGD("Mat::n_1zeros__III()"); + + Mat _retval_ = Mat::zeros( rows, cols, type ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1zeros__III() 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_1zeros__III() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1zeros__III()}"); + return 0; + } +} + + + +// +// static Mat Mat::zeros(Size size, int type) +// + + +JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1zeros__DDI + (JNIEnv* env, jclass cls, jdouble size_width, jdouble size_height, jint type) +{ + try { + LOGD("Mat::n_1zeros__DDI()"); + Size size((int)size_width, (int)size_height); + Mat _retval_ = Mat::zeros( size, type ); + + return (jlong) new Mat(_retval_); + } catch(cv::Exception e) { + LOGD("Mat::n_1zeros__DDI() 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_1zeros__DDI() catched unknown exception (...)"); + jclass je = env->FindClass("java/lang/Exception"); + env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1zeros__DDI()}"); + return 0; + } +} + + + +// +// native support for java finalize() +// static void Mat::n_delete( __int64 self ) +// + +JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1delete + (JNIEnv* env, jclass cls, jlong self) +{ + delete (Mat*) self; } // unlike other nPut()-s this one (with double[]) should convert input values to correct type @@ -157,9 +1971,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD } -#ifdef __cplusplus -} -#endif +} // extern "C" template static int mat_put(cv::Mat* m, int row, int col, int count, char* buff) { @@ -192,9 +2004,7 @@ template static int mat_put(cv::Mat* m, int row, int col, int count, } -#ifdef __cplusplus extern "C" { -#endif JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutB (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jbyteArray vals) @@ -253,10 +2063,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutF } -#ifdef __cplusplus -} -#endif - +} // extern "C" template int mat_get(cv::Mat* m, int row, int col, int count, char* buff) { @@ -288,10 +2095,7 @@ template int mat_get(cv::Mat* m, int row, int col, int count, char* return res; } -#ifdef __cplusplus extern "C" { -#endif - JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetB (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jbyteArray vals) @@ -388,63 +2192,6 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet return res; } -JNIEXPORT void JNICALL Java_org_opencv_core_Mat_nSetTo - (JNIEnv* env, jclass cls, jlong self, jdouble v0, jdouble v1, jdouble v2, jdouble v3) -{ - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - me->setTo( cv::Scalar(v0, v1, v2, v3) ); -} - -JNIEXPORT void JNICALL Java_org_opencv_core_Mat_nCopyTo - (JNIEnv* env, jclass cls, jlong self, jlong m) -{ - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - cv::Mat* _m = (cv::Mat*) m; //TODO: check for NULL - me->copyTo( *_m ); -} - -JNIEXPORT jdouble JNICALL Java_org_opencv_core_Mat_nDot - (JNIEnv* env, jclass cls, jlong self, jlong m) -{ - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - cv::Mat* _m = (cv::Mat*) m; //TODO: check for NULL - return me->dot( *_m ); -} - -JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nCross - (JNIEnv* env, jclass cls, jlong self, jlong m) -{ - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - cv::Mat* _m = (cv::Mat*) m; //TODO: check for NULL - return (jlong) new cv::Mat(me->cross( *_m )); -} - -JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nInv - (JNIEnv* env, jclass cls, jlong self) -{ - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - return (jlong) new cv::Mat(me->inv()); -} - -JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nReshape - (JNIEnv* env, jclass cls, jlong self, jint cn, jint rows) -{ - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - return (jlong) new cv::Mat(me->reshape(cn, rows)); -} - -JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nCreateMat__ - (JNIEnv* env, jclass cls) -{ - return (jlong) new cv::Mat(); -} - -JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nEye - (JNIEnv* env, jclass cls, jint _rows, jint _cols, jint _type) -{ - return (jlong) new cv::Mat(cv::Mat::eye( _rows, _cols, _type )); -} - JNIEXPORT jstring JNICALL Java_org_opencv_core_Mat_nDump (JNIEnv *env, jclass cls, jlong self) { @@ -454,33 +2201,5 @@ JNIEXPORT jstring JNICALL Java_org_opencv_core_Mat_nDump return env->NewStringUTF(s.str().c_str()); } -JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nCreateMat__III - (JNIEnv* env, jclass cls, jint _rows, jint _cols, jint _type) -{ - //LOGD("called with r=%d, c=%d", _rows, _cols); - return (jlong) new cv::Mat( _rows, _cols, _type );; -} - -JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nCreateMat__IIIDDDD - (JNIEnv* env, jclass cls, jint _rows, jint _cols, jint _type, jdouble v0, jdouble v1, jdouble v2, jdouble v3) -{ - return (jlong) new cv::Mat( _rows, _cols, _type, cv::Scalar(v0, v1, v2, v3) ); -} - -JNIEXPORT void JNICALL Java_org_opencv_core_Mat_nDelete - (JNIEnv* env, jclass cls, jlong self) -{ - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - delete me; -} - -JNIEXPORT void JNICALL Java_org_opencv_core_Mat_nRelease - (JNIEnv* env, jclass cls, jlong self) -{ - cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL - me->release(); -} -#ifdef __cplusplus -} -#endif +} // extern "C" diff --git a/modules/java/src/java/core+Mat.java b/modules/java/src/java/core+Mat.java index 84b4d52ca2..cdd4757d7c 100644 --- a/modules/java/src/java/core+Mat.java +++ b/modules/java/src/java/core+Mat.java @@ -1,164 +1,960 @@ package org.opencv.core; -//javadoc:Mat +// C++: class Mat +//javadoc: Mat public class Mat { - - public Mat(long nativeMat) { - if(nativeMat == 0) + public final long nativeObj; + public Mat(long addr) + { + if(addr == 0) throw new java.lang.UnsupportedOperationException("Native object address is NULL"); - this.nativeObj = nativeMat; + nativeObj = addr; } - - //javadoc:Mat::Mat() - public Mat() { - this( nCreateMat() ); + + + // + // C++: Mat::Mat() + // + + //javadoc: Mat::Mat() + public Mat() + { + + nativeObj = n_Mat(); + + return; } - //javadoc:Mat::Mat(rows,cols,type) - public Mat(int rows, int cols, int type) { - this( nCreateMat(rows, cols, type) ); + + // + // C++: Mat::Mat(int rows, int cols, int type) + // + + //javadoc: Mat::Mat(rows, cols, type) + public Mat(int rows, int cols, int type) + { + + nativeObj = n_Mat(rows, cols, type); + + return; } - //javadoc:Mat::Mat(rows,cols,type,s) - public Mat(int rows, int cols, int type, Scalar s) { - this( nCreateMat(rows, cols, type, s.val[0], s.val[1], s.val[2], s.val[3]) ); + + // + // C++: Mat::Mat(Size size, int type) + // + + //javadoc: Mat::Mat(size, type) + public Mat(Size size, int type) + { + + nativeObj = n_Mat(size.width, size.height, type); + + return; } - //javadoc:Mat::eye(rows,cols,type) - public static Mat eye(int rows, int cols, int type) { - return new Mat( nEye(rows, cols, type) ); + + // + // C++: Mat::Mat(int rows, int cols, int type, Scalar s) + // + + //javadoc: Mat::Mat(rows, cols, type, s) + public Mat(int rows, int cols, int type, Scalar s) + { + + nativeObj = n_Mat(rows, cols, type, s.val[0], s.val[1], s.val[2], s.val[3]); + + return; } - - //javadoc:Mat::release() - public void release() { - nRelease(nativeObj); + + + // + // C++: Mat::Mat(Size size, int type, Scalar s) + // + + //javadoc: Mat::Mat(size, type, s) + public Mat(Size size, int type, Scalar s) + { + + nativeObj = n_Mat(size.width, size.height, type, s.val[0], s.val[1], s.val[2], s.val[3]); + + return; } - - //javadoc:Mat::finalize() - @Override - protected void finalize() throws Throwable { - nDelete(nativeObj); - super.finalize(); + + + // + // C++: Mat::Mat(Mat m, Range rowRange, Range colRange = Range::all()) + // + + //javadoc: Mat::Mat(m, rowRange, colRange) + public Mat(Mat m, Range rowRange, Range colRange) + { + + nativeObj = n_Mat(m.nativeObj, rowRange.start, rowRange.end, colRange.start, colRange.end); + + return; } - //javadoc:Mat::toString() - @Override - public String toString() { - return "Mat [ " + - rows() + "*" + cols() + "*" + CvType.typeToString(type()) + - ", isCont=" + isContinuous() + ", isSubmat=" + isSubmatrix() + - ", nativeObj=0x" + Long.toHexString(nativeObj) + - ", dataAddr=0x" + Long.toHexString(dataAddr()) + - " ]"; + //javadoc: Mat::Mat(m, rowRange) + public Mat(Mat m, Range rowRange) + { + + nativeObj = n_Mat(m.nativeObj, rowRange.start, rowRange.end); + + return; } - //javadoc:Mat::dump() - public String dump() { - return nDump(nativeObj); + + // + // C++: Mat::Mat(Mat m, Rect roi) + // + + //javadoc: Mat::Mat(m, roi) + public Mat(Mat m, Rect roi) + { + + nativeObj = n_Mat(m.nativeObj, roi.x, roi.y, roi.width, roi.height); + + return; } - - //javadoc:Mat::empty() - public boolean empty() { - if(nativeObj == 0) return true; - return nIsEmpty(nativeObj); + + + // + // C++: Mat Mat::adjustROI(int dtop, int dbottom, int dleft, int dright) + // + + //javadoc: Mat::adjustROI(dtop, dbottom, dleft, dright) + public Mat adjustROI(int dtop, int dbottom, int dleft, int dright) + { + + Mat retVal = new Mat(n_adjustROI(nativeObj, dtop, dbottom, dleft, dright)); + + return retVal; } - //javadoc:Mat::size() - public Size size() { - return new Size(nSize(nativeObj)); + + // + // C++: void Mat::assignTo(Mat m, int type = -1) + // + + //javadoc: Mat::assignTo(m, type) + public void assignTo(Mat m, int type) + { + + n_assignTo(nativeObj, m.nativeObj, type); + + return; } - //javadoc:Mat::type() - public int type() { - return nType(nativeObj); + //javadoc: Mat::assignTo(m) + public void assignTo(Mat m) + { + + n_assignTo(nativeObj, m.nativeObj); + + return; } - //javadoc:Mat::depth() - public int depth() { - return CvType.depth(type()); + + // + // C++: int Mat::channels() + // + + //javadoc: Mat::channels() + public int channels() + { + + int retVal = n_channels(nativeObj); + + return retVal; } - //javadoc:Mat::channels() - public int channels() { - return CvType.channels(type()); + + // + // C++: int Mat::checkVector(int elemChannels, int depth = -1, bool requireContinuous = true) + // + + //javadoc: Mat::checkVector(elemChannels, depth, requireContinuous) + public int checkVector(int elemChannels, int depth, boolean requireContinuous) + { + + int retVal = n_checkVector(nativeObj, elemChannels, depth, requireContinuous); + + return retVal; } - //javadoc:Mat::elemSize() - public int elemSize() { - return CvType.ELEM_SIZE(type()); + //javadoc: Mat::checkVector(elemChannels, depth) + public int checkVector(int elemChannels, int depth) + { + + int retVal = n_checkVector(nativeObj, elemChannels, depth); + + return retVal; } - //javadoc:Mat::rows() - public int rows() { - return nRows(nativeObj); + //javadoc: Mat::checkVector(elemChannels) + public int checkVector(int elemChannels) + { + + int retVal = n_checkVector(nativeObj, elemChannels); + + return retVal; } - //javadoc:Mat::height() - public int height() { - return rows(); + + // + // C++: Mat Mat::clone() + // + + //javadoc: Mat::clone() + public Mat clone() + { + + Mat retVal = new Mat(n_clone(nativeObj)); + + return retVal; } - //javadoc:Mat::cols() - public int cols() { - return nCols(nativeObj); + + // + // C++: Mat Mat::col(int x) + // + + //javadoc: Mat::col(x) + public Mat col(int x) + { + + Mat retVal = new Mat(n_col(nativeObj, x)); + + return retVal; } - //javadoc:Mat::width() - public int width() { - return cols(); + + // + // C++: Mat Mat::colRange(int startcol, int endcol) + // + + //javadoc: Mat::colRange(startcol, endcol) + public Mat colRange(int startcol, int endcol) + { + + Mat retVal = new Mat(n_colRange(nativeObj, startcol, endcol)); + + return retVal; } - //javadoc:Mat::total() - public int total() { - return rows() * cols(); + + // + // C++: Mat Mat::colRange(Range r) + // + + //javadoc: Mat::colRange(r) + public Mat colRange(Range r) + { + + Mat retVal = new Mat(n_colRange(nativeObj, r.start, r.end)); + + return retVal; } - //javadoc:Mat::dataAddr() - public long dataAddr() { - return nData(nativeObj); + + // + // C++: int Mat::cols() + // + + //javadoc: Mat::cols() + public int cols() + { + + int retVal = n_cols(nativeObj); + + return retVal; } - //javadoc:Mat::isContinuous() - public boolean isContinuous() { - return nIsCont(nativeObj); + + // + // C++: void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta = 0) + // + + //javadoc: Mat::convertTo(m, rtype, alpha, beta) + public void convertTo(Mat m, int rtype, double alpha, double beta) + { + + n_convertTo(nativeObj, m.nativeObj, rtype, alpha, beta); + + return; + } + + //javadoc: Mat::convertTo(m, rtype, alpha) + public void convertTo(Mat m, int rtype, double alpha) + { + + n_convertTo(nativeObj, m.nativeObj, rtype, alpha); + + return; + } + + //javadoc: Mat::convertTo(m, rtype) + public void convertTo(Mat m, int rtype) + { + + n_convertTo(nativeObj, m.nativeObj, rtype); + + return; } - //javadoc:Mat::isSubmatrix() - public boolean isSubmatrix() { - return nIsSubmat(nativeObj); + + // + // C++: void Mat::copyTo(Mat& m) + // + + //javadoc: Mat::copyTo(m) + public void copyTo(Mat m) + { + + n_copyTo(nativeObj, m.nativeObj); + + return; } - //javadoc:Mat::submat(rowStart,rowEnd,colStart,colEnd) - public Mat submat(int rowStart, int rowEnd, int colStart, int colEnd) { - return new Mat( nSubmat(nativeObj, rowStart, rowEnd, colStart, colEnd) ); + + // + // C++: void Mat::copyTo(Mat& m, Mat mask) + // + + //javadoc: Mat::copyTo(m, mask) + public void copyTo(Mat m, Mat mask) + { + + n_copyTo(nativeObj, m.nativeObj, mask.nativeObj); + + return; } - //javadoc:Mat::rowRange(startrow,endrow) - public Mat rowRange(int startrow, int endrow) { - return submat(startrow, endrow, 0, -1); + + // + // C++: void Mat::create(int rows, int cols, int type) + // + + //javadoc: Mat::create(rows, cols, type) + public void create(int rows, int cols, int type) + { + + n_create(nativeObj, rows, cols, type); + + return; } - //javadoc:Mat::row(i) - public Mat row(int i) { - return submat(i, i+1, 0, -1); + + // + // C++: void Mat::create(Size size, int type) + // + + //javadoc: Mat::create(size, type) + public void create(Size size, int type) + { + + n_create(nativeObj, size.width, size.height, type); + + return; } - //javadoc:Mat::colRange(startcol,endcol) - public Mat colRange(int startcol, int endcol) { - return submat(0, -1, startcol, endcol); + + // + // C++: Mat Mat::cross(Mat m) + // + + //javadoc: Mat::cross(m) + public Mat cross(Mat m) + { + + Mat retVal = new Mat(n_cross(nativeObj, m.nativeObj)); + + return retVal; } - //javadoc:Mat::col(j) - public Mat col(int j) { - return submat(0, -1, j, j+1); + + // + // C++: long Mat::dataAddr() + // + + //javadoc: Mat::dataAddr() + public long dataAddr() + { + + long retVal = n_dataAddr(nativeObj); + + return retVal; } - - //javadoc:Mat::clone() - public Mat clone() { - return new Mat( nClone(nativeObj) ); + + + // + // C++: int Mat::depth() + // + + //javadoc: Mat::depth() + public int depth() + { + + int retVal = n_depth(nativeObj); + + return retVal; + } + + + // + // C++: Mat Mat::diag(int d = 0) + // + + //javadoc: Mat::diag(d) + public Mat diag(int d) + { + + Mat retVal = new Mat(n_diag(nativeObj, d)); + + return retVal; + } + + //javadoc: Mat::diag() + public Mat diag() + { + + Mat retVal = new Mat(n_diag(nativeObj, 0)); + + return retVal; + } + + + // + // C++: static Mat Mat::diag(Mat d) + // + + //javadoc: Mat::diag(d) + public static Mat diag(Mat d) + { + + Mat retVal = new Mat(n_diag(d.nativeObj)); + + return retVal; + } + + + // + // C++: double Mat::dot(Mat m) + // + + //javadoc: Mat::dot(m) + public double dot(Mat m) + { + + double retVal = n_dot(nativeObj, m.nativeObj); + + return retVal; + } + + + // + // C++: size_t Mat::elemSize() + // + + //javadoc: Mat::elemSize() + public long elemSize() + { + + long retVal = n_elemSize(nativeObj); + + return retVal; + } + + + // + // C++: size_t Mat::elemSize1() + // + + //javadoc: Mat::elemSize1() + public long elemSize1() + { + + long retVal = n_elemSize1(nativeObj); + + return retVal; + } + + + // + // C++: bool Mat::empty() + // + + //javadoc: Mat::empty() + public boolean empty() + { + + boolean retVal = n_empty(nativeObj); + + return retVal; + } + + + // + // C++: static Mat Mat::eye(int rows, int cols, int type) + // + + //javadoc: Mat::eye(rows, cols, type) + public static Mat eye(int rows, int cols, int type) + { + + Mat retVal = new Mat(n_eye(rows, cols, type)); + + return retVal; + } + + + // + // C++: static Mat Mat::eye(Size size, int type) + // + + //javadoc: Mat::eye(size, type) + public static Mat eye(Size size, int type) + { + + Mat retVal = new Mat(n_eye(size.width, size.height, type)); + + return retVal; + } + + + // + // C++: Mat Mat::inv(int method = DECOMP_LU) + // + + //javadoc: Mat::inv(method) + public Mat inv(int method) + { + + Mat retVal = new Mat(n_inv(nativeObj, method)); + + return retVal; + } + + //javadoc: Mat::inv() + public Mat inv() + { + + Mat retVal = new Mat(n_inv(nativeObj)); + + return retVal; + } + + + // + // C++: bool Mat::isContinuous() + // + + //javadoc: Mat::isContinuous() + public boolean isContinuous() + { + + boolean retVal = n_isContinuous(nativeObj); + + return retVal; + } + + + // + // C++: bool Mat::isSubmatrix() + // + + //javadoc: Mat::isSubmatrix() + public boolean isSubmatrix() + { + + boolean retVal = n_isSubmatrix(nativeObj); + + return retVal; + } + + + // + // C++: void Mat::locateROI(Size wholeSize, Point ofs) + // + + //javadoc: Mat::locateROI(wholeSize, ofs) + public void locateROI(Size wholeSize, Point ofs) + { + + n_locateROI(nativeObj, wholeSize.width, wholeSize.height, ofs.x, ofs.y); + + return; + } + + + // + // C++: Mat Mat::mul(Mat m, double scale = 1) + // + + //javadoc: Mat::mul(m, scale) + public Mat mul(Mat m, double scale) + { + + Mat retVal = new Mat(n_mul(nativeObj, m.nativeObj, scale)); + + return retVal; + } + + //javadoc: Mat::mul(m) + public Mat mul(Mat m) + { + + Mat retVal = new Mat(n_mul(nativeObj, m.nativeObj)); + + return retVal; + } + + + // + // C++: static Mat Mat::ones(int rows, int cols, int type) + // + + //javadoc: Mat::ones(rows, cols, type) + public static Mat ones(int rows, int cols, int type) + { + + Mat retVal = new Mat(n_ones(rows, cols, type)); + + return retVal; + } + + + // + // C++: static Mat Mat::ones(Size size, int type) + // + + //javadoc: Mat::ones(size, type) + public static Mat ones(Size size, int type) + { + + Mat retVal = new Mat(n_ones(size.width, size.height, type)); + + return retVal; + } + + + // + // C++: void Mat::push_back(Mat m) + // + + //javadoc: Mat::push_back(m) + public void push_back(Mat m) + { + + n_push_back(nativeObj, m.nativeObj); + + return; + } + + + // + // C++: void Mat::release() + // + + //javadoc: Mat::release() + public void release() + { + + n_release(nativeObj); + + return; + } + + + // + // C++: Mat Mat::reshape(int cn, int rows = 0) + // + + //javadoc: Mat::reshape(cn, rows) + public Mat reshape(int cn, int rows) + { + + Mat retVal = new Mat(n_reshape(nativeObj, cn, rows)); + + return retVal; + } + + //javadoc: Mat::reshape(cn) + public Mat reshape(int cn) + { + + Mat retVal = new Mat(n_reshape(nativeObj, cn)); + + return retVal; } + + // + // C++: Mat Mat::row(int y) + // + + //javadoc: Mat::row(y) + public Mat row(int y) + { + + Mat retVal = new Mat(n_row(nativeObj, y)); + + return retVal; + } + + + // + // C++: Mat Mat::rowRange(int startrow, int endrow) + // + + //javadoc: Mat::rowRange(startrow, endrow) + public Mat rowRange(int startrow, int endrow) + { + + Mat retVal = new Mat(n_rowRange(nativeObj, startrow, endrow)); + + return retVal; + } + + + // + // C++: Mat Mat::rowRange(Range r) + // + + //javadoc: Mat::rowRange(r) + public Mat rowRange(Range r) + { + + Mat retVal = new Mat(n_rowRange(nativeObj, r.start, r.end)); + + return retVal; + } + + + // + // C++: int Mat::rows() + // + + //javadoc: Mat::rows() + public int rows() + { + + int retVal = n_rows(nativeObj); + + return retVal; + } + + + // + // C++: Mat Mat::operator =(Scalar s) + // + + //javadoc: Mat::operator =(s) + public Mat setTo(Scalar s) + { + + Mat retVal = new Mat(n_setTo(nativeObj, s.val[0], s.val[1], s.val[2], s.val[3])); + + return retVal; + } + + + // + // C++: Mat Mat::setTo(Mat value, Mat mask = Mat()) + // + + //javadoc: Mat::setTo(value, mask) + public Mat setTo(Mat value, Mat mask) + { + + Mat retVal = new Mat(n_setTo(nativeObj, value.nativeObj, mask.nativeObj)); + + return retVal; + } + + //javadoc: Mat::setTo(value) + public Mat setTo(Mat value) + { + + Mat retVal = new Mat(n_setTo(nativeObj, value.nativeObj)); + + return retVal; + } + + + // + // C++: Size Mat::size() + // + + //javadoc: Mat::size() + public Size size() + { + + Size retVal = new Size(n_size(nativeObj)); + + return retVal; + } + + + // + // C++: size_t Mat::step1(int i = 0) + // + + //javadoc: Mat::step1(i) + public long step1(int i) + { + + long retVal = n_step1(nativeObj, i); + + return retVal; + } + + //javadoc: Mat::step1() + public long step1() + { + + long retVal = n_step1(nativeObj); + + return retVal; + } + + + // + // C++: Mat Mat::operator()(int rowStart, int rowEnd, int colStart, int colEnd) + // + + //javadoc: Mat::operator()(rowStart, rowEnd, colStart, colEnd) + public Mat submat(int rowStart, int rowEnd, int colStart, int colEnd) + { + + Mat retVal = new Mat(n_submat_rr(nativeObj, rowStart, rowEnd, colStart, colEnd)); + + return retVal; + } + + + // + // C++: Mat Mat::operator()(Range rowRange, Range colRange) + // + + //javadoc: Mat::operator()(rowRange, colRange) + public Mat submat(Range rowRange, Range colRange) + { + + Mat retVal = new Mat(n_submat_rr(nativeObj, rowRange.start, rowRange.end, colRange.start, colRange.end)); + + return retVal; + } + + + // + // C++: Mat Mat::operator()(Rect roi) + // + + //javadoc: Mat::operator()(roi) + public Mat submat(Rect roi) + { + + Mat retVal = new Mat(n_submat(nativeObj, roi.x, roi.y, roi.width, roi.height)); + + return retVal; + } + + + // + // C++: Mat Mat::t() + // + + //javadoc: Mat::t() + public Mat t() + { + + Mat retVal = new Mat(n_t(nativeObj)); + + return retVal; + } + + + // + // C++: size_t Mat::total() + // + + //javadoc: Mat::total() + public long total() + { + + long retVal = n_total(nativeObj); + + return retVal; + } + + + // + // C++: int Mat::type() + // + + //javadoc: Mat::type() + public int type() + { + + int retVal = n_type(nativeObj); + + return retVal; + } + + + // + // C++: static Mat Mat::zeros(int rows, int cols, int type) + // + + //javadoc: Mat::zeros(rows, cols, type) + public static Mat zeros(int rows, int cols, int type) + { + + Mat retVal = new Mat(n_zeros(rows, cols, type)); + + return retVal; + } + + + // + // C++: static Mat Mat::zeros(Size size, int type) + // + + //javadoc: Mat::zeros(size, type) + public static Mat zeros(Size size, int type) + { + + Mat retVal = new Mat(n_zeros(size.width, size.height, type)); + + return retVal; + } + + + @Override + protected void finalize() throws Throwable { + n_delete(nativeObj); + super.finalize(); + } + + //javadoc:Mat::toString() + @Override + public String toString() { + return "Mat [ " + + rows() + "*" + cols() + "*" + CvType.typeToString(type()) + + ", isCont=" + isContinuous() + ", isSubmat=" + isSubmatrix() + + ", nativeObj=0x" + Long.toHexString(nativeObj) + + ", dataAddr=0x" + Long.toHexString(dataAddr()) + + " ]"; + } + + //javadoc:Mat::dump() + public String dump() { + return nDump(nativeObj); + } + //javadoc:Mat::put(row,col,data) public int put(int row, int col, double...data) { return nPutD(nativeObj, row, col, data.length, data); @@ -250,65 +1046,204 @@ public class Mat { return nGet(nativeObj, row, col); } - - //javadoc:Mat::setTo(s) - public void setTo(Scalar s) { - nSetTo(nativeObj, s.val[0], s.val[1], s.val[2], s.val[3]); - } - - //javadoc:Mat::copyTo(m) - public void copyTo(Mat m) { - nCopyTo(nativeObj, m.nativeObj); - } - - //javadoc:Mat::dot(m) - public double dot(Mat m) { - return nDot(nativeObj, m.nativeObj); - } - - //javadoc:Mat::cross(m) - public Mat cross(Mat m) { - return new Mat( nCross(nativeObj, m.nativeObj) ); + //javadoc:Mat::height() + public int height() { + return rows(); } - - //javadoc:Mat::inv() - public Mat inv() { - return new Mat( nInv(nativeObj) ); + + //javadoc:Mat::width() + public int width() { + return cols(); } - //javadoc:Mat::reshape(cn) - public Mat reshape(int cn) { - return new Mat( nReshape(nativeObj, cn, 0) ); - } - - //javadoc:Mat::reshape(cn, rows) - public Mat reshape(int cn, int rows) { - return new Mat( nReshape(nativeObj, cn, rows) ); - } - //javadoc:Mat::getNativeObjAddr() public long getNativeObjAddr() { return nativeObj; } - + + + // // native stuff + // static { System.loadLibrary("opencv_java"); } - public final long nativeObj; - private static native long nCreateMat(); - private static native long nCreateMat(int rows, int cols, int type); - private static native long nCreateMat(int rows, int cols, int type, double v0, double v1, double v2, double v3); - private static native void nRelease(long self); - private static native void nDelete(long self); - private static native int nType(long self); - private static native int nRows(long self); - private static native int nCols(long self); - private static native long nData(long self); - private static native boolean nIsEmpty(long self); - private static native boolean nIsCont(long self); - private static native boolean nIsSubmat(long self); - private static native double[] nSize(long self); - private static native long nSubmat(long self, int rowStart, int rowEnd, int colStart, int colEnd); - private static native long nClone(long self); + + // C++: Mat::Mat() + private static native long n_Mat(); + + // C++: Mat::Mat(int rows, int cols, int type) + private static native long n_Mat(int rows, int cols, int type); + + // C++: Mat::Mat(Size size, int type) + private static native long n_Mat(double size_width, double size_height, int type); + + // C++: Mat::Mat(int rows, int cols, int type, Scalar s) + private static native long n_Mat(int rows, int cols, int type, double s_val0, double s_val1, double s_val2, double s_val3); + + // C++: Mat::Mat(Size size, int type, Scalar s) + private static native long n_Mat(double size_width, double size_height, int type, double s_val0, double s_val1, double s_val2, double s_val3); + + // C++: Mat::Mat(Mat m, Range rowRange, Range colRange = Range::all()) + private static native long n_Mat(long m_nativeObj, int rowRange_start, int rowRange_end, int colRange_start, int colRange_end); + private static native long n_Mat(long m_nativeObj, int rowRange_start, int rowRange_end); + + // C++: Mat Mat::adjustROI(int dtop, int dbottom, int dleft, int dright) + private static native long n_adjustROI(long nativeObj, int dtop, int dbottom, int dleft, int dright); + + // C++: void Mat::assignTo(Mat m, int type = -1) + private static native void n_assignTo(long nativeObj, long m_nativeObj, int type); + private static native void n_assignTo(long nativeObj, long m_nativeObj); + + // C++: int Mat::channels() + private static native int n_channels(long nativeObj); + + // C++: int Mat::checkVector(int elemChannels, int depth = -1, bool requireContinuous = true) + private static native int n_checkVector(long nativeObj, int elemChannels, int depth, boolean requireContinuous); + private static native int n_checkVector(long nativeObj, int elemChannels, int depth); + private static native int n_checkVector(long nativeObj, int elemChannels); + + // C++: Mat Mat::clone() + private static native long n_clone(long nativeObj); + + // C++: Mat Mat::col(int x) + private static native long n_col(long nativeObj, int x); + + // C++: Mat Mat::colRange(int startcol, int endcol) + private static native long n_colRange(long nativeObj, int startcol, int endcol); + + // C++: int Mat::cols() + private static native int n_cols(long nativeObj); + + // C++: void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta = 0) + private static native void n_convertTo(long nativeObj, long m_nativeObj, int rtype, double alpha, double beta); + private static native void n_convertTo(long nativeObj, long m_nativeObj, int rtype, double alpha); + private static native void n_convertTo(long nativeObj, long m_nativeObj, int rtype); + + // C++: void Mat::copyTo(Mat& m) + private static native void n_copyTo(long nativeObj, long m_nativeObj); + + // C++: void Mat::copyTo(Mat& m, Mat mask) + private static native void n_copyTo(long nativeObj, long m_nativeObj, long mask_nativeObj); + + // C++: void Mat::create(int rows, int cols, int type) + private static native void n_create(long nativeObj, int rows, int cols, int type); + + // C++: void Mat::create(Size size, int type) + private static native void n_create(long nativeObj, double size_width, double size_height, int type); + + // C++: Mat Mat::cross(Mat m) + private static native long n_cross(long nativeObj, long m_nativeObj); + + // C++: long Mat::dataAddr() + private static native long n_dataAddr(long nativeObj); + + // C++: int Mat::depth() + private static native int n_depth(long nativeObj); + + // C++: Mat Mat::diag(int d = 0) + private static native long n_diag(long nativeObj, int d); + + // C++: static Mat Mat::diag(Mat d) + private static native long n_diag(long d_nativeObj); + + // C++: double Mat::dot(Mat m) + private static native double n_dot(long nativeObj, long m_nativeObj); + + // C++: size_t Mat::elemSize() + private static native long n_elemSize(long nativeObj); + + // C++: size_t Mat::elemSize1() + private static native long n_elemSize1(long nativeObj); + + // C++: bool Mat::empty() + private static native boolean n_empty(long nativeObj); + + // C++: static Mat Mat::eye(int rows, int cols, int type) + private static native long n_eye(int rows, int cols, int type); + + // C++: static Mat Mat::eye(Size size, int type) + private static native long n_eye(double size_width, double size_height, int type); + + // C++: Mat Mat::inv(int method = DECOMP_LU) + private static native long n_inv(long nativeObj, int method); + private static native long n_inv(long nativeObj); + + // C++: bool Mat::isContinuous() + private static native boolean n_isContinuous(long nativeObj); + + // C++: bool Mat::isSubmatrix() + private static native boolean n_isSubmatrix(long nativeObj); + + // C++: void Mat::locateROI(Size wholeSize, Point ofs) + private static native void n_locateROI(long nativeObj, double wholeSize_width, double wholeSize_height, double ofs_x, double ofs_y); + + // C++: Mat Mat::mul(Mat m, double scale = 1) + private static native long n_mul(long nativeObj, long m_nativeObj, double scale); + private static native long n_mul(long nativeObj, long m_nativeObj); + + // C++: static Mat Mat::ones(int rows, int cols, int type) + private static native long n_ones(int rows, int cols, int type); + + // C++: static Mat Mat::ones(Size size, int type) + private static native long n_ones(double size_width, double size_height, int type); + + // C++: void Mat::push_back(Mat m) + private static native void n_push_back(long nativeObj, long m_nativeObj); + + // C++: void Mat::release() + private static native void n_release(long nativeObj); + + // C++: Mat Mat::reshape(int cn, int rows = 0) + private static native long n_reshape(long nativeObj, int cn, int rows); + private static native long n_reshape(long nativeObj, int cn); + + // C++: Mat Mat::row(int y) + private static native long n_row(long nativeObj, int y); + + // C++: Mat Mat::rowRange(int startrow, int endrow) + private static native long n_rowRange(long nativeObj, int startrow, int endrow); + + // C++: int Mat::rows() + private static native int n_rows(long nativeObj); + + // C++: Mat Mat::operator =(Scalar s) + private static native long n_setTo(long nativeObj, double s_val0, double s_val1, double s_val2, double s_val3); + + // C++: Mat Mat::setTo(Mat value, Mat mask = Mat()) + private static native long n_setTo(long nativeObj, long value_nativeObj, long mask_nativeObj); + private static native long n_setTo(long nativeObj, long value_nativeObj); + + // C++: Size Mat::size() + private static native double[] n_size(long nativeObj); + + // C++: size_t Mat::step1(int i = 0) + private static native long n_step1(long nativeObj, int i); + private static native long n_step1(long nativeObj); + + // C++: Mat Mat::operator()(Range rowRange, Range colRange) + private static native long n_submat_rr(long nativeObj, int rowRange_start, int rowRange_end, int colRange_start, int colRange_end); + + // C++: Mat Mat::operator()(Rect roi) + private static native long n_submat(long nativeObj, int roi_x, int roi_y, int roi_width, int roi_height); + + // C++: Mat Mat::t() + private static native long n_t(long nativeObj); + + // C++: size_t Mat::total() + private static native long n_total(long nativeObj); + + // C++: int Mat::type() + private static native int n_type(long nativeObj); + + // C++: static Mat Mat::zeros(int rows, int cols, int type) + private static native long n_zeros(int rows, int cols, int type); + + // C++: static Mat Mat::zeros(Size size, int type) + private static native long n_zeros(double size_width, double size_height, int type); + + // native support for java finalize() + private static native void n_delete(long nativeObj); + + private static native int nPutD(long self, int row, int col, int count, double[] data); private static native int nPutF(long self, int row, int col, int count, float[] data); private static native int nPutI(long self, int row, int col, int count, int[] data); @@ -320,13 +1255,5 @@ public class Mat { private static native int nGetF(long self, int row, int col, int count, float[] vals); private static native int nGetD(long self, int row, int col, int count, double[] vals); private static native double[] nGet(long self, int row, int col); - private static native void nSetTo(long self, double v0, double v1, double v2, double v3); - private static native void nCopyTo(long self, long mat); - private static native double nDot(long self, long mat); - private static native long nCross(long self, long mat); - private static native long nInv(long self); - private static native long nReshape(long self, int cn, int rows); - private static native long nEye(int rows, int cols, int type); private static native String nDump(long self); - }