001package org.opencv.core;
002
003// C++: class Mat
004//javadoc: Mat
005public class Mat {
006
007    public final long nativeObj;
008
009    public Mat(long addr)
010    {
011        if (addr == 0)
012            throw new java.lang.UnsupportedOperationException("Native object address is NULL");
013        nativeObj = addr;
014    }
015
016    //
017    // C++: Mat::Mat()
018    //
019
020    // javadoc: Mat::Mat()
021    public Mat()
022    {
023
024        nativeObj = n_Mat();
025
026        return;
027    }
028
029    //
030    // C++: Mat::Mat(int rows, int cols, int type)
031    //
032
033    // javadoc: Mat::Mat(rows, cols, type)
034    public Mat(int rows, int cols, int type)
035    {
036
037        nativeObj = n_Mat(rows, cols, type);
038
039        return;
040    }
041
042    //
043    // C++: Mat::Mat(Size size, int type)
044    //
045
046    // javadoc: Mat::Mat(size, type)
047    public Mat(Size size, int type)
048    {
049
050        nativeObj = n_Mat(size.width, size.height, type);
051
052        return;
053    }
054
055    //
056    // C++: Mat::Mat(int rows, int cols, int type, Scalar s)
057    //
058
059    // javadoc: Mat::Mat(rows, cols, type, s)
060    public Mat(int rows, int cols, int type, Scalar s)
061    {
062
063        nativeObj = n_Mat(rows, cols, type, s.val[0], s.val[1], s.val[2], s.val[3]);
064
065        return;
066    }
067
068    //
069    // C++: Mat::Mat(Size size, int type, Scalar s)
070    //
071
072    // javadoc: Mat::Mat(size, type, s)
073    public Mat(Size size, int type, Scalar s)
074    {
075
076        nativeObj = n_Mat(size.width, size.height, type, s.val[0], s.val[1], s.val[2], s.val[3]);
077
078        return;
079    }
080
081    //
082    // C++: Mat::Mat(Mat m, Range rowRange, Range colRange = Range::all())
083    //
084
085    // javadoc: Mat::Mat(m, rowRange, colRange)
086    public Mat(Mat m, Range rowRange, Range colRange)
087    {
088
089        nativeObj = n_Mat(m.nativeObj, rowRange.start, rowRange.end, colRange.start, colRange.end);
090
091        return;
092    }
093
094    // javadoc: Mat::Mat(m, rowRange)
095    public Mat(Mat m, Range rowRange)
096    {
097
098        nativeObj = n_Mat(m.nativeObj, rowRange.start, rowRange.end);
099
100        return;
101    }
102
103    //
104    // C++: Mat::Mat(Mat m, Rect roi)
105    //
106
107    // javadoc: Mat::Mat(m, roi)
108    public Mat(Mat m, Rect roi)
109    {
110
111        nativeObj = n_Mat(m.nativeObj, roi.y, roi.y + roi.height, roi.x, roi.x + roi.width);
112
113        return;
114    }
115
116    //
117    // C++: Mat Mat::adjustROI(int dtop, int dbottom, int dleft, int dright)
118    //
119
120    // javadoc: Mat::adjustROI(dtop, dbottom, dleft, dright)
121    public Mat adjustROI(int dtop, int dbottom, int dleft, int dright)
122    {
123
124        Mat retVal = new Mat(n_adjustROI(nativeObj, dtop, dbottom, dleft, dright));
125
126        return retVal;
127    }
128
129    //
130    // C++: void Mat::assignTo(Mat m, int type = -1)
131    //
132
133    // javadoc: Mat::assignTo(m, type)
134    public void assignTo(Mat m, int type)
135    {
136
137        n_assignTo(nativeObj, m.nativeObj, type);
138
139        return;
140    }
141
142    // javadoc: Mat::assignTo(m)
143    public void assignTo(Mat m)
144    {
145
146        n_assignTo(nativeObj, m.nativeObj);
147
148        return;
149    }
150
151    //
152    // C++: int Mat::channels()
153    //
154
155    // javadoc: Mat::channels()
156    public int channels()
157    {
158
159        int retVal = n_channels(nativeObj);
160
161        return retVal;
162    }
163
164    //
165    // C++: int Mat::checkVector(int elemChannels, int depth = -1, bool
166    // requireContinuous = true)
167    //
168
169    // javadoc: Mat::checkVector(elemChannels, depth, requireContinuous)
170    public int checkVector(int elemChannels, int depth, boolean requireContinuous)
171    {
172
173        int retVal = n_checkVector(nativeObj, elemChannels, depth, requireContinuous);
174
175        return retVal;
176    }
177
178    // javadoc: Mat::checkVector(elemChannels, depth)
179    public int checkVector(int elemChannels, int depth)
180    {
181
182        int retVal = n_checkVector(nativeObj, elemChannels, depth);
183
184        return retVal;
185    }
186
187    // javadoc: Mat::checkVector(elemChannels)
188    public int checkVector(int elemChannels)
189    {
190
191        int retVal = n_checkVector(nativeObj, elemChannels);
192
193        return retVal;
194    }
195
196    //
197    // C++: Mat Mat::clone()
198    //
199
200    // javadoc: Mat::clone()
201    public Mat clone()
202    {
203
204        Mat retVal = new Mat(n_clone(nativeObj));
205
206        return retVal;
207    }
208
209    //
210    // C++: Mat Mat::col(int x)
211    //
212
213    // javadoc: Mat::col(x)
214    public Mat col(int x)
215    {
216
217        Mat retVal = new Mat(n_col(nativeObj, x));
218
219        return retVal;
220    }
221
222    //
223    // C++: Mat Mat::colRange(int startcol, int endcol)
224    //
225
226    // javadoc: Mat::colRange(startcol, endcol)
227    public Mat colRange(int startcol, int endcol)
228    {
229
230        Mat retVal = new Mat(n_colRange(nativeObj, startcol, endcol));
231
232        return retVal;
233    }
234
235    //
236    // C++: Mat Mat::colRange(Range r)
237    //
238
239    // javadoc: Mat::colRange(r)
240    public Mat colRange(Range r)
241    {
242
243        Mat retVal = new Mat(n_colRange(nativeObj, r.start, r.end));
244
245        return retVal;
246    }
247
248    //
249    // C++: int Mat::dims()
250    //
251
252    // javadoc: Mat::dims()
253    public int dims()
254    {
255
256        int retVal = n_dims(nativeObj);
257
258        return retVal;
259    }
260
261    //
262    // C++: int Mat::cols()
263    //
264
265    // javadoc: Mat::cols()
266    public int cols()
267    {
268
269        int retVal = n_cols(nativeObj);
270
271        return retVal;
272    }
273
274    //
275    // C++: void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta
276    // = 0)
277    //
278
279    // javadoc: Mat::convertTo(m, rtype, alpha, beta)
280    public void convertTo(Mat m, int rtype, double alpha, double beta)
281    {
282
283        n_convertTo(nativeObj, m.nativeObj, rtype, alpha, beta);
284
285        return;
286    }
287
288    // javadoc: Mat::convertTo(m, rtype, alpha)
289    public void convertTo(Mat m, int rtype, double alpha)
290    {
291
292        n_convertTo(nativeObj, m.nativeObj, rtype, alpha);
293
294        return;
295    }
296
297    // javadoc: Mat::convertTo(m, rtype)
298    public void convertTo(Mat m, int rtype)
299    {
300
301        n_convertTo(nativeObj, m.nativeObj, rtype);
302
303        return;
304    }
305
306    //
307    // C++: void Mat::copyTo(Mat& m)
308    //
309
310    // javadoc: Mat::copyTo(m)
311    public void copyTo(Mat m)
312    {
313
314        n_copyTo(nativeObj, m.nativeObj);
315
316        return;
317    }
318
319    //
320    // C++: void Mat::copyTo(Mat& m, Mat mask)
321    //
322
323    // javadoc: Mat::copyTo(m, mask)
324    public void copyTo(Mat m, Mat mask)
325    {
326
327        n_copyTo(nativeObj, m.nativeObj, mask.nativeObj);
328
329        return;
330    }
331
332    //
333    // C++: void Mat::create(int rows, int cols, int type)
334    //
335
336    // javadoc: Mat::create(rows, cols, type)
337    public void create(int rows, int cols, int type)
338    {
339
340        n_create(nativeObj, rows, cols, type);
341
342        return;
343    }
344
345    //
346    // C++: void Mat::create(Size size, int type)
347    //
348
349    // javadoc: Mat::create(size, type)
350    public void create(Size size, int type)
351    {
352
353        n_create(nativeObj, size.width, size.height, type);
354
355        return;
356    }
357
358    //
359    // C++: Mat Mat::cross(Mat m)
360    //
361
362    // javadoc: Mat::cross(m)
363    public Mat cross(Mat m)
364    {
365
366        Mat retVal = new Mat(n_cross(nativeObj, m.nativeObj));
367
368        return retVal;
369    }
370
371    //
372    // C++: long Mat::dataAddr()
373    //
374
375    // javadoc: Mat::dataAddr()
376    public long dataAddr()
377    {
378
379        long retVal = n_dataAddr(nativeObj);
380
381        return retVal;
382    }
383
384    //
385    // C++: int Mat::depth()
386    //
387
388    // javadoc: Mat::depth()
389    public int depth()
390    {
391
392        int retVal = n_depth(nativeObj);
393
394        return retVal;
395    }
396
397    //
398    // C++: Mat Mat::diag(int d = 0)
399    //
400
401    // javadoc: Mat::diag(d)
402    public Mat diag(int d)
403    {
404
405        Mat retVal = new Mat(n_diag(nativeObj, d));
406
407        return retVal;
408    }
409
410    // javadoc: Mat::diag()
411    public Mat diag()
412    {
413
414        Mat retVal = new Mat(n_diag(nativeObj, 0));
415
416        return retVal;
417    }
418
419    //
420    // C++: static Mat Mat::diag(Mat d)
421    //
422
423    // javadoc: Mat::diag(d)
424    public static Mat diag(Mat d)
425    {
426
427        Mat retVal = new Mat(n_diag(d.nativeObj));
428
429        return retVal;
430    }
431
432    //
433    // C++: double Mat::dot(Mat m)
434    //
435
436    // javadoc: Mat::dot(m)
437    public double dot(Mat m)
438    {
439
440        double retVal = n_dot(nativeObj, m.nativeObj);
441
442        return retVal;
443    }
444
445    //
446    // C++: size_t Mat::elemSize()
447    //
448
449    // javadoc: Mat::elemSize()
450    public long elemSize()
451    {
452
453        long retVal = n_elemSize(nativeObj);
454
455        return retVal;
456    }
457
458    //
459    // C++: size_t Mat::elemSize1()
460    //
461
462    // javadoc: Mat::elemSize1()
463    public long elemSize1()
464    {
465
466        long retVal = n_elemSize1(nativeObj);
467
468        return retVal;
469    }
470
471    //
472    // C++: bool Mat::empty()
473    //
474
475    // javadoc: Mat::empty()
476    public boolean empty()
477    {
478
479        boolean retVal = n_empty(nativeObj);
480
481        return retVal;
482    }
483
484    //
485    // C++: static Mat Mat::eye(int rows, int cols, int type)
486    //
487
488    // javadoc: Mat::eye(rows, cols, type)
489    public static Mat eye(int rows, int cols, int type)
490    {
491
492        Mat retVal = new Mat(n_eye(rows, cols, type));
493
494        return retVal;
495    }
496
497    //
498    // C++: static Mat Mat::eye(Size size, int type)
499    //
500
501    // javadoc: Mat::eye(size, type)
502    public static Mat eye(Size size, int type)
503    {
504
505        Mat retVal = new Mat(n_eye(size.width, size.height, type));
506
507        return retVal;
508    }
509
510    //
511    // C++: Mat Mat::inv(int method = DECOMP_LU)
512    //
513
514    // javadoc: Mat::inv(method)
515    public Mat inv(int method)
516    {
517
518        Mat retVal = new Mat(n_inv(nativeObj, method));
519
520        return retVal;
521    }
522
523    // javadoc: Mat::inv()
524    public Mat inv()
525    {
526
527        Mat retVal = new Mat(n_inv(nativeObj));
528
529        return retVal;
530    }
531
532    //
533    // C++: bool Mat::isContinuous()
534    //
535
536    // javadoc: Mat::isContinuous()
537    public boolean isContinuous()
538    {
539
540        boolean retVal = n_isContinuous(nativeObj);
541
542        return retVal;
543    }
544
545    //
546    // C++: bool Mat::isSubmatrix()
547    //
548
549    // javadoc: Mat::isSubmatrix()
550    public boolean isSubmatrix()
551    {
552
553        boolean retVal = n_isSubmatrix(nativeObj);
554
555        return retVal;
556    }
557
558    //
559    // C++: void Mat::locateROI(Size wholeSize, Point ofs)
560    //
561
562    // javadoc: Mat::locateROI(wholeSize, ofs)
563    public void locateROI(Size wholeSize, Point ofs)
564    {
565        double[] wholeSize_out = new double[2];
566        double[] ofs_out = new double[2];
567        locateROI_0(nativeObj, wholeSize_out, ofs_out);
568        if(wholeSize!=null){ wholeSize.width = wholeSize_out[0]; wholeSize.height = wholeSize_out[1]; }
569        if(ofs!=null){ ofs.x = ofs_out[0]; ofs.y = ofs_out[1]; }
570        return;
571    }
572
573    //
574    // C++: Mat Mat::mul(Mat m, double scale = 1)
575    //
576
577    // javadoc: Mat::mul(m, scale)
578    public Mat mul(Mat m, double scale)
579    {
580
581        Mat retVal = new Mat(n_mul(nativeObj, m.nativeObj, scale));
582
583        return retVal;
584    }
585
586    // javadoc: Mat::mul(m)
587    public Mat mul(Mat m)
588    {
589
590        Mat retVal = new Mat(n_mul(nativeObj, m.nativeObj));
591
592        return retVal;
593    }
594
595    //
596    // C++: static Mat Mat::ones(int rows, int cols, int type)
597    //
598
599    // javadoc: Mat::ones(rows, cols, type)
600    public static Mat ones(int rows, int cols, int type)
601    {
602
603        Mat retVal = new Mat(n_ones(rows, cols, type));
604
605        return retVal;
606    }
607
608    //
609    // C++: static Mat Mat::ones(Size size, int type)
610    //
611
612    // javadoc: Mat::ones(size, type)
613    public static Mat ones(Size size, int type)
614    {
615
616        Mat retVal = new Mat(n_ones(size.width, size.height, type));
617
618        return retVal;
619    }
620
621    //
622    // C++: void Mat::push_back(Mat m)
623    //
624
625    // javadoc: Mat::push_back(m)
626    public void push_back(Mat m)
627    {
628
629        n_push_back(nativeObj, m.nativeObj);
630
631        return;
632    }
633
634    //
635    // C++: void Mat::release()
636    //
637
638    // javadoc: Mat::release()
639    public void release()
640    {
641
642        n_release(nativeObj);
643
644        return;
645    }
646
647    //
648    // C++: Mat Mat::reshape(int cn, int rows = 0)
649    //
650
651    // javadoc: Mat::reshape(cn, rows)
652    public Mat reshape(int cn, int rows)
653    {
654
655        Mat retVal = new Mat(n_reshape(nativeObj, cn, rows));
656
657        return retVal;
658    }
659
660    // javadoc: Mat::reshape(cn)
661    public Mat reshape(int cn)
662    {
663
664        Mat retVal = new Mat(n_reshape(nativeObj, cn));
665
666        return retVal;
667    }
668
669    //
670    // C++: Mat Mat::row(int y)
671    //
672
673    // javadoc: Mat::row(y)
674    public Mat row(int y)
675    {
676
677        Mat retVal = new Mat(n_row(nativeObj, y));
678
679        return retVal;
680    }
681
682    //
683    // C++: Mat Mat::rowRange(int startrow, int endrow)
684    //
685
686    // javadoc: Mat::rowRange(startrow, endrow)
687    public Mat rowRange(int startrow, int endrow)
688    {
689
690        Mat retVal = new Mat(n_rowRange(nativeObj, startrow, endrow));
691
692        return retVal;
693    }
694
695    //
696    // C++: Mat Mat::rowRange(Range r)
697    //
698
699    // javadoc: Mat::rowRange(r)
700    public Mat rowRange(Range r)
701    {
702
703        Mat retVal = new Mat(n_rowRange(nativeObj, r.start, r.end));
704
705        return retVal;
706    }
707
708    //
709    // C++: int Mat::rows()
710    //
711
712    // javadoc: Mat::rows()
713    public int rows()
714    {
715
716        int retVal = n_rows(nativeObj);
717
718        return retVal;
719    }
720
721    //
722    // C++: Mat Mat::operator =(Scalar s)
723    //
724
725    // javadoc: Mat::operator =(s)
726    public Mat setTo(Scalar s)
727    {
728
729        Mat retVal = new Mat(n_setTo(nativeObj, s.val[0], s.val[1], s.val[2], s.val[3]));
730
731        return retVal;
732    }
733
734    //
735    // C++: Mat Mat::setTo(Scalar value, Mat mask = Mat())
736    //
737
738    // javadoc: Mat::setTo(value, mask)
739    public Mat setTo(Scalar value, Mat mask)
740    {
741
742        Mat retVal = new Mat(n_setTo(nativeObj, value.val[0], value.val[1], value.val[2], value.val[3], mask.nativeObj));
743
744        return retVal;
745    }
746
747    //
748    // C++: Mat Mat::setTo(Mat value, Mat mask = Mat())
749    //
750
751    // javadoc: Mat::setTo(value, mask)
752    public Mat setTo(Mat value, Mat mask)
753    {
754
755        Mat retVal = new Mat(n_setTo(nativeObj, value.nativeObj, mask.nativeObj));
756
757        return retVal;
758    }
759
760    // javadoc: Mat::setTo(value)
761    public Mat setTo(Mat value)
762    {
763
764        Mat retVal = new Mat(n_setTo(nativeObj, value.nativeObj));
765
766        return retVal;
767    }
768
769    //
770    // C++: Size Mat::size()
771    //
772
773    // javadoc: Mat::size()
774    public Size size()
775    {
776
777        Size retVal = new Size(n_size(nativeObj));
778
779        return retVal;
780    }
781
782    //
783    // C++: size_t Mat::step1(int i = 0)
784    //
785
786    // javadoc: Mat::step1(i)
787    public long step1(int i)
788    {
789
790        long retVal = n_step1(nativeObj, i);
791
792        return retVal;
793    }
794
795    // javadoc: Mat::step1()
796    public long step1()
797    {
798
799        long retVal = n_step1(nativeObj);
800
801        return retVal;
802    }
803
804    //
805    // C++: Mat Mat::operator()(int rowStart, int rowEnd, int colStart, int
806    // colEnd)
807    //
808
809    // javadoc: Mat::operator()(rowStart, rowEnd, colStart, colEnd)
810    public Mat submat(int rowStart, int rowEnd, int colStart, int colEnd)
811    {
812
813        Mat retVal = new Mat(n_submat_rr(nativeObj, rowStart, rowEnd, colStart, colEnd));
814
815        return retVal;
816    }
817
818    //
819    // C++: Mat Mat::operator()(Range rowRange, Range colRange)
820    //
821
822    // javadoc: Mat::operator()(rowRange, colRange)
823    public Mat submat(Range rowRange, Range colRange)
824    {
825
826        Mat retVal = new Mat(n_submat_rr(nativeObj, rowRange.start, rowRange.end, colRange.start, colRange.end));
827
828        return retVal;
829    }
830
831    //
832    // C++: Mat Mat::operator()(Rect roi)
833    //
834
835    // javadoc: Mat::operator()(roi)
836    public Mat submat(Rect roi)
837    {
838
839        Mat retVal = new Mat(n_submat(nativeObj, roi.x, roi.y, roi.width, roi.height));
840
841        return retVal;
842    }
843
844    //
845    // C++: Mat Mat::t()
846    //
847
848    // javadoc: Mat::t()
849    public Mat t()
850    {
851
852        Mat retVal = new Mat(n_t(nativeObj));
853
854        return retVal;
855    }
856
857    //
858    // C++: size_t Mat::total()
859    //
860
861    // javadoc: Mat::total()
862    public long total()
863    {
864
865        long retVal = n_total(nativeObj);
866
867        return retVal;
868    }
869
870    //
871    // C++: int Mat::type()
872    //
873
874    // javadoc: Mat::type()
875    public int type()
876    {
877
878        int retVal = n_type(nativeObj);
879
880        return retVal;
881    }
882
883    //
884    // C++: static Mat Mat::zeros(int rows, int cols, int type)
885    //
886
887    // javadoc: Mat::zeros(rows, cols, type)
888    public static Mat zeros(int rows, int cols, int type)
889    {
890
891        Mat retVal = new Mat(n_zeros(rows, cols, type));
892
893        return retVal;
894    }
895
896    //
897    // C++: static Mat Mat::zeros(Size size, int type)
898    //
899
900    // javadoc: Mat::zeros(size, type)
901    public static Mat zeros(Size size, int type)
902    {
903
904        Mat retVal = new Mat(n_zeros(size.width, size.height, type));
905
906        return retVal;
907    }
908
909    @Override
910    protected void finalize() throws Throwable {
911        n_delete(nativeObj);
912        super.finalize();
913    }
914
915    // javadoc:Mat::toString()
916    @Override
917    public String toString() {
918        return "Mat [ " +
919                rows() + "*" + cols() + "*" + CvType.typeToString(type()) +
920                ", isCont=" + isContinuous() + ", isSubmat=" + isSubmatrix() +
921                ", nativeObj=0x" + Long.toHexString(nativeObj) +
922                ", dataAddr=0x" + Long.toHexString(dataAddr()) +
923                " ]";
924    }
925
926    // javadoc:Mat::dump()
927    public String dump() {
928        return nDump(nativeObj);
929    }
930
931    // javadoc:Mat::put(row,col,data)
932    public int put(int row, int col, double... data) {
933        int t = type();
934        if (data == null || data.length % CvType.channels(t) != 0)
935            throw new java.lang.UnsupportedOperationException(
936                    "Provided data element number (" +
937                            (data == null ? 0 : data.length) +
938                            ") should be multiple of the Mat channels count (" +
939                            CvType.channels(t) + ")");
940        return nPutD(nativeObj, row, col, data.length, data);
941    }
942
943    // javadoc:Mat::put(row,col,data)
944    public int put(int row, int col, float[] data) {
945        int t = type();
946        if (data == null || data.length % CvType.channels(t) != 0)
947            throw new java.lang.UnsupportedOperationException(
948                    "Provided data element number (" +
949                            (data == null ? 0 : data.length) +
950                            ") should be multiple of the Mat channels count (" +
951                            CvType.channels(t) + ")");
952        if (CvType.depth(t) == CvType.CV_32F) {
953            return nPutF(nativeObj, row, col, data.length, data);
954        }
955        throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
956    }
957
958    // javadoc:Mat::put(row,col,data)
959    public int put(int row, int col, int[] data) {
960        int t = type();
961        if (data == null || data.length % CvType.channels(t) != 0)
962            throw new java.lang.UnsupportedOperationException(
963                    "Provided data element number (" +
964                            (data == null ? 0 : data.length) +
965                            ") should be multiple of the Mat channels count (" +
966                            CvType.channels(t) + ")");
967        if (CvType.depth(t) == CvType.CV_32S) {
968            return nPutI(nativeObj, row, col, data.length, data);
969        }
970        throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
971    }
972
973    // javadoc:Mat::put(row,col,data)
974    public int put(int row, int col, short[] data) {
975        int t = type();
976        if (data == null || data.length % CvType.channels(t) != 0)
977            throw new java.lang.UnsupportedOperationException(
978                    "Provided data element number (" +
979                            (data == null ? 0 : data.length) +
980                            ") should be multiple of the Mat channels count (" +
981                            CvType.channels(t) + ")");
982        if (CvType.depth(t) == CvType.CV_16U || CvType.depth(t) == CvType.CV_16S) {
983            return nPutS(nativeObj, row, col, data.length, data);
984        }
985        throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
986    }
987
988    // javadoc:Mat::put(row,col,data)
989    public int put(int row, int col, byte[] data) {
990        int t = type();
991        if (data == null || data.length % CvType.channels(t) != 0)
992            throw new java.lang.UnsupportedOperationException(
993                    "Provided data element number (" +
994                            (data == null ? 0 : data.length) +
995                            ") should be multiple of the Mat channels count (" +
996                            CvType.channels(t) + ")");
997        if (CvType.depth(t) == CvType.CV_8U || CvType.depth(t) == CvType.CV_8S) {
998            return nPutB(nativeObj, row, col, data.length, data);
999        }
1000        throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1001    }
1002
1003    // javadoc:Mat::get(row,col,data)
1004    public int get(int row, int col, byte[] data) {
1005        int t = type();
1006        if (data == null || data.length % CvType.channels(t) != 0)
1007            throw new java.lang.UnsupportedOperationException(
1008                    "Provided data element number (" +
1009                            (data == null ? 0 : data.length) +
1010                            ") should be multiple of the Mat channels count (" +
1011                            CvType.channels(t) + ")");
1012        if (CvType.depth(t) == CvType.CV_8U || CvType.depth(t) == CvType.CV_8S) {
1013            return nGetB(nativeObj, row, col, data.length, data);
1014        }
1015        throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1016    }
1017
1018    // javadoc:Mat::get(row,col,data)
1019    public int get(int row, int col, short[] data) {
1020        int t = type();
1021        if (data == null || data.length % CvType.channels(t) != 0)
1022            throw new java.lang.UnsupportedOperationException(
1023                    "Provided data element number (" +
1024                            (data == null ? 0 : data.length) +
1025                            ") should be multiple of the Mat channels count (" +
1026                            CvType.channels(t) + ")");
1027        if (CvType.depth(t) == CvType.CV_16U || CvType.depth(t) == CvType.CV_16S) {
1028            return nGetS(nativeObj, row, col, data.length, data);
1029        }
1030        throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1031    }
1032
1033    // javadoc:Mat::get(row,col,data)
1034    public int get(int row, int col, int[] data) {
1035        int t = type();
1036        if (data == null || data.length % CvType.channels(t) != 0)
1037            throw new java.lang.UnsupportedOperationException(
1038                    "Provided data element number (" +
1039                            (data == null ? 0 : data.length) +
1040                            ") should be multiple of the Mat channels count (" +
1041                            CvType.channels(t) + ")");
1042        if (CvType.depth(t) == CvType.CV_32S) {
1043            return nGetI(nativeObj, row, col, data.length, data);
1044        }
1045        throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1046    }
1047
1048    // javadoc:Mat::get(row,col,data)
1049    public int get(int row, int col, float[] data) {
1050        int t = type();
1051        if (data == null || data.length % CvType.channels(t) != 0)
1052            throw new java.lang.UnsupportedOperationException(
1053                    "Provided data element number (" +
1054                            (data == null ? 0 : data.length) +
1055                            ") should be multiple of the Mat channels count (" +
1056                            CvType.channels(t) + ")");
1057        if (CvType.depth(t) == CvType.CV_32F) {
1058            return nGetF(nativeObj, row, col, data.length, data);
1059        }
1060        throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1061    }
1062
1063    // javadoc:Mat::get(row,col,data)
1064    public int get(int row, int col, double[] data) {
1065        int t = type();
1066        if (data == null || data.length % CvType.channels(t) != 0)
1067            throw new java.lang.UnsupportedOperationException(
1068                    "Provided data element number (" +
1069                            (data == null ? 0 : data.length) +
1070                            ") should be multiple of the Mat channels count (" +
1071                            CvType.channels(t) + ")");
1072        if (CvType.depth(t) == CvType.CV_64F) {
1073            return nGetD(nativeObj, row, col, data.length, data);
1074        }
1075        throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t);
1076    }
1077
1078    // javadoc:Mat::get(row,col)
1079    public double[] get(int row, int col) {
1080        return nGet(nativeObj, row, col);
1081    }
1082
1083    // javadoc:Mat::height()
1084    public int height() {
1085        return rows();
1086    }
1087
1088    // javadoc:Mat::width()
1089    public int width() {
1090        return cols();
1091    }
1092
1093    // javadoc:Mat::getNativeObjAddr()
1094    public long getNativeObjAddr() {
1095        return nativeObj;
1096    }
1097
1098    // C++: Mat::Mat()
1099    private static native long n_Mat();
1100
1101    // C++: Mat::Mat(int rows, int cols, int type)
1102    private static native long n_Mat(int rows, int cols, int type);
1103
1104    // C++: Mat::Mat(Size size, int type)
1105    private static native long n_Mat(double size_width, double size_height, int type);
1106
1107    // C++: Mat::Mat(int rows, int cols, int type, Scalar s)
1108    private static native long n_Mat(int rows, int cols, int type, double s_val0, double s_val1, double s_val2, double s_val3);
1109
1110    // C++: Mat::Mat(Size size, int type, Scalar s)
1111    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);
1112
1113    // C++: Mat::Mat(Mat m, Range rowRange, Range colRange = Range::all())
1114    private static native long n_Mat(long m_nativeObj, int rowRange_start, int rowRange_end, int colRange_start, int colRange_end);
1115
1116    private static native long n_Mat(long m_nativeObj, int rowRange_start, int rowRange_end);
1117
1118    // C++: Mat Mat::adjustROI(int dtop, int dbottom, int dleft, int dright)
1119    private static native long n_adjustROI(long nativeObj, int dtop, int dbottom, int dleft, int dright);
1120
1121    // C++: void Mat::assignTo(Mat m, int type = -1)
1122    private static native void n_assignTo(long nativeObj, long m_nativeObj, int type);
1123
1124    private static native void n_assignTo(long nativeObj, long m_nativeObj);
1125
1126    // C++: int Mat::channels()
1127    private static native int n_channels(long nativeObj);
1128
1129    // C++: int Mat::checkVector(int elemChannels, int depth = -1, bool
1130    // requireContinuous = true)
1131    private static native int n_checkVector(long nativeObj, int elemChannels, int depth, boolean requireContinuous);
1132
1133    private static native int n_checkVector(long nativeObj, int elemChannels, int depth);
1134
1135    private static native int n_checkVector(long nativeObj, int elemChannels);
1136
1137    // C++: Mat Mat::clone()
1138    private static native long n_clone(long nativeObj);
1139
1140    // C++: Mat Mat::col(int x)
1141    private static native long n_col(long nativeObj, int x);
1142
1143    // C++: Mat Mat::colRange(int startcol, int endcol)
1144    private static native long n_colRange(long nativeObj, int startcol, int endcol);
1145
1146    // C++: int Mat::dims()
1147    private static native int n_dims(long nativeObj);
1148
1149    // C++: int Mat::cols()
1150    private static native int n_cols(long nativeObj);
1151
1152    // C++: void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta
1153    // = 0)
1154    private static native void n_convertTo(long nativeObj, long m_nativeObj, int rtype, double alpha, double beta);
1155
1156    private static native void n_convertTo(long nativeObj, long m_nativeObj, int rtype, double alpha);
1157
1158    private static native void n_convertTo(long nativeObj, long m_nativeObj, int rtype);
1159
1160    // C++: void Mat::copyTo(Mat& m)
1161    private static native void n_copyTo(long nativeObj, long m_nativeObj);
1162
1163    // C++: void Mat::copyTo(Mat& m, Mat mask)
1164    private static native void n_copyTo(long nativeObj, long m_nativeObj, long mask_nativeObj);
1165
1166    // C++: void Mat::create(int rows, int cols, int type)
1167    private static native void n_create(long nativeObj, int rows, int cols, int type);
1168
1169    // C++: void Mat::create(Size size, int type)
1170    private static native void n_create(long nativeObj, double size_width, double size_height, int type);
1171
1172    // C++: Mat Mat::cross(Mat m)
1173    private static native long n_cross(long nativeObj, long m_nativeObj);
1174
1175    // C++: long Mat::dataAddr()
1176    private static native long n_dataAddr(long nativeObj);
1177
1178    // C++: int Mat::depth()
1179    private static native int n_depth(long nativeObj);
1180
1181    // C++: Mat Mat::diag(int d = 0)
1182    private static native long n_diag(long nativeObj, int d);
1183
1184    // C++: static Mat Mat::diag(Mat d)
1185    private static native long n_diag(long d_nativeObj);
1186
1187    // C++: double Mat::dot(Mat m)
1188    private static native double n_dot(long nativeObj, long m_nativeObj);
1189
1190    // C++: size_t Mat::elemSize()
1191    private static native long n_elemSize(long nativeObj);
1192
1193    // C++: size_t Mat::elemSize1()
1194    private static native long n_elemSize1(long nativeObj);
1195
1196    // C++: bool Mat::empty()
1197    private static native boolean n_empty(long nativeObj);
1198
1199    // C++: static Mat Mat::eye(int rows, int cols, int type)
1200    private static native long n_eye(int rows, int cols, int type);
1201
1202    // C++: static Mat Mat::eye(Size size, int type)
1203    private static native long n_eye(double size_width, double size_height, int type);
1204
1205    // C++: Mat Mat::inv(int method = DECOMP_LU)
1206    private static native long n_inv(long nativeObj, int method);
1207
1208    private static native long n_inv(long nativeObj);
1209
1210    // C++: bool Mat::isContinuous()
1211    private static native boolean n_isContinuous(long nativeObj);
1212
1213    // C++: bool Mat::isSubmatrix()
1214    private static native boolean n_isSubmatrix(long nativeObj);
1215
1216    // C++: void Mat::locateROI(Size wholeSize, Point ofs)
1217    private static native void locateROI_0(long nativeObj, double[] wholeSize_out, double[] ofs_out);
1218
1219    // C++: Mat Mat::mul(Mat m, double scale = 1)
1220    private static native long n_mul(long nativeObj, long m_nativeObj, double scale);
1221
1222    private static native long n_mul(long nativeObj, long m_nativeObj);
1223
1224    // C++: static Mat Mat::ones(int rows, int cols, int type)
1225    private static native long n_ones(int rows, int cols, int type);
1226
1227    // C++: static Mat Mat::ones(Size size, int type)
1228    private static native long n_ones(double size_width, double size_height, int type);
1229
1230    // C++: void Mat::push_back(Mat m)
1231    private static native void n_push_back(long nativeObj, long m_nativeObj);
1232
1233    // C++: void Mat::release()
1234    private static native void n_release(long nativeObj);
1235
1236    // C++: Mat Mat::reshape(int cn, int rows = 0)
1237    private static native long n_reshape(long nativeObj, int cn, int rows);
1238
1239    private static native long n_reshape(long nativeObj, int cn);
1240
1241    // C++: Mat Mat::row(int y)
1242    private static native long n_row(long nativeObj, int y);
1243
1244    // C++: Mat Mat::rowRange(int startrow, int endrow)
1245    private static native long n_rowRange(long nativeObj, int startrow, int endrow);
1246
1247    // C++: int Mat::rows()
1248    private static native int n_rows(long nativeObj);
1249
1250    // C++: Mat Mat::operator =(Scalar s)
1251    private static native long n_setTo(long nativeObj, double s_val0, double s_val1, double s_val2, double s_val3);
1252
1253    // C++: Mat Mat::setTo(Scalar value, Mat mask = Mat())
1254    private static native long n_setTo(long nativeObj, double s_val0, double s_val1, double s_val2, double s_val3, long mask_nativeObj);
1255
1256    // C++: Mat Mat::setTo(Mat value, Mat mask = Mat())
1257    private static native long n_setTo(long nativeObj, long value_nativeObj, long mask_nativeObj);
1258
1259    private static native long n_setTo(long nativeObj, long value_nativeObj);
1260
1261    // C++: Size Mat::size()
1262    private static native double[] n_size(long nativeObj);
1263
1264    // C++: size_t Mat::step1(int i = 0)
1265    private static native long n_step1(long nativeObj, int i);
1266
1267    private static native long n_step1(long nativeObj);
1268
1269    // C++: Mat Mat::operator()(Range rowRange, Range colRange)
1270    private static native long n_submat_rr(long nativeObj, int rowRange_start, int rowRange_end, int colRange_start, int colRange_end);
1271
1272    // C++: Mat Mat::operator()(Rect roi)
1273    private static native long n_submat(long nativeObj, int roi_x, int roi_y, int roi_width, int roi_height);
1274
1275    // C++: Mat Mat::t()
1276    private static native long n_t(long nativeObj);
1277
1278    // C++: size_t Mat::total()
1279    private static native long n_total(long nativeObj);
1280
1281    // C++: int Mat::type()
1282    private static native int n_type(long nativeObj);
1283
1284    // C++: static Mat Mat::zeros(int rows, int cols, int type)
1285    private static native long n_zeros(int rows, int cols, int type);
1286
1287    // C++: static Mat Mat::zeros(Size size, int type)
1288    private static native long n_zeros(double size_width, double size_height, int type);
1289
1290    // native support for java finalize()
1291    private static native void n_delete(long nativeObj);
1292
1293    private static native int nPutD(long self, int row, int col, int count, double[] data);
1294
1295    private static native int nPutF(long self, int row, int col, int count, float[] data);
1296
1297    private static native int nPutI(long self, int row, int col, int count, int[] data);
1298
1299    private static native int nPutS(long self, int row, int col, int count, short[] data);
1300
1301    private static native int nPutB(long self, int row, int col, int count, byte[] data);
1302
1303    private static native int nGetB(long self, int row, int col, int count, byte[] vals);
1304
1305    private static native int nGetS(long self, int row, int col, int count, short[] vals);
1306
1307    private static native int nGetI(long self, int row, int col, int count, int[] vals);
1308
1309    private static native int nGetF(long self, int row, int col, int count, float[] vals);
1310
1311    private static native int nGetD(long self, int row, int col, int count, double[] vals);
1312
1313    private static native double[] nGet(long self, int row, int col);
1314
1315    private static native String nDump(long self);
1316}