except:\r
from StringIO import StringIO\r
\r
-ctype2j = {\r
- # c : (j, jn, jni, jni code)\r
- "" : ("", "long", "jlong", ""), # c-tor\r
- "void" : ("void", "void", "void", ""),\r
- "bool" : ("boolean", "boolean","jboolean", "Z"),\r
- "int" : ("int", "int", "jint", "I"),\r
- "long" : ("int", "int", "jint", "I"),\r
- "float" : ("float", "float", "jfloat", "F"),\r
- "double" : ("double", "double", "jdouble", "D"),\r
- "size_t" : ("long", "long", "jlong", "J"),\r
- "env" : ("", "", "JNIEnv*", ""), # dummy 'env'\r
- "cls" : ("", "", "jclass", ""), # dummy 'cls'\r
-#\r
- "Mat" : ("Mat", (("size_t", ".nativeObj"),), "*%(n)s", "J"),\r
- "Point" : ("Point", (("double", ".x"), ("double", ".y")), "cv::Point((int)%(n)s_x, (int)%(n)s_y)", "DD"),\r
- "Point2f" : ("Point", (("double", ".x"), ("double", ".y")), "cv::Point2f((float)%(n)s_x, (float)%(n)s_y)", "DD"),\r
- "Point2d" : ("Point", (("double", ".x"), ("double", ".y")), "cv::Point2d(%(n)s_x, %(n)s_y)", "DD"),\r
- "Point3i" : ("Point", (("double", ".x"), ("double", ".y"), ("double", ".z")),\\r
- "cv::Point3i((int)%(n)s_x, (int)%(n)s_y, (int)%(n)s_z)", "DDD"),\r
- "Point3f" : ("Point", (("double", ".x"), ("double", ".y"), ("double", ".z")),\\r
- "cv::Point3f((float)%(n)s_x, (float)%(n)s_y, (float)%(n)s_z)", "DDD"),\r
- "Point3d" : ("Point", (("double", ".x"), ("double", ".y"), ("double", ".z")),\\r
- "cv::Point3d(%(n)s_x, %(n)s_y, %(n)s_z)", "DDD"),\r
- "Rect" : ("Rect", (("int", ".x"), ("int", ".y"), ("int", ".width"), ("int", ".height")), \\r
- "cv::Rect(%(n)s_x, %(n)s_y, %(n)s_width, %(n)s_height)", "IIII"),\r
- "Size" : ("Size", (("int", ".width"), ("int", ".height")), "cv::Size(%(n)s_width, %(n)s_height)", "II"),\r
- "Scalar" : ("Scalar", (("double", ".v0"), ("double", ".v1"), ("double", ".v2"), ("double", ".v3")),\\r
- "cv::Scalar(%(n)s_v0, %(n)s_v1, %(n)s_v2, %(n)s_v3)", "DDDD"),\r
+# c_type : { java/jni correspondence }\r
+type_dict = {\r
+# "simple" : { j_type : "?", jn_type : "?", jni_type : "?", suffix : "?" },\r
+ "" : { "j_type" : "", "jn_type" : "long", "jni_type" : "jlong" }, # c-tor ret_type\r
+ "void" : { "j_type" : "void", "jn_type" : "void", "jni_type" : "void" },\r
+ "env" : { "j_type" : "", "jn_type" : "", "jni_type" : "JNIEnv*"},\r
+ "cls" : { "j_type" : "", "jn_type" : "", "jni_type" : "jclass"},\r
+ "bool" : { "j_type" : "boolean", "jn_type" : "boolean", "jni_type" : "jboolean", "suffix" : "Z" },\r
+ "int" : { "j_type" : "int", "jn_type" : "int", "jni_type" : "int", "suffix" : "I" },\r
+ "long" : { "j_type" : "int", "jn_type" : "int", "jni_type" : "int", "suffix" : "I" },\r
+ "float" : { "j_type" : "float", "jn_type" : "float", "jni_type" : "jfloat", "suffix" : "F" },\r
+ "double" : { "j_type" : "double", "jn_type" : "double", "jni_type" : "jdouble", "suffix" : "D" },\r
+ "size_t" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" },\r
+ "__int64" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" },\r
+ #"+Mat+" : { "j_type" : "Mat", "jn_type" : "long", "jn_name" : "%s.nativeObj", "jni_type" : "jlong", "suffix" : "J" },\r
+# "complex" : { j_type : "?", jn_args : (("", ""),), jn_name : "", jni_var : "", jni_name : "", "suffix" : "?" },\r
+ "Mat" : { "j_type" : "Mat", "jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),),\r
+ "jni_var" : "cv::Mat %(n)s(%(n)s_nativeObj ? *((cv::Mat*)%(n)s_nativeObj) : cv::Mat())", "jni_type" : "jlong",\r
+ "suffix" : "J" },\r
+ "Point" : { "j_type" : "Point", "jn_args" : (("double", ".x"), ("double", ".y")),\r
+ "jni_var" : "cv::Point %(n)s((int)%(n)s_x, (int)%(n)s_y)",\r
+ "suffix" : "DD"},\r
+ "Point2f" : { "j_type" : "Point", "jn_args" : (("double", ".x"), ("double", ".y")),\r
+ "jni_var" : "cv::Point2f %(n)s((float)%(n)s_x, (float)%(n)s_y)",\r
+ "suffix" : "DD"},\r
+ "Point2d" : { "j_type" : "Point", "jn_args" : (("double", ".x"), ("double", ".y")),\r
+ "jni_var" : "cv::Point2d %(n)s(%(n)s_x, %(n)s_y)",\r
+ "suffix" : "DD"},\r
+ "Point3i" : { "j_type" : "Point", "jn_args" : (("double", ".x"), ("double", ".y"), ("double", ".z")),\r
+ "jni_var" : "cv::Point3i %(n)s((int)%(n)s_x, (int)%(n)s_y, (int)%(n)s_z)",\r
+ "suffix" : "DDD"},\r
+ "Point3f" : { "j_type" : "Point", "jn_args" : (("double", ".x"), ("double", ".y"), ("double", ".z")),\r
+ "jni_var" : "cv::Point3f %(n)s((float)%(n)s_x, (float)%(n)s_y, (float)%(n)s_z)",\r
+ "suffix" : "DDD"},\r
+ "Point3d" : { "j_type" : "Point", "jn_args" : (("double", ".x"), ("double", ".y"), ("double", ".z")),\r
+ "jni_var" : "cv::Point3d %(n)s(%(n)s_x, %(n)s_y, %(n)s_z)",\r
+ "suffix" : "DDD"},\r
+ "Rect" : { "j_type" : "Rect", "jn_args" : (("int", ".x"), ("int", ".y"), ("int", ".width"), ("int", ".height")),\r
+ "jni_var" : "cv::Rect %(n)s(%(n)s_x, %(n)s_y, %(n)s_width, %(n)s_height)",\r
+ "suffix" : "IIII"},\r
+ "Size" : { "j_type" : "Size", "jn_args" : (("int", ".width"), ("int", ".height")),\r
+ "jni_var" : "cv::Size %(n)s(%(n)s_width, %(n)s_height)",\r
+ "suffix" : "II"},\r
+ "Scalar" : { "j_type" : "Scalar", "jn_args" : (("double", ".v0"), ("double", ".v1"), ("double", ".v2"), ("double", ".v3")),\r
+ "jni_var" : "cv::Scalar %(n)s(%(n)s_v0, %(n)s_v1, %(n)s_v2, %(n)s_v3)",\r
+ "suffix" : "DDDD"},\r
+ "string" : { "j_type" : "java.lang.String", "jn_type" : "java.lang.String",\r
+ "jni_type" : "jstring", "jni_name" : "n_%(n)s",\r
+ "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);',\r
+ "suffix" : "Ljava_lang_String_2"},\r
\r
}\r
\r
self.static = ["","static"][ "/S" in decl[2] ]\r
self.ctype = decl[1] or ""\r
self.args = []\r
- self.jni_suffix = "__"\r
- if self.classname and self.ctype and not self.static: # non-static class methods except c-tors\r
- self.jni_suffix += "J" # artifical 'self'\r
+ #self.jni_suffix = "__"\r
+ #if self.classname and self.ctype and not self.static: # non-static class methods except c-tors\r
+ # self.jni_suffix += "J" # artifical 'self'\r
for a in decl[3]:\r
ai = ArgInfo(a)\r
self.args.append(ai)\r
- self.jni_suffix += ctype2j.get(ai.ctype, ["","","",""])[3]\r
+ # self.jni_suffix += ctype2j.get(ai.ctype, ["","","",""])[3]\r
\r
\r
\r
(classinfo.name, classinfo.cname)\r
sys.exit(-1)\r
self.classes[classinfo.name] = classinfo\r
- if classinfo.name in ctype2j:\r
+ if classinfo.name in type_dict:\r
print "Duplicated class: " + classinfo.name\r
sys.exit(-1)\r
- ctype2j[classinfo.name] = (classinfo.jname, (("size_t", ".nativeObj"),), "*%(n)s", "J")\r
+ type_dict[classinfo.name] = \\r
+ { "j_type" : classinfo.name, "jn_args" : (("__int64", ".nativeObj"),),\r
+ "jni_name" : "(*((cv::"+classinfo.name+"*)%s_nativeObj))",\r
+ "suffix" : "J" }\r
\r
\r
def add_const(self, decl): # [ "const cname", val, [], [] ]\r
c_decl = "%s %s %s(%s)" % \\r
( fi.static, fi.ctype, fi.cname, \\r
", ".join(a.ctype + " " + a.name + [""," = "+a.defval][bool(a.defval)] for a in fi.args) )\r
- indent = ""\r
+ indent = " " * 4\r
if fi.classname:\r
- indent = " " * 4\r
- self.java_code.write( "\n %s// %s\n" % (indent, c_decl) )\r
+ indent += " " * 4\r
+ self.java_code.write( "\n%s// %s\n" % (indent, c_decl) )\r
self.cpp_code.write( "\n//\n//%s\n//\n" % c_decl )\r
# check if we 'know' all the types\r
- if fi.ctype and fi.ctype!="Mat" and fi.ctype[0].isupper(): # ret val is class, NYI (TODO!)\r
- self.java_code.write( " %s// Return type '%s' is not yet supported, skipping the function\n\n"\\r
- % (indent, fi.ctype) )\r
+ type_info = type_dict.get(fi.ctype)\r
+ if not (type_info and type_info.get("jn_type")): # unsupported ret type\r
+ msg = "// Return type '%s' is not supported, skipping the function\n\n" % fi.ctype\r
+ self.java_code.write( indent + msg )\r
+ self.cpp_code.write( msg )\r
print "SKIP:", c_decl, "\n\tdue to RET type", fi.ctype\r
return\r
- types = [fi.ctype]\r
- types.extend([a.ctype for a in fi.args])\r
- for t in types:\r
- if t not in ctype2j:\r
- self.java_code.write( " %s// Unknown type '%s', skipping the function\n\n" % (indent, t) )\r
- print "SKIP:", c_decl, "\n\tdue to ARG type", t\r
- return\r
for a in fi.args:\r
- if a.ctype[0].isupper() and a.ctype != "Mat" and a.out: # C++ reference to a class (gcc disallows temp obj reference)\r
- self.java_code.write( " %s// Unknown type '%s&', skipping the function\n\n" % (indent, t) )\r
- print "SKIP:", c_decl, "\n\tdue to ARG type", a.ctype + "&"\r
+ if a.ctype not in type_dict:\r
+ msg = "// Unknown type '%s', skipping the function\n\n" % a.ctype\r
+ self.java_code.write( indent + msg )\r
+ self.cpp_code.write( msg )\r
+ print "SKIP:", c_decl, "\n\tdue to ARG type", a.ctype\r
return\r
- if fi.cname == "minEnclosingCircle":\r
- self.java_code.write( " %s// Temporary skipping the function %s\n\n" % (indent, fi.cname) )\r
- print "SKIP:", c_decl, "\n\tdue to Temporary filtering"\r
+ if a.ctype != "Mat" and "jn_args" in type_dict[a.ctype] and a.out: # complex out args not yet supported\r
+ msg = "// Unsupported type '%s&', skipping the function\n\n" % a.ctype\r
+ self.java_code.write( indent + msg )\r
+ self.cpp_code.write( msg )\r
+ print "SKIP:", c_decl, "\n\tdue to OUT ARG of type", a.ctype\r
return\r
\r
self.ported_func_counter += 1\r
+\r
# java args\r
- args = fi.args[:]\r
+ args = fi.args[:] # copy\r
if args and args[-1].defval:\r
isoverload = True\r
- suffix = fi.jni_suffix\r
\r
while True:\r
\r
- # java native method args\r
+ # java native method args\r
jn_args = []\r
- if fi.classname and fi.ctype and not fi.static: # non-static class method except c-tor\r
- jn_args.append(ArgInfo([ "size_t", "nativeObj", "", [], "" ])) # adding 'this'\r
- for a in args:\r
- if a.ctype[0].isupper(): # Point/Rect/...\r
- #"Point" : ("Point", [["int", ".x"], ["int", ".y"]], ...)\r
- fields = ctype2j[a.ctype][1]\r
- for f in fields:\r
- jn_args.append( ArgInfo([ f[0], a.name + f[1], "", [], "" ]) )\r
- else:\r
- jn_args.append(a)\r
-\r
# jni (cpp) function args\r
jni_args = [ArgInfo([ "env", "env", "", [], "" ]), ArgInfo([ "cls", "cls", "", [], "" ])]\r
- if fi.classname and fi.ctype and not fi.static:\r
- jni_args.append(ArgInfo([ "size_t", "self", "", [], "" ]))\r
+ suffix = "__"\r
+ if fi.classname and fi.ctype and not fi.static: # non-static class method except c-tor\r
+ # adding 'self'\r
+ jn_args.append ( ArgInfo([ "__int64", "nativeObj", "", [], "" ]) )\r
+ jni_args.append( ArgInfo([ "__int64", "self", "", [], "" ]) )\r
+ suffix += "J"\r
for a in args:\r
- if a.ctype[0].isupper(): # Point/Rect/...\r
- #"Point" : ("Point", [["int", ".x"], ["int", ".y"]], ...)\r
- fields = ctype2j[a.ctype][1]\r
+ suffix += type_dict[a.ctype].get("suffix") or ""\r
+ fields = type_dict[a.ctype].get("jn_args") or []\r
+ if fields: # complex type\r
for f in fields:\r
+ jn_args.append ( ArgInfo([ f[0], a.name + f[1], "", [], "" ]) )\r
jni_args.append( ArgInfo([ f[0], a.name + f[1].replace(".","_"), "", [], "" ]) )\r
else:\r
+ jn_args.append(a)\r
jni_args.append(a)\r
\r
# java part:\r
# private java NATIVE method decl\r
# e.g.\r
# private static native void n_add(long src1, long src2, long dst, long mask, int dtype);\r
- jn_type = ""\r
- if fi.ctype == "Mat":\r
- jn_type = "long"\r
- elif fi.ctype[0].isupper():\r
- jn_type = "NYI" # TODO: NYI\r
- else:\r
- jn_type = ctype2j[fi.ctype][1]\r
-\r
self.java_code.write( Template(\\r
- " ${indent}private static native $jn_type $jn_name($jn_args);\n").substitute(\\r
+ "${indent}private static native $jn_type $jn_name($jn_args);\n").substitute(\\r
indent = indent, \\r
- jn_type=jn_type, \\r
- jn_name=fi.jn_name, \\r
- jn_args=", ".join(["%s %s" % (ctype2j[a.ctype][1], a.name.replace(".","_")) for a in jn_args])\r
+ jn_type = type_dict[fi.ctype]["jn_type"], \\r
+ jn_name = fi.jn_name, \\r
+ jn_args = ", ".join(["%s %s" % (type_dict[a.ctype]["jn_type"], a.name.replace(".","_")) for a in jn_args])\r
) );\r
\r
# java part:\r
# e.g.\r
# public static void add( Mat src1, Mat src2, Mat dst, Mat mask, int dtype )\r
# { n_add( src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj, dtype ); }\r
- impl_code = " return $jn_name($jn_args_call); "\r
+ impl_code = "return $jn_name($jn_args_call);"\r
if fi.ctype == "void":\r
- impl_code = " $jn_name($jn_args_call); "\r
+ impl_code = "$jn_name($jn_args_call);"\r
elif fi.ctype == "": # c-tor\r
- impl_code = " nativeObj = $jn_name($jn_args_call); "\r
+ impl_code = "nativeObj = $jn_name($jn_args_call);"\r
elif fi.ctype in self.classes: # wrapped class\r
impl_code = " return new %s( $jn_name($jn_args_call) ); " % \\r
self.classes[fi.ctype].jname\r
static = fi.static\r
\r
self.java_code.write( Template(\\r
- " ${indent}public $static $j_type $j_name($j_args)").substitute(\\r
+ "${indent}public $static $j_type $j_name($j_args)").substitute(\\r
indent = indent, \\r
static=static, \\r
- j_type=ctype2j[fi.ctype][0], \\r
+ j_type=type_dict[fi.ctype]["j_type"], \\r
j_name=fi.jname, \\r
- j_args=", ".join(["%s %s" % (ctype2j[a.ctype][0], a.name) for a in args]) \\r
+ j_args=", ".join(["%s %s" % (type_dict[a.ctype]["j_type"], a.name) for a in args]) \\r
) )\r
\r
- self.java_code.write( Template("\n $indent{ " + impl_code + " }\n").substitute(\\r
+ self.java_code.write( Template("\n$indent{ " + impl_code + " }\n").substitute(\\r
indent = indent, \\r
jn_name=fi.jn_name, \\r
- jn_args_call=", ".join([a.name + ["",".nativeObj"][ctype2j[a.ctype][0]=="Mat"] for a in jn_args])\\r
+ jn_args_call=", ".join( [a.name for a in jn_args] )\\r
) )\r
\r
# cpp part:\r
ret = "return "\r
if fi.ctype == "void":\r
ret = ""\r
- elif fi.ctype == "Mat":\r
- ret = "return (jlong) new cv::Mat"\r
- elif fi.ctype[0].isupper():\r
- ret = NYI # NYI\r
+ elif fi.ctype in self.classes: # wrapped class:\r
+ ret = "return (jlong) new cv::" + self.classes[fi.ctype].jname\r
\r
cvname = "cv::" + fi.name\r
j2cvargs = []\r
elif fi.static:\r
cvname = "cv::%s::%s" % (fi.classname, fi.name)\r
else:\r
- cvname = "%s->%s" % ("me", fi.name)\r
+ cvname = "me->" + fi.name\r
j2cvargs.append(\\r
- "cv::%s* me = (cv::%s*) self; //TODO: check for NULL" % \\r
- (fi.classname, fi.classname) \\r
+ "cv::%(cls)s* me = (cv::%(cls)s*) self; //TODO: check for NULL" \\r
+ % { "cls" : fi.classname} \\r
)\r
cvargs = []\r
for a in args:\r
- cva = a.name\r
- if a.ctype[0].isupper(): # Point/Rect/...\r
- # "Point" : ("Point", (("int", ".x"), ("int", ".y")), "Point(%(n)s_x, %(n)s_y)", "II")\r
- # Point(p_x, p_y)\r
- cva = ctype2j[a.ctype][2] % {"n" : a.name}\r
- if a.ctype == "Mat":\r
- j2cvargs.append("cv::Mat* %s = (cv::Mat*) %s_nativeObj; //TODO: check for NULL"\\r
- % (a.name, a.name))\r
- pass\r
- cvargs.append(cva)\r
-\r
- rtype = "NYI"\r
- if fi.ctype == "Mat":\r
- rtype = "jlong"\r
- elif fi.ctype[0].isupper():\r
- rtype = "NYI" # TODO: NYI\r
- else:\r
- rtype = ctype2j[fi.ctype][2]\r
+ cvargs.append( type_dict[a.ctype].get("jni_name", "%(n)s") % {"n" : a.name})\r
+ if "jni_var" in type_dict[a.ctype]: # complex type\r
+ j2cvargs.append(type_dict[a.ctype]["jni_var"] % {"n" : a.name} + ";")\r
\r
+ rtype = type_dict[fi.ctype]["jni_type"]\r
self.cpp_code.write ( Template( \\r
"""\r
#ifdef __cplusplus\r
rtype = rtype, \\r
module = self.module, \\r
fname = fi.jni_name + ["",suffix][isoverload], \\r
- args = ", ".join(["%s %s" % (ctype2j[a.ctype][2], a.name) for a in jni_args]), \\r
+ args = ", ".join(["%s %s" % (type_dict[a.ctype].get("jni_type"), a.name) for a in jni_args]), \\r
j2cv = "\n ".join([a for a in j2cvargs]), \\r
ret = ret, \\r
cvname = cvname, \\r
# processing args with default values\r
if args and args[-1].defval:\r
a = args.pop()\r
- suffix = suffix[0:-len(ctype2j[a.ctype][3])]\r
else:\r
break\r
\r
}\r
\r
// unlike other nPut()-s this one (with double[]) should convert input values to correct type\r
-#define PUT_ITEM(T, R, C) for(int ch=0; ch<me->channels() & count>0; ch++,count--) *((T*)me->ptr(R, C)+ch) = cv::saturate_cast<T>(*(src+ch))\r
+#define PUT_ITEM(T, R, C) for(int ch=0; ch<me->channels() && count>0; ch++,count--) *((T*)me->ptr(R, C)+ch) = cv::saturate_cast<T>(*(src+ch))\r
JNIEXPORT jint JNICALL Java_org_opencv_Mat_nPutD\r
(JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jdoubleArray vals)\r
{\r
double* values = (double*)env->GetPrimitiveArrayCritical(vals, 0);\r
double* src = values;\r
int r, c;\r
- for(c=col; c<me->cols & count>0; c++)\r
+ for(c=col; c<me->cols && count>0; c++)\r
{\r
switch(me->depth()) {\r
case CV_8U: PUT_ITEM(uchar, row, c); break;\r
src++;\r
}\r
\r
- for(r=row+1; r<me->rows & count>0; r++)\r
- for(c=0; c<me->cols & count>0; c++)\r
+ for(r=row+1; r<me->rows && count>0; r++)\r
+ for(c=0; c<me->cols && count>0; c++)\r
{\r
switch(me->depth()) {\r
case CV_8U: PUT_ITEM(uchar, r, c); break;\r
{\r
cv::Mat* me = (cv::Mat*) self;\r
if(! self) return 0; // no native object behind\r
- if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type\r
+ if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type\r
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range\r
\r
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);\r
{\r
cv::Mat* me = (cv::Mat*) self;\r
if(! self) return 0; // no native object behind\r
- if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type\r
+ if(me->depth() != CV_32S) return 0; // incompatible type\r
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range\r
\r
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);\r
{\r
cv::Mat* me = (cv::Mat*) self;\r
if(! self) return 0; // no native object behind\r
- if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type\r
+ if(me->depth() != CV_32F) return 0; // incompatible type\r
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range\r
\r
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);\r
{\r
cv::Mat* me = (cv::Mat*) self;\r
if(! self) return 0; // no native object behind\r
- if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type\r
+ if(me->depth() != CV_64F) return 0; // incompatible type\r
if(me->rows<=row || me->cols<=col) return 0; // indexes out of range\r
\r
char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);\r
return res;\r
}\r
\r
+JNIEXPORT jdoubleArray JNICALL Java_org_opencv_Mat_nGet\r
+ (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count)\r
+{\r
+ cv::Mat* me = (cv::Mat*) self;\r
+ if(! self) return 0; // no native object behind\r
+ if(me->rows<=row || me->cols<=col) return 0; // indexes out of range\r
+\r
+ jdoubleArray res = env->NewDoubleArray(me->channels());\r
+ if(res){\r
+ jdouble buff[me->channels()];\r
+ int i;\r
+ switch(me->depth()){\r
+ case CV_8U: for(i=0; i<me->channels(); i++) buff[i] = *((unsigned char*) me->ptr(row, col) + i); break;\r
+ case CV_8S: for(i=0; i<me->channels(); i++) buff[i] = *((signed char*) me->ptr(row, col) + i); break;\r
+ case CV_16U: for(i=0; i<me->channels(); i++) buff[i] = *((unsigned short*)me->ptr(row, col) + i); break;\r
+ case CV_16S: for(i=0; i<me->channels(); i++) buff[i] = *((signed short*) me->ptr(row, col) + i); break;\r
+ case CV_32S: for(i=0; i<me->channels(); i++) buff[i] = *((int*) me->ptr(row, col) + i); break;\r
+ case CV_32F: for(i=0; i<me->channels(); i++) buff[i] = *((float*) me->ptr(row, col) + i); break;\r
+ case CV_64F: for(i=0; i<me->channels(); i++) buff[i] = *((double*) me->ptr(row, col) + i); break;\r
+ }\r
+ env->SetDoubleArrayRegion(res, 0, me->channels(), buff);\r
+ }\r
+ return res;\r
+}\r
\r
JNIEXPORT void JNICALL Java_org_opencv_Mat_nSetTo\r
(JNIEnv* env, jclass cls, jlong self, jdouble v0, jdouble v1, jdouble v2, jdouble v3)\r
{\r
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL\r
- me->setTo( cv::Scalar(v0, v1, v2, v3), cv::Mat() );\r
+ me->setTo( cv::Scalar(v0, v1, v2, v3) );\r
}\r
\r
JNIEXPORT void JNICALL Java_org_opencv_Mat_nCopyTo\r