Improved rst_parser; added javadoc comments generator; added javadoc markers to handw...
authorAndrey Kamaev <no@email>
Fri, 8 Jul 2011 15:00:11 +0000 (15:00 +0000)
committerAndrey Kamaev <no@email>
Fri, 8 Jul 2011 15:00:11 +0000 (15:00 +0000)
modules/java/gen_javadoc.py [new file with mode: 0644]
modules/java/rst_parser.py
modules/java/src/java/Mat.java
modules/java/src/java/Point.java
modules/java/src/java/Point3.java
modules/java/src/java/Rect.java
modules/java/src/java/Scalar.java
modules/java/src/java/Size.java

diff --git a/modules/java/gen_javadoc.py b/modules/java/gen_javadoc.py
new file mode 100644 (file)
index 0000000..fa35ea1
--- /dev/null
@@ -0,0 +1,163 @@
+import os, sys, re, string, glob
+
+javadoc_marker = "//javadoc:"
+
+def parceJavadocMarker(line):
+    assert line.lstrip().startswith(javadoc_marker)
+    offset = line[:line.find(javadoc_marker)]
+    line = line.strip()[len(javadoc_marker):]
+    args_start = line.rfind("(")
+    args_end = line.rfind(")")
+    assert args_start * args_end > 0
+    if args_start >= 0:
+        assert args_start < args_end
+        return (line[:args_start].strip(), offset,  filter(None, list(arg.strip() for arg in line[args_start+1:args_end].split(","))))
+    return (line, offset, [])
+
+def document(infile, outfile, decls):
+    inf = open(infile, "rt")
+    outf = open(outfile, "wt")
+    try:
+        for l in inf.readlines():
+            if l.lstrip().startswith(javadoc_marker):
+                marker = parceJavadocMarker(l)
+                decl = decls.get(marker[0],None)
+                if decl:
+                    for line in makeJavadoc(decl, marker[2]).split("\n"):
+                        outf.write(marker[1] + line + "\n")
+                else:
+                    print "Error: could not find documentation for %s" % l.lstrip()[len(javadoc_marker):-1]
+            else:
+                outf.write(l.replace("\t", "    ").rstrip()+"\n")
+    except:
+        inf.close()
+        outf.close()
+        os.remove(outfile)
+        raise
+    else:
+        inf.close()
+        outf.close()
+
+def ReformatForJavadoc(s):
+    out = ""
+    for term in s.split("\n"):
+        if term.startswith("*") or term.startswith("#."):
+            term = "  " + term
+        if not term:
+            out += " *\n"
+        else:
+            pos_start = 0
+            pos_end = min(77, len(term)-1)
+            while pos_start < pos_end:
+                if pos_end - pos_start == 77:
+                    while pos_end >= pos_start:
+                        if not term[pos_end].isspace():
+                            pos_end -= 1
+                        else:
+                            break
+                    if pos_end < pos_start:
+                        pos_end = min(pos_start + 77, len(term)-1)
+                        while pos_end < len(term):
+                            if not term[pos_end].isspace():
+                                pos_end += 1
+                            else:
+                                break
+                out += " * " + term[pos_start:pos_end+1].rstrip() + "\n"
+                pos_start = pos_end + 1
+                pos_end = min(pos_start + 77, len(term)-1)
+    return out
+
+def getJavaName(decl):
+    name = "org.opencv."
+    name += decl["module"]
+    if "class" in decl:
+        name += "." + decl["class"]
+    if "method" in decl:
+        name += "." + decl["method"]
+    return name
+
+def getDocURL(decl):
+    url = "http://opencv.itseez.com/modules/"
+    url += decl["module"]
+    url += "/doc/"
+    url += os.path.basename(decl["file"]).replace(".rst",".html")
+    url += "#" + decl["name"].replace("::","-").replace("()","").replace("=","").strip().rstrip("_").replace(" ","-").replace("_","-").lower()
+    return url
+
+def makeJavadoc(decl, args = None): 
+    doc = ""
+    prefix = "/**\n"
+
+    if decl.get("isclass", False):
+        decl_type = "class"
+    elif decl.get("isstruct", False):
+        decl_type = "struct"
+    elif "class" in decl:
+        decl_type = "method"
+    else:
+        decl_type = "function"
+
+    # brief goes first
+    if "brief" in decl:
+        doc += prefix + ReformatForJavadoc(decl["brief"])
+        prefix = " *\n"
+    elif "long" not in decl:
+        print "Warning: no description for " + decl_type + " \"%s\" File: %s (line %s)" % (func["name"], func["file"], func["line"])
+        doc += prefix + ReformatForJavadoc("This " + decl_type + " is undocumented")
+        prefix = " *\n"
+    
+    # long goes after brief
+    if "long" in decl:
+        doc += prefix  + ReformatForJavadoc(decl["long"])
+        prefix = " *\n"
+
+    # @param tags
+    if args and (decl_type == "method" or decl_type == "function"):
+        documented_params = decl.get("params",{})
+        for arg in args:
+            arg_doc = documented_params.get(arg, None)
+            if not arg_doc:
+                arg_doc = "a " + arg
+                print "Warning: parameter \"%s\" of \"%s\" is undocumented. File: %s (line %s)" % (arg, decl["name"], decl["file"], decl["line"])
+            doc += prefix + ReformatForJavadoc("@param " + arg + " " + arg_doc)
+            prefix = ""
+        prefix = " *\n"
+
+    # @see tags
+    # always link to documentation
+    doc += prefix + " * @see <a href=\"" + getDocURL(decl) + "\">" + getJavaName(decl) + "</a>\n"
+    prefix = ""
+    # other links
+    if "seealso" in decl:
+        for see in decl["seealso"]:
+            doc += prefix + " * @see " + see.replace("::",".") + "\n"
+    prefix = " *\n"
+
+    #doc += prefix + " * File: " + decl["file"] + " (line " + str(decl["line"]) + ")\n"
+
+    return (doc + " */").replace("::",".")
+
+if __name__ == "__main__":
+    if len(sys.argv) < 2:
+        print "Usage:\n", os.path.basename(sys.argv[0]), " <input dir1> [<input dir2> [...]]"
+        exit(0)
+   
+    selfpath = os.path.dirname(os.path.abspath(sys.argv[0]))
+    hdr_parser_path = os.path.join(selfpath, "../python/src2")
+    
+    sys.path.append(selfpath)
+    sys.path.append(hdr_parser_path)
+    import hdr_parser
+    import rst_parser
+
+    parser = rst_parser.RstParser(hdr_parser.CppHeaderParser())
+    
+    print "Parsing documentation..."
+    for m in ["core", "flann", "imgproc", "ml", "highgui", "video", "features2d", "calib3d", "objdetect", "legacy", "contrib", "gpu", "androidcamera", "haartraining", "java", "python", "stitching", "traincascade", "ts"]:
+        parser.parse(m, os.path.join(selfpath, "../" + m))
+
+    for i in range(1, len(sys.argv)):
+        folder = os.path.abspath(sys.argv[i])
+        for jfile in glob.glob(os.path.join(folder,"*.java")):
+            outfile = os.path.abspath(os.path.basename(jfile).replace(".java", "-jdoc.java"))
+            document(jfile, outfile, parser.definitions)
index 761d2f4..0d7cd16 100644 (file)
@@ -1,5 +1,4 @@
 import os, sys, re, string, glob
-from string import Template
 
 class DeclarationParser(object):
     def __init__(self, line=None):
@@ -445,8 +444,6 @@ class RstParser(object):
             return s
         # normalize line endings
         s = re.sub(r"\r\n", "\n", s)
-        # remove tailing ::
-        s = re.sub(r"::$", "\n", s)
         # remove extra line breaks before/after _ or ,
         s = re.sub(r"\n[ ]*([_,])\n", r"\1 ", s)
         # remove extra line breaks after `
@@ -465,7 +462,7 @@ class RstParser(object):
         # remove extra line breaks after #.
         s = re.sub(r"\n#\.\n+", "\n#. ", s)
         # remove extra line breaks before `
-        s = re.sub(r"\n[ ]*`", " `", s)
+        #s = re.sub(r"\n[ ]*`", " `", s)
         # remove trailing whitespaces
         s = re.sub(r"[ ]+$", "", s)
         # remove .. for references
@@ -485,6 +482,7 @@ class RstParser(object):
 
         s = s.replace("]_", "]")
         s = s.replace(".. note::", "Note:")
+        s = s.replace(".. table::", "")
         s = s.replace(".. ocv:function::", "")
         s = s.replace(".. ocv:cfunction::", "")
 
@@ -492,7 +490,9 @@ class RstParser(object):
         s = re.sub(r"(^|\n)\.\. [a-zA-Z_0-9]+(::[a-zA-Z_0-9]+)?:(\n|$)", "\n ", s)
         # unwrap urls
         s = re.sub(r"`([^`<]+ )<(https?://[^>]+)>`_", "\\1(\\2)", s)
-        
+        # remove tailing ::
+        s = re.sub(r"::$", "\n", s)
+
         # remove whitespace before .
         s = re.sub(r"[ ]+\.", ".", s)
         # remove tailing whitespace
@@ -502,7 +502,7 @@ class RstParser(object):
         # compress line breaks
         s = re.sub(r"\n\n+", "\n\n", s)
         # remove other newlines
-        s = re.sub(r"([^.\n])\n([^*#\n])", "\\1 \\2", s)
+        s = re.sub(r"([^.\n\\=])\n([^*#\n])", "\\1 \\2", s)
         # compress whitespace
         s = re.sub(r" +", " ", s)
 
@@ -518,7 +518,7 @@ class RstParser(object):
         return s
 
 if __name__ == "__main__":
-    if len(sys.argv) < 1:
+    if len(sys.argv) < 2:
         print "Usage:\n", os.path.basename(sys.argv[0]), " <module path>"
         exit(0)
 
@@ -569,4 +569,8 @@ if __name__ == "__main__":
     for lang in sorted(stat.items()):
         print "  %7s functions documented: %s" % lang
 
+#    sys.exit(0)
+ #   for name, d in parser.definitions.items():
+  #      print
+   #     print ToJavadoc(d, d.get("params",{}).keys())
 
index 5225e53..e68f62e 100644 (file)
 package org.opencv;\r
 \r
+//javadoc:Mat\r
 public class Mat {\r
 \r
 \r
-       protected Mat(long nativeMat) {\r
-               /*if(nativeMat == 0) \r
-                       throw new java.lang.UnsupportedOperationException("Native object address is NULL");*/\r
-               this.nativeObj = nativeMat;\r
-       }\r
-       \r
-       public Mat() {\r
-               this( nCreateMat() );\r
-       }\r
-\r
-       public Mat(int rows, int cols, CvType type) {\r
-               this( nCreateMat(rows, cols, type.toInt()) );\r
-       }\r
-\r
-       public Mat(int rows, int cols, int depth) {\r
-               this( rows, cols, new CvType(depth, 1) );\r
-       }\r
-\r
-       public Mat(int rows, int cols, CvType type, Scalar val) {\r
-               this( nCreateMat(rows, cols, type.toInt(), val.v0, val.v1, val.v2, val.v3) );\r
-       }\r
-\r
-       public Mat(int rows, int cols, int depth, Scalar val) {\r
-               this( rows, cols, new CvType(depth, 1), val );\r
-       }\r
-\r
-       public void dispose() {\r
-               nRelease(nativeObj);\r
-       }\r
-       \r
-       @Override\r
-       protected void finalize() throws Throwable {\r
-               nDelete(nativeObj);\r
-               nativeObj = 0;\r
-               super.finalize();\r
-       }\r
-\r
-       @Override\r
-       public String toString() {\r
-               if(nativeObj == 0) return  "Mat [ nativeObj=NULL ]";\r
-               return  "Mat [ " +\r
-                               rows() + "*" + cols() + "*" + type() + \r
-                               ", isCont=" + isContinuous() + ", isSubmat=" + isSubmatrix() +\r
-                               ", nativeObj=0x" + Long.toHexString(nativeObj) + \r
-                               ", dataAddr=0x" + Long.toHexString(dataAddr()) +  \r
-                               " ]";\r
-       }\r
-       \r
+    protected Mat(long nativeMat) {\r
+        /*if(nativeMat == 0) \r
+            throw new java.lang.UnsupportedOperationException("Native object address is NULL");*/\r
+        this.nativeObj = nativeMat;\r
+    }\r
+    \r
+    //javadoc:Mat::Mat()\r
+    public Mat() {\r
+        this( nCreateMat() );\r
+    }\r
+\r
+    //javadoc:Mat::Mat(rows,cols,type)\r
+    public Mat(int rows, int cols, CvType type) {\r
+        this( nCreateMat(rows, cols, type.toInt()) );\r
+    }\r
+\r
+    //javadoc:Mat::Mat(rows,cols,depth)\r
+    public Mat(int rows, int cols, int depth) {\r
+        this( rows, cols, new CvType(depth, 1) );\r
+    }\r
+\r
+    //javadoc:Mat::Mat(rows,cols,type,s)\r
+    public Mat(int rows, int cols, CvType type, Scalar s) {\r
+        this( nCreateMat(rows, cols, type.toInt(), s.v0, s.v1, s.v2, s.v3) );\r
+    }\r
+\r
+    //javadoc:Mat::Mat(rows,cols,depth,s)\r
+    public Mat(int rows, int cols, int depth, Scalar s) {\r
+        this( rows, cols, new CvType(depth, 1), s );\r
+    }\r
+\r
+    //javadoc:Mat::dispose()\r
+    public void dispose() {\r
+        nRelease(nativeObj);\r
+    }\r
+    \r
+    //javadoc:Mat::finalize()\r
+    @Override\r
+    protected void finalize() throws Throwable {\r
+        nDelete(nativeObj);\r
+        nativeObj = 0;\r
+        super.finalize();\r
+    }\r
+\r
+    //javadoc:Mat::toString()\r
+    @Override\r
+    public String toString() {\r
+        if(nativeObj == 0) return  "Mat [ nativeObj=NULL ]";\r
+        return  "Mat [ " +\r
+                rows() + "*" + cols() + "*" + type() + \r
+                ", isCont=" + isContinuous() + ", isSubmat=" + isSubmatrix() +\r
+                ", nativeObj=0x" + Long.toHexString(nativeObj) + \r
+                ", dataAddr=0x" + Long.toHexString(dataAddr()) +  \r
+                " ]";\r
+    }\r
+\r
+    //javadoc:Mat::dump()\r
     public String dump() {\r
-       return nDump(nativeObj);\r
+        return nDump(nativeObj);\r
+    }\r
+    \r
+    //javadoc:Mat::empty()\r
+    public boolean empty() {\r
+        if(nativeObj == 0) return true;\r
+        return nIsEmpty(nativeObj); \r
+    }\r
+\r
+    private void checkNull() {\r
+        if(nativeObj == 0) \r
+            throw new java.lang.UnsupportedOperationException("Native object address is NULL");\r
+    }\r
+\r
+    //javadoc:Mat::type()\r
+    public CvType type() {\r
+        checkNull();\r
+        return new CvType( nType(nativeObj) );\r
+    }\r
+\r
+    //javadoc:Mat::depth()\r
+    public int depth() { return type().depth(); }\r
+\r
+    //javadoc:Mat::channels()\r
+    public int channels() { return type().channels(); }\r
+\r
+    //javadoc:Mat::elemSize()\r
+    public int elemSize() { return type().CV_ELEM_SIZE(); }\r
+\r
+    //javadoc:Mat::rows()\r
+    public int rows() {\r
+        if(nativeObj == 0) \r
+            return 0;\r
+        return nRows(nativeObj);\r
+    }\r
+\r
+    //javadoc:Mat::height()\r
+    public int height() { return rows(); }\r
+\r
+    //javadoc:Mat::cols()\r
+    public int cols() {\r
+        if(nativeObj == 0) \r
+            return 0;\r
+        return nCols(nativeObj);\r
+    }\r
+\r
+    //javadoc:Mat::width()\r
+    public int width() { return cols(); }\r
+\r
+    //javadoc:Mat::total()\r
+    public int total() { return rows() * cols(); }\r
+\r
+    //javadoc:Mat::dataAddr()\r
+    public long dataAddr() {\r
+        if(nativeObj == 0) \r
+            return 0;\r
+        return nData(nativeObj);\r
+    }\r
+\r
+    //javadoc:Mat::isContinuous()\r
+    public boolean isContinuous() {\r
+        if(nativeObj == 0) \r
+            return false; // maybe throw an exception instead?\r
+        return nIsCont(nativeObj);\r
     }\r
-       \r
-       public boolean empty() {\r
-               if(nativeObj == 0) return true;\r
-               return nIsEmpty(nativeObj); \r
-}\r
 \r
-       private void checkNull() {\r
-               if(nativeObj == 0) \r
-                       throw new java.lang.UnsupportedOperationException("Native object address is NULL");\r
-       }\r
-       \r
-       public CvType type() {\r
-               checkNull();\r
-               return new CvType( nType(nativeObj) );\r
-       }\r
-       public int depth() { return type().depth(); }\r
-       public int channels() { return type().channels(); }\r
-       public int elemSize() { return type().CV_ELEM_SIZE(); }\r
-\r
-       public int rows() {\r
-               if(nativeObj == 0) \r
-                       return 0;\r
-               return nRows(nativeObj);\r
-       }\r
-       public int height() { return rows(); }\r
-       public int cols() {\r
-               if(nativeObj == 0) \r
-                       return 0;\r
-               return nCols(nativeObj);\r
-       }\r
-       public int width() { return cols(); }\r
-       public int total() { return rows() * cols(); }\r
-\r
-       public long dataAddr() {\r
-               if(nativeObj == 0) \r
-                       return 0;\r
-               return nData(nativeObj);\r
-       }\r
-\r
-       public boolean isContinuous() {\r
-               if(nativeObj == 0) \r
-                       return false; // maybe throw an exception instead?\r
-               return nIsCont(nativeObj);\r
-       }\r
-\r
-       public boolean isSubmatrix() {\r
-               if(nativeObj == 0) \r
-                       return false; // maybe throw an exception instead?\r
-               return nIsSubmat(nativeObj);\r
-       }\r
-\r
-       public Mat submat(int rowStart, int rowEnd, int colStart, int colEnd) {\r
-               checkNull();\r
-               return new Mat( nSubmat(nativeObj, rowStart, rowEnd, colStart, colEnd) );\r
-       }\r
-       public Mat rowRange(int start, int end) { return submat(start, end, 0, -1); }\r
-       public Mat row(int num) { return submat(num, num+1, 0, -1); }\r
-       public Mat colRange(int start, int end) { return submat(0, -1, start, end); }\r
-       public Mat col(int num) { return submat(0, -1, num, num+1); }\r
-       \r
-       public Mat clone() {\r
-               checkNull();\r
-               return new Mat( nClone(nativeObj) );\r
-       }\r
-       \r
-       public int put(int row, int col, double...data) {\r
-               checkNull();\r
-               if(data != null)\r
-                       return nPutD(nativeObj, row, col, data.length, data);\r
-               else\r
-                       return 0;\r
-       }\r
-       \r
-       public int put(int row, int col, float[] data) {\r
-               checkNull();\r
-               if(data != null) {\r
-                       CvType t = type(); \r
-                       if(t.depth() == CvType.CV_32F) {\r
-                               return nPutF(nativeObj, row, col, data.length, data);\r
-                       }\r
-                       throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
-               } else return 0;\r
-       }\r
-       \r
-       public int put(int row, int col, int[] data) {\r
-               checkNull();\r
-               if(data != null) {\r
-                       CvType t = type(); \r
-                       if(t.depth() == CvType.CV_32S) {\r
-                               return nPutI(nativeObj, row, col, data.length, data);\r
-                       }\r
-                       throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
-               } else return 0;\r
-       }\r
-       \r
-       public int put(int row, int col, short[] data) {\r
-               checkNull();\r
-               if(data != null) {\r
-                       CvType t = type(); \r
-                       if(t.depth() == CvType.CV_16U || t.depth() == CvType.CV_16S) {\r
-                               return nPutS(nativeObj, row, col, data.length, data);\r
-                       }\r
-                       throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
-               } else return 0;\r
-       }\r
-       \r
-       public int put(int row, int col, byte[] data) {\r
-               checkNull();\r
-               if(data != null) {\r
-                       CvType t = type(); \r
-                       if(t.depth() == CvType.CV_8U || t.depth() == CvType.CV_8S) {\r
-                               return nPutB(nativeObj, row, col, data.length, data);\r
-                       }\r
-                       throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
-               } else return 0;\r
-       }\r
-       \r
-       public int get(int row, int col, byte[] data) {\r
-               checkNull();\r
-               CvType t = type(); \r
-               if(t.depth() == CvType.CV_8U || t.depth() == CvType.CV_8S) {\r
-                       return nGetB(nativeObj, row, col, data.length, data);\r
-               }\r
-               throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
-       }\r
-\r
-       public int get(int row, int col, short[] data) {\r
-               checkNull();\r
-               CvType t = type(); \r
-               if(t.depth() == CvType.CV_16U || t.depth() == CvType.CV_16S) {\r
-                       return nGetS(nativeObj, row, col, data.length, data);\r
-               }\r
-               throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
-       }\r
-\r
-       public int get(int row, int col, int[] data) {\r
-               checkNull();\r
-               CvType t = type(); \r
-               if(t.depth() == CvType.CV_32S) {\r
-                       return nGetI(nativeObj, row, col, data.length, data);\r
-               }\r
-               throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
-       }\r
-\r
-       public int get(int row, int col, float[] data) {\r
-               checkNull();\r
-               CvType t = type(); \r
-               if(t.depth() == CvType.CV_32F) {\r
-                       return nGetF(nativeObj, row, col, data.length, data);\r
-               }\r
-               throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
-       }\r
-\r
-       public int get(int row, int col, double[] data) {\r
-               checkNull();\r
-               CvType t = type(); \r
-               if(t.depth() == CvType.CV_64F) {\r
-                       return nGetD(nativeObj, row, col, data.length, data);\r
-               }\r
-               throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
-       }\r
-\r
-       public double[] get(int row, int col) {\r
-               checkNull();\r
-               //CvType t = type();\r
-               //if(t.depth() == CvType.CV_64F) {\r
-                       return nGet(nativeObj, row, col);\r
-               //}\r
-               //throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
-       }\r
-\r
-\r
-       public void setTo(Scalar val) {\r
-               checkNull();\r
-               nSetTo(nativeObj, val.v0, val.v1, val.v2, val.v3);\r
-       }\r
-       \r
-       public void copyTo(Mat m) {\r
-               checkNull();\r
-               if(m.nativeObj == 0) \r
-                       throw new java.lang.UnsupportedOperationException("Destination native object address is NULL");\r
-               nCopyTo(nativeObj, m.nativeObj);\r
-       }\r
-       \r
-       public double dot(Mat m) {\r
-               checkNull();\r
-               return nDot(nativeObj, m.nativeObj);\r
-       }\r
-       \r
-       public Mat cross(Mat m) {\r
-               checkNull();\r
-               return new Mat( nCross(nativeObj, m.nativeObj) );\r
-       }\r
-\r
-       public Mat inv() {\r
-               checkNull();\r
-               return new Mat( nInv(nativeObj) );\r
-       }\r
-       \r
-       public long getNativeObjAddr() {\r
-               return nativeObj;\r
-       }\r
-       \r
+    //javadoc:Mat::isSubmatrix()\r
+    public boolean isSubmatrix() {\r
+        if(nativeObj == 0) \r
+            return false; // maybe throw an exception instead?\r
+        return nIsSubmat(nativeObj);\r
+    }\r
+\r
+    //javadoc:Mat::submat(rowStart,rowEnd,colStart,colEnd)\r
+    public Mat submat(int rowStart, int rowEnd, int colStart, int colEnd) {\r
+        checkNull();\r
+        return new Mat( nSubmat(nativeObj, rowStart, rowEnd, colStart, colEnd) );\r
+    }\r
+\r
+    //javadoc:Mat::rowRange(startrow,endrow)\r
+    public Mat rowRange(int startrow, int endrow) { return submat(startrow, endrow, 0, -1); }\r
+\r
+    //javadoc:Mat::row(i)\r
+    public Mat row(int i) { return submat(i, i+1, 0, -1); }\r
+\r
+    //javadoc:Mat::colRange(startcol,endcol)\r
+    public Mat colRange(int startcol, int endcol) { return submat(0, -1, startcol, endcol); }\r
+\r
+    //javadoc:Mat::col(j)\r
+    public Mat col(int j) { return submat(0, -1, j, j+1); }\r
+    \r
+    //javadoc:Mat::clone()\r
+    public Mat clone() {\r
+        checkNull();\r
+        return new Mat( nClone(nativeObj) );\r
+    }\r
+\r
+    //javadoc:Mat::put(row,col,data)\r
+    public int put(int row, int col, double...data) {\r
+        checkNull();\r
+        if(data != null)\r
+            return nPutD(nativeObj, row, col, data.length, data);\r
+        else\r
+            return 0;\r
+    }\r
+\r
+    //javadoc:Mat::put(row,col,data)\r
+    public int put(int row, int col, float[] data) {\r
+        checkNull();\r
+        if(data != null) {\r
+            CvType t = type(); \r
+            if(t.depth() == CvType.CV_32F) {\r
+                return nPutF(nativeObj, row, col, data.length, data);\r
+            }\r
+            throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
+        } else return 0;\r
+    }\r
+\r
+    //javadoc:Mat::put(row,col,data) \r
+    public int put(int row, int col, int[] data) {\r
+        checkNull();\r
+        if(data != null) {\r
+            CvType t = type(); \r
+            if(t.depth() == CvType.CV_32S) {\r
+                return nPutI(nativeObj, row, col, data.length, data);\r
+            }\r
+            throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
+        } else return 0;\r
+    }\r
+    \r
+    //javadoc:Mat::put(row,col,data)\r
+    public int put(int row, int col, short[] data) {\r
+        checkNull();\r
+        if(data != null) {\r
+            CvType t = type(); \r
+            if(t.depth() == CvType.CV_16U || t.depth() == CvType.CV_16S) {\r
+                return nPutS(nativeObj, row, col, data.length, data);\r
+            }\r
+            throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
+        } else return 0;\r
+    }\r
+    \r
+    //javadoc:Mat::put(row,col,data)\r
+    public int put(int row, int col, byte[] data) {\r
+        checkNull();\r
+        if(data != null) {\r
+            CvType t = type(); \r
+            if(t.depth() == CvType.CV_8U || t.depth() == CvType.CV_8S) {\r
+                return nPutB(nativeObj, row, col, data.length, data);\r
+            }\r
+            throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
+        } else return 0;\r
+    }\r
+    \r
+    //javadoc:Mat::get(row,col,data)\r
+    public int get(int row, int col, byte[] data) {\r
+        checkNull();\r
+        CvType t = type(); \r
+        if(t.depth() == CvType.CV_8U || t.depth() == CvType.CV_8S) {\r
+            return nGetB(nativeObj, row, col, data.length, data);\r
+        }\r
+        throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
+    }\r
+\r
+    //javadoc:Mat::get(row,col,data)\r
+    public int get(int row, int col, short[] data) {\r
+        checkNull();\r
+        CvType t = type(); \r
+        if(t.depth() == CvType.CV_16U || t.depth() == CvType.CV_16S) {\r
+            return nGetS(nativeObj, row, col, data.length, data);\r
+        }\r
+        throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
+    }\r
+\r
+    //javadoc:Mat::get(row,col,data)\r
+    public int get(int row, int col, int[] data) {\r
+        checkNull();\r
+        CvType t = type(); \r
+        if(t.depth() == CvType.CV_32S) {\r
+            return nGetI(nativeObj, row, col, data.length, data);\r
+        }\r
+        throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
+    }\r
+\r
+    //javadoc:Mat::get(row,col,data)\r
+    public int get(int row, int col, float[] data) {\r
+        checkNull();\r
+        CvType t = type(); \r
+        if(t.depth() == CvType.CV_32F) {\r
+            return nGetF(nativeObj, row, col, data.length, data);\r
+        }\r
+        throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
+    }\r
+\r
+    //javadoc:Mat::get(row,col,data)\r
+    public int get(int row, int col, double[] data) {\r
+        checkNull();\r
+        CvType t = type(); \r
+        if(t.depth() == CvType.CV_64F) {\r
+            return nGetD(nativeObj, row, col, data.length, data);\r
+        }\r
+        throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
+    }\r
+\r
+    //javadoc:Mat::get(row,col)\r
+    public double[] get(int row, int col) {\r
+        checkNull();\r
+        //CvType t = type();\r
+        //if(t.depth() == CvType.CV_64F) {\r
+            return nGet(nativeObj, row, col);\r
+        //}\r
+        //throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);\r
+    }\r
+\r
+\r
+    //javadoc:Mat::setTo(s)\r
+    public void setTo(Scalar s) {\r
+        checkNull();\r
+        nSetTo(nativeObj, s.v0, s.v1, s.v2, s.v3);\r
+    }\r
+    \r
+    //javadoc:Mat::copyTo(m)\r
+    public void copyTo(Mat m) {\r
+        checkNull();\r
+        if(m.nativeObj == 0) \r
+            throw new java.lang.UnsupportedOperationException("Destination native object address is NULL");\r
+        nCopyTo(nativeObj, m.nativeObj);\r
+    }\r
+    \r
+    //javadoc:Mat::dot(m)\r
+    public double dot(Mat m) {\r
+        checkNull();\r
+        return nDot(nativeObj, m.nativeObj);\r
+    }\r
+    \r
+    //javadoc:Mat::cross(m)\r
+    public Mat cross(Mat m) {\r
+        checkNull();\r
+        return new Mat( nCross(nativeObj, m.nativeObj) );\r
+    }\r
+\r
+    //javadoc:Mat::inv()\r
+    public Mat inv() {\r
+        checkNull();\r
+        return new Mat( nInv(nativeObj) );\r
+    }\r
+    \r
+    //javadoc:Mat::getNativeObjAddr()\r
+    public long getNativeObjAddr() {\r
+        return nativeObj;\r
+    }\r
+    \r
+    //javadoc:Mat::eye(rows,cols,type)\r
     static public Mat eye(int rows, int cols, CvType type) {\r
         return new Mat( nEye(rows, cols, type.toInt()) );\r
     }\r
-       \r
-       // native stuff\r
-       static { System.loadLibrary("opencv_java"); }\r
-       protected long nativeObj;\r
-       private static native long nCreateMat();\r
-       private static native long nCreateMat(int rows, int cols, int type);\r
-       private static native long nCreateMat(int rows, int cols, int type, double v0, double v1, double v2, double v3);\r
-       private static native void nRelease(long self);\r
-       private static native void nDelete(long self);\r
-       private static native int nType(long self);\r
-       private static native int nRows(long self);\r
-       private static native int nCols(long self);\r
-       private static native long nData(long self);\r
-       private static native boolean nIsEmpty(long self);\r
-       private static native boolean nIsCont(long self);\r
-       private static native boolean nIsSubmat(long self);\r
-       private static native long nSubmat(long self, int rowStart, int rowEnd, int colStart, int colEnd);\r
-       private static native long nClone(long self);\r
-       private static native int nPutD(long self, int row, int col, int count, double[] data);\r
-       private static native int nPutF(long self, int row, int col, int count, float[] data);\r
-       private static native int nPutI(long self, int row, int col, int count, int[] data);\r
-       private static native int nPutS(long self, int row, int col, int count, short[] data);\r
-       private static native int nPutB(long self, int row, int col, int count, byte[] data);\r
-       private static native int nGetB(long self, int row, int col, int count, byte[] vals);\r
-       private static native int nGetS(long self, int row, int col, int count, short[] vals);\r
-       private static native int nGetI(long self, int row, int col, int count, int[] vals);\r
-       private static native int nGetF(long self, int row, int col, int count, float[] vals);\r
-       private static native int nGetD(long self, int row, int col, int count, double[] vals);\r
-       private static native double[] nGet(long self, int row, int col);\r
-       private static native void nSetTo(long self, double v0, double v1, double v2, double v3);\r
-       private static native void nCopyTo(long self, long mat);\r
-       private static native double nDot(long self, long mat);\r
-       private static native long nCross(long self, long mat);\r
-       private static native long nInv(long self);\r
+    \r
+    // native stuff\r
+    static { System.loadLibrary("opencv_java"); }\r
+    protected long nativeObj;\r
+    private static native long nCreateMat();\r
+    private static native long nCreateMat(int rows, int cols, int type);\r
+    private static native long nCreateMat(int rows, int cols, int type, double v0, double v1, double v2, double v3);\r
+    private static native void nRelease(long self);\r
+    private static native void nDelete(long self);\r
+    private static native int nType(long self);\r
+    private static native int nRows(long self);\r
+    private static native int nCols(long self);\r
+    private static native long nData(long self);\r
+    private static native boolean nIsEmpty(long self);\r
+    private static native boolean nIsCont(long self);\r
+    private static native boolean nIsSubmat(long self);\r
+    private static native long nSubmat(long self, int rowStart, int rowEnd, int colStart, int colEnd);\r
+    private static native long nClone(long self);\r
+    private static native int nPutD(long self, int row, int col, int count, double[] data);\r
+    private static native int nPutF(long self, int row, int col, int count, float[] data);\r
+    private static native int nPutI(long self, int row, int col, int count, int[] data);\r
+    private static native int nPutS(long self, int row, int col, int count, short[] data);\r
+    private static native int nPutB(long self, int row, int col, int count, byte[] data);\r
+    private static native int nGetB(long self, int row, int col, int count, byte[] vals);\r
+    private static native int nGetS(long self, int row, int col, int count, short[] vals);\r
+    private static native int nGetI(long self, int row, int col, int count, int[] vals);\r
+    private static native int nGetF(long self, int row, int col, int count, float[] vals);\r
+    private static native int nGetD(long self, int row, int col, int count, double[] vals);\r
+    private static native double[] nGet(long self, int row, int col);\r
+    private static native void nSetTo(long self, double v0, double v1, double v2, double v3);\r
+    private static native void nCopyTo(long self, long mat);\r
+    private static native double nDot(long self, long mat);\r
+    private static native long nCross(long self, long mat);\r
+    private static native long nInv(long self);\r
     private static native long nEye(int rows, int cols, int type);\r
     private static native String nDump(long self);\r
 \r
index 22a4487..b1e5cd6 100644 (file)
@@ -1,5 +1,6 @@
 package org.opencv;\r
 \r
+//javadoc:Point_\r
 public class Point {\r
        \r
        public double x, y;\r
index b010c68..4fcb465 100644 (file)
@@ -1,5 +1,6 @@
 package org.opencv;\r
 \r
+//javadoc:Point3_\r
 public class Point3 {\r
 \r
        public double x, y, z;\r
index 721dbf6..3dce4a9 100644 (file)
@@ -1,5 +1,6 @@
 package org.opencv;\r
 \r
+//javadoc:Rect_\r
 public class Rect {\r
        \r
        int x, y, width, height;\r
index a91268f..c649286 100644 (file)
@@ -1,5 +1,6 @@
 package org.opencv;\r
 \r
+//javadoc:Scalar_\r
 public class Scalar {\r
        \r
        public double v0, v1, v2, v3;\r
index 55e29d7..c3af143 100644 (file)
@@ -1,5 +1,6 @@
 package org.opencv;\r
 \r
+//javadoc:Size_\r
 public class Size {\r
 \r
        public int width, height;\r