1 package org.opencv.core;
3 import java.nio.ByteBuffer;
9 public final long nativeObj;
14 throw new java.lang.UnsupportedOperationException("Native object address is NULL");
22 // javadoc: Mat::Mat()
32 // C++: Mat::Mat(int rows, int cols, int type)
35 // javadoc: Mat::Mat(rows, cols, type)
36 public Mat(int rows, int cols, int type)
39 nativeObj = n_Mat(rows, cols, type);
45 // C++: Mat::Mat(int rows, int cols, int type, void* data)
48 // javadoc: Mat::Mat(rows, cols, type, data)
49 public Mat(int rows, int cols, int type, ByteBuffer data)
52 nativeObj = n_Mat(rows, cols, type, data);
58 // C++: Mat::Mat(Size size, int type)
61 // javadoc: Mat::Mat(size, type)
62 public Mat(Size size, int type)
65 nativeObj = n_Mat(size.width, size.height, type);
71 // C++: Mat::Mat(int ndims, const int* sizes, int type)
74 // javadoc: Mat::Mat(sizes, type)
75 public Mat(int[] sizes, int type)
78 nativeObj = n_Mat(sizes.length, sizes, type);
84 // C++: Mat::Mat(int rows, int cols, int type, Scalar s)
87 // javadoc: Mat::Mat(rows, cols, type, s)
88 public Mat(int rows, int cols, int type, Scalar s)
91 nativeObj = n_Mat(rows, cols, type, s.val[0], s.val[1], s.val[2], s.val[3]);
97 // C++: Mat::Mat(Size size, int type, Scalar s)
100 // javadoc: Mat::Mat(size, type, s)
101 public Mat(Size size, int type, Scalar s)
104 nativeObj = n_Mat(size.width, size.height, type, s.val[0], s.val[1], s.val[2], s.val[3]);
110 // C++: Mat::Mat(int ndims, const int* sizes, int type, Scalar s)
113 // javadoc: Mat::Mat(sizes, type, s)
114 public Mat(int[] sizes, int type, Scalar s)
117 nativeObj = n_Mat(sizes.length, sizes, type, s.val[0], s.val[1], s.val[2], s.val[3]);
123 // C++: Mat::Mat(Mat m, Range rowRange, Range colRange = Range::all())
126 // javadoc: Mat::Mat(m, rowRange, colRange)
127 public Mat(Mat m, Range rowRange, Range colRange)
130 nativeObj = n_Mat(m.nativeObj, rowRange.start, rowRange.end, colRange.start, colRange.end);
135 // javadoc: Mat::Mat(m, rowRange)
136 public Mat(Mat m, Range rowRange)
139 nativeObj = n_Mat(m.nativeObj, rowRange.start, rowRange.end);
145 // C++: Mat::Mat(const Mat& m, const std::vector<Range>& ranges)
148 // javadoc: Mat::Mat(m, ranges)
149 public Mat(Mat m, Range[] ranges)
152 nativeObj = n_Mat(m.nativeObj, ranges);
158 // C++: Mat::Mat(Mat m, Rect roi)
161 // javadoc: Mat::Mat(m, roi)
162 public Mat(Mat m, Rect roi)
165 nativeObj = n_Mat(m.nativeObj, roi.y, roi.y + roi.height, roi.x, roi.x + roi.width);
171 // C++: Mat Mat::adjustROI(int dtop, int dbottom, int dleft, int dright)
174 // javadoc: Mat::adjustROI(dtop, dbottom, dleft, dright)
175 public Mat adjustROI(int dtop, int dbottom, int dleft, int dright)
178 Mat retVal = new Mat(n_adjustROI(nativeObj, dtop, dbottom, dleft, dright));
184 // C++: void Mat::assignTo(Mat m, int type = -1)
187 // javadoc: Mat::assignTo(m, type)
188 public void assignTo(Mat m, int type)
191 n_assignTo(nativeObj, m.nativeObj, type);
196 // javadoc: Mat::assignTo(m)
197 public void assignTo(Mat m)
200 n_assignTo(nativeObj, m.nativeObj);
206 // C++: int Mat::channels()
209 // javadoc: Mat::channels()
210 public int channels()
213 int retVal = n_channels(nativeObj);
219 // C++: int Mat::checkVector(int elemChannels, int depth = -1, bool
220 // requireContinuous = true)
223 // javadoc: Mat::checkVector(elemChannels, depth, requireContinuous)
224 public int checkVector(int elemChannels, int depth, boolean requireContinuous)
227 int retVal = n_checkVector(nativeObj, elemChannels, depth, requireContinuous);
232 // javadoc: Mat::checkVector(elemChannels, depth)
233 public int checkVector(int elemChannels, int depth)
236 int retVal = n_checkVector(nativeObj, elemChannels, depth);
241 // javadoc: Mat::checkVector(elemChannels)
242 public int checkVector(int elemChannels)
245 int retVal = n_checkVector(nativeObj, elemChannels);
251 // C++: Mat Mat::clone()
254 // javadoc: Mat::clone()
258 Mat retVal = new Mat(n_clone(nativeObj));
264 // C++: Mat Mat::col(int x)
267 // javadoc: Mat::col(x)
268 public Mat col(int x)
271 Mat retVal = new Mat(n_col(nativeObj, x));
277 // C++: Mat Mat::colRange(int startcol, int endcol)
280 // javadoc: Mat::colRange(startcol, endcol)
281 public Mat colRange(int startcol, int endcol)
284 Mat retVal = new Mat(n_colRange(nativeObj, startcol, endcol));
290 // C++: Mat Mat::colRange(Range r)
293 // javadoc: Mat::colRange(r)
294 public Mat colRange(Range r)
297 Mat retVal = new Mat(n_colRange(nativeObj, r.start, r.end));
303 // C++: int Mat::dims()
306 // javadoc: Mat::dims()
310 int retVal = n_dims(nativeObj);
316 // C++: int Mat::cols()
319 // javadoc: Mat::cols()
323 int retVal = n_cols(nativeObj);
329 // C++: void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta
333 // javadoc: Mat::convertTo(m, rtype, alpha, beta)
334 public void convertTo(Mat m, int rtype, double alpha, double beta)
337 n_convertTo(nativeObj, m.nativeObj, rtype, alpha, beta);
342 // javadoc: Mat::convertTo(m, rtype, alpha)
343 public void convertTo(Mat m, int rtype, double alpha)
346 n_convertTo(nativeObj, m.nativeObj, rtype, alpha);
351 // javadoc: Mat::convertTo(m, rtype)
352 public void convertTo(Mat m, int rtype)
355 n_convertTo(nativeObj, m.nativeObj, rtype);
361 // C++: void Mat::copyTo(Mat& m)
364 // javadoc: Mat::copyTo(m)
365 public void copyTo(Mat m)
368 n_copyTo(nativeObj, m.nativeObj);
374 // C++: void Mat::copyTo(Mat& m, Mat mask)
377 // javadoc: Mat::copyTo(m, mask)
378 public void copyTo(Mat m, Mat mask)
381 n_copyTo(nativeObj, m.nativeObj, mask.nativeObj);
387 // C++: void Mat::create(int rows, int cols, int type)
390 // javadoc: Mat::create(rows, cols, type)
391 public void create(int rows, int cols, int type)
394 n_create(nativeObj, rows, cols, type);
400 // C++: void Mat::create(Size size, int type)
403 // javadoc: Mat::create(size, type)
404 public void create(Size size, int type)
407 n_create(nativeObj, size.width, size.height, type);
413 // C++: void Mat::create(int ndims, const int* sizes, int type)
416 // javadoc: Mat::create(sizes, type)
417 public void create(int[] sizes, int type)
420 n_create(nativeObj, sizes.length, sizes, type);
426 // C++: void Mat::copySize(const Mat& m);
429 // javadoc: Mat::copySize(m)
430 public void copySize(Mat m)
432 n_copySize(nativeObj, m.nativeObj);
438 // C++: Mat Mat::cross(Mat m)
441 // javadoc: Mat::cross(m)
442 public Mat cross(Mat m)
445 Mat retVal = new Mat(n_cross(nativeObj, m.nativeObj));
451 // C++: long Mat::dataAddr()
454 // javadoc: Mat::dataAddr()
455 public long dataAddr()
458 long retVal = n_dataAddr(nativeObj);
464 // C++: int Mat::depth()
467 // javadoc: Mat::depth()
471 int retVal = n_depth(nativeObj);
477 // C++: Mat Mat::diag(int d = 0)
480 // javadoc: Mat::diag(d)
481 public Mat diag(int d)
484 Mat retVal = new Mat(n_diag(nativeObj, d));
489 // javadoc: Mat::diag()
493 Mat retVal = new Mat(n_diag(nativeObj, 0));
499 // C++: static Mat Mat::diag(Mat d)
502 // javadoc: Mat::diag(d)
503 public static Mat diag(Mat d)
506 Mat retVal = new Mat(n_diag(d.nativeObj));
512 // C++: double Mat::dot(Mat m)
515 // javadoc: Mat::dot(m)
516 public double dot(Mat m)
519 double retVal = n_dot(nativeObj, m.nativeObj);
525 // C++: size_t Mat::elemSize()
528 // javadoc: Mat::elemSize()
529 public long elemSize()
532 long retVal = n_elemSize(nativeObj);
538 // C++: size_t Mat::elemSize1()
541 // javadoc: Mat::elemSize1()
542 public long elemSize1()
545 long retVal = n_elemSize1(nativeObj);
551 // C++: bool Mat::empty()
554 // javadoc: Mat::empty()
555 public boolean empty()
558 boolean retVal = n_empty(nativeObj);
564 // C++: static Mat Mat::eye(int rows, int cols, int type)
567 // javadoc: Mat::eye(rows, cols, type)
568 public static Mat eye(int rows, int cols, int type)
571 Mat retVal = new Mat(n_eye(rows, cols, type));
577 // C++: static Mat Mat::eye(Size size, int type)
580 // javadoc: Mat::eye(size, type)
581 public static Mat eye(Size size, int type)
584 Mat retVal = new Mat(n_eye(size.width, size.height, type));
590 // C++: Mat Mat::inv(int method = DECOMP_LU)
593 // javadoc: Mat::inv(method)
594 public Mat inv(int method)
597 Mat retVal = new Mat(n_inv(nativeObj, method));
602 // javadoc: Mat::inv()
606 Mat retVal = new Mat(n_inv(nativeObj));
612 // C++: bool Mat::isContinuous()
615 // javadoc: Mat::isContinuous()
616 public boolean isContinuous()
619 boolean retVal = n_isContinuous(nativeObj);
625 // C++: bool Mat::isSubmatrix()
628 // javadoc: Mat::isSubmatrix()
629 public boolean isSubmatrix()
632 boolean retVal = n_isSubmatrix(nativeObj);
638 // C++: void Mat::locateROI(Size wholeSize, Point ofs)
641 // javadoc: Mat::locateROI(wholeSize, ofs)
642 public void locateROI(Size wholeSize, Point ofs)
644 double[] wholeSize_out = new double[2];
645 double[] ofs_out = new double[2];
646 locateROI_0(nativeObj, wholeSize_out, ofs_out);
647 if(wholeSize!=null){ wholeSize.width = wholeSize_out[0]; wholeSize.height = wholeSize_out[1]; }
648 if(ofs!=null){ ofs.x = ofs_out[0]; ofs.y = ofs_out[1]; }
653 // C++: Mat Mat::mul(Mat m, double scale = 1)
656 // javadoc: Mat::mul(m, scale)
657 public Mat mul(Mat m, double scale)
660 Mat retVal = new Mat(n_mul(nativeObj, m.nativeObj, scale));
665 // javadoc: Mat::mul(m)
666 public Mat mul(Mat m)
669 Mat retVal = new Mat(n_mul(nativeObj, m.nativeObj));
675 // C++: static Mat Mat::ones(int rows, int cols, int type)
678 // javadoc: Mat::ones(rows, cols, type)
679 public static Mat ones(int rows, int cols, int type)
682 Mat retVal = new Mat(n_ones(rows, cols, type));
688 // C++: static Mat Mat::ones(Size size, int type)
691 // javadoc: Mat::ones(size, type)
692 public static Mat ones(Size size, int type)
695 Mat retVal = new Mat(n_ones(size.width, size.height, type));
701 // C++: static Mat Mat::ones(int ndims, const int* sizes, int type)
704 // javadoc: Mat::ones(sizes, type)
705 public static Mat ones(int[] sizes, int type)
708 Mat retVal = new Mat(n_ones(sizes.length, sizes, type));
714 // C++: void Mat::push_back(Mat m)
717 // javadoc: Mat::push_back(m)
718 public void push_back(Mat m)
721 n_push_back(nativeObj, m.nativeObj);
727 // C++: void Mat::release()
730 // javadoc: Mat::release()
731 public void release()
734 n_release(nativeObj);
740 // C++: Mat Mat::reshape(int cn, int rows = 0)
743 // javadoc: Mat::reshape(cn, rows)
744 public Mat reshape(int cn, int rows)
747 Mat retVal = new Mat(n_reshape(nativeObj, cn, rows));
752 // javadoc: Mat::reshape(cn)
753 public Mat reshape(int cn)
756 Mat retVal = new Mat(n_reshape(nativeObj, cn));
762 // C++: Mat Mat::reshape(int cn, int newndims, const int* newsz)
765 // javadoc: Mat::reshape(cn, newshape)
766 public Mat reshape(int cn, int[] newshape)
768 Mat retVal = new Mat(n_reshape_1(nativeObj, cn, newshape.length, newshape));
774 // C++: Mat Mat::row(int y)
777 // javadoc: Mat::row(y)
778 public Mat row(int y)
781 Mat retVal = new Mat(n_row(nativeObj, y));
787 // C++: Mat Mat::rowRange(int startrow, int endrow)
790 // javadoc: Mat::rowRange(startrow, endrow)
791 public Mat rowRange(int startrow, int endrow)
794 Mat retVal = new Mat(n_rowRange(nativeObj, startrow, endrow));
800 // C++: Mat Mat::rowRange(Range r)
803 // javadoc: Mat::rowRange(r)
804 public Mat rowRange(Range r)
807 Mat retVal = new Mat(n_rowRange(nativeObj, r.start, r.end));
813 // C++: int Mat::rows()
816 // javadoc: Mat::rows()
820 int retVal = n_rows(nativeObj);
826 // C++: Mat Mat::operator =(Scalar s)
829 // javadoc: Mat::operator =(s)
830 public Mat setTo(Scalar s)
833 Mat retVal = new Mat(n_setTo(nativeObj, s.val[0], s.val[1], s.val[2], s.val[3]));
839 // C++: Mat Mat::setTo(Scalar value, Mat mask = Mat())
842 // javadoc: Mat::setTo(value, mask)
843 public Mat setTo(Scalar value, Mat mask)
846 Mat retVal = new Mat(n_setTo(nativeObj, value.val[0], value.val[1], value.val[2], value.val[3], mask.nativeObj));
852 // C++: Mat Mat::setTo(Mat value, Mat mask = Mat())
855 // javadoc: Mat::setTo(value, mask)
856 public Mat setTo(Mat value, Mat mask)
859 Mat retVal = new Mat(n_setTo(nativeObj, value.nativeObj, mask.nativeObj));
864 // javadoc: Mat::setTo(value)
865 public Mat setTo(Mat value)
868 Mat retVal = new Mat(n_setTo(nativeObj, value.nativeObj));
874 // C++: Size Mat::size()
877 // javadoc: Mat::size()
881 Size retVal = new Size(n_size(nativeObj));
887 // C++: int Mat::size(int i)
890 // javadoc: Mat::size(int i)
891 public int size(int i)
893 int retVal = n_size_i(nativeObj, i);
899 // C++: size_t Mat::step1(int i = 0)
902 // javadoc: Mat::step1(i)
903 public long step1(int i)
906 long retVal = n_step1(nativeObj, i);
911 // javadoc: Mat::step1()
915 long retVal = n_step1(nativeObj);
921 // C++: Mat Mat::operator()(int rowStart, int rowEnd, int colStart, int
925 // javadoc: Mat::operator()(rowStart, rowEnd, colStart, colEnd)
926 public Mat submat(int rowStart, int rowEnd, int colStart, int colEnd)
929 Mat retVal = new Mat(n_submat_rr(nativeObj, rowStart, rowEnd, colStart, colEnd));
935 // C++: Mat Mat::operator()(Range rowRange, Range colRange)
938 // javadoc: Mat::operator()(rowRange, colRange)
939 public Mat submat(Range rowRange, Range colRange)
942 Mat retVal = new Mat(n_submat_rr(nativeObj, rowRange.start, rowRange.end, colRange.start, colRange.end));
948 // C++: Mat Mat::operator()(const std::vector<Range>& ranges)
951 // javadoc: Mat::operator()(ranges[])
952 public Mat submat(Range[] ranges)
955 Mat retVal = new Mat(n_submat_ranges(nativeObj, ranges));
961 // C++: Mat Mat::operator()(Rect roi)
964 // javadoc: Mat::operator()(roi)
965 public Mat submat(Rect roi)
968 Mat retVal = new Mat(n_submat(nativeObj, roi.x, roi.y, roi.width, roi.height));
981 Mat retVal = new Mat(n_t(nativeObj));
987 // C++: size_t Mat::total()
990 // javadoc: Mat::total()
994 long retVal = n_total(nativeObj);
1000 // C++: int Mat::type()
1003 // javadoc: Mat::type()
1007 int retVal = n_type(nativeObj);
1013 // C++: static Mat Mat::zeros(int rows, int cols, int type)
1016 // javadoc: Mat::zeros(rows, cols, type)
1017 public static Mat zeros(int rows, int cols, int type)
1020 Mat retVal = new Mat(n_zeros(rows, cols, type));
1026 // C++: static Mat Mat::zeros(Size size, int type)
1029 // javadoc: Mat::zeros(size, type)
1030 public static Mat zeros(Size size, int type)
1033 Mat retVal = new Mat(n_zeros(size.width, size.height, type));
1039 // C++: static Mat Mat::zeros(int ndims, const int* sizes, int type)
1042 // javadoc: Mat::zeros(sizes, type)
1043 public static Mat zeros(int[] sizes, int type)
1046 Mat retVal = new Mat(n_zeros(sizes.length, sizes, type));
1052 protected void finalize() throws Throwable {
1053 n_delete(nativeObj);
1057 // javadoc:Mat::toString()
1059 public String toString() {
1061 rows() + "*" + cols() + "*" + CvType.typeToString(type()) +
1062 ", isCont=" + isContinuous() + ", isSubmat=" + isSubmatrix() +
1063 ", nativeObj=0x" + Long.toHexString(nativeObj) +
1064 ", dataAddr=0x" + Long.toHexString(dataAddr()) +
1068 // javadoc:Mat::dump()
1069 public String dump() {
1070 return nDump(nativeObj);
1073 // javadoc:Mat::put(row,col,data)
1074 public int put(int row, int col, double... data) {
1076 if (data == null || data.length % CvType.channels(t) != 0)
1077 throw new java.lang.UnsupportedOperationException(
1078 "Provided data element number (" +
1079 (data == null ? 0 : data.length) +
1080 ") should be multiple of the Mat channels count (" +
1081 CvType.channels(t) + ")");
1082 return nPutD(nativeObj, row, col, data.length, data);
1085 // javadoc:Mat::put(idx,data)
1086 public int put(int[] idx, double... data) {
1088 if (data == null || data.length % CvType.channels(t) != 0)
1089 throw new java.lang.UnsupportedOperationException(
1090 "Provided data element number (" +
1091 (data == null ? 0 : data.length) +
1092 ") should be multiple of the Mat channels count (" +
1093 CvType.channels(t) + ")");
1094 if (idx.length != dims())
1095 throw new IllegalArgumentException("Incorrect number of indices");
1096 return nPutDIdx(nativeObj, idx, data.length, data);
1099 // javadoc:Mat::put(row,col,data)
1100 public int put(int row, int col, float[] data) {
1102 if (data == null || data.length % CvType.channels(t) != 0)
1103 throw new java.lang.UnsupportedOperationException(
1104 "Provided data element number (" +
1105 (data == null ? 0 : data.length) +
1106 ") should be multiple of the Mat channels count (" +
1107 CvType.channels(t) + ")");
1108 if (CvType.depth(t) == CvType.CV_32F) {
1109 return nPutF(nativeObj, row, col, data.length, data);
1111 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1114 // javadoc:Mat::put(idx,data)
1115 public int put(int[] idx, float[] data) {
1117 if (data == null || data.length % CvType.channels(t) != 0)
1118 throw new java.lang.UnsupportedOperationException(
1119 "Provided data element number (" +
1120 (data == null ? 0 : data.length) +
1121 ") should be multiple of the Mat channels count (" +
1122 CvType.channels(t) + ")");
1123 if (idx.length != dims())
1124 throw new IllegalArgumentException("Incorrect number of indices");
1125 if (CvType.depth(t) == CvType.CV_32F) {
1126 return nPutFIdx(nativeObj, idx, data.length, data);
1128 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1131 // javadoc:Mat::put(row,col,data)
1132 public int put(int row, int col, int[] data) {
1134 if (data == null || data.length % CvType.channels(t) != 0)
1135 throw new java.lang.UnsupportedOperationException(
1136 "Provided data element number (" +
1137 (data == null ? 0 : data.length) +
1138 ") should be multiple of the Mat channels count (" +
1139 CvType.channels(t) + ")");
1140 if (CvType.depth(t) == CvType.CV_32S) {
1141 return nPutI(nativeObj, row, col, data.length, data);
1143 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1146 // javadoc:Mat::put(idx,data)
1147 public int put(int[] idx, int[] data) {
1149 if (data == null || data.length % CvType.channels(t) != 0)
1150 throw new java.lang.UnsupportedOperationException(
1151 "Provided data element number (" +
1152 (data == null ? 0 : data.length) +
1153 ") should be multiple of the Mat channels count (" +
1154 CvType.channels(t) + ")");
1155 if (idx.length != dims())
1156 throw new IllegalArgumentException("Incorrect number of indices");
1157 if (CvType.depth(t) == CvType.CV_32S) {
1158 return nPutIIdx(nativeObj, idx, data.length, data);
1160 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1163 // javadoc:Mat::put(row,col,data)
1164 public int put(int row, int col, short[] data) {
1166 if (data == null || data.length % CvType.channels(t) != 0)
1167 throw new java.lang.UnsupportedOperationException(
1168 "Provided data element number (" +
1169 (data == null ? 0 : data.length) +
1170 ") should be multiple of the Mat channels count (" +
1171 CvType.channels(t) + ")");
1172 if (CvType.depth(t) == CvType.CV_16U || CvType.depth(t) == CvType.CV_16S) {
1173 return nPutS(nativeObj, row, col, data.length, data);
1175 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1178 // javadoc:Mat::put(idx,data)
1179 public int put(int[] idx, short[] data) {
1181 if (data == null || data.length % CvType.channels(t) != 0)
1182 throw new java.lang.UnsupportedOperationException(
1183 "Provided data element number (" +
1184 (data == null ? 0 : data.length) +
1185 ") should be multiple of the Mat channels count (" +
1186 CvType.channels(t) + ")");
1187 if (idx.length != dims())
1188 throw new IllegalArgumentException("Incorrect number of indices");
1189 if (CvType.depth(t) == CvType.CV_16U || CvType.depth(t) == CvType.CV_16S) {
1190 return nPutSIdx(nativeObj, idx, data.length, data);
1192 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1195 // javadoc:Mat::put(row,col,data)
1196 public int put(int row, int col, byte[] data) {
1198 if (data == null || data.length % CvType.channels(t) != 0)
1199 throw new java.lang.UnsupportedOperationException(
1200 "Provided data element number (" +
1201 (data == null ? 0 : data.length) +
1202 ") should be multiple of the Mat channels count (" +
1203 CvType.channels(t) + ")");
1204 if (CvType.depth(t) == CvType.CV_8U || CvType.depth(t) == CvType.CV_8S) {
1205 return nPutB(nativeObj, row, col, data.length, data);
1207 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1210 // javadoc:Mat::put(idx,data)
1211 public int put(int[] idx, byte[] data) {
1213 if (data == null || data.length % CvType.channels(t) != 0)
1214 throw new java.lang.UnsupportedOperationException(
1215 "Provided data element number (" +
1216 (data == null ? 0 : data.length) +
1217 ") should be multiple of the Mat channels count (" +
1218 CvType.channels(t) + ")");
1219 if (idx.length != dims())
1220 throw new IllegalArgumentException("Incorrect number of indices");
1221 if (CvType.depth(t) == CvType.CV_8U || CvType.depth(t) == CvType.CV_8S) {
1222 return nPutBIdx(nativeObj, idx, data.length, data);
1224 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1227 // javadoc:Mat::put(row,col,data,offset,length)
1228 public int put(int row, int col, byte[] data, int offset, int length) {
1230 if (data == null || length % CvType.channels(t) != 0)
1231 throw new java.lang.UnsupportedOperationException(
1232 "Provided data element number (" +
1233 (data == null ? 0 : data.length) +
1234 ") should be multiple of the Mat channels count (" +
1235 CvType.channels(t) + ")");
1236 if (CvType.depth(t) == CvType.CV_8U || CvType.depth(t) == CvType.CV_8S) {
1237 return nPutBwOffset(nativeObj, row, col, length, offset, data);
1239 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1242 // javadoc:Mat::put(idx,data,offset,length)
1243 public int put(int[] idx, byte[] data, int offset, int length) {
1245 if (data == null || length % CvType.channels(t) != 0)
1246 throw new java.lang.UnsupportedOperationException(
1247 "Provided data element number (" +
1248 (data == null ? 0 : data.length) +
1249 ") should be multiple of the Mat channels count (" +
1250 CvType.channels(t) + ")");
1251 if (idx.length != dims())
1252 throw new IllegalArgumentException("Incorrect number of indices");
1253 if (CvType.depth(t) == CvType.CV_8U || CvType.depth(t) == CvType.CV_8S) {
1254 return nPutBwIdxOffset(nativeObj, idx, length, offset, data);
1256 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1259 // javadoc:Mat::get(row,col,data)
1260 public int get(int row, int col, byte[] data) {
1262 if (data == null || data.length % CvType.channels(t) != 0)
1263 throw new java.lang.UnsupportedOperationException(
1264 "Provided data element number (" +
1265 (data == null ? 0 : data.length) +
1266 ") should be multiple of the Mat channels count (" +
1267 CvType.channels(t) + ")");
1268 if (CvType.depth(t) == CvType.CV_8U || CvType.depth(t) == CvType.CV_8S) {
1269 return nGetB(nativeObj, row, col, data.length, data);
1271 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1274 // javadoc:Mat::get(idx,data)
1275 public int get(int[] idx, byte[] data) {
1277 if (data == null || data.length % CvType.channels(t) != 0)
1278 throw new java.lang.UnsupportedOperationException(
1279 "Provided data element number (" +
1280 (data == null ? 0 : data.length) +
1281 ") should be multiple of the Mat channels count (" +
1282 CvType.channels(t) + ")");
1283 if (idx.length != dims())
1284 throw new IllegalArgumentException("Incorrect number of indices");
1285 if (CvType.depth(t) == CvType.CV_8U || CvType.depth(t) == CvType.CV_8S) {
1286 return nGetBIdx(nativeObj, idx, data.length, data);
1288 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1291 // javadoc:Mat::get(row,col,data)
1292 public int get(int row, int col, short[] data) {
1294 if (data == null || data.length % CvType.channels(t) != 0)
1295 throw new java.lang.UnsupportedOperationException(
1296 "Provided data element number (" +
1297 (data == null ? 0 : data.length) +
1298 ") should be multiple of the Mat channels count (" +
1299 CvType.channels(t) + ")");
1300 if (CvType.depth(t) == CvType.CV_16U || CvType.depth(t) == CvType.CV_16S) {
1301 return nGetS(nativeObj, row, col, data.length, data);
1303 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1306 // javadoc:Mat::get(idx,data)
1307 public int get(int[] idx, short[] data) {
1309 if (data == null || data.length % CvType.channels(t) != 0)
1310 throw new java.lang.UnsupportedOperationException(
1311 "Provided data element number (" +
1312 (data == null ? 0 : data.length) +
1313 ") should be multiple of the Mat channels count (" +
1314 CvType.channels(t) + ")");
1315 if (idx.length != dims())
1316 throw new IllegalArgumentException("Incorrect number of indices");
1317 if (CvType.depth(t) == CvType.CV_16U || CvType.depth(t) == CvType.CV_16S) {
1318 return nGetSIdx(nativeObj, idx, data.length, data);
1320 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1323 // javadoc:Mat::get(row,col,data)
1324 public int get(int row, int col, int[] data) {
1326 if (data == null || data.length % CvType.channels(t) != 0)
1327 throw new java.lang.UnsupportedOperationException(
1328 "Provided data element number (" +
1329 (data == null ? 0 : data.length) +
1330 ") should be multiple of the Mat channels count (" +
1331 CvType.channels(t) + ")");
1332 if (CvType.depth(t) == CvType.CV_32S) {
1333 return nGetI(nativeObj, row, col, data.length, data);
1335 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1338 // javadoc:Mat::get(idx,data)
1339 public int get(int[] idx, int[] data) {
1341 if (data == null || data.length % CvType.channels(t) != 0)
1342 throw new java.lang.UnsupportedOperationException(
1343 "Provided data element number (" +
1344 (data == null ? 0 : data.length) +
1345 ") should be multiple of the Mat channels count (" +
1346 CvType.channels(t) + ")");
1347 if (idx.length != dims())
1348 throw new IllegalArgumentException("Incorrect number of indices");
1349 if (CvType.depth(t) == CvType.CV_32S) {
1350 return nGetIIdx(nativeObj, idx, data.length, data);
1352 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1355 // javadoc:Mat::get(row,col,data)
1356 public int get(int row, int col, float[] data) {
1358 if (data == null || data.length % CvType.channels(t) != 0)
1359 throw new java.lang.UnsupportedOperationException(
1360 "Provided data element number (" +
1361 (data == null ? 0 : data.length) +
1362 ") should be multiple of the Mat channels count (" +
1363 CvType.channels(t) + ")");
1364 if (CvType.depth(t) == CvType.CV_32F) {
1365 return nGetF(nativeObj, row, col, data.length, data);
1367 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1370 // javadoc:Mat::get(idx,data)
1371 public int get(int[] idx, float[] data) {
1373 if (data == null || data.length % CvType.channels(t) != 0)
1374 throw new java.lang.UnsupportedOperationException(
1375 "Provided data element number (" +
1376 (data == null ? 0 : data.length) +
1377 ") should be multiple of the Mat channels count (" +
1378 CvType.channels(t) + ")");
1379 if (idx.length != dims())
1380 throw new IllegalArgumentException("Incorrect number of indices");
1381 if (CvType.depth(t) == CvType.CV_32F) {
1382 return nGetFIdx(nativeObj, idx, data.length, data);
1384 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1387 // javadoc:Mat::get(row,col,data)
1388 public int get(int row, int col, double[] data) {
1390 if (data == null || data.length % CvType.channels(t) != 0)
1391 throw new java.lang.UnsupportedOperationException(
1392 "Provided data element number (" +
1393 (data == null ? 0 : data.length) +
1394 ") should be multiple of the Mat channels count (" +
1395 CvType.channels(t) + ")");
1396 if (CvType.depth(t) == CvType.CV_64F) {
1397 return nGetD(nativeObj, row, col, data.length, data);
1399 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1402 // javadoc:Mat::get(idx,data)
1403 public int get(int[] idx, double[] data) {
1405 if (data == null || data.length % CvType.channels(t) != 0)
1406 throw new java.lang.UnsupportedOperationException(
1407 "Provided data element number (" +
1408 (data == null ? 0 : data.length) +
1409 ") should be multiple of the Mat channels count (" +
1410 CvType.channels(t) + ")");
1411 if (idx.length != dims())
1412 throw new IllegalArgumentException("Incorrect number of indices");
1413 if (CvType.depth(t) == CvType.CV_64F) {
1414 return nGetDIdx(nativeObj, idx, data.length, data);
1416 throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1419 // javadoc:Mat::get(row,col)
1420 public double[] get(int row, int col) {
1421 return nGet(nativeObj, row, col);
1424 // javadoc:Mat::get(idx)
1425 public double[] get(int[] idx) {
1426 if (idx.length != dims())
1427 throw new IllegalArgumentException("Incorrect number of indices");
1428 return nGetIdx(nativeObj, idx);
1431 // javadoc:Mat::height()
1432 public int height() {
1436 // javadoc:Mat::width()
1437 public int width() {
1441 // javadoc:Mat::getNativeObjAddr()
1442 public long getNativeObjAddr() {
1447 private static native long n_Mat();
1449 // C++: Mat::Mat(int rows, int cols, int type)
1450 private static native long n_Mat(int rows, int cols, int type);
1452 // C++: Mat::Mat(int ndims, const int* sizes, int type)
1453 private static native long n_Mat(int ndims, int[] sizes, int type);
1455 // C++: Mat::Mat(int rows, int cols, int type, void* data)
1456 private static native long n_Mat(int rows, int cols, int type, ByteBuffer data);
1458 // C++: Mat::Mat(Size size, int type)
1459 private static native long n_Mat(double size_width, double size_height, int type);
1461 // C++: Mat::Mat(int rows, int cols, int type, Scalar s)
1462 private static native long n_Mat(int rows, int cols, int type, double s_val0, double s_val1, double s_val2, double s_val3);
1464 // C++: Mat::Mat(Size size, int type, Scalar s)
1465 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);
1467 // C++: Mat::Mat(int ndims, const int* sizes, int type, Scalar s)
1468 private static native long n_Mat(int ndims, int[] sizes, int type, double s_val0, double s_val1, double s_val2, double s_val3);
1470 // C++: Mat::Mat(Mat m, Range rowRange, Range colRange = Range::all())
1471 private static native long n_Mat(long m_nativeObj, int rowRange_start, int rowRange_end, int colRange_start, int colRange_end);
1473 private static native long n_Mat(long m_nativeObj, int rowRange_start, int rowRange_end);
1475 // C++: Mat::Mat(const Mat& m, const std::vector<Range>& ranges)
1476 private static native long n_Mat(long m_nativeObj, Range[] ranges);
1478 // C++: Mat Mat::adjustROI(int dtop, int dbottom, int dleft, int dright)
1479 private static native long n_adjustROI(long nativeObj, int dtop, int dbottom, int dleft, int dright);
1481 // C++: void Mat::assignTo(Mat m, int type = -1)
1482 private static native void n_assignTo(long nativeObj, long m_nativeObj, int type);
1484 private static native void n_assignTo(long nativeObj, long m_nativeObj);
1486 // C++: int Mat::channels()
1487 private static native int n_channels(long nativeObj);
1489 // C++: int Mat::checkVector(int elemChannels, int depth = -1, bool
1490 // requireContinuous = true)
1491 private static native int n_checkVector(long nativeObj, int elemChannels, int depth, boolean requireContinuous);
1493 private static native int n_checkVector(long nativeObj, int elemChannels, int depth);
1495 private static native int n_checkVector(long nativeObj, int elemChannels);
1497 // C++: Mat Mat::clone()
1498 private static native long n_clone(long nativeObj);
1500 // C++: Mat Mat::col(int x)
1501 private static native long n_col(long nativeObj, int x);
1503 // C++: Mat Mat::colRange(int startcol, int endcol)
1504 private static native long n_colRange(long nativeObj, int startcol, int endcol);
1506 // C++: int Mat::dims()
1507 private static native int n_dims(long nativeObj);
1509 // C++: int Mat::cols()
1510 private static native int n_cols(long nativeObj);
1512 // C++: void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta
1514 private static native void n_convertTo(long nativeObj, long m_nativeObj, int rtype, double alpha, double beta);
1516 private static native void n_convertTo(long nativeObj, long m_nativeObj, int rtype, double alpha);
1518 private static native void n_convertTo(long nativeObj, long m_nativeObj, int rtype);
1520 // C++: void Mat::copyTo(Mat& m)
1521 private static native void n_copyTo(long nativeObj, long m_nativeObj);
1523 // C++: void Mat::copyTo(Mat& m, Mat mask)
1524 private static native void n_copyTo(long nativeObj, long m_nativeObj, long mask_nativeObj);
1526 // C++: void Mat::create(int rows, int cols, int type)
1527 private static native void n_create(long nativeObj, int rows, int cols, int type);
1529 // C++: void Mat::create(Size size, int type)
1530 private static native void n_create(long nativeObj, double size_width, double size_height, int type);
1532 // C++: void Mat::create(int ndims, const int* sizes, int type)
1533 private static native void n_create(long nativeObj, int ndims, int[] sizes, int type);
1535 // C++: void Mat::copySize(const Mat& m)
1536 private static native void n_copySize(long nativeObj, long m_nativeObj);
1538 // C++: Mat Mat::cross(Mat m)
1539 private static native long n_cross(long nativeObj, long m_nativeObj);
1541 // C++: long Mat::dataAddr()
1542 private static native long n_dataAddr(long nativeObj);
1544 // C++: int Mat::depth()
1545 private static native int n_depth(long nativeObj);
1547 // C++: Mat Mat::diag(int d = 0)
1548 private static native long n_diag(long nativeObj, int d);
1550 // C++: static Mat Mat::diag(Mat d)
1551 private static native long n_diag(long d_nativeObj);
1553 // C++: double Mat::dot(Mat m)
1554 private static native double n_dot(long nativeObj, long m_nativeObj);
1556 // C++: size_t Mat::elemSize()
1557 private static native long n_elemSize(long nativeObj);
1559 // C++: size_t Mat::elemSize1()
1560 private static native long n_elemSize1(long nativeObj);
1562 // C++: bool Mat::empty()
1563 private static native boolean n_empty(long nativeObj);
1565 // C++: static Mat Mat::eye(int rows, int cols, int type)
1566 private static native long n_eye(int rows, int cols, int type);
1568 // C++: static Mat Mat::eye(Size size, int type)
1569 private static native long n_eye(double size_width, double size_height, int type);
1571 // C++: Mat Mat::inv(int method = DECOMP_LU)
1572 private static native long n_inv(long nativeObj, int method);
1574 private static native long n_inv(long nativeObj);
1576 // C++: bool Mat::isContinuous()
1577 private static native boolean n_isContinuous(long nativeObj);
1579 // C++: bool Mat::isSubmatrix()
1580 private static native boolean n_isSubmatrix(long nativeObj);
1582 // C++: void Mat::locateROI(Size wholeSize, Point ofs)
1583 private static native void locateROI_0(long nativeObj, double[] wholeSize_out, double[] ofs_out);
1585 // C++: Mat Mat::mul(Mat m, double scale = 1)
1586 private static native long n_mul(long nativeObj, long m_nativeObj, double scale);
1588 private static native long n_mul(long nativeObj, long m_nativeObj);
1590 // C++: static Mat Mat::ones(int rows, int cols, int type)
1591 private static native long n_ones(int rows, int cols, int type);
1593 // C++: static Mat Mat::ones(Size size, int type)
1594 private static native long n_ones(double size_width, double size_height, int type);
1596 // C++: static Mat Mat::ones(int ndims, const int* sizes, int type)
1597 private static native long n_ones(int ndims, int[] sizes, int type);
1599 // C++: void Mat::push_back(Mat m)
1600 private static native void n_push_back(long nativeObj, long m_nativeObj);
1602 // C++: void Mat::release()
1603 private static native void n_release(long nativeObj);
1605 // C++: Mat Mat::reshape(int cn, int rows = 0)
1606 private static native long n_reshape(long nativeObj, int cn, int rows);
1608 private static native long n_reshape(long nativeObj, int cn);
1610 // C++: Mat Mat::reshape(int cn, int newndims, const int* newsz)
1611 private static native long n_reshape_1(long nativeObj, int cn, int newndims, int[] newsz);
1613 // C++: Mat Mat::row(int y)
1614 private static native long n_row(long nativeObj, int y);
1616 // C++: Mat Mat::rowRange(int startrow, int endrow)
1617 private static native long n_rowRange(long nativeObj, int startrow, int endrow);
1619 // C++: int Mat::rows()
1620 private static native int n_rows(long nativeObj);
1622 // C++: Mat Mat::operator =(Scalar s)
1623 private static native long n_setTo(long nativeObj, double s_val0, double s_val1, double s_val2, double s_val3);
1625 // C++: Mat Mat::setTo(Scalar value, Mat mask = Mat())
1626 private static native long n_setTo(long nativeObj, double s_val0, double s_val1, double s_val2, double s_val3, long mask_nativeObj);
1628 // C++: Mat Mat::setTo(Mat value, Mat mask = Mat())
1629 private static native long n_setTo(long nativeObj, long value_nativeObj, long mask_nativeObj);
1631 private static native long n_setTo(long nativeObj, long value_nativeObj);
1633 // C++: Size Mat::size()
1634 private static native double[] n_size(long nativeObj);
1636 // C++: int Mat::size(int i)
1637 private static native int n_size_i(long nativeObj, int i);
1639 // C++: size_t Mat::step1(int i = 0)
1640 private static native long n_step1(long nativeObj, int i);
1642 private static native long n_step1(long nativeObj);
1644 // C++: Mat Mat::operator()(Range rowRange, Range colRange)
1645 private static native long n_submat_rr(long nativeObj, int rowRange_start, int rowRange_end, int colRange_start, int colRange_end);
1647 // C++: Mat Mat::operator()(const std::vector<Range>& ranges)
1648 private static native long n_submat_ranges(long nativeObj, Range[] ranges);
1650 // C++: Mat Mat::operator()(Rect roi)
1651 private static native long n_submat(long nativeObj, int roi_x, int roi_y, int roi_width, int roi_height);
1653 // C++: Mat Mat::t()
1654 private static native long n_t(long nativeObj);
1656 // C++: size_t Mat::total()
1657 private static native long n_total(long nativeObj);
1659 // C++: int Mat::type()
1660 private static native int n_type(long nativeObj);
1662 // C++: static Mat Mat::zeros(int rows, int cols, int type)
1663 private static native long n_zeros(int rows, int cols, int type);
1665 // C++: static Mat Mat::zeros(Size size, int type)
1666 private static native long n_zeros(double size_width, double size_height, int type);
1668 // C++: static Mat Mat::zeros(int ndims, const int* sizes, int type)
1669 private static native long n_zeros(int ndims, int[] sizes, int type);
1671 // native support for java finalize()
1672 private static native void n_delete(long nativeObj);
1674 private static native int nPutD(long self, int row, int col, int count, double[] data);
1676 private static native int nPutDIdx(long self, int[] idx, int count, double[] data);
1678 private static native int nPutF(long self, int row, int col, int count, float[] data);
1680 private static native int nPutFIdx(long self, int[] idx, int count, float[] data);
1682 private static native int nPutI(long self, int row, int col, int count, int[] data);
1684 private static native int nPutIIdx(long self, int[] idx, int count, int[] data);
1686 private static native int nPutS(long self, int row, int col, int count, short[] data);
1688 private static native int nPutSIdx(long self, int[] idx, int count, short[] data);
1690 private static native int nPutB(long self, int row, int col, int count, byte[] data);
1692 private static native int nPutBIdx(long self, int[] idx, int count, byte[] data);
1694 private static native int nPutBwOffset(long self, int row, int col, int count, int offset, byte[] data);
1696 private static native int nPutBwIdxOffset(long self, int[] idx, int count, int offset, byte[] data);
1698 private static native int nGetB(long self, int row, int col, int count, byte[] vals);
1700 private static native int nGetBIdx(long self, int[] idx, int count, byte[] vals);
1702 private static native int nGetS(long self, int row, int col, int count, short[] vals);
1704 private static native int nGetSIdx(long self, int[] idx, int count, short[] vals);
1706 private static native int nGetI(long self, int row, int col, int count, int[] vals);
1708 private static native int nGetIIdx(long self, int[] idx, int count, int[] vals);
1710 private static native int nGetF(long self, int row, int col, int count, float[] vals);
1712 private static native int nGetFIdx(long self, int[] idx, int count, float[] vals);
1714 private static native int nGetD(long self, int row, int col, int count, double[] vals);
1716 private static native int nGetDIdx(long self, int[] idx, int count, double[] vals);
1718 private static native double[] nGet(long self, int row, int col);
1720 private static native double[] nGetIdx(long self, int[] idx);
1722 private static native String nDump(long self);