Java API: updating OpenCV version, minor Core API improvements, enabling EM.
This commit is contained in:
parent
2efa446e81
commit
4a6346961f
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>OpenCV-2.4.beta</name>
|
||||
<name>OpenCV-2.4.0</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.opencv"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
android:versionCode="240"
|
||||
android:versionName="2.4.0">
|
||||
</manifest>
|
||||
|
@ -871,6 +871,15 @@ public class MatTest extends OpenCVTestCase {
|
||||
assertMatEqual(gray127, gray0);
|
||||
}
|
||||
|
||||
public void testSetToScalarMask() {
|
||||
Mat mask = gray0.clone();
|
||||
mask.put(1, 1, 1, 2, 3);
|
||||
gray0.setTo(new Scalar(1), mask);
|
||||
assertEquals(3, Core.countNonZero(gray0));
|
||||
Core.subtract(gray0, mask, gray0);
|
||||
assertEquals(0, Core.countNonZero(gray0));
|
||||
}
|
||||
|
||||
public void testSize() {
|
||||
assertEquals(new Size(matSize, matSize), gray0.size());
|
||||
|
||||
|
@ -1 +1,2 @@
|
||||
include/opencv2/core/core.hpp
|
||||
../java/src/cpp/core_manual.hpp
|
||||
|
@ -14,7 +14,7 @@ class_ignore_list = (
|
||||
#features2d
|
||||
#"KeyPoint", "MSER", "StarDetector", "SURF", "DMatch",
|
||||
#ml
|
||||
"EM",
|
||||
#"EM",
|
||||
)
|
||||
|
||||
const_ignore_list = (
|
||||
@ -289,8 +289,15 @@ type_dict = {
|
||||
"jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); std::string n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)',
|
||||
"suffix" : "Ljava_lang_String_2"},
|
||||
"TermCriteria": { "j_type" : "TermCriteria", "jn_args" : (("int", ".type"), ("int", ".maxCount"), ("double", ".epsilon")),
|
||||
"jni_var" : "TermCriteria %(n)s(%(n)s_type, %(n)s_maxCount, %(n)s_epsilon)",
|
||||
"jni_var" : "TermCriteria %(n)s(%(n)s_type, %(n)s_maxCount, %(n)s_epsilon)", "jni_type" : "jdoubleArray",
|
||||
"suffix" : "IID"},
|
||||
"CvTermCriteria": { "j_type" : "TermCriteria", "jn_args" : (("int", ".type"), ("int", ".maxCount"), ("double", ".epsilon")),
|
||||
"jni_var" : "TermCriteria %(n)s(%(n)s_type, %(n)s_maxCount, %(n)s_epsilon)", "jni_type" : "jdoubleArray",
|
||||
"suffix" : "IID"},
|
||||
"Vec2d" : { "j_type" : "double[]", "jn_args" : (("double", ".val[0]"), ("double", ".val[1]")),
|
||||
"jn_type" : "double[]",
|
||||
"jni_var" : "Vec2d %(n)s(%(n)s_val0, %(n)s_val1)", "jni_type" : "jdoubleArray",
|
||||
"suffix" : "DD"},
|
||||
"Vec3d" : { "j_type" : "double[]", "jn_args" : (("double", ".val[0]"), ("double", ".val[1]"), ("double", ".val[2]")),
|
||||
"jn_type" : "double[]",
|
||||
"jni_var" : "Vec3d %(n)s(%(n)s_val0, %(n)s_val1, %(n)s_val2)", "jni_type" : "jdoubleArray",
|
||||
@ -615,7 +622,7 @@ class FuncInfo(object):
|
||||
if m.startswith("="):
|
||||
self.jname = m[1:]
|
||||
self.static = ["","static"][ "/S" in decl[2] ]
|
||||
self.ctype = decl[1] or ""
|
||||
self.ctype = re.sub(r"^CvTermCriteria", "TermCriteria", decl[1] or "")
|
||||
self.args = []
|
||||
arg_fix_map = func_arg_fix.get(classname, {}).get(self.jname, {})
|
||||
for a in decl[3]:
|
||||
|
@ -1557,6 +1557,38 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDD
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Mat Mat::setTo(Scalar value, Mat mask = Mat())
|
||||
//
|
||||
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1setTo__JDDDDJ
|
||||
(JNIEnv* env, jclass cls, jlong self, jdouble s_val0, jdouble s_val1, jdouble s_val2, jdouble s_val3, jlong mask_nativeObj)
|
||||
{
|
||||
try {
|
||||
LOGD("Mat::n_1setTo__JDDDDJ()");
|
||||
Mat* me = (Mat*) self; //TODO: check for NULL
|
||||
Scalar s(s_val0, s_val1, s_val2, s_val3);
|
||||
Mat& mask = *((Mat*)mask_nativeObj);
|
||||
Mat _retval_ = me->setTo( s, mask );
|
||||
|
||||
return (jlong) new Mat(_retval_);
|
||||
} catch(cv::Exception e) {
|
||||
LOGD("Mat::n_1setTo__JDDDDJ() 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__JDDDDJ() catched unknown exception (...)");
|
||||
jclass je = env->FindClass("java/lang/Exception");
|
||||
env->ThrowNew(je, "Unknown exception in JNI code {Mat::n_1setTo__JDDDDJ()}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Mat Mat::setTo(Mat value, Mat mask = Mat())
|
||||
//
|
||||
@ -1930,45 +1962,59 @@ JNIEXPORT void JNICALL Java_org_opencv_core_Mat_n_1delete
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD
|
||||
(JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jdoubleArray vals)
|
||||
{
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(!me || !me->data) return 0; // no native object behind
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
try {
|
||||
LOGD("Mat::nPutD()");
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(!me || !me->data) return 0; // no native object behind
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
|
||||
int rest = ((me->rows - row) * me->cols - col) * me->channels();
|
||||
if(count>rest) count = rest;
|
||||
int res = count;
|
||||
double* values = (double*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
double* src = values;
|
||||
int r, c;
|
||||
for(c=col; c<me->cols && count>0; c++)
|
||||
{
|
||||
switch(me->depth()) {
|
||||
case CV_8U: PUT_ITEM(uchar, row, c); break;
|
||||
case CV_8S: PUT_ITEM(schar, row, c); break;
|
||||
case CV_16U: PUT_ITEM(ushort, row, c); break;
|
||||
case CV_16S: PUT_ITEM(short, row, c); break;
|
||||
case CV_32S: PUT_ITEM(int, row, c); break;
|
||||
case CV_32F: PUT_ITEM(float, row, c); break;
|
||||
case CV_64F: PUT_ITEM(double, row, c); break;
|
||||
}
|
||||
}
|
||||
|
||||
for(r=row+1; r<me->rows && count>0; r++)
|
||||
for(c=0; c<me->cols && count>0; c++)
|
||||
int rest = ((me->rows - row) * me->cols - col) * me->channels();
|
||||
if(count>rest) count = rest;
|
||||
int res = count;
|
||||
double* values = (double*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
double* src = values;
|
||||
int r, c;
|
||||
for(c=col; c<me->cols && count>0; c++)
|
||||
{
|
||||
switch(me->depth()) {
|
||||
case CV_8U: PUT_ITEM(uchar, r, c); break;
|
||||
case CV_8S: PUT_ITEM(schar, r, c); break;
|
||||
case CV_16U: PUT_ITEM(ushort, r, c); break;
|
||||
case CV_16S: PUT_ITEM(short, r, c); break;
|
||||
case CV_32S: PUT_ITEM(int, r, c); break;
|
||||
case CV_32F: PUT_ITEM(float, r, c); break;
|
||||
case CV_64F: PUT_ITEM(double, r, c); break;
|
||||
case CV_8U: PUT_ITEM(uchar, row, c); break;
|
||||
case CV_8S: PUT_ITEM(schar, row, c); break;
|
||||
case CV_16U: PUT_ITEM(ushort, row, c); break;
|
||||
case CV_16S: PUT_ITEM(short, row, c); break;
|
||||
case CV_32S: PUT_ITEM(int, row, c); break;
|
||||
case CV_32F: PUT_ITEM(float, row, c); break;
|
||||
case CV_64F: PUT_ITEM(double, row, c); break;
|
||||
}
|
||||
}
|
||||
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
for(r=row+1; r<me->rows && count>0; r++)
|
||||
for(c=0; c<me->cols && count>0; c++)
|
||||
{
|
||||
switch(me->depth()) {
|
||||
case CV_8U: PUT_ITEM(uchar, r, c); break;
|
||||
case CV_8S: PUT_ITEM(schar, r, c); break;
|
||||
case CV_16U: PUT_ITEM(ushort, r, c); break;
|
||||
case CV_16S: PUT_ITEM(short, r, c); break;
|
||||
case CV_32S: PUT_ITEM(int, r, c); break;
|
||||
case CV_32F: PUT_ITEM(float, r, c); break;
|
||||
case CV_64F: PUT_ITEM(double, r, c); break;
|
||||
}
|
||||
}
|
||||
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
} catch(cv::Exception e) {
|
||||
LOGD("Mat::nPutD() 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::nPutD() catched unknown exception (...)");
|
||||
jclass je = env->FindClass("java/lang/Exception");
|
||||
env->ThrowNew(je, "Unknown exception in JNI code {Mat::nPutD()}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2010,57 +2056,113 @@ extern "C" {
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutB
|
||||
(JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jbyteArray vals)
|
||||
{
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
try {
|
||||
LOGD("Mat::nPutB()");
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_put<char>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_put<char>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
} catch(cv::Exception e) {
|
||||
LOGD("Mat::nPutB() 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::nPutB() catched unknown exception (...)");
|
||||
jclass je = env->FindClass("java/lang/Exception");
|
||||
env->ThrowNew(je, "Unknown exception in JNI code {Mat::nPutB()}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutS
|
||||
(JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jshortArray vals)
|
||||
{
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
try {
|
||||
LOGD("Mat::nPutS()");
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_put<short>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_put<short>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
} catch(cv::Exception e) {
|
||||
LOGD("Mat::nPutS() 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::nPutS() catched unknown exception (...)");
|
||||
jclass je = env->FindClass("java/lang/Exception");
|
||||
env->ThrowNew(je, "Unknown exception in JNI code {Mat::nPutS()}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutI
|
||||
(JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jintArray vals)
|
||||
{
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_32S) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
try {
|
||||
LOGD("Mat::nPutI()");
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_32S) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_put<int>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_put<int>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
} catch(cv::Exception e) {
|
||||
LOGD("Mat::nPutI() 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::nPutI() catched unknown exception (...)");
|
||||
jclass je = env->FindClass("java/lang/Exception");
|
||||
env->ThrowNew(je, "Unknown exception in JNI code {Mat::nPutI()}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutF
|
||||
(JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jfloatArray vals)
|
||||
{
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_32F) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
try {
|
||||
LOGD("Mat::nPutF()");
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_32F) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_put<float>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_put<float>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
} catch(cv::Exception e) {
|
||||
LOGD("Mat::nPutF() 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::nPutF() catched unknown exception (...)");
|
||||
jclass je = env->FindClass("java/lang/Exception");
|
||||
env->ThrowNew(je, "Unknown exception in JNI code {Mat::nPutF()}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2101,96 +2203,180 @@ extern "C" {
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetB
|
||||
(JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jbyteArray vals)
|
||||
{
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
try {
|
||||
LOGD("Mat::nGetB()");
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_get<char>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_get<char>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
} catch(cv::Exception e) {
|
||||
LOGD("Mat::nGetB() 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::nGetB() catched unknown exception (...)");
|
||||
jclass je = env->FindClass("java/lang/Exception");
|
||||
env->ThrowNew(je, "Unknown exception in JNI code {Mat::nGetB()}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetS
|
||||
(JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jshortArray vals)
|
||||
{
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
try {
|
||||
LOGD("Mat::nGetS()");
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_get<short>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_get<short>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
} catch(cv::Exception e) {
|
||||
LOGD("Mat::nGetS() 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::nGetS() catched unknown exception (...)");
|
||||
jclass je = env->FindClass("java/lang/Exception");
|
||||
env->ThrowNew(je, "Unknown exception in JNI code {Mat::nGetS()}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetI
|
||||
(JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jintArray vals)
|
||||
{
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_32S) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
try {
|
||||
LOGD("Mat::nGetI()");
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_32S) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_get<int>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_get<int>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
} catch(cv::Exception e) {
|
||||
LOGD("Mat::nGetI() 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::nGetI() catched unknown exception (...)");
|
||||
jclass je = env->FindClass("java/lang/Exception");
|
||||
env->ThrowNew(je, "Unknown exception in JNI code {Mat::nGetI()}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetF
|
||||
(JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jfloatArray vals)
|
||||
{
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_32F) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
try {
|
||||
LOGD("Mat::nGetF()");
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_32F) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_get<float>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_get<float>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
} catch(cv::Exception e) {
|
||||
LOGD("Mat::nGetF() 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::nGetF() catched unknown exception (...)");
|
||||
jclass je = env->FindClass("java/lang/Exception");
|
||||
env->ThrowNew(je, "Unknown exception in JNI code {Mat::nGetF()}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetD
|
||||
(JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jdoubleArray vals)
|
||||
{
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_64F) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
try {
|
||||
LOGD("Mat::nGetD()");
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->depth() != CV_64F) return 0; // incompatible type
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_get<double>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
|
||||
int res = mat_get<double>(me, row, col, count, values);
|
||||
env->ReleasePrimitiveArrayCritical(vals, values, 0);
|
||||
return res;
|
||||
} catch(cv::Exception e) {
|
||||
LOGD("Mat::nGetD() 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::nGetD() catched unknown exception (...)");
|
||||
jclass je = env->FindClass("java/lang/Exception");
|
||||
env->ThrowNew(je, "Unknown exception in JNI code {Mat::nGetD()}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet
|
||||
(JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count)
|
||||
{
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
try {
|
||||
LOGD("Mat::nGet()");
|
||||
cv::Mat* me = (cv::Mat*) self;
|
||||
if(! self) return 0; // no native object behind
|
||||
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
|
||||
|
||||
jdoubleArray res = env->NewDoubleArray(me->channels());
|
||||
if(res){
|
||||
jdouble buff[me->channels()];
|
||||
int i;
|
||||
switch(me->depth()){
|
||||
case CV_8U: for(i=0; i<me->channels(); i++) buff[i] = *((unsigned char*) me->ptr(row, col) + i); break;
|
||||
case CV_8S: for(i=0; i<me->channels(); i++) buff[i] = *((signed char*) me->ptr(row, col) + i); break;
|
||||
case CV_16U: for(i=0; i<me->channels(); i++) buff[i] = *((unsigned short*)me->ptr(row, col) + i); break;
|
||||
case CV_16S: for(i=0; i<me->channels(); i++) buff[i] = *((signed short*) me->ptr(row, col) + i); break;
|
||||
case CV_32S: for(i=0; i<me->channels(); i++) buff[i] = *((int*) me->ptr(row, col) + i); break;
|
||||
case CV_32F: for(i=0; i<me->channels(); i++) buff[i] = *((float*) me->ptr(row, col) + i); break;
|
||||
case CV_64F: for(i=0; i<me->channels(); i++) buff[i] = *((double*) me->ptr(row, col) + i); break;
|
||||
jdoubleArray res = env->NewDoubleArray(me->channels());
|
||||
if(res){
|
||||
jdouble buff[me->channels()];
|
||||
int i;
|
||||
switch(me->depth()){
|
||||
case CV_8U: for(i=0; i<me->channels(); i++) buff[i] = *((unsigned char*) me->ptr(row, col) + i); break;
|
||||
case CV_8S: for(i=0; i<me->channels(); i++) buff[i] = *((signed char*) me->ptr(row, col) + i); break;
|
||||
case CV_16U: for(i=0; i<me->channels(); i++) buff[i] = *((unsigned short*)me->ptr(row, col) + i); break;
|
||||
case CV_16S: for(i=0; i<me->channels(); i++) buff[i] = *((signed short*) me->ptr(row, col) + i); break;
|
||||
case CV_32S: for(i=0; i<me->channels(); i++) buff[i] = *((int*) me->ptr(row, col) + i); break;
|
||||
case CV_32F: for(i=0; i<me->channels(); i++) buff[i] = *((float*) me->ptr(row, col) + i); break;
|
||||
case CV_64F: for(i=0; i<me->channels(); i++) buff[i] = *((double*) me->ptr(row, col) + i); break;
|
||||
}
|
||||
env->SetDoubleArrayRegion(res, 0, me->channels(), buff);
|
||||
}
|
||||
env->SetDoubleArrayRegion(res, 0, me->channels(), buff);
|
||||
return res;
|
||||
} catch(cv::Exception e) {
|
||||
LOGD("Mat::nGet() 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::nGet() catched unknown exception (...)");
|
||||
jclass je = env->FindClass("java/lang/Exception");
|
||||
env->ThrowNew(je, "Unknown exception in JNI code {Mat::nGet()}");
|
||||
return 0;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_opencv_core_Mat_nDump
|
||||
|
26
modules/java/src/cpp/core_manual.hpp
Normal file
26
modules/java/src/cpp/core_manual.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
|
||||
#if 0
|
||||
|
||||
namespace cv
|
||||
{
|
||||
CV_EXPORTS_W void add(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1);
|
||||
|
||||
CV_EXPORTS_W void subtract(InputArray src1, Scalar src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1);
|
||||
|
||||
CV_EXPORTS_W void multiply(InputArray src1, Scalar src2, OutputArray dst, double scale=1, int dtype=-1);
|
||||
|
||||
CV_EXPORTS_W void divide(InputArray src1, Scalar src2, OutputArray dst, double scale=1, int dtype=-1);
|
||||
|
||||
CV_EXPORTS_W void absdiff(InputArray src1, Scalar src2, OutputArray dst);
|
||||
|
||||
CV_EXPORTS_W void compare(InputArray src1, Scalar src2, OutputArray dst, int cmpop);
|
||||
|
||||
CV_EXPORTS_W void min(InputArray src1, Scalar src2, OutputArray dst);
|
||||
|
||||
CV_EXPORTS_W void max(InputArray src1, Scalar src2, OutputArray dst);
|
||||
|
||||
}
|
||||
#endif //0
|
@ -718,6 +718,19 @@ public class Mat {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//
|
||||
// C++: Mat Mat::setTo(Scalar value, Mat mask = Mat())
|
||||
//
|
||||
|
||||
// javadoc: Mat::setTo(value, mask)
|
||||
public Mat setTo(Scalar value, Mat mask)
|
||||
{
|
||||
|
||||
Mat retVal = new Mat(n_setTo(nativeObj, value.val[0], value.val[1], value.val[2], value.val[3], mask.nativeObj));
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//
|
||||
// C++: Mat Mat::setTo(Mat value, Mat mask = Mat())
|
||||
//
|
||||
@ -1228,6 +1241,9 @@ public class Mat {
|
||||
// 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(Scalar value, Mat mask = Mat())
|
||||
private static native long n_setTo(long nativeObj, double s_val0, double s_val1, double s_val2, double s_val3, long mask_nativeObj);
|
||||
|
||||
// C++: Mat Mat::setTo(Mat value, Mat mask = Mat())
|
||||
private static native long n_setTo(long nativeObj, long value_nativeObj, long mask_nativeObj);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user