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