mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -414,6 +414,29 @@ void Mat::copyTo( OutputArray _dst, InputArray _mask ) const
|
||||
copymask(ptrs[0], 0, ptrs[2], 0, ptrs[1], 0, sz, &esz);
|
||||
}
|
||||
|
||||
|
||||
static bool can_apply_memset(const Mat &mat, const Scalar &s, int &fill_value)
|
||||
{
|
||||
// check if depth is 1 byte.
|
||||
switch (mat.depth())
|
||||
{
|
||||
case CV_8U: fill_value = saturate_cast<uchar>( s.val[0] ); break;
|
||||
case CV_8S: fill_value = saturate_cast<schar>( s.val[0] ); break;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
// check if all element is same.
|
||||
const int64* is = (const int64*)&s.val[0];
|
||||
switch (mat.channels())
|
||||
{
|
||||
case 1: return true;
|
||||
case 2: return (is[0] == is[1]);
|
||||
case 3: return (is[0] == is[1] && is[1] == is[2]);
|
||||
case 4: return (is[0] == is[1] && is[1] == is[2] && is[2] == is[3]);
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
Mat& Mat::operator = (const Scalar& s)
|
||||
{
|
||||
CV_INSTRUMENT_REGION();
|
||||
@@ -434,6 +457,14 @@ Mat& Mat::operator = (const Scalar& s)
|
||||
}
|
||||
else
|
||||
{
|
||||
int fill_value = 0;
|
||||
if ( can_apply_memset(*this, s, fill_value) )
|
||||
{
|
||||
for (size_t i = 0; i < it.nplanes; i++, ++it)
|
||||
memset(dptr, fill_value, elsize);
|
||||
return *this;
|
||||
}
|
||||
|
||||
if( it.nplanes > 0 )
|
||||
{
|
||||
double scalar[12];
|
||||
|
||||
@@ -561,7 +561,7 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, Stream& stream) co
|
||||
{convertToNoScale<double, uchar>, convertToNoScale<double, schar>, convertToNoScale<double, ushort>, convertToNoScale<double, short>, convertToNoScale<double, int>, convertToNoScale<double, float>, 0}
|
||||
};
|
||||
|
||||
funcs[sdepth][ddepth](reshape(1), dst.reshape(1), stream);
|
||||
funcs[sdepth][ddepth](src.reshape(1), dst.reshape(1), stream);
|
||||
}
|
||||
|
||||
void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, double alpha, double beta, Stream& stream) const
|
||||
@@ -591,7 +591,7 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, double alpha, doub
|
||||
{convertToScale<double, uchar>, convertToScale<double, schar>, convertToScale<double, ushort>, convertToScale<double, short>, convertToScale<double, int>, convertToScale<double, float>, convertToScale<double, double>}
|
||||
};
|
||||
|
||||
funcs[sdepth][ddepth](reshape(1), dst.reshape(1), alpha, beta, stream);
|
||||
funcs[sdepth][ddepth](src.reshape(1), dst.reshape(1), alpha, beta, stream);
|
||||
}
|
||||
|
||||
void cv::cuda::convertFp16(InputArray _src, OutputArray _dst, Stream& stream)
|
||||
|
||||
@@ -6464,6 +6464,9 @@ struct Image2D::Impl
|
||||
CV_Error(Error::OpenCLApiCallError, "OpenCL runtime not found!");
|
||||
|
||||
cl_context context = (cl_context)Context::getDefault().ptr();
|
||||
if (!context)
|
||||
return false;
|
||||
|
||||
// Figure out how many formats are supported by this context.
|
||||
cl_uint numFormats = 0;
|
||||
cl_int err = clGetSupportedImageFormats(context, CL_MEM_READ_WRITE,
|
||||
|
||||
Reference in New Issue
Block a user