001//
002// This file is auto-generated. Please don't modify it!
003//
004package org.opencv.core;
005
006import java.util.ArrayList;
007import java.util.List;
008import org.opencv.core.Mat;
009import org.opencv.core.MatOfDouble;
010import org.opencv.core.MatOfInt;
011import org.opencv.core.Scalar;
012import org.opencv.core.TermCriteria;
013import org.opencv.utils.Converters;
014
015// C++: class Core
016
017public class Core {
018    // these constants are wrapped inside functions to prevent inlining
019    private static String getVersion() { return "4.5.2"; }
020    private static String getNativeLibraryName() { return "opencv_java452"; }
021    private static int getVersionMajorJ() { return 4; }
022    private static int getVersionMinorJ() { return 5; }
023    private static int getVersionRevisionJ() { return 2; }
024    private static String getVersionStatusJ() { return ""; }
025
026    public static final String VERSION = getVersion();
027    public static final String NATIVE_LIBRARY_NAME = getNativeLibraryName();
028    public static final int VERSION_MAJOR = getVersionMajorJ();
029    public static final int VERSION_MINOR = getVersionMinorJ();
030    public static final int VERSION_REVISION = getVersionRevisionJ();
031    public static final String VERSION_STATUS = getVersionStatusJ();
032
033    private static final int
034            CV_8U = 0,
035            CV_8S = 1,
036            CV_16U = 2,
037            CV_16S = 3,
038            CV_32S = 4,
039            CV_32F = 5,
040            CV_64F = 6,
041            CV_USRTYPE1 = 7;
042
043
044    // C++: enum <unnamed>
045    public static final int
046            SVD_MODIFY_A = 1,
047            SVD_NO_UV = 2,
048            SVD_FULL_UV = 4,
049            FILLED = -1,
050            REDUCE_SUM = 0,
051            REDUCE_AVG = 1,
052            REDUCE_MAX = 2,
053            REDUCE_MIN = 3,
054            RNG_UNIFORM = 0,
055            RNG_NORMAL = 1;
056
057
058    // C++: enum BorderTypes (cv.BorderTypes)
059    public static final int
060            BORDER_CONSTANT = 0,
061            BORDER_REPLICATE = 1,
062            BORDER_REFLECT = 2,
063            BORDER_WRAP = 3,
064            BORDER_REFLECT_101 = 4,
065            BORDER_TRANSPARENT = 5,
066            BORDER_REFLECT101 = BORDER_REFLECT_101,
067            BORDER_DEFAULT = BORDER_REFLECT_101,
068            BORDER_ISOLATED = 16;
069
070
071    // C++: enum CmpTypes (cv.CmpTypes)
072    public static final int
073            CMP_EQ = 0,
074            CMP_GT = 1,
075            CMP_GE = 2,
076            CMP_LT = 3,
077            CMP_LE = 4,
078            CMP_NE = 5;
079
080
081    // C++: enum CovarFlags (cv.CovarFlags)
082    public static final int
083            COVAR_SCRAMBLED = 0,
084            COVAR_NORMAL = 1,
085            COVAR_USE_AVG = 2,
086            COVAR_SCALE = 4,
087            COVAR_ROWS = 8,
088            COVAR_COLS = 16;
089
090
091    // C++: enum DecompTypes (cv.DecompTypes)
092    public static final int
093            DECOMP_LU = 0,
094            DECOMP_SVD = 1,
095            DECOMP_EIG = 2,
096            DECOMP_CHOLESKY = 3,
097            DECOMP_QR = 4,
098            DECOMP_NORMAL = 16;
099
100
101    // C++: enum DftFlags (cv.DftFlags)
102    public static final int
103            DFT_INVERSE = 1,
104            DFT_SCALE = 2,
105            DFT_ROWS = 4,
106            DFT_COMPLEX_OUTPUT = 16,
107            DFT_REAL_OUTPUT = 32,
108            DFT_COMPLEX_INPUT = 64,
109            DCT_INVERSE = DFT_INVERSE,
110            DCT_ROWS = DFT_ROWS;
111
112
113    // C++: enum Code (cv.Error.Code)
114    public static final int
115            StsOk = 0,
116            StsBackTrace = -1,
117            StsError = -2,
118            StsInternal = -3,
119            StsNoMem = -4,
120            StsBadArg = -5,
121            StsBadFunc = -6,
122            StsNoConv = -7,
123            StsAutoTrace = -8,
124            HeaderIsNull = -9,
125            BadImageSize = -10,
126            BadOffset = -11,
127            BadDataPtr = -12,
128            BadStep = -13,
129            BadModelOrChSeq = -14,
130            BadNumChannels = -15,
131            BadNumChannel1U = -16,
132            BadDepth = -17,
133            BadAlphaChannel = -18,
134            BadOrder = -19,
135            BadOrigin = -20,
136            BadAlign = -21,
137            BadCallBack = -22,
138            BadTileSize = -23,
139            BadCOI = -24,
140            BadROISize = -25,
141            MaskIsTiled = -26,
142            StsNullPtr = -27,
143            StsVecLengthErr = -28,
144            StsFilterStructContentErr = -29,
145            StsKernelStructContentErr = -30,
146            StsFilterOffsetErr = -31,
147            StsBadSize = -201,
148            StsDivByZero = -202,
149            StsInplaceNotSupported = -203,
150            StsObjectNotFound = -204,
151            StsUnmatchedFormats = -205,
152            StsBadFlag = -206,
153            StsBadPoint = -207,
154            StsBadMask = -208,
155            StsUnmatchedSizes = -209,
156            StsUnsupportedFormat = -210,
157            StsOutOfRange = -211,
158            StsParseError = -212,
159            StsNotImplemented = -213,
160            StsBadMemBlock = -214,
161            StsAssert = -215,
162            GpuNotSupported = -216,
163            GpuApiCallError = -217,
164            OpenGlNotSupported = -218,
165            OpenGlApiCallError = -219,
166            OpenCLApiCallError = -220,
167            OpenCLDoubleNotSupported = -221,
168            OpenCLInitError = -222,
169            OpenCLNoAMDBlasFft = -223;
170
171
172    // C++: enum FormatType (cv.Formatter.FormatType)
173    public static final int
174            Formatter_FMT_DEFAULT = 0,
175            Formatter_FMT_MATLAB = 1,
176            Formatter_FMT_CSV = 2,
177            Formatter_FMT_PYTHON = 3,
178            Formatter_FMT_NUMPY = 4,
179            Formatter_FMT_C = 5;
180
181
182    // C++: enum GemmFlags (cv.GemmFlags)
183    public static final int
184            GEMM_1_T = 1,
185            GEMM_2_T = 2,
186            GEMM_3_T = 4;
187
188
189    // C++: enum KmeansFlags (cv.KmeansFlags)
190    public static final int
191            KMEANS_RANDOM_CENTERS = 0,
192            KMEANS_PP_CENTERS = 2,
193            KMEANS_USE_INITIAL_LABELS = 1;
194
195
196    // C++: enum NormTypes (cv.NormTypes)
197    public static final int
198            NORM_INF = 1,
199            NORM_L1 = 2,
200            NORM_L2 = 4,
201            NORM_L2SQR = 5,
202            NORM_HAMMING = 6,
203            NORM_HAMMING2 = 7,
204            NORM_TYPE_MASK = 7,
205            NORM_RELATIVE = 8,
206            NORM_MINMAX = 32;
207
208
209    // C++: enum Flags (cv.PCA.Flags)
210    public static final int
211            PCA_DATA_AS_ROW = 0,
212            PCA_DATA_AS_COL = 1,
213            PCA_USE_AVG = 2;
214
215
216    // C++: enum Param (cv.Param)
217    public static final int
218            Param_INT = 0,
219            Param_BOOLEAN = 1,
220            Param_REAL = 2,
221            Param_STRING = 3,
222            Param_MAT = 4,
223            Param_MAT_VECTOR = 5,
224            Param_ALGORITHM = 6,
225            Param_FLOAT = 7,
226            Param_UNSIGNED_INT = 8,
227            Param_UINT64 = 9,
228            Param_UCHAR = 11,
229            Param_SCALAR = 12;
230
231
232    // C++: enum RotateFlags (cv.RotateFlags)
233    public static final int
234            ROTATE_90_CLOCKWISE = 0,
235            ROTATE_180 = 1,
236            ROTATE_90_COUNTERCLOCKWISE = 2;
237
238
239    // C++: enum SortFlags (cv.SortFlags)
240    public static final int
241            SORT_EVERY_ROW = 0,
242            SORT_EVERY_COLUMN = 1,
243            SORT_ASCENDING = 0,
244            SORT_DESCENDING = 16;
245
246
247    //
248    // C++:  float cv::cubeRoot(float val)
249    //
250
251    /**
252     * Computes the cube root of an argument.
253     *
254     *  The function cubeRoot computes \(\sqrt[3]{\texttt{val}}\). Negative arguments are handled correctly.
255     *  NaN and Inf are not handled. The accuracy approaches the maximum possible accuracy for
256     *  single-precision data.
257     *  @param val A function argument.
258     * @return automatically generated
259     */
260    public static float cubeRoot(float val) {
261        return cubeRoot_0(val);
262    }
263
264
265    //
266    // C++:  float cv::fastAtan2(float y, float x)
267    //
268
269    /**
270     * Calculates the angle of a 2D vector in degrees.
271     *
272     *  The function fastAtan2 calculates the full-range angle of an input 2D vector. The angle is measured
273     *  in degrees and varies from 0 to 360 degrees. The accuracy is about 0.3 degrees.
274     *  @param x x-coordinate of the vector.
275     *  @param y y-coordinate of the vector.
276     * @return automatically generated
277     */
278    public static float fastAtan2(float y, float x) {
279        return fastAtan2_0(y, x);
280    }
281
282
283    //
284    // C++:  bool cv::ipp::useIPP()
285    //
286
287    /**
288     * proxy for hal::Cholesky
289     * @return automatically generated
290     */
291    public static boolean useIPP() {
292        return useIPP_0();
293    }
294
295
296    //
297    // C++:  void cv::ipp::setUseIPP(bool flag)
298    //
299
300    public static void setUseIPP(boolean flag) {
301        setUseIPP_0(flag);
302    }
303
304
305    //
306    // C++:  String cv::ipp::getIppVersion()
307    //
308
309    public static String getIppVersion() {
310        return getIppVersion_0();
311    }
312
313
314    //
315    // C++:  bool cv::ipp::useIPP_NotExact()
316    //
317
318    public static boolean useIPP_NotExact() {
319        return useIPP_NotExact_0();
320    }
321
322
323    //
324    // C++:  void cv::ipp::setUseIPP_NotExact(bool flag)
325    //
326
327    public static void setUseIPP_NotExact(boolean flag) {
328        setUseIPP_NotExact_0(flag);
329    }
330
331
332    //
333    // C++:  int cv::borderInterpolate(int p, int len, int borderType)
334    //
335
336    /**
337     * Computes the source location of an extrapolated pixel.
338     *
339     * The function computes and returns the coordinate of a donor pixel corresponding to the specified
340     * extrapolated pixel when using the specified extrapolation border mode. For example, if you use
341     * cv::BORDER_WRAP mode in the horizontal direction, cv::BORDER_REFLECT_101 in the vertical direction and
342     * want to compute value of the "virtual" pixel Point(-5, 100) in a floating-point image img , it
343     * looks like:
344     * <code>
345     *     float val = img.at&lt;float&gt;(borderInterpolate(100, img.rows, cv::BORDER_REFLECT_101),
346     *                               borderInterpolate(-5, img.cols, cv::BORDER_WRAP));
347     * </code>
348     * Normally, the function is not called directly. It is used inside filtering functions and also in
349     * copyMakeBorder.
350     * @param p 0-based coordinate of the extrapolated pixel along one of the axes, likely &lt;0 or &gt;= len
351     * @param len Length of the array along the corresponding axis.
352     * @param borderType Border type, one of the #BorderTypes, except for #BORDER_TRANSPARENT and
353     * #BORDER_ISOLATED . When borderType==#BORDER_CONSTANT , the function always returns -1, regardless
354     * of p and len.
355     *
356     * SEE: copyMakeBorder
357     * @return automatically generated
358     */
359    public static int borderInterpolate(int p, int len, int borderType) {
360        return borderInterpolate_0(p, len, borderType);
361    }
362
363
364    //
365    // C++:  void cv::copyMakeBorder(Mat src, Mat& dst, int top, int bottom, int left, int right, int borderType, Scalar value = Scalar())
366    //
367
368    /**
369     * Forms a border around an image.
370     *
371     * The function copies the source image into the middle of the destination image. The areas to the
372     * left, to the right, above and below the copied source image will be filled with extrapolated
373     * pixels. This is not what filtering functions based on it do (they extrapolate pixels on-fly), but
374     * what other more complex functions, including your own, may do to simplify image boundary handling.
375     *
376     * The function supports the mode when src is already in the middle of dst . In this case, the
377     * function does not copy src itself but simply constructs the border, for example:
378     *
379     * <code>
380     *     // let border be the same in all directions
381     *     int border=2;
382     *     // constructs a larger image to fit both the image and the border
383     *     Mat gray_buf(rgb.rows + border*2, rgb.cols + border*2, rgb.depth());
384     *     // select the middle part of it w/o copying data
385     *     Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows));
386     *     // convert image from RGB to grayscale
387     *     cvtColor(rgb, gray, COLOR_RGB2GRAY);
388     *     // form a border in-place
389     *     copyMakeBorder(gray, gray_buf, border, border,
390     *                    border, border, BORDER_REPLICATE);
391     *     // now do some custom filtering ...
392     *     ...
393     * </code>
394     * <b>Note:</b> When the source image is a part (ROI) of a bigger image, the function will try to use the
395     * pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as
396     * if src was not a ROI, use borderType | #BORDER_ISOLATED.
397     *
398     * @param src Source image.
399     * @param dst Destination image of the same type as src and the size Size(src.cols+left+right,
400     * src.rows+top+bottom) .
401     * @param top the top pixels
402     * @param bottom the bottom pixels
403     * @param left the left pixels
404     * @param right Parameter specifying how many pixels in each direction from the source image rectangle
405     * to extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs
406     * to be built.
407     * @param borderType Border type. See borderInterpolate for details.
408     * @param value Border value if borderType==BORDER_CONSTANT .
409     *
410     * SEE:  borderInterpolate
411     */
412    public static void copyMakeBorder(Mat src, Mat dst, int top, int bottom, int left, int right, int borderType, Scalar value) {
413        copyMakeBorder_0(src.nativeObj, dst.nativeObj, top, bottom, left, right, borderType, value.val[0], value.val[1], value.val[2], value.val[3]);
414    }
415
416    /**
417     * Forms a border around an image.
418     *
419     * The function copies the source image into the middle of the destination image. The areas to the
420     * left, to the right, above and below the copied source image will be filled with extrapolated
421     * pixels. This is not what filtering functions based on it do (they extrapolate pixels on-fly), but
422     * what other more complex functions, including your own, may do to simplify image boundary handling.
423     *
424     * The function supports the mode when src is already in the middle of dst . In this case, the
425     * function does not copy src itself but simply constructs the border, for example:
426     *
427     * <code>
428     *     // let border be the same in all directions
429     *     int border=2;
430     *     // constructs a larger image to fit both the image and the border
431     *     Mat gray_buf(rgb.rows + border*2, rgb.cols + border*2, rgb.depth());
432     *     // select the middle part of it w/o copying data
433     *     Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows));
434     *     // convert image from RGB to grayscale
435     *     cvtColor(rgb, gray, COLOR_RGB2GRAY);
436     *     // form a border in-place
437     *     copyMakeBorder(gray, gray_buf, border, border,
438     *                    border, border, BORDER_REPLICATE);
439     *     // now do some custom filtering ...
440     *     ...
441     * </code>
442     * <b>Note:</b> When the source image is a part (ROI) of a bigger image, the function will try to use the
443     * pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as
444     * if src was not a ROI, use borderType | #BORDER_ISOLATED.
445     *
446     * @param src Source image.
447     * @param dst Destination image of the same type as src and the size Size(src.cols+left+right,
448     * src.rows+top+bottom) .
449     * @param top the top pixels
450     * @param bottom the bottom pixels
451     * @param left the left pixels
452     * @param right Parameter specifying how many pixels in each direction from the source image rectangle
453     * to extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs
454     * to be built.
455     * @param borderType Border type. See borderInterpolate for details.
456     *
457     * SEE:  borderInterpolate
458     */
459    public static void copyMakeBorder(Mat src, Mat dst, int top, int bottom, int left, int right, int borderType) {
460        copyMakeBorder_1(src.nativeObj, dst.nativeObj, top, bottom, left, right, borderType);
461    }
462
463
464    //
465    // C++:  void cv::add(Mat src1, Mat src2, Mat& dst, Mat mask = Mat(), int dtype = -1)
466    //
467
468    /**
469     * Calculates the per-element sum of two arrays or an array and a scalar.
470     *
471     * The function add calculates:
472     * <ul>
473     *   <li>
474     *  Sum of two arrays when both input arrays have the same size and the same number of channels:
475     * \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1}(I) +  \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
476     *   </li>
477     *   <li>
478     *  Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of
479     * elements as {@code src1.channels()}:
480     * \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1}(I) +  \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
481     *   </li>
482     *   <li>
483     *  Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of
484     * elements as {@code src2.channels()}:
485     * \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1} +  \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
486     * where {@code I} is a multi-dimensional index of array elements. In case of multi-channel arrays, each
487     * channel is processed independently.
488     *   </li>
489     * </ul>
490     *
491     * The first function in the list above can be replaced with matrix expressions:
492     * <code>
493     *     dst = src1 + src2;
494     *     dst += src1; // equivalent to add(dst, src1, dst);
495     * </code>
496     * The input arrays and the output array can all have the same or different depths. For example, you
497     * can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit
498     * floating-point array. Depth of the output array is determined by the dtype parameter. In the second
499     * and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can
500     * be set to the default -1. In this case, the output array will have the same depth as the input
501     * array, be it src1, src2 or both.
502     * <b>Note:</b> Saturation is not applied when the output array has the depth CV_32S. You may even get
503     * result of an incorrect sign in the case of overflow.
504     * @param src1 first input array or a scalar.
505     * @param src2 second input array or a scalar.
506     * @param dst output array that has the same size and number of channels as the input array(s); the
507     * depth is defined by dtype or src1/src2.
508     * @param mask optional operation mask - 8-bit single channel array, that specifies elements of the
509     * output array to be changed.
510     * @param dtype optional depth of the output array (see the discussion below).
511     * SEE: subtract, addWeighted, scaleAdd, Mat::convertTo
512     */
513    public static void add(Mat src1, Mat src2, Mat dst, Mat mask, int dtype) {
514        add_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj, dtype);
515    }
516
517    /**
518     * Calculates the per-element sum of two arrays or an array and a scalar.
519     *
520     * The function add calculates:
521     * <ul>
522     *   <li>
523     *  Sum of two arrays when both input arrays have the same size and the same number of channels:
524     * \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1}(I) +  \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
525     *   </li>
526     *   <li>
527     *  Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of
528     * elements as {@code src1.channels()}:
529     * \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1}(I) +  \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
530     *   </li>
531     *   <li>
532     *  Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of
533     * elements as {@code src2.channels()}:
534     * \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1} +  \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
535     * where {@code I} is a multi-dimensional index of array elements. In case of multi-channel arrays, each
536     * channel is processed independently.
537     *   </li>
538     * </ul>
539     *
540     * The first function in the list above can be replaced with matrix expressions:
541     * <code>
542     *     dst = src1 + src2;
543     *     dst += src1; // equivalent to add(dst, src1, dst);
544     * </code>
545     * The input arrays and the output array can all have the same or different depths. For example, you
546     * can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit
547     * floating-point array. Depth of the output array is determined by the dtype parameter. In the second
548     * and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can
549     * be set to the default -1. In this case, the output array will have the same depth as the input
550     * array, be it src1, src2 or both.
551     * <b>Note:</b> Saturation is not applied when the output array has the depth CV_32S. You may even get
552     * result of an incorrect sign in the case of overflow.
553     * @param src1 first input array or a scalar.
554     * @param src2 second input array or a scalar.
555     * @param dst output array that has the same size and number of channels as the input array(s); the
556     * depth is defined by dtype or src1/src2.
557     * @param mask optional operation mask - 8-bit single channel array, that specifies elements of the
558     * output array to be changed.
559     * SEE: subtract, addWeighted, scaleAdd, Mat::convertTo
560     */
561    public static void add(Mat src1, Mat src2, Mat dst, Mat mask) {
562        add_1(src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj);
563    }
564
565    /**
566     * Calculates the per-element sum of two arrays or an array and a scalar.
567     *
568     * The function add calculates:
569     * <ul>
570     *   <li>
571     *  Sum of two arrays when both input arrays have the same size and the same number of channels:
572     * \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1}(I) +  \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
573     *   </li>
574     *   <li>
575     *  Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of
576     * elements as {@code src1.channels()}:
577     * \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1}(I) +  \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
578     *   </li>
579     *   <li>
580     *  Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of
581     * elements as {@code src2.channels()}:
582     * \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1} +  \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
583     * where {@code I} is a multi-dimensional index of array elements. In case of multi-channel arrays, each
584     * channel is processed independently.
585     *   </li>
586     * </ul>
587     *
588     * The first function in the list above can be replaced with matrix expressions:
589     * <code>
590     *     dst = src1 + src2;
591     *     dst += src1; // equivalent to add(dst, src1, dst);
592     * </code>
593     * The input arrays and the output array can all have the same or different depths. For example, you
594     * can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit
595     * floating-point array. Depth of the output array is determined by the dtype parameter. In the second
596     * and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can
597     * be set to the default -1. In this case, the output array will have the same depth as the input
598     * array, be it src1, src2 or both.
599     * <b>Note:</b> Saturation is not applied when the output array has the depth CV_32S. You may even get
600     * result of an incorrect sign in the case of overflow.
601     * @param src1 first input array or a scalar.
602     * @param src2 second input array or a scalar.
603     * @param dst output array that has the same size and number of channels as the input array(s); the
604     * depth is defined by dtype or src1/src2.
605     * output array to be changed.
606     * SEE: subtract, addWeighted, scaleAdd, Mat::convertTo
607     */
608    public static void add(Mat src1, Mat src2, Mat dst) {
609        add_2(src1.nativeObj, src2.nativeObj, dst.nativeObj);
610    }
611
612
613    //
614    // C++:  void cv::subtract(Mat src1, Mat src2, Mat& dst, Mat mask = Mat(), int dtype = -1)
615    //
616
617    /**
618     * Calculates the per-element difference between two arrays or array and a scalar.
619     *
620     * The function subtract calculates:
621     * <ul>
622     *   <li>
623     *  Difference between two arrays, when both input arrays have the same size and the same number of
624     * channels:
625     *     \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1}(I) -  \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
626     *   </li>
627     *   <li>
628     *  Difference between an array and a scalar, when src2 is constructed from Scalar or has the same
629     * number of elements as {@code src1.channels()}:
630     *     \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1}(I) -  \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
631     *   </li>
632     *   <li>
633     *  Difference between a scalar and an array, when src1 is constructed from Scalar or has the same
634     * number of elements as {@code src2.channels()}:
635     *     \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1} -  \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
636     *   </li>
637     *   <li>
638     *  The reverse difference between a scalar and an array in the case of {@code SubRS}:
639     *     \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src2} -  \texttt{src1}(I) ) \quad \texttt{if mask}(I) \ne0\)
640     * where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
641     * channel is processed independently.
642     *   </li>
643     * </ul>
644     *
645     * The first function in the list above can be replaced with matrix expressions:
646     * <code>
647     *     dst = src1 - src2;
648     *     dst -= src1; // equivalent to subtract(dst, src1, dst);
649     * </code>
650     * The input arrays and the output array can all have the same or different depths. For example, you
651     * can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of
652     * the output array is determined by dtype parameter. In the second and third cases above, as well as
653     * in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this
654     * case the output array will have the same depth as the input array, be it src1, src2 or both.
655     * <b>Note:</b> Saturation is not applied when the output array has the depth CV_32S. You may even get
656     * result of an incorrect sign in the case of overflow.
657     * @param src1 first input array or a scalar.
658     * @param src2 second input array or a scalar.
659     * @param dst output array of the same size and the same number of channels as the input array.
660     * @param mask optional operation mask; this is an 8-bit single channel array that specifies elements
661     * of the output array to be changed.
662     * @param dtype optional depth of the output array
663     * SEE:  add, addWeighted, scaleAdd, Mat::convertTo
664     */
665    public static void subtract(Mat src1, Mat src2, Mat dst, Mat mask, int dtype) {
666        subtract_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj, dtype);
667    }
668
669    /**
670     * Calculates the per-element difference between two arrays or array and a scalar.
671     *
672     * The function subtract calculates:
673     * <ul>
674     *   <li>
675     *  Difference between two arrays, when both input arrays have the same size and the same number of
676     * channels:
677     *     \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1}(I) -  \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
678     *   </li>
679     *   <li>
680     *  Difference between an array and a scalar, when src2 is constructed from Scalar or has the same
681     * number of elements as {@code src1.channels()}:
682     *     \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1}(I) -  \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
683     *   </li>
684     *   <li>
685     *  Difference between a scalar and an array, when src1 is constructed from Scalar or has the same
686     * number of elements as {@code src2.channels()}:
687     *     \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1} -  \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
688     *   </li>
689     *   <li>
690     *  The reverse difference between a scalar and an array in the case of {@code SubRS}:
691     *     \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src2} -  \texttt{src1}(I) ) \quad \texttt{if mask}(I) \ne0\)
692     * where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
693     * channel is processed independently.
694     *   </li>
695     * </ul>
696     *
697     * The first function in the list above can be replaced with matrix expressions:
698     * <code>
699     *     dst = src1 - src2;
700     *     dst -= src1; // equivalent to subtract(dst, src1, dst);
701     * </code>
702     * The input arrays and the output array can all have the same or different depths. For example, you
703     * can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of
704     * the output array is determined by dtype parameter. In the second and third cases above, as well as
705     * in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this
706     * case the output array will have the same depth as the input array, be it src1, src2 or both.
707     * <b>Note:</b> Saturation is not applied when the output array has the depth CV_32S. You may even get
708     * result of an incorrect sign in the case of overflow.
709     * @param src1 first input array or a scalar.
710     * @param src2 second input array or a scalar.
711     * @param dst output array of the same size and the same number of channels as the input array.
712     * @param mask optional operation mask; this is an 8-bit single channel array that specifies elements
713     * of the output array to be changed.
714     * SEE:  add, addWeighted, scaleAdd, Mat::convertTo
715     */
716    public static void subtract(Mat src1, Mat src2, Mat dst, Mat mask) {
717        subtract_1(src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj);
718    }
719
720    /**
721     * Calculates the per-element difference between two arrays or array and a scalar.
722     *
723     * The function subtract calculates:
724     * <ul>
725     *   <li>
726     *  Difference between two arrays, when both input arrays have the same size and the same number of
727     * channels:
728     *     \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1}(I) -  \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
729     *   </li>
730     *   <li>
731     *  Difference between an array and a scalar, when src2 is constructed from Scalar or has the same
732     * number of elements as {@code src1.channels()}:
733     *     \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1}(I) -  \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
734     *   </li>
735     *   <li>
736     *  Difference between a scalar and an array, when src1 is constructed from Scalar or has the same
737     * number of elements as {@code src2.channels()}:
738     *     \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src1} -  \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
739     *   </li>
740     *   <li>
741     *  The reverse difference between a scalar and an array in the case of {@code SubRS}:
742     *     \(\texttt{dst}(I) =  \texttt{saturate} ( \texttt{src2} -  \texttt{src1}(I) ) \quad \texttt{if mask}(I) \ne0\)
743     * where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
744     * channel is processed independently.
745     *   </li>
746     * </ul>
747     *
748     * The first function in the list above can be replaced with matrix expressions:
749     * <code>
750     *     dst = src1 - src2;
751     *     dst -= src1; // equivalent to subtract(dst, src1, dst);
752     * </code>
753     * The input arrays and the output array can all have the same or different depths. For example, you
754     * can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of
755     * the output array is determined by dtype parameter. In the second and third cases above, as well as
756     * in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this
757     * case the output array will have the same depth as the input array, be it src1, src2 or both.
758     * <b>Note:</b> Saturation is not applied when the output array has the depth CV_32S. You may even get
759     * result of an incorrect sign in the case of overflow.
760     * @param src1 first input array or a scalar.
761     * @param src2 second input array or a scalar.
762     * @param dst output array of the same size and the same number of channels as the input array.
763     * of the output array to be changed.
764     * SEE:  add, addWeighted, scaleAdd, Mat::convertTo
765     */
766    public static void subtract(Mat src1, Mat src2, Mat dst) {
767        subtract_2(src1.nativeObj, src2.nativeObj, dst.nativeObj);
768    }
769
770
771    //
772    // C++:  void cv::multiply(Mat src1, Mat src2, Mat& dst, double scale = 1, int dtype = -1)
773    //
774
775    /**
776     * Calculates the per-element scaled product of two arrays.
777     *
778     * The function multiply calculates the per-element product of two arrays:
779     *
780     * \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I)  \cdot \texttt{src2} (I))\)
781     *
782     * There is also a REF: MatrixExpressions -friendly variant of the first function. See Mat::mul .
783     *
784     * For a not-per-element matrix product, see gemm .
785     *
786     * <b>Note:</b> Saturation is not applied when the output array has the depth
787     * CV_32S. You may even get result of an incorrect sign in the case of
788     * overflow.
789     * @param src1 first input array.
790     * @param src2 second input array of the same size and the same type as src1.
791     * @param dst output array of the same size and type as src1.
792     * @param scale optional scale factor.
793     * @param dtype optional depth of the output array
794     * SEE: add, subtract, divide, scaleAdd, addWeighted, accumulate, accumulateProduct, accumulateSquare,
795     * Mat::convertTo
796     */
797    public static void multiply(Mat src1, Mat src2, Mat dst, double scale, int dtype) {
798        multiply_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, scale, dtype);
799    }
800
801    /**
802     * Calculates the per-element scaled product of two arrays.
803     *
804     * The function multiply calculates the per-element product of two arrays:
805     *
806     * \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I)  \cdot \texttt{src2} (I))\)
807     *
808     * There is also a REF: MatrixExpressions -friendly variant of the first function. See Mat::mul .
809     *
810     * For a not-per-element matrix product, see gemm .
811     *
812     * <b>Note:</b> Saturation is not applied when the output array has the depth
813     * CV_32S. You may even get result of an incorrect sign in the case of
814     * overflow.
815     * @param src1 first input array.
816     * @param src2 second input array of the same size and the same type as src1.
817     * @param dst output array of the same size and type as src1.
818     * @param scale optional scale factor.
819     * SEE: add, subtract, divide, scaleAdd, addWeighted, accumulate, accumulateProduct, accumulateSquare,
820     * Mat::convertTo
821     */
822    public static void multiply(Mat src1, Mat src2, Mat dst, double scale) {
823        multiply_1(src1.nativeObj, src2.nativeObj, dst.nativeObj, scale);
824    }
825
826    /**
827     * Calculates the per-element scaled product of two arrays.
828     *
829     * The function multiply calculates the per-element product of two arrays:
830     *
831     * \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I)  \cdot \texttt{src2} (I))\)
832     *
833     * There is also a REF: MatrixExpressions -friendly variant of the first function. See Mat::mul .
834     *
835     * For a not-per-element matrix product, see gemm .
836     *
837     * <b>Note:</b> Saturation is not applied when the output array has the depth
838     * CV_32S. You may even get result of an incorrect sign in the case of
839     * overflow.
840     * @param src1 first input array.
841     * @param src2 second input array of the same size and the same type as src1.
842     * @param dst output array of the same size and type as src1.
843     * SEE: add, subtract, divide, scaleAdd, addWeighted, accumulate, accumulateProduct, accumulateSquare,
844     * Mat::convertTo
845     */
846    public static void multiply(Mat src1, Mat src2, Mat dst) {
847        multiply_2(src1.nativeObj, src2.nativeObj, dst.nativeObj);
848    }
849
850
851    //
852    // C++:  void cv::divide(Mat src1, Mat src2, Mat& dst, double scale = 1, int dtype = -1)
853    //
854
855    /**
856     * Performs per-element division of two arrays or a scalar by an array.
857     *
858     * The function cv::divide divides one array by another:
859     * \(\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\)
860     * or a scalar by an array when there is no src1 :
861     * \(\texttt{dst(I) = saturate(scale/src2(I))}\)
862     *
863     * Different channels of multi-channel arrays are processed independently.
864     *
865     * For integer types when src2(I) is zero, dst(I) will also be zero.
866     *
867     * <b>Note:</b> In case of floating point data there is no special defined behavior for zero src2(I) values.
868     * Regular floating-point division is used.
869     * Expect correct IEEE-754 behaviour for floating-point data (with NaN, Inf result values).
870     *
871     * <b>Note:</b> Saturation is not applied when the output array has the depth CV_32S. You may even get
872     * result of an incorrect sign in the case of overflow.
873     * @param src1 first input array.
874     * @param src2 second input array of the same size and type as src1.
875     * @param scale scalar factor.
876     * @param dst output array of the same size and type as src2.
877     * @param dtype optional depth of the output array; if -1, dst will have depth src2.depth(), but in
878     * case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth().
879     * SEE:  multiply, add, subtract
880     */
881    public static void divide(Mat src1, Mat src2, Mat dst, double scale, int dtype) {
882        divide_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, scale, dtype);
883    }
884
885    /**
886     * Performs per-element division of two arrays or a scalar by an array.
887     *
888     * The function cv::divide divides one array by another:
889     * \(\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\)
890     * or a scalar by an array when there is no src1 :
891     * \(\texttt{dst(I) = saturate(scale/src2(I))}\)
892     *
893     * Different channels of multi-channel arrays are processed independently.
894     *
895     * For integer types when src2(I) is zero, dst(I) will also be zero.
896     *
897     * <b>Note:</b> In case of floating point data there is no special defined behavior for zero src2(I) values.
898     * Regular floating-point division is used.
899     * Expect correct IEEE-754 behaviour for floating-point data (with NaN, Inf result values).
900     *
901     * <b>Note:</b> Saturation is not applied when the output array has the depth CV_32S. You may even get
902     * result of an incorrect sign in the case of overflow.
903     * @param src1 first input array.
904     * @param src2 second input array of the same size and type as src1.
905     * @param scale scalar factor.
906     * @param dst output array of the same size and type as src2.
907     * case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth().
908     * SEE:  multiply, add, subtract
909     */
910    public static void divide(Mat src1, Mat src2, Mat dst, double scale) {
911        divide_1(src1.nativeObj, src2.nativeObj, dst.nativeObj, scale);
912    }
913
914    /**
915     * Performs per-element division of two arrays or a scalar by an array.
916     *
917     * The function cv::divide divides one array by another:
918     * \(\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\)
919     * or a scalar by an array when there is no src1 :
920     * \(\texttt{dst(I) = saturate(scale/src2(I))}\)
921     *
922     * Different channels of multi-channel arrays are processed independently.
923     *
924     * For integer types when src2(I) is zero, dst(I) will also be zero.
925     *
926     * <b>Note:</b> In case of floating point data there is no special defined behavior for zero src2(I) values.
927     * Regular floating-point division is used.
928     * Expect correct IEEE-754 behaviour for floating-point data (with NaN, Inf result values).
929     *
930     * <b>Note:</b> Saturation is not applied when the output array has the depth CV_32S. You may even get
931     * result of an incorrect sign in the case of overflow.
932     * @param src1 first input array.
933     * @param src2 second input array of the same size and type as src1.
934     * @param dst output array of the same size and type as src2.
935     * case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth().
936     * SEE:  multiply, add, subtract
937     */
938    public static void divide(Mat src1, Mat src2, Mat dst) {
939        divide_2(src1.nativeObj, src2.nativeObj, dst.nativeObj);
940    }
941
942
943    //
944    // C++:  void cv::divide(double scale, Mat src2, Mat& dst, int dtype = -1)
945    //
946
947    public static void divide(double scale, Mat src2, Mat dst, int dtype) {
948        divide_3(scale, src2.nativeObj, dst.nativeObj, dtype);
949    }
950
951    public static void divide(double scale, Mat src2, Mat dst) {
952        divide_4(scale, src2.nativeObj, dst.nativeObj);
953    }
954
955
956    //
957    // C++:  void cv::scaleAdd(Mat src1, double alpha, Mat src2, Mat& dst)
958    //
959
960    /**
961     * Calculates the sum of a scaled array and another array.
962     *
963     * The function scaleAdd is one of the classical primitive linear algebra operations, known as DAXPY
964     * or SAXPY in [BLAS](http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms). It calculates
965     * the sum of a scaled array and another array:
966     * \(\texttt{dst} (I)= \texttt{scale} \cdot \texttt{src1} (I) +  \texttt{src2} (I)\)
967     * The function can also be emulated with a matrix expression, for example:
968     * <code>
969     *     Mat A(3, 3, CV_64F);
970     *     ...
971     *     A.row(0) = A.row(1)*2 + A.row(2);
972     * </code>
973     * @param src1 first input array.
974     * @param alpha scale factor for the first array.
975     * @param src2 second input array of the same size and type as src1.
976     * @param dst output array of the same size and type as src1.
977     * SEE: add, addWeighted, subtract, Mat::dot, Mat::convertTo
978     */
979    public static void scaleAdd(Mat src1, double alpha, Mat src2, Mat dst) {
980        scaleAdd_0(src1.nativeObj, alpha, src2.nativeObj, dst.nativeObj);
981    }
982
983
984    //
985    // C++:  void cv::addWeighted(Mat src1, double alpha, Mat src2, double beta, double gamma, Mat& dst, int dtype = -1)
986    //
987
988    /**
989     * Calculates the weighted sum of two arrays.
990     *
991     * The function addWeighted calculates the weighted sum of two arrays as follows:
992     * \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} +  \texttt{src2} (I)* \texttt{beta} +  \texttt{gamma} )\)
993     * where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
994     * channel is processed independently.
995     * The function can be replaced with a matrix expression:
996     * <code>
997     *     dst = src1*alpha + src2*beta + gamma;
998     * </code>
999     * <b>Note:</b> Saturation is not applied when the output array has the depth CV_32S. You may even get
1000     * result of an incorrect sign in the case of overflow.
1001     * @param src1 first input array.
1002     * @param alpha weight of the first array elements.
1003     * @param src2 second input array of the same size and channel number as src1.
1004     * @param beta weight of the second array elements.
1005     * @param gamma scalar added to each sum.
1006     * @param dst output array that has the same size and number of channels as the input arrays.
1007     * @param dtype optional depth of the output array; when both input arrays have the same depth, dtype
1008     * can be set to -1, which will be equivalent to src1.depth().
1009     * SEE:  add, subtract, scaleAdd, Mat::convertTo
1010     */
1011    public static void addWeighted(Mat src1, double alpha, Mat src2, double beta, double gamma, Mat dst, int dtype) {
1012        addWeighted_0(src1.nativeObj, alpha, src2.nativeObj, beta, gamma, dst.nativeObj, dtype);
1013    }
1014
1015    /**
1016     * Calculates the weighted sum of two arrays.
1017     *
1018     * The function addWeighted calculates the weighted sum of two arrays as follows:
1019     * \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} +  \texttt{src2} (I)* \texttt{beta} +  \texttt{gamma} )\)
1020     * where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
1021     * channel is processed independently.
1022     * The function can be replaced with a matrix expression:
1023     * <code>
1024     *     dst = src1*alpha + src2*beta + gamma;
1025     * </code>
1026     * <b>Note:</b> Saturation is not applied when the output array has the depth CV_32S. You may even get
1027     * result of an incorrect sign in the case of overflow.
1028     * @param src1 first input array.
1029     * @param alpha weight of the first array elements.
1030     * @param src2 second input array of the same size and channel number as src1.
1031     * @param beta weight of the second array elements.
1032     * @param gamma scalar added to each sum.
1033     * @param dst output array that has the same size and number of channels as the input arrays.
1034     * can be set to -1, which will be equivalent to src1.depth().
1035     * SEE:  add, subtract, scaleAdd, Mat::convertTo
1036     */
1037    public static void addWeighted(Mat src1, double alpha, Mat src2, double beta, double gamma, Mat dst) {
1038        addWeighted_1(src1.nativeObj, alpha, src2.nativeObj, beta, gamma, dst.nativeObj);
1039    }
1040
1041
1042    //
1043    // C++:  void cv::convertScaleAbs(Mat src, Mat& dst, double alpha = 1, double beta = 0)
1044    //
1045
1046    /**
1047     * Scales, calculates absolute values, and converts the result to 8-bit.
1048     *
1049     * On each element of the input array, the function convertScaleAbs
1050     * performs three operations sequentially: scaling, taking an absolute
1051     * value, conversion to an unsigned 8-bit type:
1052     * \(\texttt{dst} (I)= \texttt{saturate\_cast&lt;uchar&gt;} (| \texttt{src} (I)* \texttt{alpha} +  \texttt{beta} |)\)
1053     * In case of multi-channel arrays, the function processes each channel
1054     * independently. When the output is not 8-bit, the operation can be
1055     * emulated by calling the Mat::convertTo method (or by using matrix
1056     * expressions) and then by calculating an absolute value of the result.
1057     * For example:
1058     * <code>
1059     *     Mat_&lt;float&gt; A(30,30);
1060     *     randu(A, Scalar(-100), Scalar(100));
1061     *     Mat_&lt;float&gt; B = A*5 + 3;
1062     *     B = abs(B);
1063     *     // Mat_&lt;float&gt; B = abs(A*5+3) will also do the job,
1064     *     // but it will allocate a temporary matrix
1065     * </code>
1066     * @param src input array.
1067     * @param dst output array.
1068     * @param alpha optional scale factor.
1069     * @param beta optional delta added to the scaled values.
1070     * SEE:  Mat::convertTo, cv::abs(const Mat&amp;)
1071     */
1072    public static void convertScaleAbs(Mat src, Mat dst, double alpha, double beta) {
1073        convertScaleAbs_0(src.nativeObj, dst.nativeObj, alpha, beta);
1074    }
1075
1076    /**
1077     * Scales, calculates absolute values, and converts the result to 8-bit.
1078     *
1079     * On each element of the input array, the function convertScaleAbs
1080     * performs three operations sequentially: scaling, taking an absolute
1081     * value, conversion to an unsigned 8-bit type:
1082     * \(\texttt{dst} (I)= \texttt{saturate\_cast&lt;uchar&gt;} (| \texttt{src} (I)* \texttt{alpha} +  \texttt{beta} |)\)
1083     * In case of multi-channel arrays, the function processes each channel
1084     * independently. When the output is not 8-bit, the operation can be
1085     * emulated by calling the Mat::convertTo method (or by using matrix
1086     * expressions) and then by calculating an absolute value of the result.
1087     * For example:
1088     * <code>
1089     *     Mat_&lt;float&gt; A(30,30);
1090     *     randu(A, Scalar(-100), Scalar(100));
1091     *     Mat_&lt;float&gt; B = A*5 + 3;
1092     *     B = abs(B);
1093     *     // Mat_&lt;float&gt; B = abs(A*5+3) will also do the job,
1094     *     // but it will allocate a temporary matrix
1095     * </code>
1096     * @param src input array.
1097     * @param dst output array.
1098     * @param alpha optional scale factor.
1099     * SEE:  Mat::convertTo, cv::abs(const Mat&amp;)
1100     */
1101    public static void convertScaleAbs(Mat src, Mat dst, double alpha) {
1102        convertScaleAbs_1(src.nativeObj, dst.nativeObj, alpha);
1103    }
1104
1105    /**
1106     * Scales, calculates absolute values, and converts the result to 8-bit.
1107     *
1108     * On each element of the input array, the function convertScaleAbs
1109     * performs three operations sequentially: scaling, taking an absolute
1110     * value, conversion to an unsigned 8-bit type:
1111     * \(\texttt{dst} (I)= \texttt{saturate\_cast&lt;uchar&gt;} (| \texttt{src} (I)* \texttt{alpha} +  \texttt{beta} |)\)
1112     * In case of multi-channel arrays, the function processes each channel
1113     * independently. When the output is not 8-bit, the operation can be
1114     * emulated by calling the Mat::convertTo method (or by using matrix
1115     * expressions) and then by calculating an absolute value of the result.
1116     * For example:
1117     * <code>
1118     *     Mat_&lt;float&gt; A(30,30);
1119     *     randu(A, Scalar(-100), Scalar(100));
1120     *     Mat_&lt;float&gt; B = A*5 + 3;
1121     *     B = abs(B);
1122     *     // Mat_&lt;float&gt; B = abs(A*5+3) will also do the job,
1123     *     // but it will allocate a temporary matrix
1124     * </code>
1125     * @param src input array.
1126     * @param dst output array.
1127     * SEE:  Mat::convertTo, cv::abs(const Mat&amp;)
1128     */
1129    public static void convertScaleAbs(Mat src, Mat dst) {
1130        convertScaleAbs_2(src.nativeObj, dst.nativeObj);
1131    }
1132
1133
1134    //
1135    // C++:  void cv::convertFp16(Mat src, Mat& dst)
1136    //
1137
1138    /**
1139     * Converts an array to half precision floating number.
1140     *
1141     * This function converts FP32 (single precision floating point) from/to FP16 (half precision floating point). CV_16S format is used to represent FP16 data.
1142     * There are two use modes (src -&gt; dst): CV_32F -&gt; CV_16S and CV_16S -&gt; CV_32F. The input array has to have type of CV_32F or
1143     * CV_16S to represent the bit depth. If the input array is neither of them, the function will raise an error.
1144     * The format of half precision floating point is defined in IEEE 754-2008.
1145     *
1146     * @param src input array.
1147     * @param dst output array.
1148     */
1149    public static void convertFp16(Mat src, Mat dst) {
1150        convertFp16_0(src.nativeObj, dst.nativeObj);
1151    }
1152
1153
1154    //
1155    // C++:  void cv::LUT(Mat src, Mat lut, Mat& dst)
1156    //
1157
1158    /**
1159     * Performs a look-up table transform of an array.
1160     *
1161     * The function LUT fills the output array with values from the look-up table. Indices of the entries
1162     * are taken from the input array. That is, the function processes each element of src as follows:
1163     * \(\texttt{dst} (I)  \leftarrow \texttt{lut(src(I) + d)}\)
1164     * where
1165     * \(d =  \fork{0}{if \(\texttt{src}\) has depth \(\texttt{CV_8U}\)}{128}{if \(\texttt{src}\) has depth \(\texttt{CV_8S}\)}\)
1166     * @param src input array of 8-bit elements.
1167     * @param lut look-up table of 256 elements; in case of multi-channel input array, the table should
1168     * either have a single channel (in this case the same table is used for all channels) or the same
1169     * number of channels as in the input array.
1170     * @param dst output array of the same size and number of channels as src, and the same depth as lut.
1171     * SEE:  convertScaleAbs, Mat::convertTo
1172     */
1173    public static void LUT(Mat src, Mat lut, Mat dst) {
1174        LUT_0(src.nativeObj, lut.nativeObj, dst.nativeObj);
1175    }
1176
1177
1178    //
1179    // C++:  Scalar cv::sum(Mat src)
1180    //
1181
1182    /**
1183     * Calculates the sum of array elements.
1184     *
1185     * The function cv::sum calculates and returns the sum of array elements,
1186     * independently for each channel.
1187     * @param src input array that must have from 1 to 4 channels.
1188     * SEE:  countNonZero, mean, meanStdDev, norm, minMaxLoc, reduce
1189     * @return automatically generated
1190     */
1191    public static Scalar sumElems(Mat src) {
1192        return new Scalar(sumElems_0(src.nativeObj));
1193    }
1194
1195
1196    //
1197    // C++:  int cv::countNonZero(Mat src)
1198    //
1199
1200    /**
1201     * Counts non-zero array elements.
1202     *
1203     * The function returns the number of non-zero elements in src :
1204     * \(\sum _{I: \; \texttt{src} (I) \ne0 } 1\)
1205     * @param src single-channel array.
1206     * SEE:  mean, meanStdDev, norm, minMaxLoc, calcCovarMatrix
1207     * @return automatically generated
1208     */
1209    public static int countNonZero(Mat src) {
1210        return countNonZero_0(src.nativeObj);
1211    }
1212
1213
1214    //
1215    // C++:  void cv::findNonZero(Mat src, Mat& idx)
1216    //
1217
1218    /**
1219     * Returns the list of locations of non-zero pixels
1220     *
1221     * Given a binary matrix (likely returned from an operation such
1222     * as threshold(), compare(), &gt;, ==, etc, return all of
1223     * the non-zero indices as a cv::Mat or std::vector&lt;cv::Point&gt; (x,y)
1224     * For example:
1225     * <code>
1226     *     cv::Mat binaryImage; // input, binary image
1227     *     cv::Mat locations;   // output, locations of non-zero pixels
1228     *     cv::findNonZero(binaryImage, locations);
1229     *
1230     *     // access pixel coordinates
1231     *     Point pnt = locations.at&lt;Point&gt;(i);
1232     * </code>
1233     * or
1234     * <code>
1235     *     cv::Mat binaryImage; // input, binary image
1236     *     vector&lt;Point&gt; locations;   // output, locations of non-zero pixels
1237     *     cv::findNonZero(binaryImage, locations);
1238     *
1239     *     // access pixel coordinates
1240     *     Point pnt = locations[i];
1241     * </code>
1242     * @param src single-channel array
1243     * @param idx the output array, type of cv::Mat or std::vector&lt;Point&gt;, corresponding to non-zero indices in the input
1244     */
1245    public static void findNonZero(Mat src, Mat idx) {
1246        findNonZero_0(src.nativeObj, idx.nativeObj);
1247    }
1248
1249
1250    //
1251    // C++:  Scalar cv::mean(Mat src, Mat mask = Mat())
1252    //
1253
1254    /**
1255     * Calculates an average (mean) of array elements.
1256     *
1257     * The function cv::mean calculates the mean value M of array elements,
1258     * independently for each channel, and return it:
1259     * \(\begin{array}{l} N =  \sum _{I: \; \texttt{mask} (I) \ne 0} 1 \\ M_c =  \left ( \sum _{I: \; \texttt{mask} (I) \ne 0}{ \texttt{mtx} (I)_c} \right )/N \end{array}\)
1260     * When all the mask elements are 0's, the function returns Scalar::all(0)
1261     * @param src input array that should have from 1 to 4 channels so that the result can be stored in
1262     * Scalar_ .
1263     * @param mask optional operation mask.
1264     * SEE:  countNonZero, meanStdDev, norm, minMaxLoc
1265     * @return automatically generated
1266     */
1267    public static Scalar mean(Mat src, Mat mask) {
1268        return new Scalar(mean_0(src.nativeObj, mask.nativeObj));
1269    }
1270
1271    /**
1272     * Calculates an average (mean) of array elements.
1273     *
1274     * The function cv::mean calculates the mean value M of array elements,
1275     * independently for each channel, and return it:
1276     * \(\begin{array}{l} N =  \sum _{I: \; \texttt{mask} (I) \ne 0} 1 \\ M_c =  \left ( \sum _{I: \; \texttt{mask} (I) \ne 0}{ \texttt{mtx} (I)_c} \right )/N \end{array}\)
1277     * When all the mask elements are 0's, the function returns Scalar::all(0)
1278     * @param src input array that should have from 1 to 4 channels so that the result can be stored in
1279     * Scalar_ .
1280     * SEE:  countNonZero, meanStdDev, norm, minMaxLoc
1281     * @return automatically generated
1282     */
1283    public static Scalar mean(Mat src) {
1284        return new Scalar(mean_1(src.nativeObj));
1285    }
1286
1287
1288    //
1289    // C++:  void cv::meanStdDev(Mat src, vector_double& mean, vector_double& stddev, Mat mask = Mat())
1290    //
1291
1292    /**
1293     * Calculates a mean and standard deviation of array elements.
1294     *
1295     * The function cv::meanStdDev calculates the mean and the standard deviation M
1296     * of array elements independently for each channel and returns it via the
1297     * output parameters:
1298     * \(\begin{array}{l} N =  \sum _{I, \texttt{mask} (I)  \ne 0} 1 \\ \texttt{mean} _c =  \frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \texttt{src} (I)_c}{N} \\ \texttt{stddev} _c =  \sqrt{\frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \left ( \texttt{src} (I)_c -  \texttt{mean} _c \right )^2}{N}} \end{array}\)
1299     * When all the mask elements are 0's, the function returns
1300     * mean=stddev=Scalar::all(0).
1301     * <b>Note:</b> The calculated standard deviation is only the diagonal of the
1302     * complete normalized covariance matrix. If the full matrix is needed, you
1303     * can reshape the multi-channel array M x N to the single-channel array
1304     * M\*N x mtx.channels() (only possible when the matrix is continuous) and
1305     * then pass the matrix to calcCovarMatrix .
1306     * @param src input array that should have from 1 to 4 channels so that the results can be stored in
1307     * Scalar_ 's.
1308     * @param mean output parameter: calculated mean value.
1309     * @param stddev output parameter: calculated standard deviation.
1310     * @param mask optional operation mask.
1311     * SEE:  countNonZero, mean, norm, minMaxLoc, calcCovarMatrix
1312     */
1313    public static void meanStdDev(Mat src, MatOfDouble mean, MatOfDouble stddev, Mat mask) {
1314        Mat mean_mat = mean;
1315        Mat stddev_mat = stddev;
1316        meanStdDev_0(src.nativeObj, mean_mat.nativeObj, stddev_mat.nativeObj, mask.nativeObj);
1317    }
1318
1319    /**
1320     * Calculates a mean and standard deviation of array elements.
1321     *
1322     * The function cv::meanStdDev calculates the mean and the standard deviation M
1323     * of array elements independently for each channel and returns it via the
1324     * output parameters:
1325     * \(\begin{array}{l} N =  \sum _{I, \texttt{mask} (I)  \ne 0} 1 \\ \texttt{mean} _c =  \frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \texttt{src} (I)_c}{N} \\ \texttt{stddev} _c =  \sqrt{\frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \left ( \texttt{src} (I)_c -  \texttt{mean} _c \right )^2}{N}} \end{array}\)
1326     * When all the mask elements are 0's, the function returns
1327     * mean=stddev=Scalar::all(0).
1328     * <b>Note:</b> The calculated standard deviation is only the diagonal of the
1329     * complete normalized covariance matrix. If the full matrix is needed, you
1330     * can reshape the multi-channel array M x N to the single-channel array
1331     * M\*N x mtx.channels() (only possible when the matrix is continuous) and
1332     * then pass the matrix to calcCovarMatrix .
1333     * @param src input array that should have from 1 to 4 channels so that the results can be stored in
1334     * Scalar_ 's.
1335     * @param mean output parameter: calculated mean value.
1336     * @param stddev output parameter: calculated standard deviation.
1337     * SEE:  countNonZero, mean, norm, minMaxLoc, calcCovarMatrix
1338     */
1339    public static void meanStdDev(Mat src, MatOfDouble mean, MatOfDouble stddev) {
1340        Mat mean_mat = mean;
1341        Mat stddev_mat = stddev;
1342        meanStdDev_1(src.nativeObj, mean_mat.nativeObj, stddev_mat.nativeObj);
1343    }
1344
1345
1346    //
1347    // C++:  double cv::norm(Mat src1, int normType = NORM_L2, Mat mask = Mat())
1348    //
1349
1350    /**
1351     * Calculates the  absolute norm of an array.
1352     *
1353     * This version of #norm calculates the absolute norm of src1. The type of norm to calculate is specified using #NormTypes.
1354     *
1355     * As example for one array consider the function \(r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\).
1356     * The \( L_{1}, L_{2} \) and \( L_{\infty} \) norm for the sample value \(r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\)
1357     * is calculated as follows
1358     * \(align*}
1359     *     \| r(-1) \|_{L_1} &amp;= |-1| + |2| = 3 \\
1360     *     \| r(-1) \|_{L_2} &amp;= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
1361     *     \| r(-1) \|_{L_\infty} &amp;= \max(|-1|,|2|) = 2
1362     * \)
1363     * and for \(r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\) the calculation is
1364     * \(align*}
1365     *     \| r(0.5) \|_{L_1} &amp;= |0.5| + |0.5| = 1 \\
1366     *     \| r(0.5) \|_{L_2} &amp;= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
1367     *     \| r(0.5) \|_{L_\infty} &amp;= \max(|0.5|,|0.5|) = 0.5.
1368     * \)
1369     * The following graphic shows all values for the three norm functions \(\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\) and \(\| r(x) \|_{L_\infty}\).
1370     * It is notable that the \( L_{1} \) norm forms the upper and the \( L_{\infty} \) norm forms the lower border for the example function \( r(x) \).
1371     * ![Graphs for the different norm functions from the above example](pics/NormTypes_OneArray_1-2-INF.png)
1372     *
1373     * When the mask parameter is specified and it is not empty, the norm is
1374     *
1375     * If normType is not specified, #NORM_L2 is used.
1376     * calculated only over the region specified by the mask.
1377     *
1378     * Multi-channel input arrays are treated as single-channel arrays, that is,
1379     * the results for all channels are combined.
1380     *
1381     * Hamming norms can only be calculated with CV_8U depth arrays.
1382     *
1383     * @param src1 first input array.
1384     * @param normType type of the norm (see #NormTypes).
1385     * @param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type.
1386     * @return automatically generated
1387     */
1388    public static double norm(Mat src1, int normType, Mat mask) {
1389        return norm_0(src1.nativeObj, normType, mask.nativeObj);
1390    }
1391
1392    /**
1393     * Calculates the  absolute norm of an array.
1394     *
1395     * This version of #norm calculates the absolute norm of src1. The type of norm to calculate is specified using #NormTypes.
1396     *
1397     * As example for one array consider the function \(r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\).
1398     * The \( L_{1}, L_{2} \) and \( L_{\infty} \) norm for the sample value \(r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\)
1399     * is calculated as follows
1400     * \(align*}
1401     *     \| r(-1) \|_{L_1} &amp;= |-1| + |2| = 3 \\
1402     *     \| r(-1) \|_{L_2} &amp;= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
1403     *     \| r(-1) \|_{L_\infty} &amp;= \max(|-1|,|2|) = 2
1404     * \)
1405     * and for \(r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\) the calculation is
1406     * \(align*}
1407     *     \| r(0.5) \|_{L_1} &amp;= |0.5| + |0.5| = 1 \\
1408     *     \| r(0.5) \|_{L_2} &amp;= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
1409     *     \| r(0.5) \|_{L_\infty} &amp;= \max(|0.5|,|0.5|) = 0.5.
1410     * \)
1411     * The following graphic shows all values for the three norm functions \(\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\) and \(\| r(x) \|_{L_\infty}\).
1412     * It is notable that the \( L_{1} \) norm forms the upper and the \( L_{\infty} \) norm forms the lower border for the example function \( r(x) \).
1413     * ![Graphs for the different norm functions from the above example](pics/NormTypes_OneArray_1-2-INF.png)
1414     *
1415     * When the mask parameter is specified and it is not empty, the norm is
1416     *
1417     * If normType is not specified, #NORM_L2 is used.
1418     * calculated only over the region specified by the mask.
1419     *
1420     * Multi-channel input arrays are treated as single-channel arrays, that is,
1421     * the results for all channels are combined.
1422     *
1423     * Hamming norms can only be calculated with CV_8U depth arrays.
1424     *
1425     * @param src1 first input array.
1426     * @param normType type of the norm (see #NormTypes).
1427     * @return automatically generated
1428     */
1429    public static double norm(Mat src1, int normType) {
1430        return norm_1(src1.nativeObj, normType);
1431    }
1432
1433    /**
1434     * Calculates the  absolute norm of an array.
1435     *
1436     * This version of #norm calculates the absolute norm of src1. The type of norm to calculate is specified using #NormTypes.
1437     *
1438     * As example for one array consider the function \(r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\).
1439     * The \( L_{1}, L_{2} \) and \( L_{\infty} \) norm for the sample value \(r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\)
1440     * is calculated as follows
1441     * \(align*}
1442     *     \| r(-1) \|_{L_1} &amp;= |-1| + |2| = 3 \\
1443     *     \| r(-1) \|_{L_2} &amp;= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
1444     *     \| r(-1) \|_{L_\infty} &amp;= \max(|-1|,|2|) = 2
1445     * \)
1446     * and for \(r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\) the calculation is
1447     * \(align*}
1448     *     \| r(0.5) \|_{L_1} &amp;= |0.5| + |0.5| = 1 \\
1449     *     \| r(0.5) \|_{L_2} &amp;= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
1450     *     \| r(0.5) \|_{L_\infty} &amp;= \max(|0.5|,|0.5|) = 0.5.
1451     * \)
1452     * The following graphic shows all values for the three norm functions \(\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\) and \(\| r(x) \|_{L_\infty}\).
1453     * It is notable that the \( L_{1} \) norm forms the upper and the \( L_{\infty} \) norm forms the lower border for the example function \( r(x) \).
1454     * ![Graphs for the different norm functions from the above example](pics/NormTypes_OneArray_1-2-INF.png)
1455     *
1456     * When the mask parameter is specified and it is not empty, the norm is
1457     *
1458     * If normType is not specified, #NORM_L2 is used.
1459     * calculated only over the region specified by the mask.
1460     *
1461     * Multi-channel input arrays are treated as single-channel arrays, that is,
1462     * the results for all channels are combined.
1463     *
1464     * Hamming norms can only be calculated with CV_8U depth arrays.
1465     *
1466     * @param src1 first input array.
1467     * @return automatically generated
1468     */
1469    public static double norm(Mat src1) {
1470        return norm_2(src1.nativeObj);
1471    }
1472
1473
1474    //
1475    // C++:  double cv::norm(Mat src1, Mat src2, int normType = NORM_L2, Mat mask = Mat())
1476    //
1477
1478    /**
1479     * Calculates an absolute difference norm or a relative difference norm.
1480     *
1481     * This version of cv::norm calculates the absolute difference norm
1482     * or the relative difference norm of arrays src1 and src2.
1483     * The type of norm to calculate is specified using #NormTypes.
1484     *
1485     * @param src1 first input array.
1486     * @param src2 second input array of the same size and the same type as src1.
1487     * @param normType type of the norm (see #NormTypes).
1488     * @param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type.
1489     * @return automatically generated
1490     */
1491    public static double norm(Mat src1, Mat src2, int normType, Mat mask) {
1492        return norm_3(src1.nativeObj, src2.nativeObj, normType, mask.nativeObj);
1493    }
1494
1495    /**
1496     * Calculates an absolute difference norm or a relative difference norm.
1497     *
1498     * This version of cv::norm calculates the absolute difference norm
1499     * or the relative difference norm of arrays src1 and src2.
1500     * The type of norm to calculate is specified using #NormTypes.
1501     *
1502     * @param src1 first input array.
1503     * @param src2 second input array of the same size and the same type as src1.
1504     * @param normType type of the norm (see #NormTypes).
1505     * @return automatically generated
1506     */
1507    public static double norm(Mat src1, Mat src2, int normType) {
1508        return norm_4(src1.nativeObj, src2.nativeObj, normType);
1509    }
1510
1511    /**
1512     * Calculates an absolute difference norm or a relative difference norm.
1513     *
1514     * This version of cv::norm calculates the absolute difference norm
1515     * or the relative difference norm of arrays src1 and src2.
1516     * The type of norm to calculate is specified using #NormTypes.
1517     *
1518     * @param src1 first input array.
1519     * @param src2 second input array of the same size and the same type as src1.
1520     * @return automatically generated
1521     */
1522    public static double norm(Mat src1, Mat src2) {
1523        return norm_5(src1.nativeObj, src2.nativeObj);
1524    }
1525
1526
1527    //
1528    // C++:  double cv::PSNR(Mat src1, Mat src2, double R = 255.)
1529    //
1530
1531    /**
1532     * Computes the Peak Signal-to-Noise Ratio (PSNR) image quality metric.
1533     *
1534     * This function calculates the Peak Signal-to-Noise Ratio (PSNR) image quality metric in decibels (dB),
1535     * between two input arrays src1 and src2. The arrays must have the same type.
1536     *
1537     * The PSNR is calculated as follows:
1538     *
1539     * \(
1540     * \texttt{PSNR} = 10 \cdot \log_{10}{\left( \frac{R^2}{MSE} \right) }
1541     * \)
1542     *
1543     * where R is the maximum integer value of depth (e.g. 255 in the case of CV_8U data)
1544     * and MSE is the mean squared error between the two arrays.
1545     *
1546     * @param src1 first input array.
1547     * @param src2 second input array of the same size as src1.
1548     * @param R the maximum pixel value (255 by default)
1549     * @return automatically generated
1550     */
1551    public static double PSNR(Mat src1, Mat src2, double R) {
1552        return PSNR_0(src1.nativeObj, src2.nativeObj, R);
1553    }
1554
1555    /**
1556     * Computes the Peak Signal-to-Noise Ratio (PSNR) image quality metric.
1557     *
1558     * This function calculates the Peak Signal-to-Noise Ratio (PSNR) image quality metric in decibels (dB),
1559     * between two input arrays src1 and src2. The arrays must have the same type.
1560     *
1561     * The PSNR is calculated as follows:
1562     *
1563     * \(
1564     * \texttt{PSNR} = 10 \cdot \log_{10}{\left( \frac{R^2}{MSE} \right) }
1565     * \)
1566     *
1567     * where R is the maximum integer value of depth (e.g. 255 in the case of CV_8U data)
1568     * and MSE is the mean squared error between the two arrays.
1569     *
1570     * @param src1 first input array.
1571     * @param src2 second input array of the same size as src1.
1572     * @return automatically generated
1573     */
1574    public static double PSNR(Mat src1, Mat src2) {
1575        return PSNR_1(src1.nativeObj, src2.nativeObj);
1576    }
1577
1578
1579    //
1580    // C++:  void cv::batchDistance(Mat src1, Mat src2, Mat& dist, int dtype, Mat& nidx, int normType = NORM_L2, int K = 0, Mat mask = Mat(), int update = 0, bool crosscheck = false)
1581    //
1582
1583    /**
1584     * naive nearest neighbor finder
1585     *
1586     * see http://en.wikipedia.org/wiki/Nearest_neighbor_search
1587     * TODO: document
1588     * @param src1 automatically generated
1589     * @param src2 automatically generated
1590     * @param dist automatically generated
1591     * @param dtype automatically generated
1592     * @param nidx automatically generated
1593     * @param normType automatically generated
1594     * @param K automatically generated
1595     * @param mask automatically generated
1596     * @param update automatically generated
1597     * @param crosscheck automatically generated
1598     */
1599    public static void batchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx, int normType, int K, Mat mask, int update, boolean crosscheck) {
1600        batchDistance_0(src1.nativeObj, src2.nativeObj, dist.nativeObj, dtype, nidx.nativeObj, normType, K, mask.nativeObj, update, crosscheck);
1601    }
1602
1603    /**
1604     * naive nearest neighbor finder
1605     *
1606     * see http://en.wikipedia.org/wiki/Nearest_neighbor_search
1607     * TODO: document
1608     * @param src1 automatically generated
1609     * @param src2 automatically generated
1610     * @param dist automatically generated
1611     * @param dtype automatically generated
1612     * @param nidx automatically generated
1613     * @param normType automatically generated
1614     * @param K automatically generated
1615     * @param mask automatically generated
1616     * @param update automatically generated
1617     */
1618    public static void batchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx, int normType, int K, Mat mask, int update) {
1619        batchDistance_1(src1.nativeObj, src2.nativeObj, dist.nativeObj, dtype, nidx.nativeObj, normType, K, mask.nativeObj, update);
1620    }
1621
1622    /**
1623     * naive nearest neighbor finder
1624     *
1625     * see http://en.wikipedia.org/wiki/Nearest_neighbor_search
1626     * TODO: document
1627     * @param src1 automatically generated
1628     * @param src2 automatically generated
1629     * @param dist automatically generated
1630     * @param dtype automatically generated
1631     * @param nidx automatically generated
1632     * @param normType automatically generated
1633     * @param K automatically generated
1634     * @param mask automatically generated
1635     */
1636    public static void batchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx, int normType, int K, Mat mask) {
1637        batchDistance_2(src1.nativeObj, src2.nativeObj, dist.nativeObj, dtype, nidx.nativeObj, normType, K, mask.nativeObj);
1638    }
1639
1640    /**
1641     * naive nearest neighbor finder
1642     *
1643     * see http://en.wikipedia.org/wiki/Nearest_neighbor_search
1644     * TODO: document
1645     * @param src1 automatically generated
1646     * @param src2 automatically generated
1647     * @param dist automatically generated
1648     * @param dtype automatically generated
1649     * @param nidx automatically generated
1650     * @param normType automatically generated
1651     * @param K automatically generated
1652     */
1653    public static void batchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx, int normType, int K) {
1654        batchDistance_3(src1.nativeObj, src2.nativeObj, dist.nativeObj, dtype, nidx.nativeObj, normType, K);
1655    }
1656
1657    /**
1658     * naive nearest neighbor finder
1659     *
1660     * see http://en.wikipedia.org/wiki/Nearest_neighbor_search
1661     * TODO: document
1662     * @param src1 automatically generated
1663     * @param src2 automatically generated
1664     * @param dist automatically generated
1665     * @param dtype automatically generated
1666     * @param nidx automatically generated
1667     * @param normType automatically generated
1668     */
1669    public static void batchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx, int normType) {
1670        batchDistance_4(src1.nativeObj, src2.nativeObj, dist.nativeObj, dtype, nidx.nativeObj, normType);
1671    }
1672
1673    /**
1674     * naive nearest neighbor finder
1675     *
1676     * see http://en.wikipedia.org/wiki/Nearest_neighbor_search
1677     * TODO: document
1678     * @param src1 automatically generated
1679     * @param src2 automatically generated
1680     * @param dist automatically generated
1681     * @param dtype automatically generated
1682     * @param nidx automatically generated
1683     */
1684    public static void batchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx) {
1685        batchDistance_5(src1.nativeObj, src2.nativeObj, dist.nativeObj, dtype, nidx.nativeObj);
1686    }
1687
1688
1689    //
1690    // C++:  void cv::normalize(Mat src, Mat& dst, double alpha = 1, double beta = 0, int norm_type = NORM_L2, int dtype = -1, Mat mask = Mat())
1691    //
1692
1693    /**
1694     * Normalizes the norm or value range of an array.
1695     *
1696     * The function cv::normalize normalizes scale and shift the input array elements so that
1697     * \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
1698     * (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
1699     * \(\min _I  \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I  \texttt{dst} (I)= \texttt{beta}\)
1700     *
1701     * when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
1702     * normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
1703     * sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
1704     * min-max but modify the whole array, you can use norm and Mat::convertTo.
1705     *
1706     * In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
1707     * the range transformation for sparse matrices is not allowed since it can shift the zero level.
1708     *
1709     * Possible usage with some positive example data:
1710     * <code>
1711     *     vector&lt;double&gt; positiveData = { 2.0, 8.0, 10.0 };
1712     *     vector&lt;double&gt; normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
1713     *
1714     *     // Norm to probability (total count)
1715     *     // sum(numbers) = 20.0
1716     *     // 2.0      0.1     (2.0/20.0)
1717     *     // 8.0      0.4     (8.0/20.0)
1718     *     // 10.0     0.5     (10.0/20.0)
1719     *     normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
1720     *
1721     *     // Norm to unit vector: ||positiveData|| = 1.0
1722     *     // 2.0      0.15
1723     *     // 8.0      0.62
1724     *     // 10.0     0.77
1725     *     normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
1726     *
1727     *     // Norm to max element
1728     *     // 2.0      0.2     (2.0/10.0)
1729     *     // 8.0      0.8     (8.0/10.0)
1730     *     // 10.0     1.0     (10.0/10.0)
1731     *     normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
1732     *
1733     *     // Norm to range [0.0;1.0]
1734     *     // 2.0      0.0     (shift to left border)
1735     *     // 8.0      0.75    (6.0/8.0)
1736     *     // 10.0     1.0     (shift to right border)
1737     *     normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
1738     * </code>
1739     *
1740     * @param src input array.
1741     * @param dst output array of the same size as src .
1742     * @param alpha norm value to normalize to or the lower range boundary in case of the range
1743     * normalization.
1744     * @param beta upper range boundary in case of the range normalization; it is not used for the norm
1745     * normalization.
1746     * @param norm_type normalization type (see cv::NormTypes).
1747     * @param dtype when negative, the output array has the same type as src; otherwise, it has the same
1748     * number of channels as src and the depth =CV_MAT_DEPTH(dtype).
1749     * @param mask optional operation mask.
1750     * SEE: norm, Mat::convertTo, SparseMat::convertTo
1751     */
1752    public static void normalize(Mat src, Mat dst, double alpha, double beta, int norm_type, int dtype, Mat mask) {
1753        normalize_0(src.nativeObj, dst.nativeObj, alpha, beta, norm_type, dtype, mask.nativeObj);
1754    }
1755
1756    /**
1757     * Normalizes the norm or value range of an array.
1758     *
1759     * The function cv::normalize normalizes scale and shift the input array elements so that
1760     * \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
1761     * (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
1762     * \(\min _I  \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I  \texttt{dst} (I)= \texttt{beta}\)
1763     *
1764     * when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
1765     * normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
1766     * sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
1767     * min-max but modify the whole array, you can use norm and Mat::convertTo.
1768     *
1769     * In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
1770     * the range transformation for sparse matrices is not allowed since it can shift the zero level.
1771     *
1772     * Possible usage with some positive example data:
1773     * <code>
1774     *     vector&lt;double&gt; positiveData = { 2.0, 8.0, 10.0 };
1775     *     vector&lt;double&gt; normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
1776     *
1777     *     // Norm to probability (total count)
1778     *     // sum(numbers) = 20.0
1779     *     // 2.0      0.1     (2.0/20.0)
1780     *     // 8.0      0.4     (8.0/20.0)
1781     *     // 10.0     0.5     (10.0/20.0)
1782     *     normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
1783     *
1784     *     // Norm to unit vector: ||positiveData|| = 1.0
1785     *     // 2.0      0.15
1786     *     // 8.0      0.62
1787     *     // 10.0     0.77
1788     *     normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
1789     *
1790     *     // Norm to max element
1791     *     // 2.0      0.2     (2.0/10.0)
1792     *     // 8.0      0.8     (8.0/10.0)
1793     *     // 10.0     1.0     (10.0/10.0)
1794     *     normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
1795     *
1796     *     // Norm to range [0.0;1.0]
1797     *     // 2.0      0.0     (shift to left border)
1798     *     // 8.0      0.75    (6.0/8.0)
1799     *     // 10.0     1.0     (shift to right border)
1800     *     normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
1801     * </code>
1802     *
1803     * @param src input array.
1804     * @param dst output array of the same size as src .
1805     * @param alpha norm value to normalize to or the lower range boundary in case of the range
1806     * normalization.
1807     * @param beta upper range boundary in case of the range normalization; it is not used for the norm
1808     * normalization.
1809     * @param norm_type normalization type (see cv::NormTypes).
1810     * @param dtype when negative, the output array has the same type as src; otherwise, it has the same
1811     * number of channels as src and the depth =CV_MAT_DEPTH(dtype).
1812     * SEE: norm, Mat::convertTo, SparseMat::convertTo
1813     */
1814    public static void normalize(Mat src, Mat dst, double alpha, double beta, int norm_type, int dtype) {
1815        normalize_1(src.nativeObj, dst.nativeObj, alpha, beta, norm_type, dtype);
1816    }
1817
1818    /**
1819     * Normalizes the norm or value range of an array.
1820     *
1821     * The function cv::normalize normalizes scale and shift the input array elements so that
1822     * \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
1823     * (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
1824     * \(\min _I  \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I  \texttt{dst} (I)= \texttt{beta}\)
1825     *
1826     * when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
1827     * normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
1828     * sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
1829     * min-max but modify the whole array, you can use norm and Mat::convertTo.
1830     *
1831     * In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
1832     * the range transformation for sparse matrices is not allowed since it can shift the zero level.
1833     *
1834     * Possible usage with some positive example data:
1835     * <code>
1836     *     vector&lt;double&gt; positiveData = { 2.0, 8.0, 10.0 };
1837     *     vector&lt;double&gt; normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
1838     *
1839     *     // Norm to probability (total count)
1840     *     // sum(numbers) = 20.0
1841     *     // 2.0      0.1     (2.0/20.0)
1842     *     // 8.0      0.4     (8.0/20.0)
1843     *     // 10.0     0.5     (10.0/20.0)
1844     *     normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
1845     *
1846     *     // Norm to unit vector: ||positiveData|| = 1.0
1847     *     // 2.0      0.15
1848     *     // 8.0      0.62
1849     *     // 10.0     0.77
1850     *     normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
1851     *
1852     *     // Norm to max element
1853     *     // 2.0      0.2     (2.0/10.0)
1854     *     // 8.0      0.8     (8.0/10.0)
1855     *     // 10.0     1.0     (10.0/10.0)
1856     *     normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
1857     *
1858     *     // Norm to range [0.0;1.0]
1859     *     // 2.0      0.0     (shift to left border)
1860     *     // 8.0      0.75    (6.0/8.0)
1861     *     // 10.0     1.0     (shift to right border)
1862     *     normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
1863     * </code>
1864     *
1865     * @param src input array.
1866     * @param dst output array of the same size as src .
1867     * @param alpha norm value to normalize to or the lower range boundary in case of the range
1868     * normalization.
1869     * @param beta upper range boundary in case of the range normalization; it is not used for the norm
1870     * normalization.
1871     * @param norm_type normalization type (see cv::NormTypes).
1872     * number of channels as src and the depth =CV_MAT_DEPTH(dtype).
1873     * SEE: norm, Mat::convertTo, SparseMat::convertTo
1874     */
1875    public static void normalize(Mat src, Mat dst, double alpha, double beta, int norm_type) {
1876        normalize_2(src.nativeObj, dst.nativeObj, alpha, beta, norm_type);
1877    }
1878
1879    /**
1880     * Normalizes the norm or value range of an array.
1881     *
1882     * The function cv::normalize normalizes scale and shift the input array elements so that
1883     * \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
1884     * (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
1885     * \(\min _I  \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I  \texttt{dst} (I)= \texttt{beta}\)
1886     *
1887     * when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
1888     * normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
1889     * sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
1890     * min-max but modify the whole array, you can use norm and Mat::convertTo.
1891     *
1892     * In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
1893     * the range transformation for sparse matrices is not allowed since it can shift the zero level.
1894     *
1895     * Possible usage with some positive example data:
1896     * <code>
1897     *     vector&lt;double&gt; positiveData = { 2.0, 8.0, 10.0 };
1898     *     vector&lt;double&gt; normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
1899     *
1900     *     // Norm to probability (total count)
1901     *     // sum(numbers) = 20.0
1902     *     // 2.0      0.1     (2.0/20.0)
1903     *     // 8.0      0.4     (8.0/20.0)
1904     *     // 10.0     0.5     (10.0/20.0)
1905     *     normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
1906     *
1907     *     // Norm to unit vector: ||positiveData|| = 1.0
1908     *     // 2.0      0.15
1909     *     // 8.0      0.62
1910     *     // 10.0     0.77
1911     *     normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
1912     *
1913     *     // Norm to max element
1914     *     // 2.0      0.2     (2.0/10.0)
1915     *     // 8.0      0.8     (8.0/10.0)
1916     *     // 10.0     1.0     (10.0/10.0)
1917     *     normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
1918     *
1919     *     // Norm to range [0.0;1.0]
1920     *     // 2.0      0.0     (shift to left border)
1921     *     // 8.0      0.75    (6.0/8.0)
1922     *     // 10.0     1.0     (shift to right border)
1923     *     normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
1924     * </code>
1925     *
1926     * @param src input array.
1927     * @param dst output array of the same size as src .
1928     * @param alpha norm value to normalize to or the lower range boundary in case of the range
1929     * normalization.
1930     * @param beta upper range boundary in case of the range normalization; it is not used for the norm
1931     * normalization.
1932     * number of channels as src and the depth =CV_MAT_DEPTH(dtype).
1933     * SEE: norm, Mat::convertTo, SparseMat::convertTo
1934     */
1935    public static void normalize(Mat src, Mat dst, double alpha, double beta) {
1936        normalize_3(src.nativeObj, dst.nativeObj, alpha, beta);
1937    }
1938
1939    /**
1940     * Normalizes the norm or value range of an array.
1941     *
1942     * The function cv::normalize normalizes scale and shift the input array elements so that
1943     * \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
1944     * (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
1945     * \(\min _I  \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I  \texttt{dst} (I)= \texttt{beta}\)
1946     *
1947     * when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
1948     * normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
1949     * sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
1950     * min-max but modify the whole array, you can use norm and Mat::convertTo.
1951     *
1952     * In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
1953     * the range transformation for sparse matrices is not allowed since it can shift the zero level.
1954     *
1955     * Possible usage with some positive example data:
1956     * <code>
1957     *     vector&lt;double&gt; positiveData = { 2.0, 8.0, 10.0 };
1958     *     vector&lt;double&gt; normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
1959     *
1960     *     // Norm to probability (total count)
1961     *     // sum(numbers) = 20.0
1962     *     // 2.0      0.1     (2.0/20.0)
1963     *     // 8.0      0.4     (8.0/20.0)
1964     *     // 10.0     0.5     (10.0/20.0)
1965     *     normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
1966     *
1967     *     // Norm to unit vector: ||positiveData|| = 1.0
1968     *     // 2.0      0.15
1969     *     // 8.0      0.62
1970     *     // 10.0     0.77
1971     *     normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
1972     *
1973     *     // Norm to max element
1974     *     // 2.0      0.2     (2.0/10.0)
1975     *     // 8.0      0.8     (8.0/10.0)
1976     *     // 10.0     1.0     (10.0/10.0)
1977     *     normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
1978     *
1979     *     // Norm to range [0.0;1.0]
1980     *     // 2.0      0.0     (shift to left border)
1981     *     // 8.0      0.75    (6.0/8.0)
1982     *     // 10.0     1.0     (shift to right border)
1983     *     normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
1984     * </code>
1985     *
1986     * @param src input array.
1987     * @param dst output array of the same size as src .
1988     * @param alpha norm value to normalize to or the lower range boundary in case of the range
1989     * normalization.
1990     * normalization.
1991     * number of channels as src and the depth =CV_MAT_DEPTH(dtype).
1992     * SEE: norm, Mat::convertTo, SparseMat::convertTo
1993     */
1994    public static void normalize(Mat src, Mat dst, double alpha) {
1995        normalize_4(src.nativeObj, dst.nativeObj, alpha);
1996    }
1997
1998    /**
1999     * Normalizes the norm or value range of an array.
2000     *
2001     * The function cv::normalize normalizes scale and shift the input array elements so that
2002     * \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
2003     * (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
2004     * \(\min _I  \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I  \texttt{dst} (I)= \texttt{beta}\)
2005     *
2006     * when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
2007     * normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
2008     * sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
2009     * min-max but modify the whole array, you can use norm and Mat::convertTo.
2010     *
2011     * In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
2012     * the range transformation for sparse matrices is not allowed since it can shift the zero level.
2013     *
2014     * Possible usage with some positive example data:
2015     * <code>
2016     *     vector&lt;double&gt; positiveData = { 2.0, 8.0, 10.0 };
2017     *     vector&lt;double&gt; normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
2018     *
2019     *     // Norm to probability (total count)
2020     *     // sum(numbers) = 20.0
2021     *     // 2.0      0.1     (2.0/20.0)
2022     *     // 8.0      0.4     (8.0/20.0)
2023     *     // 10.0     0.5     (10.0/20.0)
2024     *     normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
2025     *
2026     *     // Norm to unit vector: ||positiveData|| = 1.0
2027     *     // 2.0      0.15
2028     *     // 8.0      0.62
2029     *     // 10.0     0.77
2030     *     normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
2031     *
2032     *     // Norm to max element
2033     *     // 2.0      0.2     (2.0/10.0)
2034     *     // 8.0      0.8     (8.0/10.0)
2035     *     // 10.0     1.0     (10.0/10.0)
2036     *     normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
2037     *
2038     *     // Norm to range [0.0;1.0]
2039     *     // 2.0      0.0     (shift to left border)
2040     *     // 8.0      0.75    (6.0/8.0)
2041     *     // 10.0     1.0     (shift to right border)
2042     *     normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
2043     * </code>
2044     *
2045     * @param src input array.
2046     * @param dst output array of the same size as src .
2047     * normalization.
2048     * normalization.
2049     * number of channels as src and the depth =CV_MAT_DEPTH(dtype).
2050     * SEE: norm, Mat::convertTo, SparseMat::convertTo
2051     */
2052    public static void normalize(Mat src, Mat dst) {
2053        normalize_5(src.nativeObj, dst.nativeObj);
2054    }
2055
2056
2057    //
2058    // C++:  void cv::reduce(Mat src, Mat& dst, int dim, int rtype, int dtype = -1)
2059    //
2060
2061    /**
2062     * Reduces a matrix to a vector.
2063     *
2064     * The function #reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of
2065     * 1D vectors and performing the specified operation on the vectors until a single row/column is
2066     * obtained. For example, the function can be used to compute horizontal and vertical projections of a
2067     * raster image. In case of #REDUCE_MAX and #REDUCE_MIN , the output image should have the same type as the source one.
2068     * In case of #REDUCE_SUM and #REDUCE_AVG , the output may have a larger element bit-depth to preserve accuracy.
2069     * And multi-channel arrays are also supported in these two reduction modes.
2070     *
2071     * The following code demonstrates its usage for a single channel matrix.
2072     * SNIPPET: snippets/core_reduce.cpp example
2073     *
2074     * And the following code demonstrates its usage for a two-channel matrix.
2075     * SNIPPET: snippets/core_reduce.cpp example2
2076     *
2077     * @param src input 2D matrix.
2078     * @param dst output vector. Its size and type is defined by dim and dtype parameters.
2079     * @param dim dimension index along which the matrix is reduced. 0 means that the matrix is reduced to
2080     * a single row. 1 means that the matrix is reduced to a single column.
2081     * @param rtype reduction operation that could be one of #ReduceTypes
2082     * @param dtype when negative, the output vector will have the same type as the input matrix,
2083     * otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), src.channels()).
2084     * SEE: repeat
2085     */
2086    public static void reduce(Mat src, Mat dst, int dim, int rtype, int dtype) {
2087        reduce_0(src.nativeObj, dst.nativeObj, dim, rtype, dtype);
2088    }
2089
2090    /**
2091     * Reduces a matrix to a vector.
2092     *
2093     * The function #reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of
2094     * 1D vectors and performing the specified operation on the vectors until a single row/column is
2095     * obtained. For example, the function can be used to compute horizontal and vertical projections of a
2096     * raster image. In case of #REDUCE_MAX and #REDUCE_MIN , the output image should have the same type as the source one.
2097     * In case of #REDUCE_SUM and #REDUCE_AVG , the output may have a larger element bit-depth to preserve accuracy.
2098     * And multi-channel arrays are also supported in these two reduction modes.
2099     *
2100     * The following code demonstrates its usage for a single channel matrix.
2101     * SNIPPET: snippets/core_reduce.cpp example
2102     *
2103     * And the following code demonstrates its usage for a two-channel matrix.
2104     * SNIPPET: snippets/core_reduce.cpp example2
2105     *
2106     * @param src input 2D matrix.
2107     * @param dst output vector. Its size and type is defined by dim and dtype parameters.
2108     * @param dim dimension index along which the matrix is reduced. 0 means that the matrix is reduced to
2109     * a single row. 1 means that the matrix is reduced to a single column.
2110     * @param rtype reduction operation that could be one of #ReduceTypes
2111     * otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), src.channels()).
2112     * SEE: repeat
2113     */
2114    public static void reduce(Mat src, Mat dst, int dim, int rtype) {
2115        reduce_1(src.nativeObj, dst.nativeObj, dim, rtype);
2116    }
2117
2118
2119    //
2120    // C++:  void cv::merge(vector_Mat mv, Mat& dst)
2121    //
2122
2123    /**
2124     *
2125     * @param mv input vector of matrices to be merged; all the matrices in mv must have the same
2126     * size and the same depth.
2127     * @param dst output array of the same size and the same depth as mv[0]; The number of channels will
2128     * be the total number of channels in the matrix array.
2129     */
2130    public static void merge(List<Mat> mv, Mat dst) {
2131        Mat mv_mat = Converters.vector_Mat_to_Mat(mv);
2132        merge_0(mv_mat.nativeObj, dst.nativeObj);
2133    }
2134
2135
2136    //
2137    // C++:  void cv::split(Mat m, vector_Mat& mv)
2138    //
2139
2140    /**
2141     *
2142     * @param m input multi-channel array.
2143     * @param mv output vector of arrays; the arrays themselves are reallocated, if needed.
2144     */
2145    public static void split(Mat m, List<Mat> mv) {
2146        Mat mv_mat = new Mat();
2147        split_0(m.nativeObj, mv_mat.nativeObj);
2148        Converters.Mat_to_vector_Mat(mv_mat, mv);
2149        mv_mat.release();
2150    }
2151
2152
2153    //
2154    // C++:  void cv::mixChannels(vector_Mat src, vector_Mat dst, vector_int fromTo)
2155    //
2156
2157    /**
2158     *
2159     * @param src input array or vector of matrices; all of the matrices must have the same size and the
2160     * same depth.
2161     * @param dst output array or vector of matrices; all the matrices <b>must be allocated</b>; their size and
2162     * depth must be the same as in src[0].
2163     * @param fromTo array of index pairs specifying which channels are copied and where; fromTo[k\*2] is
2164     * a 0-based index of the input channel in src, fromTo[k\*2+1] is an index of the output channel in
2165     * dst; the continuous channel numbering is used: the first input image channels are indexed from 0 to
2166     * src[0].channels()-1, the second input image channels are indexed from src[0].channels() to
2167     * src[0].channels() + src[1].channels()-1, and so on, the same scheme is used for the output image
2168     * channels; as a special case, when fromTo[k\*2] is negative, the corresponding output channel is
2169     * filled with zero .
2170     */
2171    public static void mixChannels(List<Mat> src, List<Mat> dst, MatOfInt fromTo) {
2172        Mat src_mat = Converters.vector_Mat_to_Mat(src);
2173        Mat dst_mat = Converters.vector_Mat_to_Mat(dst);
2174        Mat fromTo_mat = fromTo;
2175        mixChannels_0(src_mat.nativeObj, dst_mat.nativeObj, fromTo_mat.nativeObj);
2176    }
2177
2178
2179    //
2180    // C++:  void cv::extractChannel(Mat src, Mat& dst, int coi)
2181    //
2182
2183    /**
2184     * Extracts a single channel from src (coi is 0-based index)
2185     * @param src input array
2186     * @param dst output array
2187     * @param coi index of channel to extract
2188     * SEE: mixChannels, split
2189     */
2190    public static void extractChannel(Mat src, Mat dst, int coi) {
2191        extractChannel_0(src.nativeObj, dst.nativeObj, coi);
2192    }
2193
2194
2195    //
2196    // C++:  void cv::insertChannel(Mat src, Mat& dst, int coi)
2197    //
2198
2199    /**
2200     * Inserts a single channel to dst (coi is 0-based index)
2201     * @param src input array
2202     * @param dst output array
2203     * @param coi index of channel for insertion
2204     * SEE: mixChannels, merge
2205     */
2206    public static void insertChannel(Mat src, Mat dst, int coi) {
2207        insertChannel_0(src.nativeObj, dst.nativeObj, coi);
2208    }
2209
2210
2211    //
2212    // C++:  void cv::flip(Mat src, Mat& dst, int flipCode)
2213    //
2214
2215    /**
2216     * Flips a 2D array around vertical, horizontal, or both axes.
2217     *
2218     * The function cv::flip flips the array in one of three different ways (row
2219     * and column indices are 0-based):
2220     * \(\texttt{dst} _{ij} =
2221     * \left\{
2222     * \begin{array}{l l}
2223     * \texttt{src} _{\texttt{src.rows}-i-1,j} &amp; if\;  \texttt{flipCode} = 0 \\
2224     * \texttt{src} _{i, \texttt{src.cols} -j-1} &amp; if\;  \texttt{flipCode} &gt; 0 \\
2225     * \texttt{src} _{ \texttt{src.rows} -i-1, \texttt{src.cols} -j-1} &amp; if\; \texttt{flipCode} &lt; 0 \\
2226     * \end{array}
2227     * \right.\)
2228     * The example scenarios of using the function are the following:
2229     * Vertical flipping of the image (flipCode == 0) to switch between
2230     *     top-left and bottom-left image origin. This is a typical operation
2231     *     in video processing on Microsoft Windows\* OS.
2232     * Horizontal flipping of the image with the subsequent horizontal
2233     *     shift and absolute difference calculation to check for a
2234     *     vertical-axis symmetry (flipCode &gt; 0).
2235     * Simultaneous horizontal and vertical flipping of the image with
2236     *     the subsequent shift and absolute difference calculation to check
2237     *     for a central symmetry (flipCode &lt; 0).
2238     * Reversing the order of point arrays (flipCode &gt; 0 or
2239     *     flipCode == 0).
2240     * @param src input array.
2241     * @param dst output array of the same size and type as src.
2242     * @param flipCode a flag to specify how to flip the array; 0 means
2243     * flipping around the x-axis and positive value (for example, 1) means
2244     * flipping around y-axis. Negative value (for example, -1) means flipping
2245     * around both axes.
2246     * SEE: transpose , repeat , completeSymm
2247     */
2248    public static void flip(Mat src, Mat dst, int flipCode) {
2249        flip_0(src.nativeObj, dst.nativeObj, flipCode);
2250    }
2251
2252
2253    //
2254    // C++:  void cv::rotate(Mat src, Mat& dst, int rotateCode)
2255    //
2256
2257    /**
2258     * Rotates a 2D array in multiples of 90 degrees.
2259     * The function cv::rotate rotates the array in one of three different ways:
2260     * Rotate by 90 degrees clockwise (rotateCode = ROTATE_90_CLOCKWISE).
2261     * Rotate by 180 degrees clockwise (rotateCode = ROTATE_180).
2262     * Rotate by 270 degrees clockwise (rotateCode = ROTATE_90_COUNTERCLOCKWISE).
2263     * @param src input array.
2264     * @param dst output array of the same type as src.  The size is the same with ROTATE_180,
2265     * and the rows and cols are switched for ROTATE_90_CLOCKWISE and ROTATE_90_COUNTERCLOCKWISE.
2266     * @param rotateCode an enum to specify how to rotate the array; see the enum #RotateFlags
2267     * SEE: transpose , repeat , completeSymm, flip, RotateFlags
2268     */
2269    public static void rotate(Mat src, Mat dst, int rotateCode) {
2270        rotate_0(src.nativeObj, dst.nativeObj, rotateCode);
2271    }
2272
2273
2274    //
2275    // C++:  void cv::repeat(Mat src, int ny, int nx, Mat& dst)
2276    //
2277
2278    /**
2279     * Fills the output array with repeated copies of the input array.
2280     *
2281     * The function cv::repeat duplicates the input array one or more times along each of the two axes:
2282     * \(\texttt{dst} _{ij}= \texttt{src} _{i\mod src.rows, \; j\mod src.cols }\)
2283     * The second variant of the function is more convenient to use with REF: MatrixExpressions.
2284     * @param src input array to replicate.
2285     * @param ny Flag to specify how many times the {@code src} is repeated along the
2286     * vertical axis.
2287     * @param nx Flag to specify how many times the {@code src} is repeated along the
2288     * horizontal axis.
2289     * @param dst output array of the same type as {@code src}.
2290     * SEE: cv::reduce
2291     */
2292    public static void repeat(Mat src, int ny, int nx, Mat dst) {
2293        repeat_0(src.nativeObj, ny, nx, dst.nativeObj);
2294    }
2295
2296
2297    //
2298    // C++:  void cv::hconcat(vector_Mat src, Mat& dst)
2299    //
2300
2301    /**
2302     *
2303     *  <code>
2304     *     std::vector&lt;cv::Mat&gt; matrices = { cv::Mat(4, 1, CV_8UC1, cv::Scalar(1)),
2305     *                                       cv::Mat(4, 1, CV_8UC1, cv::Scalar(2)),
2306     *                                       cv::Mat(4, 1, CV_8UC1, cv::Scalar(3)),};
2307     *
2308     *     cv::Mat out;
2309     *     cv::hconcat( matrices, out );
2310     *     //out:
2311     *     //[1, 2, 3;
2312     *     // 1, 2, 3;
2313     *     // 1, 2, 3;
2314     *     // 1, 2, 3]
2315     *  </code>
2316     *  @param src input array or vector of matrices. all of the matrices must have the same number of rows and the same depth.
2317     *  @param dst output array. It has the same number of rows and depth as the src, and the sum of cols of the src.
2318     * same depth.
2319     */
2320    public static void hconcat(List<Mat> src, Mat dst) {
2321        Mat src_mat = Converters.vector_Mat_to_Mat(src);
2322        hconcat_0(src_mat.nativeObj, dst.nativeObj);
2323    }
2324
2325
2326    //
2327    // C++:  void cv::vconcat(vector_Mat src, Mat& dst)
2328    //
2329
2330    /**
2331     *
2332     *  <code>
2333     *     std::vector&lt;cv::Mat&gt; matrices = { cv::Mat(1, 4, CV_8UC1, cv::Scalar(1)),
2334     *                                       cv::Mat(1, 4, CV_8UC1, cv::Scalar(2)),
2335     *                                       cv::Mat(1, 4, CV_8UC1, cv::Scalar(3)),};
2336     *
2337     *     cv::Mat out;
2338     *     cv::vconcat( matrices, out );
2339     *     //out:
2340     *     //[1,   1,   1,   1;
2341     *     // 2,   2,   2,   2;
2342     *     // 3,   3,   3,   3]
2343     *  </code>
2344     *  @param src input array or vector of matrices. all of the matrices must have the same number of cols and the same depth
2345     *  @param dst output array. It has the same number of cols and depth as the src, and the sum of rows of the src.
2346     * same depth.
2347     */
2348    public static void vconcat(List<Mat> src, Mat dst) {
2349        Mat src_mat = Converters.vector_Mat_to_Mat(src);
2350        vconcat_0(src_mat.nativeObj, dst.nativeObj);
2351    }
2352
2353
2354    //
2355    // C++:  void cv::bitwise_and(Mat src1, Mat src2, Mat& dst, Mat mask = Mat())
2356    //
2357
2358    /**
2359     * computes bitwise conjunction of the two arrays (dst = src1 &amp; src2)
2360     * Calculates the per-element bit-wise conjunction of two arrays or an
2361     * array and a scalar.
2362     *
2363     * The function cv::bitwise_and calculates the per-element bit-wise logical conjunction for:
2364     * Two arrays when src1 and src2 have the same size:
2365     *     \(\texttt{dst} (I) =  \texttt{src1} (I)  \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
2366     * An array and a scalar when src2 is constructed from Scalar or has
2367     *     the same number of elements as {@code src1.channels()}:
2368     *     \(\texttt{dst} (I) =  \texttt{src1} (I)  \wedge \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
2369     * A scalar and an array when src1 is constructed from Scalar or has
2370     *     the same number of elements as {@code src2.channels()}:
2371     *     \(\texttt{dst} (I) =  \texttt{src1}  \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
2372     * In case of floating-point arrays, their machine-specific bit
2373     * representations (usually IEEE754-compliant) are used for the operation.
2374     * In case of multi-channel arrays, each channel is processed
2375     * independently. In the second and third cases above, the scalar is first
2376     * converted to the array type.
2377     * @param src1 first input array or a scalar.
2378     * @param src2 second input array or a scalar.
2379     * @param dst output array that has the same size and type as the input
2380     * arrays.
2381     * @param mask optional operation mask, 8-bit single channel array, that
2382     * specifies elements of the output array to be changed.
2383     */
2384    public static void bitwise_and(Mat src1, Mat src2, Mat dst, Mat mask) {
2385        bitwise_and_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj);
2386    }
2387
2388    /**
2389     * computes bitwise conjunction of the two arrays (dst = src1 &amp; src2)
2390     * Calculates the per-element bit-wise conjunction of two arrays or an
2391     * array and a scalar.
2392     *
2393     * The function cv::bitwise_and calculates the per-element bit-wise logical conjunction for:
2394     * Two arrays when src1 and src2 have the same size:
2395     *     \(\texttt{dst} (I) =  \texttt{src1} (I)  \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
2396     * An array and a scalar when src2 is constructed from Scalar or has
2397     *     the same number of elements as {@code src1.channels()}:
2398     *     \(\texttt{dst} (I) =  \texttt{src1} (I)  \wedge \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
2399     * A scalar and an array when src1 is constructed from Scalar or has
2400     *     the same number of elements as {@code src2.channels()}:
2401     *     \(\texttt{dst} (I) =  \texttt{src1}  \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
2402     * In case of floating-point arrays, their machine-specific bit
2403     * representations (usually IEEE754-compliant) are used for the operation.
2404     * In case of multi-channel arrays, each channel is processed
2405     * independently. In the second and third cases above, the scalar is first
2406     * converted to the array type.
2407     * @param src1 first input array or a scalar.
2408     * @param src2 second input array or a scalar.
2409     * @param dst output array that has the same size and type as the input
2410     * arrays.
2411     * specifies elements of the output array to be changed.
2412     */
2413    public static void bitwise_and(Mat src1, Mat src2, Mat dst) {
2414        bitwise_and_1(src1.nativeObj, src2.nativeObj, dst.nativeObj);
2415    }
2416
2417
2418    //
2419    // C++:  void cv::bitwise_or(Mat src1, Mat src2, Mat& dst, Mat mask = Mat())
2420    //
2421
2422    /**
2423     * Calculates the per-element bit-wise disjunction of two arrays or an
2424     * array and a scalar.
2425     *
2426     * The function cv::bitwise_or calculates the per-element bit-wise logical disjunction for:
2427     * Two arrays when src1 and src2 have the same size:
2428     *     \(\texttt{dst} (I) =  \texttt{src1} (I)  \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
2429     * An array and a scalar when src2 is constructed from Scalar or has
2430     *     the same number of elements as {@code src1.channels()}:
2431     *     \(\texttt{dst} (I) =  \texttt{src1} (I)  \vee \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
2432     * A scalar and an array when src1 is constructed from Scalar or has
2433     *     the same number of elements as {@code src2.channels()}:
2434     *     \(\texttt{dst} (I) =  \texttt{src1}  \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
2435     * In case of floating-point arrays, their machine-specific bit
2436     * representations (usually IEEE754-compliant) are used for the operation.
2437     * In case of multi-channel arrays, each channel is processed
2438     * independently. In the second and third cases above, the scalar is first
2439     * converted to the array type.
2440     * @param src1 first input array or a scalar.
2441     * @param src2 second input array or a scalar.
2442     * @param dst output array that has the same size and type as the input
2443     * arrays.
2444     * @param mask optional operation mask, 8-bit single channel array, that
2445     * specifies elements of the output array to be changed.
2446     */
2447    public static void bitwise_or(Mat src1, Mat src2, Mat dst, Mat mask) {
2448        bitwise_or_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj);
2449    }
2450
2451    /**
2452     * Calculates the per-element bit-wise disjunction of two arrays or an
2453     * array and a scalar.
2454     *
2455     * The function cv::bitwise_or calculates the per-element bit-wise logical disjunction for:
2456     * Two arrays when src1 and src2 have the same size:
2457     *     \(\texttt{dst} (I) =  \texttt{src1} (I)  \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
2458     * An array and a scalar when src2 is constructed from Scalar or has
2459     *     the same number of elements as {@code src1.channels()}:
2460     *     \(\texttt{dst} (I) =  \texttt{src1} (I)  \vee \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
2461     * A scalar and an array when src1 is constructed from Scalar or has
2462     *     the same number of elements as {@code src2.channels()}:
2463     *     \(\texttt{dst} (I) =  \texttt{src1}  \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
2464     * In case of floating-point arrays, their machine-specific bit
2465     * representations (usually IEEE754-compliant) are used for the operation.
2466     * In case of multi-channel arrays, each channel is processed
2467     * independently. In the second and third cases above, the scalar is first
2468     * converted to the array type.
2469     * @param src1 first input array or a scalar.
2470     * @param src2 second input array or a scalar.
2471     * @param dst output array that has the same size and type as the input
2472     * arrays.
2473     * specifies elements of the output array to be changed.
2474     */
2475    public static void bitwise_or(Mat src1, Mat src2, Mat dst) {
2476        bitwise_or_1(src1.nativeObj, src2.nativeObj, dst.nativeObj);
2477    }
2478
2479
2480    //
2481    // C++:  void cv::bitwise_xor(Mat src1, Mat src2, Mat& dst, Mat mask = Mat())
2482    //
2483
2484    /**
2485     * Calculates the per-element bit-wise "exclusive or" operation on two
2486     * arrays or an array and a scalar.
2487     *
2488     * The function cv::bitwise_xor calculates the per-element bit-wise logical "exclusive-or"
2489     * operation for:
2490     * Two arrays when src1 and src2 have the same size:
2491     *     \(\texttt{dst} (I) =  \texttt{src1} (I)  \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
2492     * An array and a scalar when src2 is constructed from Scalar or has
2493     *     the same number of elements as {@code src1.channels()}:
2494     *     \(\texttt{dst} (I) =  \texttt{src1} (I)  \oplus \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
2495     * A scalar and an array when src1 is constructed from Scalar or has
2496     *     the same number of elements as {@code src2.channels()}:
2497     *     \(\texttt{dst} (I) =  \texttt{src1}  \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
2498     * In case of floating-point arrays, their machine-specific bit
2499     * representations (usually IEEE754-compliant) are used for the operation.
2500     * In case of multi-channel arrays, each channel is processed
2501     * independently. In the 2nd and 3rd cases above, the scalar is first
2502     * converted to the array type.
2503     * @param src1 first input array or a scalar.
2504     * @param src2 second input array or a scalar.
2505     * @param dst output array that has the same size and type as the input
2506     * arrays.
2507     * @param mask optional operation mask, 8-bit single channel array, that
2508     * specifies elements of the output array to be changed.
2509     */
2510    public static void bitwise_xor(Mat src1, Mat src2, Mat dst, Mat mask) {
2511        bitwise_xor_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj);
2512    }
2513
2514    /**
2515     * Calculates the per-element bit-wise "exclusive or" operation on two
2516     * arrays or an array and a scalar.
2517     *
2518     * The function cv::bitwise_xor calculates the per-element bit-wise logical "exclusive-or"
2519     * operation for:
2520     * Two arrays when src1 and src2 have the same size:
2521     *     \(\texttt{dst} (I) =  \texttt{src1} (I)  \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
2522     * An array and a scalar when src2 is constructed from Scalar or has
2523     *     the same number of elements as {@code src1.channels()}:
2524     *     \(\texttt{dst} (I) =  \texttt{src1} (I)  \oplus \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
2525     * A scalar and an array when src1 is constructed from Scalar or has
2526     *     the same number of elements as {@code src2.channels()}:
2527     *     \(\texttt{dst} (I) =  \texttt{src1}  \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
2528     * In case of floating-point arrays, their machine-specific bit
2529     * representations (usually IEEE754-compliant) are used for the operation.
2530     * In case of multi-channel arrays, each channel is processed
2531     * independently. In the 2nd and 3rd cases above, the scalar is first
2532     * converted to the array type.
2533     * @param src1 first input array or a scalar.
2534     * @param src2 second input array or a scalar.
2535     * @param dst output array that has the same size and type as the input
2536     * arrays.
2537     * specifies elements of the output array to be changed.
2538     */
2539    public static void bitwise_xor(Mat src1, Mat src2, Mat dst) {
2540        bitwise_xor_1(src1.nativeObj, src2.nativeObj, dst.nativeObj);
2541    }
2542
2543
2544    //
2545    // C++:  void cv::bitwise_not(Mat src, Mat& dst, Mat mask = Mat())
2546    //
2547
2548    /**
2549     *  Inverts every bit of an array.
2550     *
2551     * The function cv::bitwise_not calculates per-element bit-wise inversion of the input
2552     * array:
2553     * \(\texttt{dst} (I) =  \neg \texttt{src} (I)\)
2554     * In case of a floating-point input array, its machine-specific bit
2555     * representation (usually IEEE754-compliant) is used for the operation. In
2556     * case of multi-channel arrays, each channel is processed independently.
2557     * @param src input array.
2558     * @param dst output array that has the same size and type as the input
2559     * array.
2560     * @param mask optional operation mask, 8-bit single channel array, that
2561     * specifies elements of the output array to be changed.
2562     */
2563    public static void bitwise_not(Mat src, Mat dst, Mat mask) {
2564        bitwise_not_0(src.nativeObj, dst.nativeObj, mask.nativeObj);
2565    }
2566
2567    /**
2568     *  Inverts every bit of an array.
2569     *
2570     * The function cv::bitwise_not calculates per-element bit-wise inversion of the input
2571     * array:
2572     * \(\texttt{dst} (I) =  \neg \texttt{src} (I)\)
2573     * In case of a floating-point input array, its machine-specific bit
2574     * representation (usually IEEE754-compliant) is used for the operation. In
2575     * case of multi-channel arrays, each channel is processed independently.
2576     * @param src input array.
2577     * @param dst output array that has the same size and type as the input
2578     * array.
2579     * specifies elements of the output array to be changed.
2580     */
2581    public static void bitwise_not(Mat src, Mat dst) {
2582        bitwise_not_1(src.nativeObj, dst.nativeObj);
2583    }
2584
2585
2586    //
2587    // C++:  void cv::absdiff(Mat src1, Mat src2, Mat& dst)
2588    //
2589
2590    /**
2591     * Calculates the per-element absolute difference between two arrays or between an array and a scalar.
2592     *
2593     * The function cv::absdiff calculates:
2594     * Absolute difference between two arrays when they have the same
2595     *     size and type:
2596     *     \(\texttt{dst}(I) =  \texttt{saturate} (| \texttt{src1}(I) -  \texttt{src2}(I)|)\)
2597     * Absolute difference between an array and a scalar when the second
2598     *     array is constructed from Scalar or has as many elements as the
2599     *     number of channels in {@code src1}:
2600     *     \(\texttt{dst}(I) =  \texttt{saturate} (| \texttt{src1}(I) -  \texttt{src2} |)\)
2601     * Absolute difference between a scalar and an array when the first
2602     *     array is constructed from Scalar or has as many elements as the
2603     *     number of channels in {@code src2}:
2604     *     \(\texttt{dst}(I) =  \texttt{saturate} (| \texttt{src1} -  \texttt{src2}(I) |)\)
2605     *     where I is a multi-dimensional index of array elements. In case of
2606     *     multi-channel arrays, each channel is processed independently.
2607     * <b>Note:</b> Saturation is not applied when the arrays have the depth CV_32S.
2608     * You may even get a negative value in the case of overflow.
2609     * @param src1 first input array or a scalar.
2610     * @param src2 second input array or a scalar.
2611     * @param dst output array that has the same size and type as input arrays.
2612     * SEE: cv::abs(const Mat&amp;)
2613     */
2614    public static void absdiff(Mat src1, Mat src2, Mat dst) {
2615        absdiff_0(src1.nativeObj, src2.nativeObj, dst.nativeObj);
2616    }
2617
2618
2619    //
2620    // C++:  void cv::copyTo(Mat src, Mat& dst, Mat mask)
2621    //
2622
2623    /**
2624     *  This is an overloaded member function, provided for convenience (python)
2625     * Copies the matrix to another one.
2626     * When the operation mask is specified, if the Mat::create call shown above reallocates the matrix, the newly allocated matrix is initialized with all zeros before copying the data.
2627     * @param src source matrix.
2628     * @param dst Destination matrix. If it does not have a proper size or type before the operation, it is
2629     * reallocated.
2630     * @param mask Operation mask of the same size as \*this. Its non-zero elements indicate which matrix
2631     * elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels.
2632     */
2633    public static void copyTo(Mat src, Mat dst, Mat mask) {
2634        copyTo_0(src.nativeObj, dst.nativeObj, mask.nativeObj);
2635    }
2636
2637
2638    //
2639    // C++:  void cv::inRange(Mat src, Scalar lowerb, Scalar upperb, Mat& dst)
2640    //
2641
2642    /**
2643     *  Checks if array elements lie between the elements of two other arrays.
2644     *
2645     * The function checks the range as follows:
2646     * <ul>
2647     *   <li>
2648     *    For every element of a single-channel input array:
2649     *     \(\texttt{dst} (I)= \texttt{lowerb} (I)_0  \leq \texttt{src} (I)_0 \leq  \texttt{upperb} (I)_0\)
2650     *   </li>
2651     *   <li>
2652     *    For two-channel arrays:
2653     *     \(\texttt{dst} (I)= \texttt{lowerb} (I)_0  \leq \texttt{src} (I)_0 \leq  \texttt{upperb} (I)_0  \land \texttt{lowerb} (I)_1  \leq \texttt{src} (I)_1 \leq  \texttt{upperb} (I)_1\)
2654     *   </li>
2655     *   <li>
2656     *    and so forth.
2657     *   </li>
2658     * </ul>
2659     *
2660     * That is, dst (I) is set to 255 (all 1 -bits) if src (I) is within the
2661     * specified 1D, 2D, 3D, ... box and 0 otherwise.
2662     *
2663     * When the lower and/or upper boundary parameters are scalars, the indexes
2664     * (I) at lowerb and upperb in the above formulas should be omitted.
2665     * @param src first input array.
2666     * @param lowerb inclusive lower boundary array or a scalar.
2667     * @param upperb inclusive upper boundary array or a scalar.
2668     * @param dst output array of the same size as src and CV_8U type.
2669     */
2670    public static void inRange(Mat src, Scalar lowerb, Scalar upperb, Mat dst) {
2671        inRange_0(src.nativeObj, lowerb.val[0], lowerb.val[1], lowerb.val[2], lowerb.val[3], upperb.val[0], upperb.val[1], upperb.val[2], upperb.val[3], dst.nativeObj);
2672    }
2673
2674
2675    //
2676    // C++:  void cv::compare(Mat src1, Mat src2, Mat& dst, int cmpop)
2677    //
2678
2679    /**
2680     * Performs the per-element comparison of two arrays or an array and scalar value.
2681     *
2682     * The function compares:
2683     * Elements of two arrays when src1 and src2 have the same size:
2684     *     \(\texttt{dst} (I) =  \texttt{src1} (I)  \,\texttt{cmpop}\, \texttt{src2} (I)\)
2685     * Elements of src1 with a scalar src2 when src2 is constructed from
2686     *     Scalar or has a single element:
2687     *     \(\texttt{dst} (I) =  \texttt{src1}(I) \,\texttt{cmpop}\,  \texttt{src2}\)
2688     * src1 with elements of src2 when src1 is constructed from Scalar or
2689     *     has a single element:
2690     *     \(\texttt{dst} (I) =  \texttt{src1}  \,\texttt{cmpop}\, \texttt{src2} (I)\)
2691     * When the comparison result is true, the corresponding element of output
2692     * array is set to 255. The comparison operations can be replaced with the
2693     * equivalent matrix expressions:
2694     * <code>
2695     *     Mat dst1 = src1 &gt;= src2;
2696     *     Mat dst2 = src1 &lt; 8;
2697     *     ...
2698     * </code>
2699     * @param src1 first input array or a scalar; when it is an array, it must have a single channel.
2700     * @param src2 second input array or a scalar; when it is an array, it must have a single channel.
2701     * @param dst output array of type ref CV_8U that has the same size and the same number of channels as
2702     *     the input arrays.
2703     * @param cmpop a flag, that specifies correspondence between the arrays (cv::CmpTypes)
2704     * SEE: checkRange, min, max, threshold
2705     */
2706    public static void compare(Mat src1, Mat src2, Mat dst, int cmpop) {
2707        compare_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, cmpop);
2708    }
2709
2710
2711    //
2712    // C++:  void cv::min(Mat src1, Mat src2, Mat& dst)
2713    //
2714
2715    /**
2716     * Calculates per-element minimum of two arrays or an array and a scalar.
2717     *
2718     * The function cv::min calculates the per-element minimum of two arrays:
2719     * \(\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{src2} (I))\)
2720     * or array and a scalar:
2721     * \(\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{value} )\)
2722     * @param src1 first input array.
2723     * @param src2 second input array of the same size and type as src1.
2724     * @param dst output array of the same size and type as src1.
2725     * SEE: max, compare, inRange, minMaxLoc
2726     */
2727    public static void min(Mat src1, Mat src2, Mat dst) {
2728        min_0(src1.nativeObj, src2.nativeObj, dst.nativeObj);
2729    }
2730
2731
2732    //
2733    // C++:  void cv::max(Mat src1, Mat src2, Mat& dst)
2734    //
2735
2736    /**
2737     * Calculates per-element maximum of two arrays or an array and a scalar.
2738     *
2739     * The function cv::max calculates the per-element maximum of two arrays:
2740     * \(\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{src2} (I))\)
2741     * or array and a scalar:
2742     * \(\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{value} )\)
2743     * @param src1 first input array.
2744     * @param src2 second input array of the same size and type as src1 .
2745     * @param dst output array of the same size and type as src1.
2746     * SEE:  min, compare, inRange, minMaxLoc, REF: MatrixExpressions
2747     */
2748    public static void max(Mat src1, Mat src2, Mat dst) {
2749        max_0(src1.nativeObj, src2.nativeObj, dst.nativeObj);
2750    }
2751
2752
2753    //
2754    // C++:  void cv::sqrt(Mat src, Mat& dst)
2755    //
2756
2757    /**
2758     * Calculates a square root of array elements.
2759     *
2760     * The function cv::sqrt calculates a square root of each input array element.
2761     * In case of multi-channel arrays, each channel is processed
2762     * independently. The accuracy is approximately the same as of the built-in
2763     * std::sqrt .
2764     * @param src input floating-point array.
2765     * @param dst output array of the same size and type as src.
2766     */
2767    public static void sqrt(Mat src, Mat dst) {
2768        sqrt_0(src.nativeObj, dst.nativeObj);
2769    }
2770
2771
2772    //
2773    // C++:  void cv::pow(Mat src, double power, Mat& dst)
2774    //
2775
2776    /**
2777     * Raises every array element to a power.
2778     *
2779     * The function cv::pow raises every element of the input array to power :
2780     * \(\texttt{dst} (I) =  \fork{\texttt{src}(I)^{power}}{if \(\texttt{power}\) is integer}{|\texttt{src}(I)|^{power}}{otherwise}\)
2781     *
2782     * So, for a non-integer power exponent, the absolute values of input array
2783     * elements are used. However, it is possible to get true values for
2784     * negative values using some extra operations. In the example below,
2785     * computing the 5th root of array src shows:
2786     * <code>
2787     *     Mat mask = src &lt; 0;
2788     *     pow(src, 1./5, dst);
2789     *     subtract(Scalar::all(0), dst, dst, mask);
2790     * </code>
2791     * For some values of power, such as integer values, 0.5 and -0.5,
2792     * specialized faster algorithms are used.
2793     *
2794     * Special values (NaN, Inf) are not handled.
2795     * @param src input array.
2796     * @param power exponent of power.
2797     * @param dst output array of the same size and type as src.
2798     * SEE: sqrt, exp, log, cartToPolar, polarToCart
2799     */
2800    public static void pow(Mat src, double power, Mat dst) {
2801        pow_0(src.nativeObj, power, dst.nativeObj);
2802    }
2803
2804
2805    //
2806    // C++:  void cv::exp(Mat src, Mat& dst)
2807    //
2808
2809    /**
2810     * Calculates the exponent of every array element.
2811     *
2812     * The function cv::exp calculates the exponent of every element of the input
2813     * array:
2814     * \(\texttt{dst} [I] = e^{ src(I) }\)
2815     *
2816     * The maximum relative error is about 7e-6 for single-precision input and
2817     * less than 1e-10 for double-precision input. Currently, the function
2818     * converts denormalized values to zeros on output. Special values (NaN,
2819     * Inf) are not handled.
2820     * @param src input array.
2821     * @param dst output array of the same size and type as src.
2822     * SEE: log , cartToPolar , polarToCart , phase , pow , sqrt , magnitude
2823     */
2824    public static void exp(Mat src, Mat dst) {
2825        exp_0(src.nativeObj, dst.nativeObj);
2826    }
2827
2828
2829    //
2830    // C++:  void cv::log(Mat src, Mat& dst)
2831    //
2832
2833    /**
2834     * Calculates the natural logarithm of every array element.
2835     *
2836     * The function cv::log calculates the natural logarithm of every element of the input array:
2837     * \(\texttt{dst} (I) =  \log (\texttt{src}(I)) \)
2838     *
2839     * Output on zero, negative and special (NaN, Inf) values is undefined.
2840     *
2841     * @param src input array.
2842     * @param dst output array of the same size and type as src .
2843     * SEE: exp, cartToPolar, polarToCart, phase, pow, sqrt, magnitude
2844     */
2845    public static void log(Mat src, Mat dst) {
2846        log_0(src.nativeObj, dst.nativeObj);
2847    }
2848
2849
2850    //
2851    // C++:  void cv::polarToCart(Mat magnitude, Mat angle, Mat& x, Mat& y, bool angleInDegrees = false)
2852    //
2853
2854    /**
2855     * Calculates x and y coordinates of 2D vectors from their magnitude and angle.
2856     *
2857     * The function cv::polarToCart calculates the Cartesian coordinates of each 2D
2858     * vector represented by the corresponding elements of magnitude and angle:
2859     * \(\begin{array}{l} \texttt{x} (I) =  \texttt{magnitude} (I) \cos ( \texttt{angle} (I)) \\ \texttt{y} (I) =  \texttt{magnitude} (I) \sin ( \texttt{angle} (I)) \\ \end{array}\)
2860     *
2861     * The relative accuracy of the estimated coordinates is about 1e-6.
2862     * @param magnitude input floating-point array of magnitudes of 2D vectors;
2863     * it can be an empty matrix (=Mat()), in this case, the function assumes
2864     * that all the magnitudes are =1; if it is not empty, it must have the
2865     * same size and type as angle.
2866     * @param angle input floating-point array of angles of 2D vectors.
2867     * @param x output array of x-coordinates of 2D vectors; it has the same
2868     * size and type as angle.
2869     * @param y output array of y-coordinates of 2D vectors; it has the same
2870     * size and type as angle.
2871     * @param angleInDegrees when true, the input angles are measured in
2872     * degrees, otherwise, they are measured in radians.
2873     * SEE: cartToPolar, magnitude, phase, exp, log, pow, sqrt
2874     */
2875    public static void polarToCart(Mat magnitude, Mat angle, Mat x, Mat y, boolean angleInDegrees) {
2876        polarToCart_0(magnitude.nativeObj, angle.nativeObj, x.nativeObj, y.nativeObj, angleInDegrees);
2877    }
2878
2879    /**
2880     * Calculates x and y coordinates of 2D vectors from their magnitude and angle.
2881     *
2882     * The function cv::polarToCart calculates the Cartesian coordinates of each 2D
2883     * vector represented by the corresponding elements of magnitude and angle:
2884     * \(\begin{array}{l} \texttt{x} (I) =  \texttt{magnitude} (I) \cos ( \texttt{angle} (I)) \\ \texttt{y} (I) =  \texttt{magnitude} (I) \sin ( \texttt{angle} (I)) \\ \end{array}\)
2885     *
2886     * The relative accuracy of the estimated coordinates is about 1e-6.
2887     * @param magnitude input floating-point array of magnitudes of 2D vectors;
2888     * it can be an empty matrix (=Mat()), in this case, the function assumes
2889     * that all the magnitudes are =1; if it is not empty, it must have the
2890     * same size and type as angle.
2891     * @param angle input floating-point array of angles of 2D vectors.
2892     * @param x output array of x-coordinates of 2D vectors; it has the same
2893     * size and type as angle.
2894     * @param y output array of y-coordinates of 2D vectors; it has the same
2895     * size and type as angle.
2896     * degrees, otherwise, they are measured in radians.
2897     * SEE: cartToPolar, magnitude, phase, exp, log, pow, sqrt
2898     */
2899    public static void polarToCart(Mat magnitude, Mat angle, Mat x, Mat y) {
2900        polarToCart_1(magnitude.nativeObj, angle.nativeObj, x.nativeObj, y.nativeObj);
2901    }
2902
2903
2904    //
2905    // C++:  void cv::cartToPolar(Mat x, Mat y, Mat& magnitude, Mat& angle, bool angleInDegrees = false)
2906    //
2907
2908    /**
2909     * Calculates the magnitude and angle of 2D vectors.
2910     *
2911     * The function cv::cartToPolar calculates either the magnitude, angle, or both
2912     * for every 2D vector (x(I),y(I)):
2913     * \(\begin{array}{l} \texttt{magnitude} (I)= \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\)
2914     *
2915     * The angles are calculated with accuracy about 0.3 degrees. For the point
2916     * (0,0), the angle is set to 0.
2917     * @param x array of x-coordinates; this must be a single-precision or
2918     * double-precision floating-point array.
2919     * @param y array of y-coordinates, that must have the same size and same type as x.
2920     * @param magnitude output array of magnitudes of the same size and type as x.
2921     * @param angle output array of angles that has the same size and type as
2922     * x; the angles are measured in radians (from 0 to 2\*Pi) or in degrees (0 to 360 degrees).
2923     * @param angleInDegrees a flag, indicating whether the angles are measured
2924     * in radians (which is by default), or in degrees.
2925     * SEE: Sobel, Scharr
2926     */
2927    public static void cartToPolar(Mat x, Mat y, Mat magnitude, Mat angle, boolean angleInDegrees) {
2928        cartToPolar_0(x.nativeObj, y.nativeObj, magnitude.nativeObj, angle.nativeObj, angleInDegrees);
2929    }
2930
2931    /**
2932     * Calculates the magnitude and angle of 2D vectors.
2933     *
2934     * The function cv::cartToPolar calculates either the magnitude, angle, or both
2935     * for every 2D vector (x(I),y(I)):
2936     * \(\begin{array}{l} \texttt{magnitude} (I)= \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\)
2937     *
2938     * The angles are calculated with accuracy about 0.3 degrees. For the point
2939     * (0,0), the angle is set to 0.
2940     * @param x array of x-coordinates; this must be a single-precision or
2941     * double-precision floating-point array.
2942     * @param y array of y-coordinates, that must have the same size and same type as x.
2943     * @param magnitude output array of magnitudes of the same size and type as x.
2944     * @param angle output array of angles that has the same size and type as
2945     * x; the angles are measured in radians (from 0 to 2\*Pi) or in degrees (0 to 360 degrees).
2946     * in radians (which is by default), or in degrees.
2947     * SEE: Sobel, Scharr
2948     */
2949    public static void cartToPolar(Mat x, Mat y, Mat magnitude, Mat angle) {
2950        cartToPolar_1(x.nativeObj, y.nativeObj, magnitude.nativeObj, angle.nativeObj);
2951    }
2952
2953
2954    //
2955    // C++:  void cv::phase(Mat x, Mat y, Mat& angle, bool angleInDegrees = false)
2956    //
2957
2958    /**
2959     * Calculates the rotation angle of 2D vectors.
2960     *
2961     * The function cv::phase calculates the rotation angle of each 2D vector that
2962     * is formed from the corresponding elements of x and y :
2963     * \(\texttt{angle} (I) =  \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\)
2964     *
2965     * The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 ,
2966     * the corresponding angle(I) is set to 0.
2967     * @param x input floating-point array of x-coordinates of 2D vectors.
2968     * @param y input array of y-coordinates of 2D vectors; it must have the
2969     * same size and the same type as x.
2970     * @param angle output array of vector angles; it has the same size and
2971     * same type as x .
2972     * @param angleInDegrees when true, the function calculates the angle in
2973     * degrees, otherwise, they are measured in radians.
2974     */
2975    public static void phase(Mat x, Mat y, Mat angle, boolean angleInDegrees) {
2976        phase_0(x.nativeObj, y.nativeObj, angle.nativeObj, angleInDegrees);
2977    }
2978
2979    /**
2980     * Calculates the rotation angle of 2D vectors.
2981     *
2982     * The function cv::phase calculates the rotation angle of each 2D vector that
2983     * is formed from the corresponding elements of x and y :
2984     * \(\texttt{angle} (I) =  \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\)
2985     *
2986     * The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 ,
2987     * the corresponding angle(I) is set to 0.
2988     * @param x input floating-point array of x-coordinates of 2D vectors.
2989     * @param y input array of y-coordinates of 2D vectors; it must have the
2990     * same size and the same type as x.
2991     * @param angle output array of vector angles; it has the same size and
2992     * same type as x .
2993     * degrees, otherwise, they are measured in radians.
2994     */
2995    public static void phase(Mat x, Mat y, Mat angle) {
2996        phase_1(x.nativeObj, y.nativeObj, angle.nativeObj);
2997    }
2998
2999
3000    //
3001    // C++:  void cv::magnitude(Mat x, Mat y, Mat& magnitude)
3002    //
3003
3004    /**
3005     * Calculates the magnitude of 2D vectors.
3006     *
3007     * The function cv::magnitude calculates the magnitude of 2D vectors formed
3008     * from the corresponding elements of x and y arrays:
3009     * \(\texttt{dst} (I) =  \sqrt{\texttt{x}(I)^2 + \texttt{y}(I)^2}\)
3010     * @param x floating-point array of x-coordinates of the vectors.
3011     * @param y floating-point array of y-coordinates of the vectors; it must
3012     * have the same size as x.
3013     * @param magnitude output array of the same size and type as x.
3014     * SEE: cartToPolar, polarToCart, phase, sqrt
3015     */
3016    public static void magnitude(Mat x, Mat y, Mat magnitude) {
3017        magnitude_0(x.nativeObj, y.nativeObj, magnitude.nativeObj);
3018    }
3019
3020
3021    //
3022    // C++:  bool cv::checkRange(Mat a, bool quiet = true,  _hidden_ * pos = 0, double minVal = -DBL_MAX, double maxVal = DBL_MAX)
3023    //
3024
3025    /**
3026     * Checks every element of an input array for invalid values.
3027     *
3028     * The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal &gt;
3029     * <ul>
3030     *   <li>
3031     * DBL_MAX and maxVal &lt; DBL_MAX, the function also checks that each value is between minVal and
3032     * maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
3033     * are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
3034     * function either returns false (when quiet=true) or throws an exception.
3035     * @param a input array.
3036     * @param quiet a flag, indicating whether the functions quietly return false when the array elements
3037     * are out of range or they throw an exception.
3038     * elements.
3039     * @param minVal inclusive lower boundary of valid values range.
3040     * @param maxVal exclusive upper boundary of valid values range.
3041     *   </li>
3042     * </ul>
3043     * @return automatically generated
3044     */
3045    public static boolean checkRange(Mat a, boolean quiet, double minVal, double maxVal) {
3046        return checkRange_0(a.nativeObj, quiet, minVal, maxVal);
3047    }
3048
3049    /**
3050     * Checks every element of an input array for invalid values.
3051     *
3052     * The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal &gt;
3053     * <ul>
3054     *   <li>
3055     * DBL_MAX and maxVal &lt; DBL_MAX, the function also checks that each value is between minVal and
3056     * maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
3057     * are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
3058     * function either returns false (when quiet=true) or throws an exception.
3059     * @param a input array.
3060     * @param quiet a flag, indicating whether the functions quietly return false when the array elements
3061     * are out of range or they throw an exception.
3062     * elements.
3063     * @param minVal inclusive lower boundary of valid values range.
3064     *   </li>
3065     * </ul>
3066     * @return automatically generated
3067     */
3068    public static boolean checkRange(Mat a, boolean quiet, double minVal) {
3069        return checkRange_1(a.nativeObj, quiet, minVal);
3070    }
3071
3072    /**
3073     * Checks every element of an input array for invalid values.
3074     *
3075     * The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal &gt;
3076     * <ul>
3077     *   <li>
3078     * DBL_MAX and maxVal &lt; DBL_MAX, the function also checks that each value is between minVal and
3079     * maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
3080     * are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
3081     * function either returns false (when quiet=true) or throws an exception.
3082     * @param a input array.
3083     * @param quiet a flag, indicating whether the functions quietly return false when the array elements
3084     * are out of range or they throw an exception.
3085     * elements.
3086     *   </li>
3087     * </ul>
3088     * @return automatically generated
3089     */
3090    public static boolean checkRange(Mat a, boolean quiet) {
3091        return checkRange_2(a.nativeObj, quiet);
3092    }
3093
3094    /**
3095     * Checks every element of an input array for invalid values.
3096     *
3097     * The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal &gt;
3098     * <ul>
3099     *   <li>
3100     * DBL_MAX and maxVal &lt; DBL_MAX, the function also checks that each value is between minVal and
3101     * maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
3102     * are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
3103     * function either returns false (when quiet=true) or throws an exception.
3104     * @param a input array.
3105     * are out of range or they throw an exception.
3106     * elements.
3107     *   </li>
3108     * </ul>
3109     * @return automatically generated
3110     */
3111    public static boolean checkRange(Mat a) {
3112        return checkRange_4(a.nativeObj);
3113    }
3114
3115
3116    //
3117    // C++:  void cv::patchNaNs(Mat& a, double val = 0)
3118    //
3119
3120    /**
3121     * converts NaNs to the given number
3122     * @param a input/output matrix (CV_32F type).
3123     * @param val value to convert the NaNs
3124     */
3125    public static void patchNaNs(Mat a, double val) {
3126        patchNaNs_0(a.nativeObj, val);
3127    }
3128
3129    /**
3130     * converts NaNs to the given number
3131     * @param a input/output matrix (CV_32F type).
3132     */
3133    public static void patchNaNs(Mat a) {
3134        patchNaNs_1(a.nativeObj);
3135    }
3136
3137
3138    //
3139    // C++:  void cv::gemm(Mat src1, Mat src2, double alpha, Mat src3, double beta, Mat& dst, int flags = 0)
3140    //
3141
3142    /**
3143     * Performs generalized matrix multiplication.
3144     *
3145     * The function cv::gemm performs generalized matrix multiplication similar to the
3146     * gemm functions in BLAS level 3. For example,
3147     * {@code gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)}
3148     * corresponds to
3149     * \(\texttt{dst} =  \texttt{alpha} \cdot \texttt{src1} ^T  \cdot \texttt{src2} +  \texttt{beta} \cdot \texttt{src3} ^T\)
3150     *
3151     * In case of complex (two-channel) data, performed a complex matrix
3152     * multiplication.
3153     *
3154     * The function can be replaced with a matrix expression. For example, the
3155     * above call can be replaced with:
3156     * <code>
3157     *     dst = alpha*src1.t()*src2 + beta*src3.t();
3158     * </code>
3159     * @param src1 first multiplied input matrix that could be real(CV_32FC1,
3160     * CV_64FC1) or complex(CV_32FC2, CV_64FC2).
3161     * @param src2 second multiplied input matrix of the same type as src1.
3162     * @param alpha weight of the matrix product.
3163     * @param src3 third optional delta matrix added to the matrix product; it
3164     * should have the same type as src1 and src2.
3165     * @param beta weight of src3.
3166     * @param dst output matrix; it has the proper size and the same type as
3167     * input matrices.
3168     * @param flags operation flags (cv::GemmFlags)
3169     * SEE: mulTransposed , transform
3170     */
3171    public static void gemm(Mat src1, Mat src2, double alpha, Mat src3, double beta, Mat dst, int flags) {
3172        gemm_0(src1.nativeObj, src2.nativeObj, alpha, src3.nativeObj, beta, dst.nativeObj, flags);
3173    }
3174
3175    /**
3176     * Performs generalized matrix multiplication.
3177     *
3178     * The function cv::gemm performs generalized matrix multiplication similar to the
3179     * gemm functions in BLAS level 3. For example,
3180     * {@code gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)}
3181     * corresponds to
3182     * \(\texttt{dst} =  \texttt{alpha} \cdot \texttt{src1} ^T  \cdot \texttt{src2} +  \texttt{beta} \cdot \texttt{src3} ^T\)
3183     *
3184     * In case of complex (two-channel) data, performed a complex matrix
3185     * multiplication.
3186     *
3187     * The function can be replaced with a matrix expression. For example, the
3188     * above call can be replaced with:
3189     * <code>
3190     *     dst = alpha*src1.t()*src2 + beta*src3.t();
3191     * </code>
3192     * @param src1 first multiplied input matrix that could be real(CV_32FC1,
3193     * CV_64FC1) or complex(CV_32FC2, CV_64FC2).
3194     * @param src2 second multiplied input matrix of the same type as src1.
3195     * @param alpha weight of the matrix product.
3196     * @param src3 third optional delta matrix added to the matrix product; it
3197     * should have the same type as src1 and src2.
3198     * @param beta weight of src3.
3199     * @param dst output matrix; it has the proper size and the same type as
3200     * input matrices.
3201     * SEE: mulTransposed , transform
3202     */
3203    public static void gemm(Mat src1, Mat src2, double alpha, Mat src3, double beta, Mat dst) {
3204        gemm_1(src1.nativeObj, src2.nativeObj, alpha, src3.nativeObj, beta, dst.nativeObj);
3205    }
3206
3207
3208    //
3209    // C++:  void cv::mulTransposed(Mat src, Mat& dst, bool aTa, Mat delta = Mat(), double scale = 1, int dtype = -1)
3210    //
3211
3212    /**
3213     * Calculates the product of a matrix and its transposition.
3214     *
3215     * The function cv::mulTransposed calculates the product of src and its
3216     * transposition:
3217     * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\)
3218     * if aTa=true , and
3219     * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\)
3220     * otherwise. The function is used to calculate the covariance matrix. With
3221     * zero delta, it can be used as a faster substitute for general matrix
3222     * product A\*B when B=A'
3223     * @param src input single-channel matrix. Note that unlike gemm, the
3224     * function can multiply not only floating-point matrices.
3225     * @param dst output square matrix.
3226     * @param aTa Flag specifying the multiplication ordering. See the
3227     * description below.
3228     * @param delta Optional delta matrix subtracted from src before the
3229     * multiplication. When the matrix is empty ( delta=noArray() ), it is
3230     * assumed to be zero, that is, nothing is subtracted. If it has the same
3231     * size as src , it is simply subtracted. Otherwise, it is "repeated" (see
3232     * repeat ) to cover the full src and then subtracted. Type of the delta
3233     * matrix, when it is not empty, must be the same as the type of created
3234     * output matrix. See the dtype parameter description below.
3235     * @param scale Optional scale factor for the matrix product.
3236     * @param dtype Optional type of the output matrix. When it is negative,
3237     * the output matrix will have the same type as src . Otherwise, it will be
3238     * type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F .
3239     * SEE: calcCovarMatrix, gemm, repeat, reduce
3240     */
3241    public static void mulTransposed(Mat src, Mat dst, boolean aTa, Mat delta, double scale, int dtype) {
3242        mulTransposed_0(src.nativeObj, dst.nativeObj, aTa, delta.nativeObj, scale, dtype);
3243    }
3244
3245    /**
3246     * Calculates the product of a matrix and its transposition.
3247     *
3248     * The function cv::mulTransposed calculates the product of src and its
3249     * transposition:
3250     * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\)
3251     * if aTa=true , and
3252     * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\)
3253     * otherwise. The function is used to calculate the covariance matrix. With
3254     * zero delta, it can be used as a faster substitute for general matrix
3255     * product A\*B when B=A'
3256     * @param src input single-channel matrix. Note that unlike gemm, the
3257     * function can multiply not only floating-point matrices.
3258     * @param dst output square matrix.
3259     * @param aTa Flag specifying the multiplication ordering. See the
3260     * description below.
3261     * @param delta Optional delta matrix subtracted from src before the
3262     * multiplication. When the matrix is empty ( delta=noArray() ), it is
3263     * assumed to be zero, that is, nothing is subtracted. If it has the same
3264     * size as src , it is simply subtracted. Otherwise, it is "repeated" (see
3265     * repeat ) to cover the full src and then subtracted. Type of the delta
3266     * matrix, when it is not empty, must be the same as the type of created
3267     * output matrix. See the dtype parameter description below.
3268     * @param scale Optional scale factor for the matrix product.
3269     * the output matrix will have the same type as src . Otherwise, it will be
3270     * type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F .
3271     * SEE: calcCovarMatrix, gemm, repeat, reduce
3272     */
3273    public static void mulTransposed(Mat src, Mat dst, boolean aTa, Mat delta, double scale) {
3274        mulTransposed_1(src.nativeObj, dst.nativeObj, aTa, delta.nativeObj, scale);
3275    }
3276
3277    /**
3278     * Calculates the product of a matrix and its transposition.
3279     *
3280     * The function cv::mulTransposed calculates the product of src and its
3281     * transposition:
3282     * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\)
3283     * if aTa=true , and
3284     * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\)
3285     * otherwise. The function is used to calculate the covariance matrix. With
3286     * zero delta, it can be used as a faster substitute for general matrix
3287     * product A\*B when B=A'
3288     * @param src input single-channel matrix. Note that unlike gemm, the
3289     * function can multiply not only floating-point matrices.
3290     * @param dst output square matrix.
3291     * @param aTa Flag specifying the multiplication ordering. See the
3292     * description below.
3293     * @param delta Optional delta matrix subtracted from src before the
3294     * multiplication. When the matrix is empty ( delta=noArray() ), it is
3295     * assumed to be zero, that is, nothing is subtracted. If it has the same
3296     * size as src , it is simply subtracted. Otherwise, it is "repeated" (see
3297     * repeat ) to cover the full src and then subtracted. Type of the delta
3298     * matrix, when it is not empty, must be the same as the type of created
3299     * output matrix. See the dtype parameter description below.
3300     * the output matrix will have the same type as src . Otherwise, it will be
3301     * type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F .
3302     * SEE: calcCovarMatrix, gemm, repeat, reduce
3303     */
3304    public static void mulTransposed(Mat src, Mat dst, boolean aTa, Mat delta) {
3305        mulTransposed_2(src.nativeObj, dst.nativeObj, aTa, delta.nativeObj);
3306    }
3307
3308    /**
3309     * Calculates the product of a matrix and its transposition.
3310     *
3311     * The function cv::mulTransposed calculates the product of src and its
3312     * transposition:
3313     * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\)
3314     * if aTa=true , and
3315     * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\)
3316     * otherwise. The function is used to calculate the covariance matrix. With
3317     * zero delta, it can be used as a faster substitute for general matrix
3318     * product A\*B when B=A'
3319     * @param src input single-channel matrix. Note that unlike gemm, the
3320     * function can multiply not only floating-point matrices.
3321     * @param dst output square matrix.
3322     * @param aTa Flag specifying the multiplication ordering. See the
3323     * description below.
3324     * multiplication. When the matrix is empty ( delta=noArray() ), it is
3325     * assumed to be zero, that is, nothing is subtracted. If it has the same
3326     * size as src , it is simply subtracted. Otherwise, it is "repeated" (see
3327     * repeat ) to cover the full src and then subtracted. Type of the delta
3328     * matrix, when it is not empty, must be the same as the type of created
3329     * output matrix. See the dtype parameter description below.
3330     * the output matrix will have the same type as src . Otherwise, it will be
3331     * type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F .
3332     * SEE: calcCovarMatrix, gemm, repeat, reduce
3333     */
3334    public static void mulTransposed(Mat src, Mat dst, boolean aTa) {
3335        mulTransposed_3(src.nativeObj, dst.nativeObj, aTa);
3336    }
3337
3338
3339    //
3340    // C++:  void cv::transpose(Mat src, Mat& dst)
3341    //
3342
3343    /**
3344     * Transposes a matrix.
3345     *
3346     * The function cv::transpose transposes the matrix src :
3347     * \(\texttt{dst} (i,j) =  \texttt{src} (j,i)\)
3348     * <b>Note:</b> No complex conjugation is done in case of a complex matrix. It
3349     * should be done separately if needed.
3350     * @param src input array.
3351     * @param dst output array of the same type as src.
3352     */
3353    public static void transpose(Mat src, Mat dst) {
3354        transpose_0(src.nativeObj, dst.nativeObj);
3355    }
3356
3357
3358    //
3359    // C++:  void cv::transform(Mat src, Mat& dst, Mat m)
3360    //
3361
3362    /**
3363     * Performs the matrix transformation of every array element.
3364     *
3365     * The function cv::transform performs the matrix transformation of every
3366     * element of the array src and stores the results in dst :
3367     * \(\texttt{dst} (I) =  \texttt{m} \cdot \texttt{src} (I)\)
3368     * (when m.cols=src.channels() ), or
3369     * \(\texttt{dst} (I) =  \texttt{m} \cdot [ \texttt{src} (I); 1]\)
3370     * (when m.cols=src.channels()+1 )
3371     *
3372     * Every element of the N -channel array src is interpreted as N -element
3373     * vector that is transformed using the M x N or M x (N+1) matrix m to
3374     * M-element vector - the corresponding element of the output array dst .
3375     *
3376     * The function may be used for geometrical transformation of
3377     * N -dimensional points, arbitrary linear color space transformation (such
3378     * as various kinds of RGB to YUV transforms), shuffling the image
3379     * channels, and so forth.
3380     * @param src input array that must have as many channels (1 to 4) as
3381     * m.cols or m.cols-1.
3382     * @param dst output array of the same size and depth as src; it has as
3383     * many channels as m.rows.
3384     * @param m transformation 2x2 or 2x3 floating-point matrix.
3385     * SEE: perspectiveTransform, getAffineTransform, estimateAffine2D, warpAffine, warpPerspective
3386     */
3387    public static void transform(Mat src, Mat dst, Mat m) {
3388        transform_0(src.nativeObj, dst.nativeObj, m.nativeObj);
3389    }
3390
3391
3392    //
3393    // C++:  void cv::perspectiveTransform(Mat src, Mat& dst, Mat m)
3394    //
3395
3396    /**
3397     * Performs the perspective matrix transformation of vectors.
3398     *
3399     * The function cv::perspectiveTransform transforms every element of src by
3400     * treating it as a 2D or 3D vector, in the following way:
3401     * \((x, y, z)  \rightarrow (x'/w, y'/w, z'/w)\)
3402     * where
3403     * \((x', y', z', w') =  \texttt{mat} \cdot \begin{bmatrix} x &amp; y &amp; z &amp; 1  \end{bmatrix}\)
3404     * and
3405     * \(w =  \fork{w'}{if \(w' \ne 0\)}{\infty}{otherwise}\)
3406     *
3407     * Here a 3D vector transformation is shown. In case of a 2D vector
3408     * transformation, the z component is omitted.
3409     *
3410     * <b>Note:</b> The function transforms a sparse set of 2D or 3D vectors. If you
3411     * want to transform an image using perspective transformation, use
3412     * warpPerspective . If you have an inverse problem, that is, you want to
3413     * compute the most probable perspective transformation out of several
3414     * pairs of corresponding points, you can use getPerspectiveTransform or
3415     * findHomography .
3416     * @param src input two-channel or three-channel floating-point array; each
3417     * element is a 2D/3D vector to be transformed.
3418     * @param dst output array of the same size and type as src.
3419     * @param m 3x3 or 4x4 floating-point transformation matrix.
3420     * SEE:  transform, warpPerspective, getPerspectiveTransform, findHomography
3421     */
3422    public static void perspectiveTransform(Mat src, Mat dst, Mat m) {
3423        perspectiveTransform_0(src.nativeObj, dst.nativeObj, m.nativeObj);
3424    }
3425
3426
3427    //
3428    // C++:  void cv::completeSymm(Mat& m, bool lowerToUpper = false)
3429    //
3430
3431    /**
3432     * Copies the lower or the upper half of a square matrix to its another half.
3433     *
3434     * The function cv::completeSymm copies the lower or the upper half of a square matrix to
3435     * its another half. The matrix diagonal remains unchanged:
3436     * <ul>
3437     *   <li>
3438     *   \(\texttt{m}_{ij}=\texttt{m}_{ji}\) for \(i &gt; j\) if
3439     *     lowerToUpper=false
3440     *   </li>
3441     *   <li>
3442     *   \(\texttt{m}_{ij}=\texttt{m}_{ji}\) for \(i &lt; j\) if
3443     *     lowerToUpper=true
3444     *   </li>
3445     * </ul>
3446     *
3447     * @param m input-output floating-point square matrix.
3448     * @param lowerToUpper operation flag; if true, the lower half is copied to
3449     * the upper half. Otherwise, the upper half is copied to the lower half.
3450     * SEE: flip, transpose
3451     */
3452    public static void completeSymm(Mat m, boolean lowerToUpper) {
3453        completeSymm_0(m.nativeObj, lowerToUpper);
3454    }
3455
3456    /**
3457     * Copies the lower or the upper half of a square matrix to its another half.
3458     *
3459     * The function cv::completeSymm copies the lower or the upper half of a square matrix to
3460     * its another half. The matrix diagonal remains unchanged:
3461     * <ul>
3462     *   <li>
3463     *   \(\texttt{m}_{ij}=\texttt{m}_{ji}\) for \(i &gt; j\) if
3464     *     lowerToUpper=false
3465     *   </li>
3466     *   <li>
3467     *   \(\texttt{m}_{ij}=\texttt{m}_{ji}\) for \(i &lt; j\) if
3468     *     lowerToUpper=true
3469     *   </li>
3470     * </ul>
3471     *
3472     * @param m input-output floating-point square matrix.
3473     * the upper half. Otherwise, the upper half is copied to the lower half.
3474     * SEE: flip, transpose
3475     */
3476    public static void completeSymm(Mat m) {
3477        completeSymm_1(m.nativeObj);
3478    }
3479
3480
3481    //
3482    // C++:  void cv::setIdentity(Mat& mtx, Scalar s = Scalar(1))
3483    //
3484
3485    /**
3486     * Initializes a scaled identity matrix.
3487     *
3488     * The function cv::setIdentity initializes a scaled identity matrix:
3489     * \(\texttt{mtx} (i,j)= \fork{\texttt{value}}{ if \(i=j\)}{0}{otherwise}\)
3490     *
3491     * The function can also be emulated using the matrix initializers and the
3492     * matrix expressions:
3493     * <code>
3494     *     Mat A = Mat::eye(4, 3, CV_32F)*5;
3495     *     // A will be set to [[5, 0, 0], [0, 5, 0], [0, 0, 5], [0, 0, 0]]
3496     * </code>
3497     * @param mtx matrix to initialize (not necessarily square).
3498     * @param s value to assign to diagonal elements.
3499     * SEE: Mat::zeros, Mat::ones, Mat::setTo, Mat::operator=
3500     */
3501    public static void setIdentity(Mat mtx, Scalar s) {
3502        setIdentity_0(mtx.nativeObj, s.val[0], s.val[1], s.val[2], s.val[3]);
3503    }
3504
3505    /**
3506     * Initializes a scaled identity matrix.
3507     *
3508     * The function cv::setIdentity initializes a scaled identity matrix:
3509     * \(\texttt{mtx} (i,j)= \fork{\texttt{value}}{ if \(i=j\)}{0}{otherwise}\)
3510     *
3511     * The function can also be emulated using the matrix initializers and the
3512     * matrix expressions:
3513     * <code>
3514     *     Mat A = Mat::eye(4, 3, CV_32F)*5;
3515     *     // A will be set to [[5, 0, 0], [0, 5, 0], [0, 0, 5], [0, 0, 0]]
3516     * </code>
3517     * @param mtx matrix to initialize (not necessarily square).
3518     * SEE: Mat::zeros, Mat::ones, Mat::setTo, Mat::operator=
3519     */
3520    public static void setIdentity(Mat mtx) {
3521        setIdentity_1(mtx.nativeObj);
3522    }
3523
3524
3525    //
3526    // C++:  double cv::determinant(Mat mtx)
3527    //
3528
3529    /**
3530     * Returns the determinant of a square floating-point matrix.
3531     *
3532     * The function cv::determinant calculates and returns the determinant of the
3533     * specified matrix. For small matrices ( mtx.cols=mtx.rows&lt;=3 ), the
3534     * direct method is used. For larger matrices, the function uses LU
3535     * factorization with partial pivoting.
3536     *
3537     * For symmetric positively-determined matrices, it is also possible to use
3538     * eigen decomposition to calculate the determinant.
3539     * @param mtx input matrix that must have CV_32FC1 or CV_64FC1 type and
3540     * square size.
3541     * SEE: trace, invert, solve, eigen, REF: MatrixExpressions
3542     * @return automatically generated
3543     */
3544    public static double determinant(Mat mtx) {
3545        return determinant_0(mtx.nativeObj);
3546    }
3547
3548
3549    //
3550    // C++:  Scalar cv::trace(Mat mtx)
3551    //
3552
3553    /**
3554     * Returns the trace of a matrix.
3555     *
3556     * The function cv::trace returns the sum of the diagonal elements of the
3557     * matrix mtx .
3558     * \(\mathrm{tr} ( \texttt{mtx} ) =  \sum _i  \texttt{mtx} (i,i)\)
3559     * @param mtx input matrix.
3560     * @return automatically generated
3561     */
3562    public static Scalar trace(Mat mtx) {
3563        return new Scalar(trace_0(mtx.nativeObj));
3564    }
3565
3566
3567    //
3568    // C++:  double cv::invert(Mat src, Mat& dst, int flags = DECOMP_LU)
3569    //
3570
3571    /**
3572     * Finds the inverse or pseudo-inverse of a matrix.
3573     *
3574     * The function cv::invert inverts the matrix src and stores the result in dst
3575     * . When the matrix src is singular or non-square, the function calculates
3576     * the pseudo-inverse matrix (the dst matrix) so that norm(src\*dst - I) is
3577     * minimal, where I is an identity matrix.
3578     *
3579     * In case of the #DECOMP_LU method, the function returns non-zero value if
3580     * the inverse has been successfully calculated and 0 if src is singular.
3581     *
3582     * In case of the #DECOMP_SVD method, the function returns the inverse
3583     * condition number of src (the ratio of the smallest singular value to the
3584     * largest singular value) and 0 if src is singular. The SVD method
3585     * calculates a pseudo-inverse matrix if src is singular.
3586     *
3587     * Similarly to #DECOMP_LU, the method #DECOMP_CHOLESKY works only with
3588     * non-singular square matrices that should also be symmetrical and
3589     * positively defined. In this case, the function stores the inverted
3590     * matrix in dst and returns non-zero. Otherwise, it returns 0.
3591     *
3592     * @param src input floating-point M x N matrix.
3593     * @param dst output matrix of N x M size and the same type as src.
3594     * @param flags inversion method (cv::DecompTypes)
3595     * SEE: solve, SVD
3596     * @return automatically generated
3597     */
3598    public static double invert(Mat src, Mat dst, int flags) {
3599        return invert_0(src.nativeObj, dst.nativeObj, flags);
3600    }
3601
3602    /**
3603     * Finds the inverse or pseudo-inverse of a matrix.
3604     *
3605     * The function cv::invert inverts the matrix src and stores the result in dst
3606     * . When the matrix src is singular or non-square, the function calculates
3607     * the pseudo-inverse matrix (the dst matrix) so that norm(src\*dst - I) is
3608     * minimal, where I is an identity matrix.
3609     *
3610     * In case of the #DECOMP_LU method, the function returns non-zero value if
3611     * the inverse has been successfully calculated and 0 if src is singular.
3612     *
3613     * In case of the #DECOMP_SVD method, the function returns the inverse
3614     * condition number of src (the ratio of the smallest singular value to the
3615     * largest singular value) and 0 if src is singular. The SVD method
3616     * calculates a pseudo-inverse matrix if src is singular.
3617     *
3618     * Similarly to #DECOMP_LU, the method #DECOMP_CHOLESKY works only with
3619     * non-singular square matrices that should also be symmetrical and
3620     * positively defined. In this case, the function stores the inverted
3621     * matrix in dst and returns non-zero. Otherwise, it returns 0.
3622     *
3623     * @param src input floating-point M x N matrix.
3624     * @param dst output matrix of N x M size and the same type as src.
3625     * SEE: solve, SVD
3626     * @return automatically generated
3627     */
3628    public static double invert(Mat src, Mat dst) {
3629        return invert_1(src.nativeObj, dst.nativeObj);
3630    }
3631
3632
3633    //
3634    // C++:  bool cv::solve(Mat src1, Mat src2, Mat& dst, int flags = DECOMP_LU)
3635    //
3636
3637    /**
3638     * Solves one or more linear systems or least-squares problems.
3639     *
3640     * The function cv::solve solves a linear system or least-squares problem (the
3641     * latter is possible with SVD or QR methods, or by specifying the flag
3642     * #DECOMP_NORMAL ):
3643     * \(\texttt{dst} =  \arg \min _X \| \texttt{src1} \cdot \texttt{X} -  \texttt{src2} \|\)
3644     *
3645     * If #DECOMP_LU or #DECOMP_CHOLESKY method is used, the function returns 1
3646     * if src1 (or \(\texttt{src1}^T\texttt{src1}\) ) is non-singular. Otherwise,
3647     * it returns 0. In the latter case, dst is not valid. Other methods find a
3648     * pseudo-solution in case of a singular left-hand side part.
3649     *
3650     * <b>Note:</b> If you want to find a unity-norm solution of an under-defined
3651     * singular system \(\texttt{src1}\cdot\texttt{dst}=0\) , the function solve
3652     * will not do the work. Use SVD::solveZ instead.
3653     *
3654     * @param src1 input matrix on the left-hand side of the system.
3655     * @param src2 input matrix on the right-hand side of the system.
3656     * @param dst output solution.
3657     * @param flags solution (matrix inversion) method (#DecompTypes)
3658     * SEE: invert, SVD, eigen
3659     * @return automatically generated
3660     */
3661    public static boolean solve(Mat src1, Mat src2, Mat dst, int flags) {
3662        return solve_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, flags);
3663    }
3664
3665    /**
3666     * Solves one or more linear systems or least-squares problems.
3667     *
3668     * The function cv::solve solves a linear system or least-squares problem (the
3669     * latter is possible with SVD or QR methods, or by specifying the flag
3670     * #DECOMP_NORMAL ):
3671     * \(\texttt{dst} =  \arg \min _X \| \texttt{src1} \cdot \texttt{X} -  \texttt{src2} \|\)
3672     *
3673     * If #DECOMP_LU or #DECOMP_CHOLESKY method is used, the function returns 1
3674     * if src1 (or \(\texttt{src1}^T\texttt{src1}\) ) is non-singular. Otherwise,
3675     * it returns 0. In the latter case, dst is not valid. Other methods find a
3676     * pseudo-solution in case of a singular left-hand side part.
3677     *
3678     * <b>Note:</b> If you want to find a unity-norm solution of an under-defined
3679     * singular system \(\texttt{src1}\cdot\texttt{dst}=0\) , the function solve
3680     * will not do the work. Use SVD::solveZ instead.
3681     *
3682     * @param src1 input matrix on the left-hand side of the system.
3683     * @param src2 input matrix on the right-hand side of the system.
3684     * @param dst output solution.
3685     * SEE: invert, SVD, eigen
3686     * @return automatically generated
3687     */
3688    public static boolean solve(Mat src1, Mat src2, Mat dst) {
3689        return solve_1(src1.nativeObj, src2.nativeObj, dst.nativeObj);
3690    }
3691
3692
3693    //
3694    // C++:  void cv::sort(Mat src, Mat& dst, int flags)
3695    //
3696
3697    /**
3698     * Sorts each row or each column of a matrix.
3699     *
3700     * The function cv::sort sorts each matrix row or each matrix column in
3701     * ascending or descending order. So you should pass two operation flags to
3702     * get desired behaviour. If you want to sort matrix rows or columns
3703     * lexicographically, you can use STL std::sort generic function with the
3704     * proper comparison predicate.
3705     *
3706     * @param src input single-channel array.
3707     * @param dst output array of the same size and type as src.
3708     * @param flags operation flags, a combination of #SortFlags
3709     * SEE: sortIdx, randShuffle
3710     */
3711    public static void sort(Mat src, Mat dst, int flags) {
3712        sort_0(src.nativeObj, dst.nativeObj, flags);
3713    }
3714
3715
3716    //
3717    // C++:  void cv::sortIdx(Mat src, Mat& dst, int flags)
3718    //
3719
3720    /**
3721     * Sorts each row or each column of a matrix.
3722     *
3723     * The function cv::sortIdx sorts each matrix row or each matrix column in the
3724     * ascending or descending order. So you should pass two operation flags to
3725     * get desired behaviour. Instead of reordering the elements themselves, it
3726     * stores the indices of sorted elements in the output array. For example:
3727     * <code>
3728     *     Mat A = Mat::eye(3,3,CV_32F), B;
3729     *     sortIdx(A, B, SORT_EVERY_ROW + SORT_ASCENDING);
3730     *     // B will probably contain
3731     *     // (because of equal elements in A some permutations are possible):
3732     *     // [[1, 2, 0], [0, 2, 1], [0, 1, 2]]
3733     * </code>
3734     * @param src input single-channel array.
3735     * @param dst output integer array of the same size as src.
3736     * @param flags operation flags that could be a combination of cv::SortFlags
3737     * SEE: sort, randShuffle
3738     */
3739    public static void sortIdx(Mat src, Mat dst, int flags) {
3740        sortIdx_0(src.nativeObj, dst.nativeObj, flags);
3741    }
3742
3743
3744    //
3745    // C++:  int cv::solveCubic(Mat coeffs, Mat& roots)
3746    //
3747
3748    /**
3749     * Finds the real roots of a cubic equation.
3750     *
3751     * The function solveCubic finds the real roots of a cubic equation:
3752     * <ul>
3753     *   <li>
3754     *    if coeffs is a 4-element vector:
3755     * \(\texttt{coeffs} [0] x^3 +  \texttt{coeffs} [1] x^2 +  \texttt{coeffs} [2] x +  \texttt{coeffs} [3] = 0\)
3756     *   </li>
3757     *   <li>
3758     *    if coeffs is a 3-element vector:
3759     * \(x^3 +  \texttt{coeffs} [0] x^2 +  \texttt{coeffs} [1] x +  \texttt{coeffs} [2] = 0\)
3760     *   </li>
3761     * </ul>
3762     *
3763     * The roots are stored in the roots array.
3764     * @param coeffs equation coefficients, an array of 3 or 4 elements.
3765     * @param roots output array of real roots that has 1 or 3 elements.
3766     * @return number of real roots. It can be 0, 1 or 2.
3767     */
3768    public static int solveCubic(Mat coeffs, Mat roots) {
3769        return solveCubic_0(coeffs.nativeObj, roots.nativeObj);
3770    }
3771
3772
3773    //
3774    // C++:  double cv::solvePoly(Mat coeffs, Mat& roots, int maxIters = 300)
3775    //
3776
3777    /**
3778     * Finds the real or complex roots of a polynomial equation.
3779     *
3780     * The function cv::solvePoly finds real and complex roots of a polynomial equation:
3781     * \(\texttt{coeffs} [n] x^{n} +  \texttt{coeffs} [n-1] x^{n-1} + ... +  \texttt{coeffs} [1] x +  \texttt{coeffs} [0] = 0\)
3782     * @param coeffs array of polynomial coefficients.
3783     * @param roots output (complex) array of roots.
3784     * @param maxIters maximum number of iterations the algorithm does.
3785     * @return automatically generated
3786     */
3787    public static double solvePoly(Mat coeffs, Mat roots, int maxIters) {
3788        return solvePoly_0(coeffs.nativeObj, roots.nativeObj, maxIters);
3789    }
3790
3791    /**
3792     * Finds the real or complex roots of a polynomial equation.
3793     *
3794     * The function cv::solvePoly finds real and complex roots of a polynomial equation:
3795     * \(\texttt{coeffs} [n] x^{n} +  \texttt{coeffs} [n-1] x^{n-1} + ... +  \texttt{coeffs} [1] x +  \texttt{coeffs} [0] = 0\)
3796     * @param coeffs array of polynomial coefficients.
3797     * @param roots output (complex) array of roots.
3798     * @return automatically generated
3799     */
3800    public static double solvePoly(Mat coeffs, Mat roots) {
3801        return solvePoly_1(coeffs.nativeObj, roots.nativeObj);
3802    }
3803
3804
3805    //
3806    // C++:  bool cv::eigen(Mat src, Mat& eigenvalues, Mat& eigenvectors = Mat())
3807    //
3808
3809    /**
3810     * Calculates eigenvalues and eigenvectors of a symmetric matrix.
3811     *
3812     * The function cv::eigen calculates just eigenvalues, or eigenvalues and eigenvectors of the symmetric
3813     * matrix src:
3814     * <code>
3815     *     src*eigenvectors.row(i).t() = eigenvalues.at&lt;srcType&gt;(i)*eigenvectors.row(i).t()
3816     * </code>
3817     *
3818     * <b>Note:</b> Use cv::eigenNonSymmetric for calculation of real eigenvalues and eigenvectors of non-symmetric matrix.
3819     *
3820     * @param src input matrix that must have CV_32FC1 or CV_64FC1 type, square size and be symmetrical
3821     * (src ^T^ == src).
3822     * @param eigenvalues output vector of eigenvalues of the same type as src; the eigenvalues are stored
3823     * in the descending order.
3824     * @param eigenvectors output matrix of eigenvectors; it has the same size and type as src; the
3825     * eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding
3826     * eigenvalues.
3827     * SEE: eigenNonSymmetric, completeSymm , PCA
3828     * @return automatically generated
3829     */
3830    public static boolean eigen(Mat src, Mat eigenvalues, Mat eigenvectors) {
3831        return eigen_0(src.nativeObj, eigenvalues.nativeObj, eigenvectors.nativeObj);
3832    }
3833
3834    /**
3835     * Calculates eigenvalues and eigenvectors of a symmetric matrix.
3836     *
3837     * The function cv::eigen calculates just eigenvalues, or eigenvalues and eigenvectors of the symmetric
3838     * matrix src:
3839     * <code>
3840     *     src*eigenvectors.row(i).t() = eigenvalues.at&lt;srcType&gt;(i)*eigenvectors.row(i).t()
3841     * </code>
3842     *
3843     * <b>Note:</b> Use cv::eigenNonSymmetric for calculation of real eigenvalues and eigenvectors of non-symmetric matrix.
3844     *
3845     * @param src input matrix that must have CV_32FC1 or CV_64FC1 type, square size and be symmetrical
3846     * (src ^T^ == src).
3847     * @param eigenvalues output vector of eigenvalues of the same type as src; the eigenvalues are stored
3848     * in the descending order.
3849     * eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding
3850     * eigenvalues.
3851     * SEE: eigenNonSymmetric, completeSymm , PCA
3852     * @return automatically generated
3853     */
3854    public static boolean eigen(Mat src, Mat eigenvalues) {
3855        return eigen_1(src.nativeObj, eigenvalues.nativeObj);
3856    }
3857
3858
3859    //
3860    // C++:  void cv::eigenNonSymmetric(Mat src, Mat& eigenvalues, Mat& eigenvectors)
3861    //
3862
3863    /**
3864     * Calculates eigenvalues and eigenvectors of a non-symmetric matrix (real eigenvalues only).
3865     *
3866     * <b>Note:</b> Assumes real eigenvalues.
3867     *
3868     * The function calculates eigenvalues and eigenvectors (optional) of the square matrix src:
3869     * <code>
3870     *     src*eigenvectors.row(i).t() = eigenvalues.at&lt;srcType&gt;(i)*eigenvectors.row(i).t()
3871     * </code>
3872     *
3873     * @param src input matrix (CV_32FC1 or CV_64FC1 type).
3874     * @param eigenvalues output vector of eigenvalues (type is the same type as src).
3875     * @param eigenvectors output matrix of eigenvectors (type is the same type as src). The eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding eigenvalues.
3876     * SEE: eigen
3877     */
3878    public static void eigenNonSymmetric(Mat src, Mat eigenvalues, Mat eigenvectors) {
3879        eigenNonSymmetric_0(src.nativeObj, eigenvalues.nativeObj, eigenvectors.nativeObj);
3880    }
3881
3882
3883    //
3884    // C++:  void cv::calcCovarMatrix(Mat samples, Mat& covar, Mat& mean, int flags, int ctype = CV_64F)
3885    //
3886
3887    /**
3888     *
3889     * <b>Note:</b> use #COVAR_ROWS or #COVAR_COLS flag
3890     * @param samples samples stored as rows/columns of a single matrix.
3891     * @param covar output covariance matrix of the type ctype and square size.
3892     * @param mean input or output (depending on the flags) array as the average value of the input vectors.
3893     * @param flags operation flags as a combination of #CovarFlags
3894     * @param ctype type of the matrixl; it equals 'CV_64F' by default.
3895     */
3896    public static void calcCovarMatrix(Mat samples, Mat covar, Mat mean, int flags, int ctype) {
3897        calcCovarMatrix_0(samples.nativeObj, covar.nativeObj, mean.nativeObj, flags, ctype);
3898    }
3899
3900    /**
3901     *
3902     * <b>Note:</b> use #COVAR_ROWS or #COVAR_COLS flag
3903     * @param samples samples stored as rows/columns of a single matrix.
3904     * @param covar output covariance matrix of the type ctype and square size.
3905     * @param mean input or output (depending on the flags) array as the average value of the input vectors.
3906     * @param flags operation flags as a combination of #CovarFlags
3907     */
3908    public static void calcCovarMatrix(Mat samples, Mat covar, Mat mean, int flags) {
3909        calcCovarMatrix_1(samples.nativeObj, covar.nativeObj, mean.nativeObj, flags);
3910    }
3911
3912
3913    //
3914    // C++:  void cv::PCACompute(Mat data, Mat& mean, Mat& eigenvectors, int maxComponents = 0)
3915    //
3916
3917    /**
3918     * wrap PCA::operator()
3919     * @param data automatically generated
3920     * @param mean automatically generated
3921     * @param eigenvectors automatically generated
3922     * @param maxComponents automatically generated
3923     */
3924    public static void PCACompute(Mat data, Mat mean, Mat eigenvectors, int maxComponents) {
3925        PCACompute_0(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj, maxComponents);
3926    }
3927
3928    /**
3929     * wrap PCA::operator()
3930     * @param data automatically generated
3931     * @param mean automatically generated
3932     * @param eigenvectors automatically generated
3933     */
3934    public static void PCACompute(Mat data, Mat mean, Mat eigenvectors) {
3935        PCACompute_1(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj);
3936    }
3937
3938
3939    //
3940    // C++:  void cv::PCACompute(Mat data, Mat& mean, Mat& eigenvectors, Mat& eigenvalues, int maxComponents = 0)
3941    //
3942
3943    /**
3944     * wrap PCA::operator() and add eigenvalues output parameter
3945     * @param data automatically generated
3946     * @param mean automatically generated
3947     * @param eigenvectors automatically generated
3948     * @param eigenvalues automatically generated
3949     * @param maxComponents automatically generated
3950     */
3951    public static void PCACompute2(Mat data, Mat mean, Mat eigenvectors, Mat eigenvalues, int maxComponents) {
3952        PCACompute2_0(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj, eigenvalues.nativeObj, maxComponents);
3953    }
3954
3955    /**
3956     * wrap PCA::operator() and add eigenvalues output parameter
3957     * @param data automatically generated
3958     * @param mean automatically generated
3959     * @param eigenvectors automatically generated
3960     * @param eigenvalues automatically generated
3961     */
3962    public static void PCACompute2(Mat data, Mat mean, Mat eigenvectors, Mat eigenvalues) {
3963        PCACompute2_1(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj, eigenvalues.nativeObj);
3964    }
3965
3966
3967    //
3968    // C++:  void cv::PCACompute(Mat data, Mat& mean, Mat& eigenvectors, double retainedVariance)
3969    //
3970
3971    /**
3972     * wrap PCA::operator()
3973     * @param data automatically generated
3974     * @param mean automatically generated
3975     * @param eigenvectors automatically generated
3976     * @param retainedVariance automatically generated
3977     */
3978    public static void PCACompute(Mat data, Mat mean, Mat eigenvectors, double retainedVariance) {
3979        PCACompute_2(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj, retainedVariance);
3980    }
3981
3982
3983    //
3984    // C++:  void cv::PCACompute(Mat data, Mat& mean, Mat& eigenvectors, Mat& eigenvalues, double retainedVariance)
3985    //
3986
3987    /**
3988     * wrap PCA::operator() and add eigenvalues output parameter
3989     * @param data automatically generated
3990     * @param mean automatically generated
3991     * @param eigenvectors automatically generated
3992     * @param eigenvalues automatically generated
3993     * @param retainedVariance automatically generated
3994     */
3995    public static void PCACompute2(Mat data, Mat mean, Mat eigenvectors, Mat eigenvalues, double retainedVariance) {
3996        PCACompute2_2(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj, eigenvalues.nativeObj, retainedVariance);
3997    }
3998
3999
4000    //
4001    // C++:  void cv::PCAProject(Mat data, Mat mean, Mat eigenvectors, Mat& result)
4002    //
4003
4004    /**
4005     * wrap PCA::project
4006     * @param data automatically generated
4007     * @param mean automatically generated
4008     * @param eigenvectors automatically generated
4009     * @param result automatically generated
4010     */
4011    public static void PCAProject(Mat data, Mat mean, Mat eigenvectors, Mat result) {
4012        PCAProject_0(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj, result.nativeObj);
4013    }
4014
4015
4016    //
4017    // C++:  void cv::PCABackProject(Mat data, Mat mean, Mat eigenvectors, Mat& result)
4018    //
4019
4020    /**
4021     * wrap PCA::backProject
4022     * @param data automatically generated
4023     * @param mean automatically generated
4024     * @param eigenvectors automatically generated
4025     * @param result automatically generated
4026     */
4027    public static void PCABackProject(Mat data, Mat mean, Mat eigenvectors, Mat result) {
4028        PCABackProject_0(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj, result.nativeObj);
4029    }
4030
4031
4032    //
4033    // C++:  void cv::SVDecomp(Mat src, Mat& w, Mat& u, Mat& vt, int flags = 0)
4034    //
4035
4036    /**
4037     * wrap SVD::compute
4038     * @param src automatically generated
4039     * @param w automatically generated
4040     * @param u automatically generated
4041     * @param vt automatically generated
4042     * @param flags automatically generated
4043     */
4044    public static void SVDecomp(Mat src, Mat w, Mat u, Mat vt, int flags) {
4045        SVDecomp_0(src.nativeObj, w.nativeObj, u.nativeObj, vt.nativeObj, flags);
4046    }
4047
4048    /**
4049     * wrap SVD::compute
4050     * @param src automatically generated
4051     * @param w automatically generated
4052     * @param u automatically generated
4053     * @param vt automatically generated
4054     */
4055    public static void SVDecomp(Mat src, Mat w, Mat u, Mat vt) {
4056        SVDecomp_1(src.nativeObj, w.nativeObj, u.nativeObj, vt.nativeObj);
4057    }
4058
4059
4060    //
4061    // C++:  void cv::SVBackSubst(Mat w, Mat u, Mat vt, Mat rhs, Mat& dst)
4062    //
4063
4064    /**
4065     * wrap SVD::backSubst
4066     * @param w automatically generated
4067     * @param u automatically generated
4068     * @param vt automatically generated
4069     * @param rhs automatically generated
4070     * @param dst automatically generated
4071     */
4072    public static void SVBackSubst(Mat w, Mat u, Mat vt, Mat rhs, Mat dst) {
4073        SVBackSubst_0(w.nativeObj, u.nativeObj, vt.nativeObj, rhs.nativeObj, dst.nativeObj);
4074    }
4075
4076
4077    //
4078    // C++:  double cv::Mahalanobis(Mat v1, Mat v2, Mat icovar)
4079    //
4080
4081    /**
4082     * Calculates the Mahalanobis distance between two vectors.
4083     *
4084     * The function cv::Mahalanobis calculates and returns the weighted distance between two vectors:
4085     * \(d( \texttt{vec1} , \texttt{vec2} )= \sqrt{\sum_{i,j}{\texttt{icovar(i,j)}\cdot(\texttt{vec1}(I)-\texttt{vec2}(I))\cdot(\texttt{vec1(j)}-\texttt{vec2(j)})} }\)
4086     * The covariance matrix may be calculated using the #calcCovarMatrix function and then inverted using
4087     * the invert function (preferably using the #DECOMP_SVD method, as the most accurate).
4088     * @param v1 first 1D input vector.
4089     * @param v2 second 1D input vector.
4090     * @param icovar inverse covariance matrix.
4091     * @return automatically generated
4092     */
4093    public static double Mahalanobis(Mat v1, Mat v2, Mat icovar) {
4094        return Mahalanobis_0(v1.nativeObj, v2.nativeObj, icovar.nativeObj);
4095    }
4096
4097
4098    //
4099    // C++:  void cv::dft(Mat src, Mat& dst, int flags = 0, int nonzeroRows = 0)
4100    //
4101
4102    /**
4103     * Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.
4104     *
4105     * The function cv::dft performs one of the following:
4106     * <ul>
4107     *   <li>
4108     *    Forward the Fourier transform of a 1D vector of N elements:
4109     *     \(Y = F^{(N)}  \cdot X,\)
4110     *     where \(F^{(N)}_{jk}=\exp(-2\pi i j k/N)\) and \(i=\sqrt{-1}\)
4111     *   </li>
4112     *   <li>
4113     *    Inverse the Fourier transform of a 1D vector of N elements:
4114     *     \(\begin{array}{l} X'=  \left (F^{(N)} \right )^{-1}  \cdot Y =  \left (F^{(N)} \right )^*  \cdot y  \\ X = (1/N)  \cdot X, \end{array}\)
4115     *     where \(F^*=\left(\textrm{Re}(F^{(N)})-\textrm{Im}(F^{(N)})\right)^T\)
4116     *   </li>
4117     *   <li>
4118     *    Forward the 2D Fourier transform of a M x N matrix:
4119     *     \(Y = F^{(M)}  \cdot X  \cdot F^{(N)}\)
4120     *   </li>
4121     *   <li>
4122     *    Inverse the 2D Fourier transform of a M x N matrix:
4123     *     \(\begin{array}{l} X'=  \left (F^{(M)} \right )^*  \cdot Y  \cdot \left (F^{(N)} \right )^* \\ X =  \frac{1}{M \cdot N} \cdot X' \end{array}\)
4124     *   </li>
4125     * </ul>
4126     *
4127     * In case of real (single-channel) data, the output spectrum of the forward Fourier transform or input
4128     * spectrum of the inverse Fourier transform can be represented in a packed format called *CCS*
4129     * (complex-conjugate-symmetrical). It was borrowed from IPL (Intel\* Image Processing Library). Here
4130     * is how 2D *CCS* spectrum looks:
4131     * \(\begin{bmatrix} Re Y_{0,0} &amp; Re Y_{0,1} &amp; Im Y_{0,1} &amp; Re Y_{0,2} &amp; Im Y_{0,2} &amp;  \cdots &amp; Re Y_{0,N/2-1} &amp; Im Y_{0,N/2-1} &amp; Re Y_{0,N/2}  \\ Re Y_{1,0} &amp; Re Y_{1,1} &amp; Im Y_{1,1} &amp; Re Y_{1,2} &amp; Im Y_{1,2} &amp;  \cdots &amp; Re Y_{1,N/2-1} &amp; Im Y_{1,N/2-1} &amp; Re Y_{1,N/2}  \\ Im Y_{1,0} &amp; Re Y_{2,1} &amp; Im Y_{2,1} &amp; Re Y_{2,2} &amp; Im Y_{2,2} &amp;  \cdots &amp; Re Y_{2,N/2-1} &amp; Im Y_{2,N/2-1} &amp; Im Y_{1,N/2}  \\ \hdotsfor{9} \\ Re Y_{M/2-1,0} &amp;  Re Y_{M-3,1}  &amp; Im Y_{M-3,1} &amp;  \hdotsfor{3} &amp; Re Y_{M-3,N/2-1} &amp; Im Y_{M-3,N/2-1}&amp; Re Y_{M/2-1,N/2}  \\ Im Y_{M/2-1,0} &amp;  Re Y_{M-2,1}  &amp; Im Y_{M-2,1} &amp;  \hdotsfor{3} &amp; Re Y_{M-2,N/2-1} &amp; Im Y_{M-2,N/2-1}&amp; Im Y_{M/2-1,N/2}  \\ Re Y_{M/2,0}  &amp;  Re Y_{M-1,1} &amp;  Im Y_{M-1,1} &amp;  \hdotsfor{3} &amp; Re Y_{M-1,N/2-1} &amp; Im Y_{M-1,N/2-1}&amp; Re Y_{M/2,N/2} \end{bmatrix}\)
4132     *
4133     * In case of 1D transform of a real vector, the output looks like the first row of the matrix above.
4134     *
4135     * So, the function chooses an operation mode depending on the flags and size of the input array:
4136     * <ul>
4137     *   <li>
4138     *    If #DFT_ROWS is set or the input array has a single row or single column, the function
4139     *     performs a 1D forward or inverse transform of each row of a matrix when #DFT_ROWS is set.
4140     *     Otherwise, it performs a 2D transform.
4141     *   </li>
4142     *   <li>
4143     *    If the input array is real and #DFT_INVERSE is not set, the function performs a forward 1D or
4144     *     2D transform:
4145     *   <ul>
4146     *     <li>
4147     *        When #DFT_COMPLEX_OUTPUT is set, the output is a complex matrix of the same size as
4148     *         input.
4149     *     </li>
4150     *     <li>
4151     *        When #DFT_COMPLEX_OUTPUT is not set, the output is a real matrix of the same size as
4152     *         input. In case of 2D transform, it uses the packed format as shown above. In case of a
4153     *         single 1D transform, it looks like the first row of the matrix above. In case of
4154     *         multiple 1D transforms (when using the #DFT_ROWS flag), each row of the output matrix
4155     *         looks like the first row of the matrix above.
4156     *     </li>
4157     *   </ul>
4158     *   <li>
4159     *    If the input array is complex and either #DFT_INVERSE or #DFT_REAL_OUTPUT are not set, the
4160     *     output is a complex array of the same size as input. The function performs a forward or
4161     *     inverse 1D or 2D transform of the whole input array or each row of the input array
4162     *     independently, depending on the flags DFT_INVERSE and DFT_ROWS.
4163     *   </li>
4164     *   <li>
4165     *    When #DFT_INVERSE is set and the input array is real, or it is complex but #DFT_REAL_OUTPUT
4166     *     is set, the output is a real array of the same size as input. The function performs a 1D or 2D
4167     *     inverse transformation of the whole input array or each individual row, depending on the flags
4168     *     #DFT_INVERSE and #DFT_ROWS.
4169     *   </li>
4170     * </ul>
4171     *
4172     * If #DFT_SCALE is set, the scaling is done after the transformation.
4173     *
4174     * Unlike dct , the function supports arrays of arbitrary size. But only those arrays are processed
4175     * efficiently, whose sizes can be factorized in a product of small prime numbers (2, 3, and 5 in the
4176     * current implementation). Such an efficient DFT size can be calculated using the getOptimalDFTSize
4177     * method.
4178     *
4179     * The sample below illustrates how to calculate a DFT-based convolution of two 2D real arrays:
4180     * <code>
4181     *     void convolveDFT(InputArray A, InputArray B, OutputArray C)
4182     *     {
4183     *         // reallocate the output array if needed
4184     *         C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type());
4185     *         Size dftSize;
4186     *         // calculate the size of DFT transform
4187     *         dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1);
4188     *         dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1);
4189     *
4190     *         // allocate temporary buffers and initialize them with 0's
4191     *         Mat tempA(dftSize, A.type(), Scalar::all(0));
4192     *         Mat tempB(dftSize, B.type(), Scalar::all(0));
4193     *
4194     *         // copy A and B to the top-left corners of tempA and tempB, respectively
4195     *         Mat roiA(tempA, Rect(0,0,A.cols,A.rows));
4196     *         A.copyTo(roiA);
4197     *         Mat roiB(tempB, Rect(0,0,B.cols,B.rows));
4198     *         B.copyTo(roiB);
4199     *
4200     *         // now transform the padded A &amp; B in-place;
4201     *         // use "nonzeroRows" hint for faster processing
4202     *         dft(tempA, tempA, 0, A.rows);
4203     *         dft(tempB, tempB, 0, B.rows);
4204     *
4205     *         // multiply the spectrums;
4206     *         // the function handles packed spectrum representations well
4207     *         mulSpectrums(tempA, tempB, tempA);
4208     *
4209     *         // transform the product back from the frequency domain.
4210     *         // Even though all the result rows will be non-zero,
4211     *         // you need only the first C.rows of them, and thus you
4212     *         // pass nonzeroRows == C.rows
4213     *         dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows);
4214     *
4215     *         // now copy the result back to C.
4216     *         tempA(Rect(0, 0, C.cols, C.rows)).copyTo(C);
4217     *
4218     *         // all the temporary buffers will be deallocated automatically
4219     *     }
4220     * </code>
4221     * To optimize this sample, consider the following approaches:
4222     * <ul>
4223     *   <li>
4224     *    Since nonzeroRows != 0 is passed to the forward transform calls and since A and B are copied to
4225     *     the top-left corners of tempA and tempB, respectively, it is not necessary to clear the whole
4226     *     tempA and tempB. It is only necessary to clear the tempA.cols - A.cols ( tempB.cols - B.cols)
4227     *     rightmost columns of the matrices.
4228     *   </li>
4229     *   <li>
4230     *    This DFT-based convolution does not have to be applied to the whole big arrays, especially if B
4231     *     is significantly smaller than A or vice versa. Instead, you can calculate convolution by parts.
4232     *     To do this, you need to split the output array C into multiple tiles. For each tile, estimate
4233     *     which parts of A and B are required to calculate convolution in this tile. If the tiles in C are
4234     *     too small, the speed will decrease a lot because of repeated work. In the ultimate case, when
4235     *     each tile in C is a single pixel, the algorithm becomes equivalent to the naive convolution
4236     *     algorithm. If the tiles are too big, the temporary arrays tempA and tempB become too big and
4237     *     there is also a slowdown because of bad cache locality. So, there is an optimal tile size
4238     *     somewhere in the middle.
4239     *   </li>
4240     *   <li>
4241     *    If different tiles in C can be calculated in parallel and, thus, the convolution is done by
4242     *     parts, the loop can be threaded.
4243     *   </li>
4244     * </ul>
4245     *
4246     * All of the above improvements have been implemented in #matchTemplate and #filter2D . Therefore, by
4247     * using them, you can get the performance even better than with the above theoretically optimal
4248     * implementation. Though, those two functions actually calculate cross-correlation, not convolution,
4249     * so you need to "flip" the second convolution operand B vertically and horizontally using flip .
4250     * <b>Note:</b>
4251     * <ul>
4252     *   <li>
4253     *    An example using the discrete fourier transform can be found at
4254     *     opencv_source_code/samples/cpp/dft.cpp
4255     *   </li>
4256     *   <li>
4257     *    (Python) An example using the dft functionality to perform Wiener deconvolution can be found
4258     *     at opencv_source/samples/python/deconvolution.py
4259     *   </li>
4260     *   <li>
4261     *    (Python) An example rearranging the quadrants of a Fourier image can be found at
4262     *     opencv_source/samples/python/dft.py
4263     * @param src input array that could be real or complex.
4264     * @param dst output array whose size and type depends on the flags .
4265     * @param flags transformation flags, representing a combination of the #DftFlags
4266     * @param nonzeroRows when the parameter is not zero, the function assumes that only the first
4267     * nonzeroRows rows of the input array (#DFT_INVERSE is not set) or only the first nonzeroRows of the
4268     * output array (#DFT_INVERSE is set) contain non-zeros, thus, the function can handle the rest of the
4269     * rows more efficiently and save some time; this technique is very useful for calculating array
4270     * cross-correlation or convolution using DFT.
4271     * SEE: dct , getOptimalDFTSize , mulSpectrums, filter2D , matchTemplate , flip , cartToPolar ,
4272     * magnitude , phase
4273     *   </li>
4274     * </ul>
4275     */
4276    public static void dft(Mat src, Mat dst, int flags, int nonzeroRows) {
4277        dft_0(src.nativeObj, dst.nativeObj, flags, nonzeroRows);
4278    }
4279
4280    /**
4281     * Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.
4282     *
4283     * The function cv::dft performs one of the following:
4284     * <ul>
4285     *   <li>
4286     *    Forward the Fourier transform of a 1D vector of N elements:
4287     *     \(Y = F^{(N)}  \cdot X,\)
4288     *     where \(F^{(N)}_{jk}=\exp(-2\pi i j k/N)\) and \(i=\sqrt{-1}\)
4289     *   </li>
4290     *   <li>
4291     *    Inverse the Fourier transform of a 1D vector of N elements:
4292     *     \(\begin{array}{l} X'=  \left (F^{(N)} \right )^{-1}  \cdot Y =  \left (F^{(N)} \right )^*  \cdot y  \\ X = (1/N)  \cdot X, \end{array}\)
4293     *     where \(F^*=\left(\textrm{Re}(F^{(N)})-\textrm{Im}(F^{(N)})\right)^T\)
4294     *   </li>
4295     *   <li>
4296     *    Forward the 2D Fourier transform of a M x N matrix:
4297     *     \(Y = F^{(M)}  \cdot X  \cdot F^{(N)}\)
4298     *   </li>
4299     *   <li>
4300     *    Inverse the 2D Fourier transform of a M x N matrix:
4301     *     \(\begin{array}{l} X'=  \left (F^{(M)} \right )^*  \cdot Y  \cdot \left (F^{(N)} \right )^* \\ X =  \frac{1}{M \cdot N} \cdot X' \end{array}\)
4302     *   </li>
4303     * </ul>
4304     *
4305     * In case of real (single-channel) data, the output spectrum of the forward Fourier transform or input
4306     * spectrum of the inverse Fourier transform can be represented in a packed format called *CCS*
4307     * (complex-conjugate-symmetrical). It was borrowed from IPL (Intel\* Image Processing Library). Here
4308     * is how 2D *CCS* spectrum looks:
4309     * \(\begin{bmatrix} Re Y_{0,0} &amp; Re Y_{0,1} &amp; Im Y_{0,1} &amp; Re Y_{0,2} &amp; Im Y_{0,2} &amp;  \cdots &amp; Re Y_{0,N/2-1} &amp; Im Y_{0,N/2-1} &amp; Re Y_{0,N/2}  \\ Re Y_{1,0} &amp; Re Y_{1,1} &amp; Im Y_{1,1} &amp; Re Y_{1,2} &amp; Im Y_{1,2} &amp;  \cdots &amp; Re Y_{1,N/2-1} &amp; Im Y_{1,N/2-1} &amp; Re Y_{1,N/2}  \\ Im Y_{1,0} &amp; Re Y_{2,1} &amp; Im Y_{2,1} &amp; Re Y_{2,2} &amp; Im Y_{2,2} &amp;  \cdots &amp; Re Y_{2,N/2-1} &amp; Im Y_{2,N/2-1} &amp; Im Y_{1,N/2}  \\ \hdotsfor{9} \\ Re Y_{M/2-1,0} &amp;  Re Y_{M-3,1}  &amp; Im Y_{M-3,1} &amp;  \hdotsfor{3} &amp; Re Y_{M-3,N/2-1} &amp; Im Y_{M-3,N/2-1}&amp; Re Y_{M/2-1,N/2}  \\ Im Y_{M/2-1,0} &amp;  Re Y_{M-2,1}  &amp; Im Y_{M-2,1} &amp;  \hdotsfor{3} &amp; Re Y_{M-2,N/2-1} &amp; Im Y_{M-2,N/2-1}&amp; Im Y_{M/2-1,N/2}  \\ Re Y_{M/2,0}  &amp;  Re Y_{M-1,1} &amp;  Im Y_{M-1,1} &amp;  \hdotsfor{3} &amp; Re Y_{M-1,N/2-1} &amp; Im Y_{M-1,N/2-1}&amp; Re Y_{M/2,N/2} \end{bmatrix}\)
4310     *
4311     * In case of 1D transform of a real vector, the output looks like the first row of the matrix above.
4312     *
4313     * So, the function chooses an operation mode depending on the flags and size of the input array:
4314     * <ul>
4315     *   <li>
4316     *    If #DFT_ROWS is set or the input array has a single row or single column, the function
4317     *     performs a 1D forward or inverse transform of each row of a matrix when #DFT_ROWS is set.
4318     *     Otherwise, it performs a 2D transform.
4319     *   </li>
4320     *   <li>
4321     *    If the input array is real and #DFT_INVERSE is not set, the function performs a forward 1D or
4322     *     2D transform:
4323     *   <ul>
4324     *     <li>
4325     *        When #DFT_COMPLEX_OUTPUT is set, the output is a complex matrix of the same size as
4326     *         input.
4327     *     </li>
4328     *     <li>
4329     *        When #DFT_COMPLEX_OUTPUT is not set, the output is a real matrix of the same size as
4330     *         input. In case of 2D transform, it uses the packed format as shown above. In case of a
4331     *         single 1D transform, it looks like the first row of the matrix above. In case of
4332     *         multiple 1D transforms (when using the #DFT_ROWS flag), each row of the output matrix
4333     *         looks like the first row of the matrix above.
4334     *     </li>
4335     *   </ul>
4336     *   <li>
4337     *    If the input array is complex and either #DFT_INVERSE or #DFT_REAL_OUTPUT are not set, the
4338     *     output is a complex array of the same size as input. The function performs a forward or
4339     *     inverse 1D or 2D transform of the whole input array or each row of the input array
4340     *     independently, depending on the flags DFT_INVERSE and DFT_ROWS.
4341     *   </li>
4342     *   <li>
4343     *    When #DFT_INVERSE is set and the input array is real, or it is complex but #DFT_REAL_OUTPUT
4344     *     is set, the output is a real array of the same size as input. The function performs a 1D or 2D
4345     *     inverse transformation of the whole input array or each individual row, depending on the flags
4346     *     #DFT_INVERSE and #DFT_ROWS.
4347     *   </li>
4348     * </ul>
4349     *
4350     * If #DFT_SCALE is set, the scaling is done after the transformation.
4351     *
4352     * Unlike dct , the function supports arrays of arbitrary size. But only those arrays are processed
4353     * efficiently, whose sizes can be factorized in a product of small prime numbers (2, 3, and 5 in the
4354     * current implementation). Such an efficient DFT size can be calculated using the getOptimalDFTSize
4355     * method.
4356     *
4357     * The sample below illustrates how to calculate a DFT-based convolution of two 2D real arrays:
4358     * <code>
4359     *     void convolveDFT(InputArray A, InputArray B, OutputArray C)
4360     *     {
4361     *         // reallocate the output array if needed
4362     *         C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type());
4363     *         Size dftSize;
4364     *         // calculate the size of DFT transform
4365     *         dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1);
4366     *         dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1);
4367     *
4368     *         // allocate temporary buffers and initialize them with 0's
4369     *         Mat tempA(dftSize, A.type(), Scalar::all(0));
4370     *         Mat tempB(dftSize, B.type(), Scalar::all(0));
4371     *
4372     *         // copy A and B to the top-left corners of tempA and tempB, respectively
4373     *         Mat roiA(tempA, Rect(0,0,A.cols,A.rows));
4374     *         A.copyTo(roiA);
4375     *         Mat roiB(tempB, Rect(0,0,B.cols,B.rows));
4376     *         B.copyTo(roiB);
4377     *
4378     *         // now transform the padded A &amp; B in-place;
4379     *         // use "nonzeroRows" hint for faster processing
4380     *         dft(tempA, tempA, 0, A.rows);
4381     *         dft(tempB, tempB, 0, B.rows);
4382     *
4383     *         // multiply the spectrums;
4384     *         // the function handles packed spectrum representations well
4385     *         mulSpectrums(tempA, tempB, tempA);
4386     *
4387     *         // transform the product back from the frequency domain.
4388     *         // Even though all the result rows will be non-zero,
4389     *         // you need only the first C.rows of them, and thus you
4390     *         // pass nonzeroRows == C.rows
4391     *         dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows);
4392     *
4393     *         // now copy the result back to C.
4394     *         tempA(Rect(0, 0, C.cols, C.rows)).copyTo(C);
4395     *
4396     *         // all the temporary buffers will be deallocated automatically
4397     *     }
4398     * </code>
4399     * To optimize this sample, consider the following approaches:
4400     * <ul>
4401     *   <li>
4402     *    Since nonzeroRows != 0 is passed to the forward transform calls and since A and B are copied to
4403     *     the top-left corners of tempA and tempB, respectively, it is not necessary to clear the whole
4404     *     tempA and tempB. It is only necessary to clear the tempA.cols - A.cols ( tempB.cols - B.cols)
4405     *     rightmost columns of the matrices.
4406     *   </li>
4407     *   <li>
4408     *    This DFT-based convolution does not have to be applied to the whole big arrays, especially if B
4409     *     is significantly smaller than A or vice versa. Instead, you can calculate convolution by parts.
4410     *     To do this, you need to split the output array C into multiple tiles. For each tile, estimate
4411     *     which parts of A and B are required to calculate convolution in this tile. If the tiles in C are
4412     *     too small, the speed will decrease a lot because of repeated work. In the ultimate case, when
4413     *     each tile in C is a single pixel, the algorithm becomes equivalent to the naive convolution
4414     *     algorithm. If the tiles are too big, the temporary arrays tempA and tempB become too big and
4415     *     there is also a slowdown because of bad cache locality. So, there is an optimal tile size
4416     *     somewhere in the middle.
4417     *   </li>
4418     *   <li>
4419     *    If different tiles in C can be calculated in parallel and, thus, the convolution is done by
4420     *     parts, the loop can be threaded.
4421     *   </li>
4422     * </ul>
4423     *
4424     * All of the above improvements have been implemented in #matchTemplate and #filter2D . Therefore, by
4425     * using them, you can get the performance even better than with the above theoretically optimal
4426     * implementation. Though, those two functions actually calculate cross-correlation, not convolution,
4427     * so you need to "flip" the second convolution operand B vertically and horizontally using flip .
4428     * <b>Note:</b>
4429     * <ul>
4430     *   <li>
4431     *    An example using the discrete fourier transform can be found at
4432     *     opencv_source_code/samples/cpp/dft.cpp
4433     *   </li>
4434     *   <li>
4435     *    (Python) An example using the dft functionality to perform Wiener deconvolution can be found
4436     *     at opencv_source/samples/python/deconvolution.py
4437     *   </li>
4438     *   <li>
4439     *    (Python) An example rearranging the quadrants of a Fourier image can be found at
4440     *     opencv_source/samples/python/dft.py
4441     * @param src input array that could be real or complex.
4442     * @param dst output array whose size and type depends on the flags .
4443     * @param flags transformation flags, representing a combination of the #DftFlags
4444     * nonzeroRows rows of the input array (#DFT_INVERSE is not set) or only the first nonzeroRows of the
4445     * output array (#DFT_INVERSE is set) contain non-zeros, thus, the function can handle the rest of the
4446     * rows more efficiently and save some time; this technique is very useful for calculating array
4447     * cross-correlation or convolution using DFT.
4448     * SEE: dct , getOptimalDFTSize , mulSpectrums, filter2D , matchTemplate , flip , cartToPolar ,
4449     * magnitude , phase
4450     *   </li>
4451     * </ul>
4452     */
4453    public static void dft(Mat src, Mat dst, int flags) {
4454        dft_1(src.nativeObj, dst.nativeObj, flags);
4455    }
4456
4457    /**
4458     * Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.
4459     *
4460     * The function cv::dft performs one of the following:
4461     * <ul>
4462     *   <li>
4463     *    Forward the Fourier transform of a 1D vector of N elements:
4464     *     \(Y = F^{(N)}  \cdot X,\)
4465     *     where \(F^{(N)}_{jk}=\exp(-2\pi i j k/N)\) and \(i=\sqrt{-1}\)
4466     *   </li>
4467     *   <li>
4468     *    Inverse the Fourier transform of a 1D vector of N elements:
4469     *     \(\begin{array}{l} X'=  \left (F^{(N)} \right )^{-1}  \cdot Y =  \left (F^{(N)} \right )^*  \cdot y  \\ X = (1/N)  \cdot X, \end{array}\)
4470     *     where \(F^*=\left(\textrm{Re}(F^{(N)})-\textrm{Im}(F^{(N)})\right)^T\)
4471     *   </li>
4472     *   <li>
4473     *    Forward the 2D Fourier transform of a M x N matrix:
4474     *     \(Y = F^{(M)}  \cdot X  \cdot F^{(N)}\)
4475     *   </li>
4476     *   <li>
4477     *    Inverse the 2D Fourier transform of a M x N matrix:
4478     *     \(\begin{array}{l} X'=  \left (F^{(M)} \right )^*  \cdot Y  \cdot \left (F^{(N)} \right )^* \\ X =  \frac{1}{M \cdot N} \cdot X' \end{array}\)
4479     *   </li>
4480     * </ul>
4481     *
4482     * In case of real (single-channel) data, the output spectrum of the forward Fourier transform or input
4483     * spectrum of the inverse Fourier transform can be represented in a packed format called *CCS*
4484     * (complex-conjugate-symmetrical). It was borrowed from IPL (Intel\* Image Processing Library). Here
4485     * is how 2D *CCS* spectrum looks:
4486     * \(\begin{bmatrix} Re Y_{0,0} &amp; Re Y_{0,1} &amp; Im Y_{0,1} &amp; Re Y_{0,2} &amp; Im Y_{0,2} &amp;  \cdots &amp; Re Y_{0,N/2-1} &amp; Im Y_{0,N/2-1} &amp; Re Y_{0,N/2}  \\ Re Y_{1,0} &amp; Re Y_{1,1} &amp; Im Y_{1,1} &amp; Re Y_{1,2} &amp; Im Y_{1,2} &amp;  \cdots &amp; Re Y_{1,N/2-1} &amp; Im Y_{1,N/2-1} &amp; Re Y_{1,N/2}  \\ Im Y_{1,0} &amp; Re Y_{2,1} &amp; Im Y_{2,1} &amp; Re Y_{2,2} &amp; Im Y_{2,2} &amp;  \cdots &amp; Re Y_{2,N/2-1} &amp; Im Y_{2,N/2-1} &amp; Im Y_{1,N/2}  \\ \hdotsfor{9} \\ Re Y_{M/2-1,0} &amp;  Re Y_{M-3,1}  &amp; Im Y_{M-3,1} &amp;  \hdotsfor{3} &amp; Re Y_{M-3,N/2-1} &amp; Im Y_{M-3,N/2-1}&amp; Re Y_{M/2-1,N/2}  \\ Im Y_{M/2-1,0} &amp;  Re Y_{M-2,1}  &amp; Im Y_{M-2,1} &amp;  \hdotsfor{3} &amp; Re Y_{M-2,N/2-1} &amp; Im Y_{M-2,N/2-1}&amp; Im Y_{M/2-1,N/2}  \\ Re Y_{M/2,0}  &amp;  Re Y_{M-1,1} &amp;  Im Y_{M-1,1} &amp;  \hdotsfor{3} &amp; Re Y_{M-1,N/2-1} &amp; Im Y_{M-1,N/2-1}&amp; Re Y_{M/2,N/2} \end{bmatrix}\)
4487     *
4488     * In case of 1D transform of a real vector, the output looks like the first row of the matrix above.
4489     *
4490     * So, the function chooses an operation mode depending on the flags and size of the input array:
4491     * <ul>
4492     *   <li>
4493     *    If #DFT_ROWS is set or the input array has a single row or single column, the function
4494     *     performs a 1D forward or inverse transform of each row of a matrix when #DFT_ROWS is set.
4495     *     Otherwise, it performs a 2D transform.
4496     *   </li>
4497     *   <li>
4498     *    If the input array is real and #DFT_INVERSE is not set, the function performs a forward 1D or
4499     *     2D transform:
4500     *   <ul>
4501     *     <li>
4502     *        When #DFT_COMPLEX_OUTPUT is set, the output is a complex matrix of the same size as
4503     *         input.
4504     *     </li>
4505     *     <li>
4506     *        When #DFT_COMPLEX_OUTPUT is not set, the output is a real matrix of the same size as
4507     *         input. In case of 2D transform, it uses the packed format as shown above. In case of a
4508     *         single 1D transform, it looks like the first row of the matrix above. In case of
4509     *         multiple 1D transforms (when using the #DFT_ROWS flag), each row of the output matrix
4510     *         looks like the first row of the matrix above.
4511     *     </li>
4512     *   </ul>
4513     *   <li>
4514     *    If the input array is complex and either #DFT_INVERSE or #DFT_REAL_OUTPUT are not set, the
4515     *     output is a complex array of the same size as input. The function performs a forward or
4516     *     inverse 1D or 2D transform of the whole input array or each row of the input array
4517     *     independently, depending on the flags DFT_INVERSE and DFT_ROWS.
4518     *   </li>
4519     *   <li>
4520     *    When #DFT_INVERSE is set and the input array is real, or it is complex but #DFT_REAL_OUTPUT
4521     *     is set, the output is a real array of the same size as input. The function performs a 1D or 2D
4522     *     inverse transformation of the whole input array or each individual row, depending on the flags
4523     *     #DFT_INVERSE and #DFT_ROWS.
4524     *   </li>
4525     * </ul>
4526     *
4527     * If #DFT_SCALE is set, the scaling is done after the transformation.
4528     *
4529     * Unlike dct , the function supports arrays of arbitrary size. But only those arrays are processed
4530     * efficiently, whose sizes can be factorized in a product of small prime numbers (2, 3, and 5 in the
4531     * current implementation). Such an efficient DFT size can be calculated using the getOptimalDFTSize
4532     * method.
4533     *
4534     * The sample below illustrates how to calculate a DFT-based convolution of two 2D real arrays:
4535     * <code>
4536     *     void convolveDFT(InputArray A, InputArray B, OutputArray C)
4537     *     {
4538     *         // reallocate the output array if needed
4539     *         C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type());
4540     *         Size dftSize;
4541     *         // calculate the size of DFT transform
4542     *         dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1);
4543     *         dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1);
4544     *
4545     *         // allocate temporary buffers and initialize them with 0's
4546     *         Mat tempA(dftSize, A.type(), Scalar::all(0));
4547     *         Mat tempB(dftSize, B.type(), Scalar::all(0));
4548     *
4549     *         // copy A and B to the top-left corners of tempA and tempB, respectively
4550     *         Mat roiA(tempA, Rect(0,0,A.cols,A.rows));
4551     *         A.copyTo(roiA);
4552     *         Mat roiB(tempB, Rect(0,0,B.cols,B.rows));
4553     *         B.copyTo(roiB);
4554     *
4555     *         // now transform the padded A &amp; B in-place;
4556     *         // use "nonzeroRows" hint for faster processing
4557     *         dft(tempA, tempA, 0, A.rows);
4558     *         dft(tempB, tempB, 0, B.rows);
4559     *
4560     *         // multiply the spectrums;
4561     *         // the function handles packed spectrum representations well
4562     *         mulSpectrums(tempA, tempB, tempA);
4563     *
4564     *         // transform the product back from the frequency domain.
4565     *         // Even though all the result rows will be non-zero,
4566     *         // you need only the first C.rows of them, and thus you
4567     *         // pass nonzeroRows == C.rows
4568     *         dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows);
4569     *
4570     *         // now copy the result back to C.
4571     *         tempA(Rect(0, 0, C.cols, C.rows)).copyTo(C);
4572     *
4573     *         // all the temporary buffers will be deallocated automatically
4574     *     }
4575     * </code>
4576     * To optimize this sample, consider the following approaches:
4577     * <ul>
4578     *   <li>
4579     *    Since nonzeroRows != 0 is passed to the forward transform calls and since A and B are copied to
4580     *     the top-left corners of tempA and tempB, respectively, it is not necessary to clear the whole
4581     *     tempA and tempB. It is only necessary to clear the tempA.cols - A.cols ( tempB.cols - B.cols)
4582     *     rightmost columns of the matrices.
4583     *   </li>
4584     *   <li>
4585     *    This DFT-based convolution does not have to be applied to the whole big arrays, especially if B
4586     *     is significantly smaller than A or vice versa. Instead, you can calculate convolution by parts.
4587     *     To do this, you need to split the output array C into multiple tiles. For each tile, estimate
4588     *     which parts of A and B are required to calculate convolution in this tile. If the tiles in C are
4589     *     too small, the speed will decrease a lot because of repeated work. In the ultimate case, when
4590     *     each tile in C is a single pixel, the algorithm becomes equivalent to the naive convolution
4591     *     algorithm. If the tiles are too big, the temporary arrays tempA and tempB become too big and
4592     *     there is also a slowdown because of bad cache locality. So, there is an optimal tile size
4593     *     somewhere in the middle.
4594     *   </li>
4595     *   <li>
4596     *    If different tiles in C can be calculated in parallel and, thus, the convolution is done by
4597     *     parts, the loop can be threaded.
4598     *   </li>
4599     * </ul>
4600     *
4601     * All of the above improvements have been implemented in #matchTemplate and #filter2D . Therefore, by
4602     * using them, you can get the performance even better than with the above theoretically optimal
4603     * implementation. Though, those two functions actually calculate cross-correlation, not convolution,
4604     * so you need to "flip" the second convolution operand B vertically and horizontally using flip .
4605     * <b>Note:</b>
4606     * <ul>
4607     *   <li>
4608     *    An example using the discrete fourier transform can be found at
4609     *     opencv_source_code/samples/cpp/dft.cpp
4610     *   </li>
4611     *   <li>
4612     *    (Python) An example using the dft functionality to perform Wiener deconvolution can be found
4613     *     at opencv_source/samples/python/deconvolution.py
4614     *   </li>
4615     *   <li>
4616     *    (Python) An example rearranging the quadrants of a Fourier image can be found at
4617     *     opencv_source/samples/python/dft.py
4618     * @param src input array that could be real or complex.
4619     * @param dst output array whose size and type depends on the flags .
4620     * nonzeroRows rows of the input array (#DFT_INVERSE is not set) or only the first nonzeroRows of the
4621     * output array (#DFT_INVERSE is set) contain non-zeros, thus, the function can handle the rest of the
4622     * rows more efficiently and save some time; this technique is very useful for calculating array
4623     * cross-correlation or convolution using DFT.
4624     * SEE: dct , getOptimalDFTSize , mulSpectrums, filter2D , matchTemplate , flip , cartToPolar ,
4625     * magnitude , phase
4626     *   </li>
4627     * </ul>
4628     */
4629    public static void dft(Mat src, Mat dst) {
4630        dft_2(src.nativeObj, dst.nativeObj);
4631    }
4632
4633
4634    //
4635    // C++:  void cv::idft(Mat src, Mat& dst, int flags = 0, int nonzeroRows = 0)
4636    //
4637
4638    /**
4639     * Calculates the inverse Discrete Fourier Transform of a 1D or 2D array.
4640     *
4641     * idft(src, dst, flags) is equivalent to dft(src, dst, flags | #DFT_INVERSE) .
4642     * <b>Note:</b> None of dft and idft scales the result by default. So, you should pass #DFT_SCALE to one of
4643     * dft or idft explicitly to make these transforms mutually inverse.
4644     * SEE: dft, dct, idct, mulSpectrums, getOptimalDFTSize
4645     * @param src input floating-point real or complex array.
4646     * @param dst output array whose size and type depend on the flags.
4647     * @param flags operation flags (see dft and #DftFlags).
4648     * @param nonzeroRows number of dst rows to process; the rest of the rows have undefined content (see
4649     * the convolution sample in dft description.
4650     */
4651    public static void idft(Mat src, Mat dst, int flags, int nonzeroRows) {
4652        idft_0(src.nativeObj, dst.nativeObj, flags, nonzeroRows);
4653    }
4654
4655    /**
4656     * Calculates the inverse Discrete Fourier Transform of a 1D or 2D array.
4657     *
4658     * idft(src, dst, flags) is equivalent to dft(src, dst, flags | #DFT_INVERSE) .
4659     * <b>Note:</b> None of dft and idft scales the result by default. So, you should pass #DFT_SCALE to one of
4660     * dft or idft explicitly to make these transforms mutually inverse.
4661     * SEE: dft, dct, idct, mulSpectrums, getOptimalDFTSize
4662     * @param src input floating-point real or complex array.
4663     * @param dst output array whose size and type depend on the flags.
4664     * @param flags operation flags (see dft and #DftFlags).
4665     * the convolution sample in dft description.
4666     */
4667    public static void idft(Mat src, Mat dst, int flags) {
4668        idft_1(src.nativeObj, dst.nativeObj, flags);
4669    }
4670
4671    /**
4672     * Calculates the inverse Discrete Fourier Transform of a 1D or 2D array.
4673     *
4674     * idft(src, dst, flags) is equivalent to dft(src, dst, flags | #DFT_INVERSE) .
4675     * <b>Note:</b> None of dft and idft scales the result by default. So, you should pass #DFT_SCALE to one of
4676     * dft or idft explicitly to make these transforms mutually inverse.
4677     * SEE: dft, dct, idct, mulSpectrums, getOptimalDFTSize
4678     * @param src input floating-point real or complex array.
4679     * @param dst output array whose size and type depend on the flags.
4680     * the convolution sample in dft description.
4681     */
4682    public static void idft(Mat src, Mat dst) {
4683        idft_2(src.nativeObj, dst.nativeObj);
4684    }
4685
4686
4687    //
4688    // C++:  void cv::dct(Mat src, Mat& dst, int flags = 0)
4689    //
4690
4691    /**
4692     * Performs a forward or inverse discrete Cosine transform of 1D or 2D array.
4693     *
4694     * The function cv::dct performs a forward or inverse discrete Cosine transform (DCT) of a 1D or 2D
4695     * floating-point array:
4696     * <ul>
4697     *   <li>
4698     *    Forward Cosine transform of a 1D vector of N elements:
4699     *     \(Y = C^{(N)}  \cdot X\)
4700     *     where
4701     *     \(C^{(N)}_{jk}= \sqrt{\alpha_j/N} \cos \left ( \frac{\pi(2k+1)j}{2N} \right )\)
4702     *     and
4703     *     \(\alpha_0=1\), \(\alpha_j=2\) for *j &gt; 0*.
4704     *   </li>
4705     *   <li>
4706     *    Inverse Cosine transform of a 1D vector of N elements:
4707     *     \(X =  \left (C^{(N)} \right )^{-1}  \cdot Y =  \left (C^{(N)} \right )^T  \cdot Y\)
4708     *     (since \(C^{(N)}\) is an orthogonal matrix, \(C^{(N)} \cdot \left(C^{(N)}\right)^T = I\) )
4709     *   </li>
4710     *   <li>
4711     *    Forward 2D Cosine transform of M x N matrix:
4712     *     \(Y = C^{(N)}  \cdot X  \cdot \left (C^{(N)} \right )^T\)
4713     *   </li>
4714     *   <li>
4715     *    Inverse 2D Cosine transform of M x N matrix:
4716     *     \(X =  \left (C^{(N)} \right )^T  \cdot X  \cdot C^{(N)}\)
4717     *   </li>
4718     * </ul>
4719     *
4720     * The function chooses the mode of operation by looking at the flags and size of the input array:
4721     * <ul>
4722     *   <li>
4723     *    If (flags &amp; #DCT_INVERSE) == 0 , the function does a forward 1D or 2D transform. Otherwise, it
4724     *     is an inverse 1D or 2D transform.
4725     *   </li>
4726     *   <li>
4727     *    If (flags &amp; #DCT_ROWS) != 0 , the function performs a 1D transform of each row.
4728     *   </li>
4729     *   <li>
4730     *    If the array is a single column or a single row, the function performs a 1D transform.
4731     *   </li>
4732     *   <li>
4733     *    If none of the above is true, the function performs a 2D transform.
4734     *   </li>
4735     * </ul>
4736     *
4737     * <b>Note:</b> Currently dct supports even-size arrays (2, 4, 6 ...). For data analysis and approximation, you
4738     * can pad the array when necessary.
4739     * Also, the function performance depends very much, and not monotonically, on the array size (see
4740     * getOptimalDFTSize ). In the current implementation DCT of a vector of size N is calculated via DFT
4741     * of a vector of size N/2 . Thus, the optimal DCT size N1 &gt;= N can be calculated as:
4742     * <code>
4743     *     size_t getOptimalDCTSize(size_t N) { return 2*getOptimalDFTSize((N+1)/2); }
4744     *     N1 = getOptimalDCTSize(N);
4745     * </code>
4746     * @param src input floating-point array.
4747     * @param dst output array of the same size and type as src .
4748     * @param flags transformation flags as a combination of cv::DftFlags (DCT_*)
4749     * SEE: dft , getOptimalDFTSize , idct
4750     */
4751    public static void dct(Mat src, Mat dst, int flags) {
4752        dct_0(src.nativeObj, dst.nativeObj, flags);
4753    }
4754
4755    /**
4756     * Performs a forward or inverse discrete Cosine transform of 1D or 2D array.
4757     *
4758     * The function cv::dct performs a forward or inverse discrete Cosine transform (DCT) of a 1D or 2D
4759     * floating-point array:
4760     * <ul>
4761     *   <li>
4762     *    Forward Cosine transform of a 1D vector of N elements:
4763     *     \(Y = C^{(N)}  \cdot X\)
4764     *     where
4765     *     \(C^{(N)}_{jk}= \sqrt{\alpha_j/N} \cos \left ( \frac{\pi(2k+1)j}{2N} \right )\)
4766     *     and
4767     *     \(\alpha_0=1\), \(\alpha_j=2\) for *j &gt; 0*.
4768     *   </li>
4769     *   <li>
4770     *    Inverse Cosine transform of a 1D vector of N elements:
4771     *     \(X =  \left (C^{(N)} \right )^{-1}  \cdot Y =  \left (C^{(N)} \right )^T  \cdot Y\)
4772     *     (since \(C^{(N)}\) is an orthogonal matrix, \(C^{(N)} \cdot \left(C^{(N)}\right)^T = I\) )
4773     *   </li>
4774     *   <li>
4775     *    Forward 2D Cosine transform of M x N matrix:
4776     *     \(Y = C^{(N)}  \cdot X  \cdot \left (C^{(N)} \right )^T\)
4777     *   </li>
4778     *   <li>
4779     *    Inverse 2D Cosine transform of M x N matrix:
4780     *     \(X =  \left (C^{(N)} \right )^T  \cdot X  \cdot C^{(N)}\)
4781     *   </li>
4782     * </ul>
4783     *
4784     * The function chooses the mode of operation by looking at the flags and size of the input array:
4785     * <ul>
4786     *   <li>
4787     *    If (flags &amp; #DCT_INVERSE) == 0 , the function does a forward 1D or 2D transform. Otherwise, it
4788     *     is an inverse 1D or 2D transform.
4789     *   </li>
4790     *   <li>
4791     *    If (flags &amp; #DCT_ROWS) != 0 , the function performs a 1D transform of each row.
4792     *   </li>
4793     *   <li>
4794     *    If the array is a single column or a single row, the function performs a 1D transform.
4795     *   </li>
4796     *   <li>
4797     *    If none of the above is true, the function performs a 2D transform.
4798     *   </li>
4799     * </ul>
4800     *
4801     * <b>Note:</b> Currently dct supports even-size arrays (2, 4, 6 ...). For data analysis and approximation, you
4802     * can pad the array when necessary.
4803     * Also, the function performance depends very much, and not monotonically, on the array size (see
4804     * getOptimalDFTSize ). In the current implementation DCT of a vector of size N is calculated via DFT
4805     * of a vector of size N/2 . Thus, the optimal DCT size N1 &gt;= N can be calculated as:
4806     * <code>
4807     *     size_t getOptimalDCTSize(size_t N) { return 2*getOptimalDFTSize((N+1)/2); }
4808     *     N1 = getOptimalDCTSize(N);
4809     * </code>
4810     * @param src input floating-point array.
4811     * @param dst output array of the same size and type as src .
4812     * SEE: dft , getOptimalDFTSize , idct
4813     */
4814    public static void dct(Mat src, Mat dst) {
4815        dct_1(src.nativeObj, dst.nativeObj);
4816    }
4817
4818
4819    //
4820    // C++:  void cv::idct(Mat src, Mat& dst, int flags = 0)
4821    //
4822
4823    /**
4824     * Calculates the inverse Discrete Cosine Transform of a 1D or 2D array.
4825     *
4826     * idct(src, dst, flags) is equivalent to dct(src, dst, flags | DCT_INVERSE).
4827     * @param src input floating-point single-channel array.
4828     * @param dst output array of the same size and type as src.
4829     * @param flags operation flags.
4830     * SEE:  dct, dft, idft, getOptimalDFTSize
4831     */
4832    public static void idct(Mat src, Mat dst, int flags) {
4833        idct_0(src.nativeObj, dst.nativeObj, flags);
4834    }
4835
4836    /**
4837     * Calculates the inverse Discrete Cosine Transform of a 1D or 2D array.
4838     *
4839     * idct(src, dst, flags) is equivalent to dct(src, dst, flags | DCT_INVERSE).
4840     * @param src input floating-point single-channel array.
4841     * @param dst output array of the same size and type as src.
4842     * SEE:  dct, dft, idft, getOptimalDFTSize
4843     */
4844    public static void idct(Mat src, Mat dst) {
4845        idct_1(src.nativeObj, dst.nativeObj);
4846    }
4847
4848
4849    //
4850    // C++:  void cv::mulSpectrums(Mat a, Mat b, Mat& c, int flags, bool conjB = false)
4851    //
4852
4853    /**
4854     * Performs the per-element multiplication of two Fourier spectrums.
4855     *
4856     * The function cv::mulSpectrums performs the per-element multiplication of the two CCS-packed or complex
4857     * matrices that are results of a real or complex Fourier transform.
4858     *
4859     * The function, together with dft and idft , may be used to calculate convolution (pass conjB=false )
4860     * or correlation (pass conjB=true ) of two arrays rapidly. When the arrays are complex, they are
4861     * simply multiplied (per element) with an optional conjugation of the second-array elements. When the
4862     * arrays are real, they are assumed to be CCS-packed (see dft for details).
4863     * @param a first input array.
4864     * @param b second input array of the same size and type as src1 .
4865     * @param c output array of the same size and type as src1 .
4866     * @param flags operation flags; currently, the only supported flag is cv::DFT_ROWS, which indicates that
4867     * each row of src1 and src2 is an independent 1D Fourier spectrum. If you do not want to use this flag, then simply add a {@code 0} as value.
4868     * @param conjB optional flag that conjugates the second input array before the multiplication (true)
4869     * or not (false).
4870     */
4871    public static void mulSpectrums(Mat a, Mat b, Mat c, int flags, boolean conjB) {
4872        mulSpectrums_0(a.nativeObj, b.nativeObj, c.nativeObj, flags, conjB);
4873    }
4874
4875    /**
4876     * Performs the per-element multiplication of two Fourier spectrums.
4877     *
4878     * The function cv::mulSpectrums performs the per-element multiplication of the two CCS-packed or complex
4879     * matrices that are results of a real or complex Fourier transform.
4880     *
4881     * The function, together with dft and idft , may be used to calculate convolution (pass conjB=false )
4882     * or correlation (pass conjB=true ) of two arrays rapidly. When the arrays are complex, they are
4883     * simply multiplied (per element) with an optional conjugation of the second-array elements. When the
4884     * arrays are real, they are assumed to be CCS-packed (see dft for details).
4885     * @param a first input array.
4886     * @param b second input array of the same size and type as src1 .
4887     * @param c output array of the same size and type as src1 .
4888     * @param flags operation flags; currently, the only supported flag is cv::DFT_ROWS, which indicates that
4889     * each row of src1 and src2 is an independent 1D Fourier spectrum. If you do not want to use this flag, then simply add a {@code 0} as value.
4890     * or not (false).
4891     */
4892    public static void mulSpectrums(Mat a, Mat b, Mat c, int flags) {
4893        mulSpectrums_1(a.nativeObj, b.nativeObj, c.nativeObj, flags);
4894    }
4895
4896
4897    //
4898    // C++:  int cv::getOptimalDFTSize(int vecsize)
4899    //
4900
4901    /**
4902     * Returns the optimal DFT size for a given vector size.
4903     *
4904     * DFT performance is not a monotonic function of a vector size. Therefore, when you calculate
4905     * convolution of two arrays or perform the spectral analysis of an array, it usually makes sense to
4906     * pad the input data with zeros to get a bit larger array that can be transformed much faster than the
4907     * original one. Arrays whose size is a power-of-two (2, 4, 8, 16, 32, ...) are the fastest to process.
4908     * Though, the arrays whose size is a product of 2's, 3's, and 5's (for example, 300 = 5\*5\*3\*2\*2)
4909     * are also processed quite efficiently.
4910     *
4911     * The function cv::getOptimalDFTSize returns the minimum number N that is greater than or equal to vecsize
4912     * so that the DFT of a vector of size N can be processed efficiently. In the current implementation N
4913     * = 2 ^p^ \* 3 ^q^ \* 5 ^r^ for some integer p, q, r.
4914     *
4915     * The function returns a negative number if vecsize is too large (very close to INT_MAX ).
4916     *
4917     * While the function cannot be used directly to estimate the optimal vector size for DCT transform
4918     * (since the current DCT implementation supports only even-size vectors), it can be easily processed
4919     * as getOptimalDFTSize((vecsize+1)/2)\*2.
4920     * @param vecsize vector size.
4921     * SEE: dft , dct , idft , idct , mulSpectrums
4922     * @return automatically generated
4923     */
4924    public static int getOptimalDFTSize(int vecsize) {
4925        return getOptimalDFTSize_0(vecsize);
4926    }
4927
4928
4929    //
4930    // C++:  void cv::setRNGSeed(int seed)
4931    //
4932
4933    /**
4934     * Sets state of default random number generator.
4935     *
4936     * The function cv::setRNGSeed sets state of default random number generator to custom value.
4937     * @param seed new state for default random number generator
4938     * SEE: RNG, randu, randn
4939     */
4940    public static void setRNGSeed(int seed) {
4941        setRNGSeed_0(seed);
4942    }
4943
4944
4945    //
4946    // C++:  void cv::randu(Mat& dst, double low, double high)
4947    //
4948
4949    /**
4950     * Generates a single uniformly-distributed random number or an array of random numbers.
4951     *
4952     * Non-template variant of the function fills the matrix dst with uniformly-distributed
4953     * random numbers from the specified range:
4954     * \(\texttt{low} _c  \leq \texttt{dst} (I)_c &lt;  \texttt{high} _c\)
4955     * @param dst output array of random numbers; the array must be pre-allocated.
4956     * @param low inclusive lower boundary of the generated random numbers.
4957     * @param high exclusive upper boundary of the generated random numbers.
4958     * SEE: RNG, randn, theRNG
4959     */
4960    public static void randu(Mat dst, double low, double high) {
4961        randu_0(dst.nativeObj, low, high);
4962    }
4963
4964
4965    //
4966    // C++:  void cv::randn(Mat& dst, double mean, double stddev)
4967    //
4968
4969    /**
4970     * Fills the array with normally distributed random numbers.
4971     *
4972     * The function cv::randn fills the matrix dst with normally distributed random numbers with the specified
4973     * mean vector and the standard deviation matrix. The generated random numbers are clipped to fit the
4974     * value range of the output array data type.
4975     * @param dst output array of random numbers; the array must be pre-allocated and have 1 to 4 channels.
4976     * @param mean mean value (expectation) of the generated random numbers.
4977     * @param stddev standard deviation of the generated random numbers; it can be either a vector (in
4978     * which case a diagonal standard deviation matrix is assumed) or a square matrix.
4979     * SEE: RNG, randu
4980     */
4981    public static void randn(Mat dst, double mean, double stddev) {
4982        randn_0(dst.nativeObj, mean, stddev);
4983    }
4984
4985
4986    //
4987    // C++:  void cv::randShuffle(Mat& dst, double iterFactor = 1., RNG* rng = 0)
4988    //
4989
4990    /**
4991     * Shuffles the array elements randomly.
4992     *
4993     * The function cv::randShuffle shuffles the specified 1D array by randomly choosing pairs of elements and
4994     * swapping them. The number of such swap operations will be dst.rows\*dst.cols\*iterFactor .
4995     * @param dst input/output numerical 1D array.
4996     * @param iterFactor scale factor that determines the number of random swap operations (see the details
4997     * below).
4998     * instead.
4999     * SEE: RNG, sort
5000     */
5001    public static void randShuffle(Mat dst, double iterFactor) {
5002        randShuffle_0(dst.nativeObj, iterFactor);
5003    }
5004
5005    /**
5006     * Shuffles the array elements randomly.
5007     *
5008     * The function cv::randShuffle shuffles the specified 1D array by randomly choosing pairs of elements and
5009     * swapping them. The number of such swap operations will be dst.rows\*dst.cols\*iterFactor .
5010     * @param dst input/output numerical 1D array.
5011     * below).
5012     * instead.
5013     * SEE: RNG, sort
5014     */
5015    public static void randShuffle(Mat dst) {
5016        randShuffle_2(dst.nativeObj);
5017    }
5018
5019
5020    //
5021    // C++:  double cv::kmeans(Mat data, int K, Mat& bestLabels, TermCriteria criteria, int attempts, int flags, Mat& centers = Mat())
5022    //
5023
5024    /**
5025     * Finds centers of clusters and groups input samples around the clusters.
5026     *
5027     * The function kmeans implements a k-means algorithm that finds the centers of cluster_count clusters
5028     * and groups the input samples around the clusters. As an output, \(\texttt{bestLabels}_i\) contains a
5029     * 0-based cluster index for the sample stored in the \(i^{th}\) row of the samples matrix.
5030     *
5031     * <b>Note:</b>
5032     * <ul>
5033     *   <li>
5034     *    (Python) An example on K-means clustering can be found at
5035     *     opencv_source_code/samples/python/kmeans.py
5036     * @param data Data for clustering. An array of N-Dimensional points with float coordinates is needed.
5037     * Examples of this array can be:
5038     *   </li>
5039     *   <li>
5040     *    Mat points(count, 2, CV_32F);
5041     *   </li>
5042     *   <li>
5043     *    Mat points(count, 1, CV_32FC2);
5044     *   </li>
5045     *   <li>
5046     *    Mat points(1, count, CV_32FC2);
5047     *   </li>
5048     *   <li>
5049     *    std::vector&lt;cv::Point2f&gt; points(sampleCount);
5050     * @param K Number of clusters to split the set by.
5051     * @param bestLabels Input/output integer array that stores the cluster indices for every sample.
5052     * @param criteria The algorithm termination criteria, that is, the maximum number of iterations and/or
5053     * the desired accuracy. The accuracy is specified as criteria.epsilon. As soon as each of the cluster
5054     * centers moves by less than criteria.epsilon on some iteration, the algorithm stops.
5055     * @param attempts Flag to specify the number of times the algorithm is executed using different
5056     * initial labellings. The algorithm returns the labels that yield the best compactness (see the last
5057     * function parameter).
5058     * @param flags Flag that can take values of cv::KmeansFlags
5059     * @param centers Output matrix of the cluster centers, one row per each cluster center.
5060     * @return The function returns the compactness measure that is computed as
5061     * \(\sum _i  \| \texttt{samples} _i -  \texttt{centers} _{ \texttt{labels} _i} \| ^2\)
5062     * after every attempt. The best (minimum) value is chosen and the corresponding labels and the
5063     * compactness value are returned by the function. Basically, you can use only the core of the
5064     * function, set the number of attempts to 1, initialize labels each time using a custom algorithm,
5065     * pass them with the ( flags = #KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best
5066     * (most-compact) clustering.
5067     *   </li>
5068     * </ul>
5069     */
5070    public static double kmeans(Mat data, int K, Mat bestLabels, TermCriteria criteria, int attempts, int flags, Mat centers) {
5071        return kmeans_0(data.nativeObj, K, bestLabels.nativeObj, criteria.type, criteria.maxCount, criteria.epsilon, attempts, flags, centers.nativeObj);
5072    }
5073
5074    /**
5075     * Finds centers of clusters and groups input samples around the clusters.
5076     *
5077     * The function kmeans implements a k-means algorithm that finds the centers of cluster_count clusters
5078     * and groups the input samples around the clusters. As an output, \(\texttt{bestLabels}_i\) contains a
5079     * 0-based cluster index for the sample stored in the \(i^{th}\) row of the samples matrix.
5080     *
5081     * <b>Note:</b>
5082     * <ul>
5083     *   <li>
5084     *    (Python) An example on K-means clustering can be found at
5085     *     opencv_source_code/samples/python/kmeans.py
5086     * @param data Data for clustering. An array of N-Dimensional points with float coordinates is needed.
5087     * Examples of this array can be:
5088     *   </li>
5089     *   <li>
5090     *    Mat points(count, 2, CV_32F);
5091     *   </li>
5092     *   <li>
5093     *    Mat points(count, 1, CV_32FC2);
5094     *   </li>
5095     *   <li>
5096     *    Mat points(1, count, CV_32FC2);
5097     *   </li>
5098     *   <li>
5099     *    std::vector&lt;cv::Point2f&gt; points(sampleCount);
5100     * @param K Number of clusters to split the set by.
5101     * @param bestLabels Input/output integer array that stores the cluster indices for every sample.
5102     * @param criteria The algorithm termination criteria, that is, the maximum number of iterations and/or
5103     * the desired accuracy. The accuracy is specified as criteria.epsilon. As soon as each of the cluster
5104     * centers moves by less than criteria.epsilon on some iteration, the algorithm stops.
5105     * @param attempts Flag to specify the number of times the algorithm is executed using different
5106     * initial labellings. The algorithm returns the labels that yield the best compactness (see the last
5107     * function parameter).
5108     * @param flags Flag that can take values of cv::KmeansFlags
5109     * @return The function returns the compactness measure that is computed as
5110     * \(\sum _i  \| \texttt{samples} _i -  \texttt{centers} _{ \texttt{labels} _i} \| ^2\)
5111     * after every attempt. The best (minimum) value is chosen and the corresponding labels and the
5112     * compactness value are returned by the function. Basically, you can use only the core of the
5113     * function, set the number of attempts to 1, initialize labels each time using a custom algorithm,
5114     * pass them with the ( flags = #KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best
5115     * (most-compact) clustering.
5116     *   </li>
5117     * </ul>
5118     */
5119    public static double kmeans(Mat data, int K, Mat bestLabels, TermCriteria criteria, int attempts, int flags) {
5120        return kmeans_1(data.nativeObj, K, bestLabels.nativeObj, criteria.type, criteria.maxCount, criteria.epsilon, attempts, flags);
5121    }
5122
5123
5124    //
5125    // C++:  void cv::setNumThreads(int nthreads)
5126    //
5127
5128    /**
5129     * OpenCV will try to set the number of threads for the next parallel region.
5130     *
5131     * If threads == 0, OpenCV will disable threading optimizations and run all it's functions
5132     * sequentially. Passing threads &lt; 0 will reset threads number to system default. This function must
5133     * be called outside of parallel region.
5134     *
5135     * OpenCV will try to run its functions with specified threads number, but some behaviour differs from
5136     * framework:
5137     * <ul>
5138     *   <li>
5139     *    {@code TBB} - User-defined parallel constructions will run with the same threads number, if
5140     *     another is not specified. If later on user creates his own scheduler, OpenCV will use it.
5141     *   </li>
5142     *   <li>
5143     *    {@code OpenMP} - No special defined behaviour.
5144     *   </li>
5145     *   <li>
5146     *    {@code Concurrency} - If threads == 1, OpenCV will disable threading optimizations and run its
5147     *     functions sequentially.
5148     *   </li>
5149     *   <li>
5150     *    {@code GCD} - Supports only values &lt;= 0.
5151     *   </li>
5152     *   <li>
5153     *    {@code C=} - No special defined behaviour.
5154     * @param nthreads Number of threads used by OpenCV.
5155     * SEE: getNumThreads, getThreadNum
5156     *   </li>
5157     * </ul>
5158     */
5159    public static void setNumThreads(int nthreads) {
5160        setNumThreads_0(nthreads);
5161    }
5162
5163
5164    //
5165    // C++:  int cv::getNumThreads()
5166    //
5167
5168    /**
5169     * Returns the number of threads used by OpenCV for parallel regions.
5170     *
5171     * Always returns 1 if OpenCV is built without threading support.
5172     *
5173     * The exact meaning of return value depends on the threading framework used by OpenCV library:
5174     * <ul>
5175     *   <li>
5176     *  {@code TBB} - The number of threads, that OpenCV will try to use for parallel regions. If there is
5177     *   any tbb::thread_scheduler_init in user code conflicting with OpenCV, then function returns
5178     *   default number of threads used by TBB library.
5179     *   </li>
5180     *   <li>
5181     *  {@code OpenMP} - An upper bound on the number of threads that could be used to form a new team.
5182     *   </li>
5183     *   <li>
5184     *  {@code Concurrency} - The number of threads, that OpenCV will try to use for parallel regions.
5185     *   </li>
5186     *   <li>
5187     *  {@code GCD} - Unsupported; returns the GCD thread pool limit (512) for compatibility.
5188     *   </li>
5189     *   <li>
5190     *  {@code C=} - The number of threads, that OpenCV will try to use for parallel regions, if before
5191     *   called setNumThreads with threads &gt; 0, otherwise returns the number of logical CPUs,
5192     *   available for the process.
5193     * SEE: setNumThreads, getThreadNum
5194     *   </li>
5195     * </ul>
5196     * @return automatically generated
5197     */
5198    public static int getNumThreads() {
5199        return getNumThreads_0();
5200    }
5201
5202
5203    //
5204    // C++:  int cv::getThreadNum()
5205    //
5206
5207    /**
5208     * Returns the index of the currently executed thread within the current parallel region. Always
5209     * returns 0 if called outside of parallel region.
5210     *
5211     * @deprecated Current implementation doesn't corresponding to this documentation.
5212     *
5213     * The exact meaning of the return value depends on the threading framework used by OpenCV library:
5214     * <ul>
5215     *   <li>
5216     *  {@code TBB} - Unsupported with current 4.1 TBB release. Maybe will be supported in future.
5217     *   </li>
5218     *   <li>
5219     *  {@code OpenMP} - The thread number, within the current team, of the calling thread.
5220     *   </li>
5221     *   <li>
5222     *  {@code Concurrency} - An ID for the virtual processor that the current context is executing on (0
5223     *   for master thread and unique number for others, but not necessary 1,2,3,...).
5224     *   </li>
5225     *   <li>
5226     *  {@code GCD} - System calling thread's ID. Never returns 0 inside parallel region.
5227     *   </li>
5228     *   <li>
5229     *  {@code C=} - The index of the current parallel task.
5230     * SEE: setNumThreads, getNumThreads
5231     *   </li>
5232     * </ul>
5233     * @return automatically generated
5234     */
5235    @Deprecated
5236    public static int getThreadNum() {
5237        return getThreadNum_0();
5238    }
5239
5240
5241    //
5242    // C++:  String cv::getBuildInformation()
5243    //
5244
5245    /**
5246     * Returns full configuration time cmake output.
5247     *
5248     * Returned value is raw cmake output including version control system revision, compiler version,
5249     * compiler flags, enabled modules and third party libraries, etc. Output format depends on target
5250     * architecture.
5251     * @return automatically generated
5252     */
5253    public static String getBuildInformation() {
5254        return getBuildInformation_0();
5255    }
5256
5257
5258    //
5259    // C++:  String cv::getVersionString()
5260    //
5261
5262    /**
5263     * Returns library version string
5264     *
5265     * For example "3.4.1-dev".
5266     *
5267     * SEE: getMajorVersion, getMinorVersion, getRevisionVersion
5268     * @return automatically generated
5269     */
5270    public static String getVersionString() {
5271        return getVersionString_0();
5272    }
5273
5274
5275    //
5276    // C++:  int cv::getVersionMajor()
5277    //
5278
5279    /**
5280     * Returns major library version
5281     * @return automatically generated
5282     */
5283    public static int getVersionMajor() {
5284        return getVersionMajor_0();
5285    }
5286
5287
5288    //
5289    // C++:  int cv::getVersionMinor()
5290    //
5291
5292    /**
5293     * Returns minor library version
5294     * @return automatically generated
5295     */
5296    public static int getVersionMinor() {
5297        return getVersionMinor_0();
5298    }
5299
5300
5301    //
5302    // C++:  int cv::getVersionRevision()
5303    //
5304
5305    /**
5306     * Returns revision field of the library version
5307     * @return automatically generated
5308     */
5309    public static int getVersionRevision() {
5310        return getVersionRevision_0();
5311    }
5312
5313
5314    //
5315    // C++:  int64 cv::getTickCount()
5316    //
5317
5318    /**
5319     * Returns the number of ticks.
5320     *
5321     * The function returns the number of ticks after the certain event (for example, when the machine was
5322     * turned on). It can be used to initialize RNG or to measure a function execution time by reading the
5323     * tick count before and after the function call.
5324     * SEE: getTickFrequency, TickMeter
5325     * @return automatically generated
5326     */
5327    public static long getTickCount() {
5328        return getTickCount_0();
5329    }
5330
5331
5332    //
5333    // C++:  double cv::getTickFrequency()
5334    //
5335
5336    /**
5337     * Returns the number of ticks per second.
5338     *
5339     * The function returns the number of ticks per second. That is, the following code computes the
5340     * execution time in seconds:
5341     * <code>
5342     *     double t = (double)getTickCount();
5343     *     // do something ...
5344     *     t = ((double)getTickCount() - t)/getTickFrequency();
5345     * </code>
5346     * SEE: getTickCount, TickMeter
5347     * @return automatically generated
5348     */
5349    public static double getTickFrequency() {
5350        return getTickFrequency_0();
5351    }
5352
5353
5354    //
5355    // C++:  int64 cv::getCPUTickCount()
5356    //
5357
5358    /**
5359     * Returns the number of CPU ticks.
5360     *
5361     * The function returns the current number of CPU ticks on some architectures (such as x86, x64,
5362     * PowerPC). On other platforms the function is equivalent to getTickCount. It can also be used for
5363     * very accurate time measurements, as well as for RNG initialization. Note that in case of multi-CPU
5364     * systems a thread, from which getCPUTickCount is called, can be suspended and resumed at another CPU
5365     * with its own counter. So, theoretically (and practically) the subsequent calls to the function do
5366     * not necessary return the monotonously increasing values. Also, since a modern CPU varies the CPU
5367     * frequency depending on the load, the number of CPU clocks spent in some code cannot be directly
5368     * converted to time units. Therefore, getTickCount is generally a preferable solution for measuring
5369     * execution time.
5370     * @return automatically generated
5371     */
5372    public static long getCPUTickCount() {
5373        return getCPUTickCount_0();
5374    }
5375
5376
5377    //
5378    // C++:  String cv::getHardwareFeatureName(int feature)
5379    //
5380
5381    /**
5382     * Returns feature name by ID
5383     *
5384     * Returns empty string if feature is not defined
5385     * @param feature automatically generated
5386     * @return automatically generated
5387     */
5388    public static String getHardwareFeatureName(int feature) {
5389        return getHardwareFeatureName_0(feature);
5390    }
5391
5392
5393    //
5394    // C++:  string cv::getCPUFeaturesLine()
5395    //
5396
5397    /**
5398     * Returns list of CPU features enabled during compilation.
5399     *
5400     * Returned value is a string containing space separated list of CPU features with following markers:
5401     *
5402     * <ul>
5403     *   <li>
5404     *  no markers - baseline features
5405     *   </li>
5406     *   <li>
5407     *  prefix {@code *} - features enabled in dispatcher
5408     *   </li>
5409     *   <li>
5410     *  suffix {@code ?} - features enabled but not available in HW
5411     *   </li>
5412     * </ul>
5413     *
5414     * Example: {@code SSE SSE2 SSE3 *SSE4.1 *SSE4.2 *FP16 *AVX *AVX2 *AVX512-SKX?}
5415     * @return automatically generated
5416     */
5417    public static String getCPUFeaturesLine() {
5418        return getCPUFeaturesLine_0();
5419    }
5420
5421
5422    //
5423    // C++:  int cv::getNumberOfCPUs()
5424    //
5425
5426    /**
5427     * Returns the number of logical CPUs available for the process.
5428     * @return automatically generated
5429     */
5430    public static int getNumberOfCPUs() {
5431        return getNumberOfCPUs_0();
5432    }
5433
5434
5435    //
5436    // C++:  String cv::samples::findFile(String relative_path, bool required = true, bool silentMode = false)
5437    //
5438
5439    /**
5440     * Try to find requested data file
5441     *
5442     * Search directories:
5443     *
5444     * 1. Directories passed via {@code addSamplesDataSearchPath()}
5445     * 2. OPENCV_SAMPLES_DATA_PATH_HINT environment variable
5446     * 3. OPENCV_SAMPLES_DATA_PATH environment variable
5447     *    If parameter value is not empty and nothing is found then stop searching.
5448     * 4. Detects build/install path based on:
5449     *    a. current working directory (CWD)
5450     *    b. and/or binary module location (opencv_core/opencv_world, doesn't work with static linkage)
5451     * 5. Scan {@code &lt;source&gt;/{,data,samples/data}} directories if build directory is detected or the current directory is in source tree.
5452     * 6. Scan {@code &lt;install&gt;/share/OpenCV} directory if install directory is detected.
5453     *
5454     * SEE: cv::utils::findDataFile
5455     *
5456     * @param relative_path Relative path to data file
5457     * @param required Specify "file not found" handling.
5458     *        If true, function prints information message and raises cv::Exception.
5459     *        If false, function returns empty result
5460     * @param silentMode Disables messages
5461     * @return Returns path (absolute or relative to the current directory) or empty string if file is not found
5462     */
5463    public static String findFile(String relative_path, boolean required, boolean silentMode) {
5464        return findFile_0(relative_path, required, silentMode);
5465    }
5466
5467    /**
5468     * Try to find requested data file
5469     *
5470     * Search directories:
5471     *
5472     * 1. Directories passed via {@code addSamplesDataSearchPath()}
5473     * 2. OPENCV_SAMPLES_DATA_PATH_HINT environment variable
5474     * 3. OPENCV_SAMPLES_DATA_PATH environment variable
5475     *    If parameter value is not empty and nothing is found then stop searching.
5476     * 4. Detects build/install path based on:
5477     *    a. current working directory (CWD)
5478     *    b. and/or binary module location (opencv_core/opencv_world, doesn't work with static linkage)
5479     * 5. Scan {@code &lt;source&gt;/{,data,samples/data}} directories if build directory is detected or the current directory is in source tree.
5480     * 6. Scan {@code &lt;install&gt;/share/OpenCV} directory if install directory is detected.
5481     *
5482     * SEE: cv::utils::findDataFile
5483     *
5484     * @param relative_path Relative path to data file
5485     * @param required Specify "file not found" handling.
5486     *        If true, function prints information message and raises cv::Exception.
5487     *        If false, function returns empty result
5488     * @return Returns path (absolute or relative to the current directory) or empty string if file is not found
5489     */
5490    public static String findFile(String relative_path, boolean required) {
5491        return findFile_1(relative_path, required);
5492    }
5493
5494    /**
5495     * Try to find requested data file
5496     *
5497     * Search directories:
5498     *
5499     * 1. Directories passed via {@code addSamplesDataSearchPath()}
5500     * 2. OPENCV_SAMPLES_DATA_PATH_HINT environment variable
5501     * 3. OPENCV_SAMPLES_DATA_PATH environment variable
5502     *    If parameter value is not empty and nothing is found then stop searching.
5503     * 4. Detects build/install path based on:
5504     *    a. current working directory (CWD)
5505     *    b. and/or binary module location (opencv_core/opencv_world, doesn't work with static linkage)
5506     * 5. Scan {@code &lt;source&gt;/{,data,samples/data}} directories if build directory is detected or the current directory is in source tree.
5507     * 6. Scan {@code &lt;install&gt;/share/OpenCV} directory if install directory is detected.
5508     *
5509     * SEE: cv::utils::findDataFile
5510     *
5511     * @param relative_path Relative path to data file
5512     *        If true, function prints information message and raises cv::Exception.
5513     *        If false, function returns empty result
5514     * @return Returns path (absolute or relative to the current directory) or empty string if file is not found
5515     */
5516    public static String findFile(String relative_path) {
5517        return findFile_2(relative_path);
5518    }
5519
5520
5521    //
5522    // C++:  String cv::samples::findFileOrKeep(String relative_path, bool silentMode = false)
5523    //
5524
5525    public static String findFileOrKeep(String relative_path, boolean silentMode) {
5526        return findFileOrKeep_0(relative_path, silentMode);
5527    }
5528
5529    public static String findFileOrKeep(String relative_path) {
5530        return findFileOrKeep_1(relative_path);
5531    }
5532
5533
5534    //
5535    // C++:  void cv::samples::addSamplesDataSearchPath(String path)
5536    //
5537
5538    /**
5539     * Override search data path by adding new search location
5540     *
5541     * Use this only to override default behavior
5542     * Passed paths are used in LIFO order.
5543     *
5544     * @param path Path to used samples data
5545     */
5546    public static void addSamplesDataSearchPath(String path) {
5547        addSamplesDataSearchPath_0(path);
5548    }
5549
5550
5551    //
5552    // C++:  void cv::samples::addSamplesDataSearchSubDirectory(String subdir)
5553    //
5554
5555    /**
5556     * Append samples search data sub directory
5557     *
5558     * General usage is to add OpenCV modules name ({@code &lt;opencv_contrib&gt;/modules/&lt;name&gt;/samples/data} -&gt; {@code &lt;name&gt;/samples/data} + {@code modules/&lt;name&gt;/samples/data}).
5559     * Passed subdirectories are used in LIFO order.
5560     *
5561     * @param subdir samples data sub directory
5562     */
5563    public static void addSamplesDataSearchSubDirectory(String subdir) {
5564        addSamplesDataSearchSubDirectory_0(subdir);
5565    }
5566
5567
5568    //
5569    // C++:  void cv::setErrorVerbosity(bool verbose)
5570    //
5571
5572    public static void setErrorVerbosity(boolean verbose) {
5573        setErrorVerbosity_0(verbose);
5574    }
5575
5576
5577    //
5578    // C++:  void cv::add(Mat src1, Scalar src2, Mat& dst, Mat mask = Mat(), int dtype = -1)
5579    //
5580
5581    public static void add(Mat src1, Scalar src2, Mat dst, Mat mask, int dtype) {
5582        add_3(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj, mask.nativeObj, dtype);
5583    }
5584
5585    public static void add(Mat src1, Scalar src2, Mat dst, Mat mask) {
5586        add_4(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj, mask.nativeObj);
5587    }
5588
5589    public static void add(Mat src1, Scalar src2, Mat dst) {
5590        add_5(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj);
5591    }
5592
5593
5594    //
5595    // C++:  void cv::subtract(Mat src1, Scalar src2, Mat& dst, Mat mask = Mat(), int dtype = -1)
5596    //
5597
5598    public static void subtract(Mat src1, Scalar src2, Mat dst, Mat mask, int dtype) {
5599        subtract_3(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj, mask.nativeObj, dtype);
5600    }
5601
5602    public static void subtract(Mat src1, Scalar src2, Mat dst, Mat mask) {
5603        subtract_4(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj, mask.nativeObj);
5604    }
5605
5606    public static void subtract(Mat src1, Scalar src2, Mat dst) {
5607        subtract_5(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj);
5608    }
5609
5610
5611    //
5612    // C++:  void cv::multiply(Mat src1, Scalar src2, Mat& dst, double scale = 1, int dtype = -1)
5613    //
5614
5615    public static void multiply(Mat src1, Scalar src2, Mat dst, double scale, int dtype) {
5616        multiply_3(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj, scale, dtype);
5617    }
5618
5619    public static void multiply(Mat src1, Scalar src2, Mat dst, double scale) {
5620        multiply_4(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj, scale);
5621    }
5622
5623    public static void multiply(Mat src1, Scalar src2, Mat dst) {
5624        multiply_5(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj);
5625    }
5626
5627
5628    //
5629    // C++:  void cv::divide(Mat src1, Scalar src2, Mat& dst, double scale = 1, int dtype = -1)
5630    //
5631
5632    public static void divide(Mat src1, Scalar src2, Mat dst, double scale, int dtype) {
5633        divide_5(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj, scale, dtype);
5634    }
5635
5636    public static void divide(Mat src1, Scalar src2, Mat dst, double scale) {
5637        divide_6(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj, scale);
5638    }
5639
5640    public static void divide(Mat src1, Scalar src2, Mat dst) {
5641        divide_7(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj);
5642    }
5643
5644
5645    //
5646    // C++:  void cv::absdiff(Mat src1, Scalar src2, Mat& dst)
5647    //
5648
5649    public static void absdiff(Mat src1, Scalar src2, Mat dst) {
5650        absdiff_1(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj);
5651    }
5652
5653
5654    //
5655    // C++:  void cv::compare(Mat src1, Scalar src2, Mat& dst, int cmpop)
5656    //
5657
5658    public static void compare(Mat src1, Scalar src2, Mat dst, int cmpop) {
5659        compare_1(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj, cmpop);
5660    }
5661
5662
5663    //
5664    // C++:  void cv::min(Mat src1, Scalar src2, Mat& dst)
5665    //
5666
5667    public static void min(Mat src1, Scalar src2, Mat dst) {
5668        min_1(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj);
5669    }
5670
5671
5672    //
5673    // C++:  void cv::max(Mat src1, Scalar src2, Mat& dst)
5674    //
5675
5676    public static void max(Mat src1, Scalar src2, Mat dst) {
5677        max_1(src1.nativeObj, src2.val[0], src2.val[1], src2.val[2], src2.val[3], dst.nativeObj);
5678    }
5679
5680// manual port
5681public static class MinMaxLocResult {
5682    public double minVal;
5683    public double maxVal;
5684    public Point minLoc;
5685    public Point maxLoc;
5686
5687
5688    public MinMaxLocResult() {
5689        minVal=0; maxVal=0;
5690        minLoc=new Point();
5691        maxLoc=new Point();
5692    }
5693}
5694
5695
5696// C++: minMaxLoc(Mat src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, InputArray mask=noArray())
5697
5698
5699//javadoc: minMaxLoc(src, mask)
5700public static MinMaxLocResult minMaxLoc(Mat src, Mat mask) {
5701    MinMaxLocResult res = new MinMaxLocResult();
5702    long maskNativeObj=0;
5703    if (mask != null) {
5704        maskNativeObj=mask.nativeObj;
5705    }
5706    double resarr[] = n_minMaxLocManual(src.nativeObj, maskNativeObj);
5707    res.minVal=resarr[0];
5708    res.maxVal=resarr[1];
5709    res.minLoc.x=resarr[2];
5710    res.minLoc.y=resarr[3];
5711    res.maxLoc.x=resarr[4];
5712    res.maxLoc.y=resarr[5];
5713    return res;
5714}
5715
5716
5717//javadoc: minMaxLoc(src)
5718public static MinMaxLocResult minMaxLoc(Mat src) {
5719    return minMaxLoc(src, null);
5720}
5721
5722
5723    // C++:  float cv::cubeRoot(float val)
5724    private static native float cubeRoot_0(float val);
5725
5726    // C++:  float cv::fastAtan2(float y, float x)
5727    private static native float fastAtan2_0(float y, float x);
5728
5729    // C++:  bool cv::ipp::useIPP()
5730    private static native boolean useIPP_0();
5731
5732    // C++:  void cv::ipp::setUseIPP(bool flag)
5733    private static native void setUseIPP_0(boolean flag);
5734
5735    // C++:  String cv::ipp::getIppVersion()
5736    private static native String getIppVersion_0();
5737
5738    // C++:  bool cv::ipp::useIPP_NotExact()
5739    private static native boolean useIPP_NotExact_0();
5740
5741    // C++:  void cv::ipp::setUseIPP_NotExact(bool flag)
5742    private static native void setUseIPP_NotExact_0(boolean flag);
5743
5744    // C++:  int cv::borderInterpolate(int p, int len, int borderType)
5745    private static native int borderInterpolate_0(int p, int len, int borderType);
5746
5747    // C++:  void cv::copyMakeBorder(Mat src, Mat& dst, int top, int bottom, int left, int right, int borderType, Scalar value = Scalar())
5748    private static native void copyMakeBorder_0(long src_nativeObj, long dst_nativeObj, int top, int bottom, int left, int right, int borderType, double value_val0, double value_val1, double value_val2, double value_val3);
5749    private static native void copyMakeBorder_1(long src_nativeObj, long dst_nativeObj, int top, int bottom, int left, int right, int borderType);
5750
5751    // C++:  void cv::add(Mat src1, Mat src2, Mat& dst, Mat mask = Mat(), int dtype = -1)
5752    private static native void add_0(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj, long mask_nativeObj, int dtype);
5753    private static native void add_1(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj, long mask_nativeObj);
5754    private static native void add_2(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj);
5755
5756    // C++:  void cv::subtract(Mat src1, Mat src2, Mat& dst, Mat mask = Mat(), int dtype = -1)
5757    private static native void subtract_0(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj, long mask_nativeObj, int dtype);
5758    private static native void subtract_1(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj, long mask_nativeObj);
5759    private static native void subtract_2(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj);
5760
5761    // C++:  void cv::multiply(Mat src1, Mat src2, Mat& dst, double scale = 1, int dtype = -1)
5762    private static native void multiply_0(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj, double scale, int dtype);
5763    private static native void multiply_1(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj, double scale);
5764    private static native void multiply_2(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj);
5765
5766    // C++:  void cv::divide(Mat src1, Mat src2, Mat& dst, double scale = 1, int dtype = -1)
5767    private static native void divide_0(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj, double scale, int dtype);
5768    private static native void divide_1(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj, double scale);
5769    private static native void divide_2(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj);
5770
5771    // C++:  void cv::divide(double scale, Mat src2, Mat& dst, int dtype = -1)
5772    private static native void divide_3(double scale, long src2_nativeObj, long dst_nativeObj, int dtype);
5773    private static native void divide_4(double scale, long src2_nativeObj, long dst_nativeObj);
5774
5775    // C++:  void cv::scaleAdd(Mat src1, double alpha, Mat src2, Mat& dst)
5776    private static native void scaleAdd_0(long src1_nativeObj, double alpha, long src2_nativeObj, long dst_nativeObj);
5777
5778    // C++:  void cv::addWeighted(Mat src1, double alpha, Mat src2, double beta, double gamma, Mat& dst, int dtype = -1)
5779    private static native void addWeighted_0(long src1_nativeObj, double alpha, long src2_nativeObj, double beta, double gamma, long dst_nativeObj, int dtype);
5780    private static native void addWeighted_1(long src1_nativeObj, double alpha, long src2_nativeObj, double beta, double gamma, long dst_nativeObj);
5781
5782    // C++:  void cv::convertScaleAbs(Mat src, Mat& dst, double alpha = 1, double beta = 0)
5783    private static native void convertScaleAbs_0(long src_nativeObj, long dst_nativeObj, double alpha, double beta);
5784    private static native void convertScaleAbs_1(long src_nativeObj, long dst_nativeObj, double alpha);
5785    private static native void convertScaleAbs_2(long src_nativeObj, long dst_nativeObj);
5786
5787    // C++:  void cv::convertFp16(Mat src, Mat& dst)
5788    private static native void convertFp16_0(long src_nativeObj, long dst_nativeObj);
5789
5790    // C++:  void cv::LUT(Mat src, Mat lut, Mat& dst)
5791    private static native void LUT_0(long src_nativeObj, long lut_nativeObj, long dst_nativeObj);
5792
5793    // C++:  Scalar cv::sum(Mat src)
5794    private static native double[] sumElems_0(long src_nativeObj);
5795
5796    // C++:  int cv::countNonZero(Mat src)
5797    private static native int countNonZero_0(long src_nativeObj);
5798
5799    // C++:  void cv::findNonZero(Mat src, Mat& idx)
5800    private static native void findNonZero_0(long src_nativeObj, long idx_nativeObj);
5801
5802    // C++:  Scalar cv::mean(Mat src, Mat mask = Mat())
5803    private static native double[] mean_0(long src_nativeObj, long mask_nativeObj);
5804    private static native double[] mean_1(long src_nativeObj);
5805
5806    // C++:  void cv::meanStdDev(Mat src, vector_double& mean, vector_double& stddev, Mat mask = Mat())
5807    private static native void meanStdDev_0(long src_nativeObj, long mean_mat_nativeObj, long stddev_mat_nativeObj, long mask_nativeObj);
5808    private static native void meanStdDev_1(long src_nativeObj, long mean_mat_nativeObj, long stddev_mat_nativeObj);
5809
5810    // C++:  double cv::norm(Mat src1, int normType = NORM_L2, Mat mask = Mat())
5811    private static native double norm_0(long src1_nativeObj, int normType, long mask_nativeObj);
5812    private static native double norm_1(long src1_nativeObj, int normType);
5813    private static native double norm_2(long src1_nativeObj);
5814
5815    // C++:  double cv::norm(Mat src1, Mat src2, int normType = NORM_L2, Mat mask = Mat())
5816    private static native double norm_3(long src1_nativeObj, long src2_nativeObj, int normType, long mask_nativeObj);
5817    private static native double norm_4(long src1_nativeObj, long src2_nativeObj, int normType);
5818    private static native double norm_5(long src1_nativeObj, long src2_nativeObj);
5819
5820    // C++:  double cv::PSNR(Mat src1, Mat src2, double R = 255.)
5821    private static native double PSNR_0(long src1_nativeObj, long src2_nativeObj, double R);
5822    private static native double PSNR_1(long src1_nativeObj, long src2_nativeObj);
5823
5824    // C++:  void cv::batchDistance(Mat src1, Mat src2, Mat& dist, int dtype, Mat& nidx, int normType = NORM_L2, int K = 0, Mat mask = Mat(), int update = 0, bool crosscheck = false)
5825    private static native void batchDistance_0(long src1_nativeObj, long src2_nativeObj, long dist_nativeObj, int dtype, long nidx_nativeObj, int normType, int K, long mask_nativeObj, int update, boolean crosscheck);
5826    private static native void batchDistance_1(long src1_nativeObj, long src2_nativeObj, long dist_nativeObj, int dtype, long nidx_nativeObj, int normType, int K, long mask_nativeObj, int update);
5827    private static native void batchDistance_2(long src1_nativeObj, long src2_nativeObj, long dist_nativeObj, int dtype, long nidx_nativeObj, int normType, int K, long mask_nativeObj);
5828    private static native void batchDistance_3(long src1_nativeObj, long src2_nativeObj, long dist_nativeObj, int dtype, long nidx_nativeObj, int normType, int K);
5829    private static native void batchDistance_4(long src1_nativeObj, long src2_nativeObj, long dist_nativeObj, int dtype, long nidx_nativeObj, int normType);
5830    private static native void batchDistance_5(long src1_nativeObj, long src2_nativeObj, long dist_nativeObj, int dtype, long nidx_nativeObj);
5831
5832    // C++:  void cv::normalize(Mat src, Mat& dst, double alpha = 1, double beta = 0, int norm_type = NORM_L2, int dtype = -1, Mat mask = Mat())
5833    private static native void normalize_0(long src_nativeObj, long dst_nativeObj, double alpha, double beta, int norm_type, int dtype, long mask_nativeObj);
5834    private static native void normalize_1(long src_nativeObj, long dst_nativeObj, double alpha, double beta, int norm_type, int dtype);
5835    private static native void normalize_2(long src_nativeObj, long dst_nativeObj, double alpha, double beta, int norm_type);
5836    private static native void normalize_3(long src_nativeObj, long dst_nativeObj, double alpha, double beta);
5837    private static native void normalize_4(long src_nativeObj, long dst_nativeObj, double alpha);
5838    private static native void normalize_5(long src_nativeObj, long dst_nativeObj);
5839
5840    // C++:  void cv::reduce(Mat src, Mat& dst, int dim, int rtype, int dtype = -1)
5841    private static native void reduce_0(long src_nativeObj, long dst_nativeObj, int dim, int rtype, int dtype);
5842    private static native void reduce_1(long src_nativeObj, long dst_nativeObj, int dim, int rtype);
5843
5844    // C++:  void cv::merge(vector_Mat mv, Mat& dst)
5845    private static native void merge_0(long mv_mat_nativeObj, long dst_nativeObj);
5846
5847    // C++:  void cv::split(Mat m, vector_Mat& mv)
5848    private static native void split_0(long m_nativeObj, long mv_mat_nativeObj);
5849
5850    // C++:  void cv::mixChannels(vector_Mat src, vector_Mat dst, vector_int fromTo)
5851    private static native void mixChannels_0(long src_mat_nativeObj, long dst_mat_nativeObj, long fromTo_mat_nativeObj);
5852
5853    // C++:  void cv::extractChannel(Mat src, Mat& dst, int coi)
5854    private static native void extractChannel_0(long src_nativeObj, long dst_nativeObj, int coi);
5855
5856    // C++:  void cv::insertChannel(Mat src, Mat& dst, int coi)
5857    private static native void insertChannel_0(long src_nativeObj, long dst_nativeObj, int coi);
5858
5859    // C++:  void cv::flip(Mat src, Mat& dst, int flipCode)
5860    private static native void flip_0(long src_nativeObj, long dst_nativeObj, int flipCode);
5861
5862    // C++:  void cv::rotate(Mat src, Mat& dst, int rotateCode)
5863    private static native void rotate_0(long src_nativeObj, long dst_nativeObj, int rotateCode);
5864
5865    // C++:  void cv::repeat(Mat src, int ny, int nx, Mat& dst)
5866    private static native void repeat_0(long src_nativeObj, int ny, int nx, long dst_nativeObj);
5867
5868    // C++:  void cv::hconcat(vector_Mat src, Mat& dst)
5869    private static native void hconcat_0(long src_mat_nativeObj, long dst_nativeObj);
5870
5871    // C++:  void cv::vconcat(vector_Mat src, Mat& dst)
5872    private static native void vconcat_0(long src_mat_nativeObj, long dst_nativeObj);
5873
5874    // C++:  void cv::bitwise_and(Mat src1, Mat src2, Mat& dst, Mat mask = Mat())
5875    private static native void bitwise_and_0(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj, long mask_nativeObj);
5876    private static native void bitwise_and_1(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj);
5877
5878    // C++:  void cv::bitwise_or(Mat src1, Mat src2, Mat& dst, Mat mask = Mat())
5879    private static native void bitwise_or_0(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj, long mask_nativeObj);
5880    private static native void bitwise_or_1(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj);
5881
5882    // C++:  void cv::bitwise_xor(Mat src1, Mat src2, Mat& dst, Mat mask = Mat())
5883    private static native void bitwise_xor_0(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj, long mask_nativeObj);
5884    private static native void bitwise_xor_1(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj);
5885
5886    // C++:  void cv::bitwise_not(Mat src, Mat& dst, Mat mask = Mat())
5887    private static native void bitwise_not_0(long src_nativeObj, long dst_nativeObj, long mask_nativeObj);
5888    private static native void bitwise_not_1(long src_nativeObj, long dst_nativeObj);
5889
5890    // C++:  void cv::absdiff(Mat src1, Mat src2, Mat& dst)
5891    private static native void absdiff_0(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj);
5892
5893    // C++:  void cv::copyTo(Mat src, Mat& dst, Mat mask)
5894    private static native void copyTo_0(long src_nativeObj, long dst_nativeObj, long mask_nativeObj);
5895
5896    // C++:  void cv::inRange(Mat src, Scalar lowerb, Scalar upperb, Mat& dst)
5897    private static native void inRange_0(long src_nativeObj, double lowerb_val0, double lowerb_val1, double lowerb_val2, double lowerb_val3, double upperb_val0, double upperb_val1, double upperb_val2, double upperb_val3, long dst_nativeObj);
5898
5899    // C++:  void cv::compare(Mat src1, Mat src2, Mat& dst, int cmpop)
5900    private static native void compare_0(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj, int cmpop);
5901
5902    // C++:  void cv::min(Mat src1, Mat src2, Mat& dst)
5903    private static native void min_0(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj);
5904
5905    // C++:  void cv::max(Mat src1, Mat src2, Mat& dst)
5906    private static native void max_0(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj);
5907
5908    // C++:  void cv::sqrt(Mat src, Mat& dst)
5909    private static native void sqrt_0(long src_nativeObj, long dst_nativeObj);
5910
5911    // C++:  void cv::pow(Mat src, double power, Mat& dst)
5912    private static native void pow_0(long src_nativeObj, double power, long dst_nativeObj);
5913
5914    // C++:  void cv::exp(Mat src, Mat& dst)
5915    private static native void exp_0(long src_nativeObj, long dst_nativeObj);
5916
5917    // C++:  void cv::log(Mat src, Mat& dst)
5918    private static native void log_0(long src_nativeObj, long dst_nativeObj);
5919
5920    // C++:  void cv::polarToCart(Mat magnitude, Mat angle, Mat& x, Mat& y, bool angleInDegrees = false)
5921    private static native void polarToCart_0(long magnitude_nativeObj, long angle_nativeObj, long x_nativeObj, long y_nativeObj, boolean angleInDegrees);
5922    private static native void polarToCart_1(long magnitude_nativeObj, long angle_nativeObj, long x_nativeObj, long y_nativeObj);
5923
5924    // C++:  void cv::cartToPolar(Mat x, Mat y, Mat& magnitude, Mat& angle, bool angleInDegrees = false)
5925    private static native void cartToPolar_0(long x_nativeObj, long y_nativeObj, long magnitude_nativeObj, long angle_nativeObj, boolean angleInDegrees);
5926    private static native void cartToPolar_1(long x_nativeObj, long y_nativeObj, long magnitude_nativeObj, long angle_nativeObj);
5927
5928    // C++:  void cv::phase(Mat x, Mat y, Mat& angle, bool angleInDegrees = false)
5929    private static native void phase_0(long x_nativeObj, long y_nativeObj, long angle_nativeObj, boolean angleInDegrees);
5930    private static native void phase_1(long x_nativeObj, long y_nativeObj, long angle_nativeObj);
5931
5932    // C++:  void cv::magnitude(Mat x, Mat y, Mat& magnitude)
5933    private static native void magnitude_0(long x_nativeObj, long y_nativeObj, long magnitude_nativeObj);
5934
5935    // C++:  bool cv::checkRange(Mat a, bool quiet = true,  _hidden_ * pos = 0, double minVal = -DBL_MAX, double maxVal = DBL_MAX)
5936    private static native boolean checkRange_0(long a_nativeObj, boolean quiet, double minVal, double maxVal);
5937    private static native boolean checkRange_1(long a_nativeObj, boolean quiet, double minVal);
5938    private static native boolean checkRange_2(long a_nativeObj, boolean quiet);
5939    private static native boolean checkRange_4(long a_nativeObj);
5940
5941    // C++:  void cv::patchNaNs(Mat& a, double val = 0)
5942    private static native void patchNaNs_0(long a_nativeObj, double val);
5943    private static native void patchNaNs_1(long a_nativeObj);
5944
5945    // C++:  void cv::gemm(Mat src1, Mat src2, double alpha, Mat src3, double beta, Mat& dst, int flags = 0)
5946    private static native void gemm_0(long src1_nativeObj, long src2_nativeObj, double alpha, long src3_nativeObj, double beta, long dst_nativeObj, int flags);
5947    private static native void gemm_1(long src1_nativeObj, long src2_nativeObj, double alpha, long src3_nativeObj, double beta, long dst_nativeObj);
5948
5949    // C++:  void cv::mulTransposed(Mat src, Mat& dst, bool aTa, Mat delta = Mat(), double scale = 1, int dtype = -1)
5950    private static native void mulTransposed_0(long src_nativeObj, long dst_nativeObj, boolean aTa, long delta_nativeObj, double scale, int dtype);
5951    private static native void mulTransposed_1(long src_nativeObj, long dst_nativeObj, boolean aTa, long delta_nativeObj, double scale);
5952    private static native void mulTransposed_2(long src_nativeObj, long dst_nativeObj, boolean aTa, long delta_nativeObj);
5953    private static native void mulTransposed_3(long src_nativeObj, long dst_nativeObj, boolean aTa);
5954
5955    // C++:  void cv::transpose(Mat src, Mat& dst)
5956    private static native void transpose_0(long src_nativeObj, long dst_nativeObj);
5957
5958    // C++:  void cv::transform(Mat src, Mat& dst, Mat m)
5959    private static native void transform_0(long src_nativeObj, long dst_nativeObj, long m_nativeObj);
5960
5961    // C++:  void cv::perspectiveTransform(Mat src, Mat& dst, Mat m)
5962    private static native void perspectiveTransform_0(long src_nativeObj, long dst_nativeObj, long m_nativeObj);
5963
5964    // C++:  void cv::completeSymm(Mat& m, bool lowerToUpper = false)
5965    private static native void completeSymm_0(long m_nativeObj, boolean lowerToUpper);
5966    private static native void completeSymm_1(long m_nativeObj);
5967
5968    // C++:  void cv::setIdentity(Mat& mtx, Scalar s = Scalar(1))
5969    private static native void setIdentity_0(long mtx_nativeObj, double s_val0, double s_val1, double s_val2, double s_val3);
5970    private static native void setIdentity_1(long mtx_nativeObj);
5971
5972    // C++:  double cv::determinant(Mat mtx)
5973    private static native double determinant_0(long mtx_nativeObj);
5974
5975    // C++:  Scalar cv::trace(Mat mtx)
5976    private static native double[] trace_0(long mtx_nativeObj);
5977
5978    // C++:  double cv::invert(Mat src, Mat& dst, int flags = DECOMP_LU)
5979    private static native double invert_0(long src_nativeObj, long dst_nativeObj, int flags);
5980    private static native double invert_1(long src_nativeObj, long dst_nativeObj);
5981
5982    // C++:  bool cv::solve(Mat src1, Mat src2, Mat& dst, int flags = DECOMP_LU)
5983    private static native boolean solve_0(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj, int flags);
5984    private static native boolean solve_1(long src1_nativeObj, long src2_nativeObj, long dst_nativeObj);
5985
5986    // C++:  void cv::sort(Mat src, Mat& dst, int flags)
5987    private static native void sort_0(long src_nativeObj, long dst_nativeObj, int flags);
5988
5989    // C++:  void cv::sortIdx(Mat src, Mat& dst, int flags)
5990    private static native void sortIdx_0(long src_nativeObj, long dst_nativeObj, int flags);
5991
5992    // C++:  int cv::solveCubic(Mat coeffs, Mat& roots)
5993    private static native int solveCubic_0(long coeffs_nativeObj, long roots_nativeObj);
5994
5995    // C++:  double cv::solvePoly(Mat coeffs, Mat& roots, int maxIters = 300)
5996    private static native double solvePoly_0(long coeffs_nativeObj, long roots_nativeObj, int maxIters);
5997    private static native double solvePoly_1(long coeffs_nativeObj, long roots_nativeObj);
5998
5999    // C++:  bool cv::eigen(Mat src, Mat& eigenvalues, Mat& eigenvectors = Mat())
6000    private static native boolean eigen_0(long src_nativeObj, long eigenvalues_nativeObj, long eigenvectors_nativeObj);
6001    private static native boolean eigen_1(long src_nativeObj, long eigenvalues_nativeObj);
6002
6003    // C++:  void cv::eigenNonSymmetric(Mat src, Mat& eigenvalues, Mat& eigenvectors)
6004    private static native void eigenNonSymmetric_0(long src_nativeObj, long eigenvalues_nativeObj, long eigenvectors_nativeObj);
6005
6006    // C++:  void cv::calcCovarMatrix(Mat samples, Mat& covar, Mat& mean, int flags, int ctype = CV_64F)
6007    private static native void calcCovarMatrix_0(long samples_nativeObj, long covar_nativeObj, long mean_nativeObj, int flags, int ctype);
6008    private static native void calcCovarMatrix_1(long samples_nativeObj, long covar_nativeObj, long mean_nativeObj, int flags);
6009
6010    // C++:  void cv::PCACompute(Mat data, Mat& mean, Mat& eigenvectors, int maxComponents = 0)
6011    private static native void PCACompute_0(long data_nativeObj, long mean_nativeObj, long eigenvectors_nativeObj, int maxComponents);
6012    private static native void PCACompute_1(long data_nativeObj, long mean_nativeObj, long eigenvectors_nativeObj);
6013
6014    // C++:  void cv::PCACompute(Mat data, Mat& mean, Mat& eigenvectors, Mat& eigenvalues, int maxComponents = 0)
6015    private static native void PCACompute2_0(long data_nativeObj, long mean_nativeObj, long eigenvectors_nativeObj, long eigenvalues_nativeObj, int maxComponents);
6016    private static native void PCACompute2_1(long data_nativeObj, long mean_nativeObj, long eigenvectors_nativeObj, long eigenvalues_nativeObj);
6017
6018    // C++:  void cv::PCACompute(Mat data, Mat& mean, Mat& eigenvectors, double retainedVariance)
6019    private static native void PCACompute_2(long data_nativeObj, long mean_nativeObj, long eigenvectors_nativeObj, double retainedVariance);
6020
6021    // C++:  void cv::PCACompute(Mat data, Mat& mean, Mat& eigenvectors, Mat& eigenvalues, double retainedVariance)
6022    private static native void PCACompute2_2(long data_nativeObj, long mean_nativeObj, long eigenvectors_nativeObj, long eigenvalues_nativeObj, double retainedVariance);
6023
6024    // C++:  void cv::PCAProject(Mat data, Mat mean, Mat eigenvectors, Mat& result)
6025    private static native void PCAProject_0(long data_nativeObj, long mean_nativeObj, long eigenvectors_nativeObj, long result_nativeObj);
6026
6027    // C++:  void cv::PCABackProject(Mat data, Mat mean, Mat eigenvectors, Mat& result)
6028    private static native void PCABackProject_0(long data_nativeObj, long mean_nativeObj, long eigenvectors_nativeObj, long result_nativeObj);
6029
6030    // C++:  void cv::SVDecomp(Mat src, Mat& w, Mat& u, Mat& vt, int flags = 0)
6031    private static native void SVDecomp_0(long src_nativeObj, long w_nativeObj, long u_nativeObj, long vt_nativeObj, int flags);
6032    private static native void SVDecomp_1(long src_nativeObj, long w_nativeObj, long u_nativeObj, long vt_nativeObj);
6033
6034    // C++:  void cv::SVBackSubst(Mat w, Mat u, Mat vt, Mat rhs, Mat& dst)
6035    private static native void SVBackSubst_0(long w_nativeObj, long u_nativeObj, long vt_nativeObj, long rhs_nativeObj, long dst_nativeObj);
6036
6037    // C++:  double cv::Mahalanobis(Mat v1, Mat v2, Mat icovar)
6038    private static native double Mahalanobis_0(long v1_nativeObj, long v2_nativeObj, long icovar_nativeObj);
6039
6040    // C++:  void cv::dft(Mat src, Mat& dst, int flags = 0, int nonzeroRows = 0)
6041    private static native void dft_0(long src_nativeObj, long dst_nativeObj, int flags, int nonzeroRows);
6042    private static native void dft_1(long src_nativeObj, long dst_nativeObj, int flags);
6043    private static native void dft_2(long src_nativeObj, long dst_nativeObj);
6044
6045    // C++:  void cv::idft(Mat src, Mat& dst, int flags = 0, int nonzeroRows = 0)
6046    private static native void idft_0(long src_nativeObj, long dst_nativeObj, int flags, int nonzeroRows);
6047    private static native void idft_1(long src_nativeObj, long dst_nativeObj, int flags);
6048    private static native void idft_2(long src_nativeObj, long dst_nativeObj);
6049
6050    // C++:  void cv::dct(Mat src, Mat& dst, int flags = 0)
6051    private static native void dct_0(long src_nativeObj, long dst_nativeObj, int flags);
6052    private static native void dct_1(long src_nativeObj, long dst_nativeObj);
6053
6054    // C++:  void cv::idct(Mat src, Mat& dst, int flags = 0)
6055    private static native void idct_0(long src_nativeObj, long dst_nativeObj, int flags);
6056    private static native void idct_1(long src_nativeObj, long dst_nativeObj);
6057
6058    // C++:  void cv::mulSpectrums(Mat a, Mat b, Mat& c, int flags, bool conjB = false)
6059    private static native void mulSpectrums_0(long a_nativeObj, long b_nativeObj, long c_nativeObj, int flags, boolean conjB);
6060    private static native void mulSpectrums_1(long a_nativeObj, long b_nativeObj, long c_nativeObj, int flags);
6061
6062    // C++:  int cv::getOptimalDFTSize(int vecsize)
6063    private static native int getOptimalDFTSize_0(int vecsize);
6064
6065    // C++:  void cv::setRNGSeed(int seed)
6066    private static native void setRNGSeed_0(int seed);
6067
6068    // C++:  void cv::randu(Mat& dst, double low, double high)
6069    private static native void randu_0(long dst_nativeObj, double low, double high);
6070
6071    // C++:  void cv::randn(Mat& dst, double mean, double stddev)
6072    private static native void randn_0(long dst_nativeObj, double mean, double stddev);
6073
6074    // C++:  void cv::randShuffle(Mat& dst, double iterFactor = 1., RNG* rng = 0)
6075    private static native void randShuffle_0(long dst_nativeObj, double iterFactor);
6076    private static native void randShuffle_2(long dst_nativeObj);
6077
6078    // C++:  double cv::kmeans(Mat data, int K, Mat& bestLabels, TermCriteria criteria, int attempts, int flags, Mat& centers = Mat())
6079    private static native double kmeans_0(long data_nativeObj, int K, long bestLabels_nativeObj, int criteria_type, int criteria_maxCount, double criteria_epsilon, int attempts, int flags, long centers_nativeObj);
6080    private static native double kmeans_1(long data_nativeObj, int K, long bestLabels_nativeObj, int criteria_type, int criteria_maxCount, double criteria_epsilon, int attempts, int flags);
6081
6082    // C++:  void cv::setNumThreads(int nthreads)
6083    private static native void setNumThreads_0(int nthreads);
6084
6085    // C++:  int cv::getNumThreads()
6086    private static native int getNumThreads_0();
6087
6088    // C++:  int cv::getThreadNum()
6089    private static native int getThreadNum_0();
6090
6091    // C++:  String cv::getBuildInformation()
6092    private static native String getBuildInformation_0();
6093
6094    // C++:  String cv::getVersionString()
6095    private static native String getVersionString_0();
6096
6097    // C++:  int cv::getVersionMajor()
6098    private static native int getVersionMajor_0();
6099
6100    // C++:  int cv::getVersionMinor()
6101    private static native int getVersionMinor_0();
6102
6103    // C++:  int cv::getVersionRevision()
6104    private static native int getVersionRevision_0();
6105
6106    // C++:  int64 cv::getTickCount()
6107    private static native long getTickCount_0();
6108
6109    // C++:  double cv::getTickFrequency()
6110    private static native double getTickFrequency_0();
6111
6112    // C++:  int64 cv::getCPUTickCount()
6113    private static native long getCPUTickCount_0();
6114
6115    // C++:  String cv::getHardwareFeatureName(int feature)
6116    private static native String getHardwareFeatureName_0(int feature);
6117
6118    // C++:  string cv::getCPUFeaturesLine()
6119    private static native String getCPUFeaturesLine_0();
6120
6121    // C++:  int cv::getNumberOfCPUs()
6122    private static native int getNumberOfCPUs_0();
6123
6124    // C++:  String cv::samples::findFile(String relative_path, bool required = true, bool silentMode = false)
6125    private static native String findFile_0(String relative_path, boolean required, boolean silentMode);
6126    private static native String findFile_1(String relative_path, boolean required);
6127    private static native String findFile_2(String relative_path);
6128
6129    // C++:  String cv::samples::findFileOrKeep(String relative_path, bool silentMode = false)
6130    private static native String findFileOrKeep_0(String relative_path, boolean silentMode);
6131    private static native String findFileOrKeep_1(String relative_path);
6132
6133    // C++:  void cv::samples::addSamplesDataSearchPath(String path)
6134    private static native void addSamplesDataSearchPath_0(String path);
6135
6136    // C++:  void cv::samples::addSamplesDataSearchSubDirectory(String subdir)
6137    private static native void addSamplesDataSearchSubDirectory_0(String subdir);
6138
6139    // C++:  void cv::setErrorVerbosity(bool verbose)
6140    private static native void setErrorVerbosity_0(boolean verbose);
6141
6142    // C++:  void cv::add(Mat src1, Scalar src2, Mat& dst, Mat mask = Mat(), int dtype = -1)
6143    private static native void add_3(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj, long mask_nativeObj, int dtype);
6144    private static native void add_4(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj, long mask_nativeObj);
6145    private static native void add_5(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj);
6146
6147    // C++:  void cv::subtract(Mat src1, Scalar src2, Mat& dst, Mat mask = Mat(), int dtype = -1)
6148    private static native void subtract_3(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj, long mask_nativeObj, int dtype);
6149    private static native void subtract_4(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj, long mask_nativeObj);
6150    private static native void subtract_5(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj);
6151
6152    // C++:  void cv::multiply(Mat src1, Scalar src2, Mat& dst, double scale = 1, int dtype = -1)
6153    private static native void multiply_3(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj, double scale, int dtype);
6154    private static native void multiply_4(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj, double scale);
6155    private static native void multiply_5(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj);
6156
6157    // C++:  void cv::divide(Mat src1, Scalar src2, Mat& dst, double scale = 1, int dtype = -1)
6158    private static native void divide_5(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj, double scale, int dtype);
6159    private static native void divide_6(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj, double scale);
6160    private static native void divide_7(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj);
6161
6162    // C++:  void cv::absdiff(Mat src1, Scalar src2, Mat& dst)
6163    private static native void absdiff_1(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj);
6164
6165    // C++:  void cv::compare(Mat src1, Scalar src2, Mat& dst, int cmpop)
6166    private static native void compare_1(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj, int cmpop);
6167
6168    // C++:  void cv::min(Mat src1, Scalar src2, Mat& dst)
6169    private static native void min_1(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj);
6170
6171    // C++:  void cv::max(Mat src1, Scalar src2, Mat& dst)
6172    private static native void max_1(long src1_nativeObj, double src2_val0, double src2_val1, double src2_val2, double src2_val3, long dst_nativeObj);
6173private static native double[] n_minMaxLocManual(long src_nativeObj, long mask_nativeObj);
6174
6175}