From 389aae59ae2b2815e450b44a656a70286736694c Mon Sep 17 00:00:00 2001 From: LaurentBerger Date: Sat, 27 Oct 2018 20:57:02 +0200 Subject: [PATCH] add python copyto with mask (https://github.com/opencv/opencv/issues/10225) --- modules/core/include/opencv2/core.hpp | 11 +++++++++++ modules/core/src/arithm.cpp | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 73456b1fb2..182e39b934 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -1346,6 +1346,17 @@ You may even get a negative value in the case of overflow. */ CV_EXPORTS_W void absdiff(InputArray src1, InputArray src2, OutputArray dst); +/** @brief This is an overloaded member function, provided for convenience (python) +Copies the matrix to another one. +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. +@param src source matrix. +@param dst Destination matrix. If it does not have a proper size or type before the operation, it is +reallocated. +@param mask Operation mask of the same size as \*this. Its non-zero elements indicate which matrix +elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels. +*/ + +void CV_EXPORTS_W copyTo(InputArray src, OutputArray dst, InputArray mask); /** @brief Checks if array elements lie between the elements of two other arrays. The function checks the range as follows: diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index 7c504afb06..1560618c61 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -945,6 +945,13 @@ void cv::absdiff( InputArray src1, InputArray src2, OutputArray dst ) arithm_op(src1, src2, dst, noArray(), -1, getAbsDiffTab(), false, 0, OCL_OP_ABSDIFF); } +void cv::copyTo(InputArray _src, OutputArray _dst, InputArray _mask) +{ + CV_INSTRUMENT_REGION(); + + _src.copyTo(_dst, _mask); +} + /****************************************************************************************\ * multiply/divide * \****************************************************************************************/