Commit 8c0b0714 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

parents 55f02d8c f3074fd5
......@@ -124,6 +124,10 @@
#if defined CV_CPU_COMPILE_AVX && !defined CV_CPU_BASELINE_COMPILE_AVX
struct VZeroUpperGuard {
#ifdef __GNUC__
__attribute__((always_inline))
#endif
inline VZeroUpperGuard() { _mm256_zeroupper(); }
#ifdef __GNUC__
__attribute__((always_inline))
#endif
......
......@@ -1202,14 +1202,16 @@ OPENCV_HAL_IMPL_NEON_EXPAND(v_int32x4, v_int64x2, int, s32)
inline v_uint32x4 v_load_expand_q(const uchar* ptr)
{
uint8x8_t v0 = vcreate_u8(*(unsigned*)ptr);
typedef unsigned int CV_DECL_ALIGNED(1) unaligned_uint;
uint8x8_t v0 = vcreate_u8(*(unaligned_uint*)ptr);
uint16x4_t v1 = vget_low_u16(vmovl_u8(v0));
return v_uint32x4(vmovl_u16(v1));
}
inline v_int32x4 v_load_expand_q(const schar* ptr)
{
int8x8_t v0 = vcreate_s8(*(unsigned*)ptr);
typedef unsigned int CV_DECL_ALIGNED(1) unaligned_uint;
int8x8_t v0 = vcreate_s8(*(unaligned_uint*)ptr);
int16x4_t v1 = vget_low_s16(vmovl_s8(v0));
return v_int32x4(vmovl_s16(v1));
}
......
......@@ -789,9 +789,9 @@ CV_EXPORTS InstrNode* getCurrentNode();
#endif
#ifdef __CV_AVX_GUARD
#define CV_INSTRUMENT_REGION(); __CV_AVX_GUARD CV_INSTRUMENT_REGION_();
#define CV_INSTRUMENT_REGION() __CV_AVX_GUARD CV_INSTRUMENT_REGION_();
#else
#define CV_INSTRUMENT_REGION(); CV_INSTRUMENT_REGION_();
#define CV_INSTRUMENT_REGION() CV_INSTRUMENT_REGION_();
#endif
namespace cv {
......
This diff is collapsed.
......@@ -1288,17 +1288,12 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
{
CV_Assert( i < 0 );
Mat& m = *(Mat*)obj;
if( allowTransposed )
if (allowTransposed && !m.empty() &&
d == 2 && m.dims == 2 &&
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] &&
m.isContinuous())
{
if( !m.isContinuous() )
{
CV_Assert(!fixedType() && !fixedSize());
m.release();
}
if( d == 2 && m.dims == 2 && m.data &&
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] )
return;
return;
}
if(fixedType())
......@@ -1306,13 +1301,13 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
if(CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
mtype = m.type();
else
CV_Assert(CV_MAT_TYPE(mtype) == m.type());
CV_CheckTypeEQ(m.type(), CV_MAT_TYPE(mtype), "");
}
if(fixedSize())
{
CV_Assert(m.dims == d);
CV_CheckEQ(m.dims, d, "");
for(int j = 0; j < d; ++j)
CV_Assert(m.size[j] == sizes[j]);
CV_CheckEQ(m.size[j], sizes[j], "");
}
m.create(d, sizes, mtype);
return;
......@@ -1322,17 +1317,12 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
{
CV_Assert( i < 0 );
UMat& m = *(UMat*)obj;
if( allowTransposed )
if (allowTransposed && !m.empty() &&
d == 2 && m.dims == 2 &&
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] &&
m.isContinuous())
{
if( !m.isContinuous() )
{
CV_Assert(!fixedType() && !fixedSize());
m.release();
}
if( d == 2 && m.dims == 2 && !m.empty() &&
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] )
return;
return;
}
if(fixedType())
......@@ -1340,13 +1330,13 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
if(CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
mtype = m.type();
else
CV_Assert(CV_MAT_TYPE(mtype) == m.type());
CV_CheckTypeEQ(m.type(), CV_MAT_TYPE(mtype), "");
}
if(fixedSize())
{
CV_Assert(m.dims == d);
CV_CheckEQ(m.dims, d, "");
for(int j = 0; j < d; ++j)
CV_Assert(m.size[j] == sizes[j]);
CV_CheckEQ(m.size[j], sizes[j], "");
}
m.create(d, sizes, mtype);
return;
......
......@@ -177,6 +177,13 @@ TEST(Core_OutputArray, FixedType)
EXPECT_EQ(2, num_defaultResult);
}
TEST(Core_OutputArrayCreate, _13772)
{
cv::Mat1d mat;
cv::OutputArray o(mat);
ASSERT_NO_THROW(o.create(3, 5, CV_64F, -1, true));
}
TEST(Core_String, find_last_of__with__empty_string)
......
......@@ -371,7 +371,7 @@ namespace cv {
fused_layer_names.push_back(last_layer);
}
void setYolo(int classes, const std::vector<int>& mask, const std::vector<float>& anchors)
void setYolo(int classes, const std::vector<int>& mask, const std::vector<float>& anchors, float thresh, float nms_threshold)
{
cv::dnn::LayerParams region_param;
region_param.name = "Region-name";
......@@ -382,6 +382,8 @@ namespace cv {
region_param.set<int>("classes", classes);
region_param.set<int>("anchors", numAnchors);
region_param.set<bool>("logistic", true);
region_param.set<float>("thresh", thresh);
region_param.set<float>("nms_threshold", nms_threshold);
std::vector<float> usedAnchors(numAnchors * 2);
for (int i = 0; i < numAnchors; ++i)
......@@ -646,6 +648,8 @@ namespace cv {
{
int classes = getParam<int>(layer_params, "classes", -1);
int num_of_anchors = getParam<int>(layer_params, "num", -1);
float thresh = getParam<float>(layer_params, "thresh", 0.2);
float nms_threshold = getParam<float>(layer_params, "nms_threshold", 0.4);
std::string anchors_values = getParam<std::string>(layer_params, "anchors", std::string());
CV_Assert(!anchors_values.empty());
......@@ -658,7 +662,7 @@ namespace cv {
CV_Assert(classes > 0 && num_of_anchors > 0 && (num_of_anchors * 2) == anchors_vec.size());
setParams.setPermute(false);
setParams.setYolo(classes, mask_vec, anchors_vec);
setParams.setYolo(classes, mask_vec, anchors_vec, thresh, nms_threshold);
}
else {
CV_Error(cv::Error::StsParseError, "Unknown layer type: " + layer_type);
......
......@@ -62,6 +62,8 @@ namespace dnn
class BaseConvolutionLayerImpl : public ConvolutionLayer
{
public:
bool newWeightAndBias;
std::vector<double> weightsMultipliers;
BaseConvolutionLayerImpl(const LayerParams &params)
{
setParamsFrom(params);
......@@ -85,6 +87,8 @@ public:
CV_Assert(numOutput % ngroups == 0);
CV_Assert(adjustPad.width < stride.width &&
adjustPad.height < stride.height);
newWeightAndBias = false;
}
void finalize(InputArrayOfArrays inputs_arr, OutputArrayOfArrays outputs_arr) CV_OVERRIDE
......@@ -135,6 +139,20 @@ public:
(dilation.height == 1 && dilation.width == 1);
}
virtual bool tryFuse(Ptr<Layer>& top) CV_OVERRIDE
{
Mat w, b;
top->getScaleShift(w, b);
if (!w.empty() || !b.empty())
{
fuseWeights(w, b);
return true;
}
return false;
}
virtual void fuseWeights(const Mat& w_, const Mat& b_) = 0;
virtual void applyHalideScheduler(Ptr<BackendNode>& node,
const std::vector<Mat*> &inputs,
const std::vector<Mat> &outputs,
......@@ -185,11 +203,9 @@ class ConvolutionLayerImpl CV_FINAL : public BaseConvolutionLayerImpl
public:
enum { VEC_ALIGN = 8, DFT_TYPE = CV_32F };
Mat weightsMat;
std::vector<double> weightsMultipliers;
std::vector<float> biasvec;
std::vector<float> reluslope;
Ptr<ActivationLayer> activ;
bool newWeightAndBias;
bool fusedBias;
#ifdef HAVE_OPENCL
......@@ -201,7 +217,6 @@ public:
#endif
ConvolutionLayerImpl(const LayerParams &params) : BaseConvolutionLayerImpl(params)
{
newWeightAndBias = false;
fusedBias = false;
#ifdef HAVE_OPENCL
newActiv = false;
......@@ -349,19 +364,7 @@ public:
return !activ.empty();
}
virtual bool tryFuse(Ptr<Layer>& top) CV_OVERRIDE
{
Mat w, b;
top->getScaleShift(w, b);
if (!w.empty() || !b.empty())
{
fuseWeights(w, b);
return true;
}
return false;
}
void fuseWeights(const Mat& w_, const Mat& b_)
void fuseWeights(const Mat& w_, const Mat& b_) CV_OVERRIDE
{
// Convolution weights have OIHW data layout. Parameters fusion in case of
// (conv(I) + b1 ) * w + b2
......@@ -1308,6 +1311,45 @@ public:
pad.width = pad_l;
pad.height = pad_t;
weightsMultipliers.assign(numOutput, 1.0);
if (weightsMat.empty())
{
transpose(blobs[0].reshape(1, blobs[0].size[0]), weightsMat);
biasesMat = hasBias() ? blobs[1].reshape(1, numOutput)
: Mat::zeros(numOutput, 1, CV_32F);
}
}
void fuseWeights(const Mat& w_, const Mat& b_) CV_OVERRIDE
{
Mat w = w_.total() == 1 ? Mat(1, numOutput, CV_32F, Scalar(w_.at<float>(0))) : w_;
Mat b = b_.total() == 1 ? Mat(1, numOutput, CV_32F, Scalar(b_.at<float>(0))) : b_;
CV_Assert_N(!weightsMat.empty(),
w.empty() || numOutput == w.total(),
b.empty() || numOutput == b.total());
if (!w.empty())
{
transpose(blobs[0].reshape(1, blobs[0].size[0]), weightsMat);
weightsMat = weightsMat.reshape(1, numOutput);
for (int i = 0; i < numOutput; ++i)
{
double wi = w.at<float>(i);
weightsMultipliers[i] *= wi;
cv::multiply(weightsMat.row(i), weightsMultipliers[i], weightsMat.row(i));
biasesMat.at<float>(i) *= wi;
}
weightsMat = weightsMat.reshape(1, weightsMat.total() / blobs[0].size[0]);
}
if (!b.empty())
{
cv::add(biasesMat, b.reshape(1, numOutput), biasesMat);
}
newWeightAndBias = !w.empty() || !b.empty();
}
class MatMulInvoker : public ParallelLoopBody
......@@ -1575,11 +1617,19 @@ public:
if (umat_weights.empty())
{
transpose(blobs[0].reshape(1, inpCn), umat_weights);
if (hasBias())
blobs[1].reshape(1, outCn).copyTo(umat_biases);
if (newWeightAndBias)
{
weightsMat.copyTo(umat_weights);
biasesMat.copyTo(umat_biases);
}
else
umat_biases = UMat::zeros(outCn, 1, CV_32F);
{
transpose(blobs[0].reshape(1, inpCn), umat_weights);
if (hasBias())
blobs[1].reshape(1, outCn).copyTo(umat_biases);
else
umat_biases = UMat::zeros(outCn, 1, CV_32F);
}
}
String buildopt = format("-DT=%s ", ocl::typeToStr(inputs[0].type()));
......
......@@ -305,9 +305,16 @@ TEST_P(DNNTestNetwork, DenseNet_121)
TEST_P(DNNTestNetwork, FastNeuralStyle_eccv16)
{
if (backend == DNN_BACKEND_HALIDE ||
(backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16) ||
(backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD))
throw SkipTestException("");
#if defined(INF_ENGINE_RELEASE)
#if INF_ENGINE_RELEASE <= 2018050000
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_OPENCL)
throw SkipTestException("");
#endif
#endif
Mat img = imread(findDataFile("dnn/googlenet_1.png", false));
Mat inp = blobFromImage(img, 1.0, Size(320, 240), Scalar(103.939, 116.779, 123.68), false, false);
// Output image has values in range [-143.526, 148.539].
......
......@@ -394,6 +394,14 @@ TEST_P(Test_Torch_nets, ENet_accuracy)
TEST_P(Test_Torch_nets, FastNeuralStyle_accuracy)
{
checkBackend();
#if defined(INF_ENGINE_RELEASE)
#if INF_ENGINE_RELEASE <= 2018050000
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_OPENCL)
throw SkipTestException("");
#endif
#endif
std::string models[] = {"dnn/fast_neural_style_eccv16_starry_night.t7",
"dnn/fast_neural_style_instance_norm_feathers.t7"};
std::string targets[] = {"dnn/lena_starry_night.png", "dnn/lena_feathers.png"};
......
......@@ -95,6 +95,7 @@ enum ImwriteFlags {
IMWRITE_TIFF_RESUNIT = 256,//!< For TIFF, use to specify which DPI resolution unit to set; see libtiff documentation for valid values
IMWRITE_TIFF_XDPI = 257,//!< For TIFF, use to specify the X direction DPI
IMWRITE_TIFF_YDPI = 258, //!< For TIFF, use to specify the Y direction DPI
IMWRITE_TIFF_COMPRESSION = 259, //!< For TIFF, use to specify the image compression scheme. See libtiff for integer constants corresponding to compression formats. Note, for images whose depth is CV_32F, only libtiff's SGILOG compression scheme is used. For other supported depths, the compression scheme can be specified by this flag; LZW compression is the default.
IMWRITE_JPEG2000_COMPRESSION_X1000 = 272 //!< For JPEG2000, use to specify the target compression rate (multiplied by 1000). The value can be from 0 to 1000. Default is 1000.
};
......
......@@ -750,12 +750,11 @@ bool TiffEncoder::writeLibTiff( const std::vector<Mat>& img_vec, const std::vect
}
//Settings that matter to all images
// defaults for now, maybe base them on params in the future
int compression = COMPRESSION_LZW;
int predictor = PREDICTOR_HORIZONTAL;
int resUnit = -1, dpiX = -1, dpiY = -1;
readParam(params, TIFFTAG_COMPRESSION, compression);
readParam(params, IMWRITE_TIFF_COMPRESSION, compression);
readParam(params, TIFFTAG_PREDICTOR, predictor);
readParam(params, IMWRITE_TIFF_RESUNIT, resUnit);
readParam(params, IMWRITE_TIFF_XDPI, dpiX);
......
set(the_description "Image Processing")
ocv_add_dispatched_file(accum SSE4_1 AVX AVX2)
ocv_add_dispatched_file(bilateral_filter SSE2 AVX2)
ocv_add_dispatched_file(box_filter SSE2 SSE4_1 AVX2)
ocv_add_dispatched_file(filter SSE2 SSE4_1 AVX2)
ocv_add_dispatched_file(color_hsv SSE2 SSE4_1 AVX2)
ocv_add_dispatched_file(color_rgb SSE2 SSE4_1 AVX2)
ocv_add_dispatched_file(color_yuv SSE2 SSE4_1 AVX2)
ocv_add_dispatched_file(median_blur SSE2 SSE4_1 AVX2)
ocv_add_dispatched_file(morph SSE2 SSE4_1 AVX2)
ocv_add_dispatched_file(smooth SSE2 SSE4_1 AVX2)
ocv_define_module(imgproc opencv_core WRAP java python js)
......@@ -39,7 +39,7 @@ PERF_TEST_P( TestFilter2d, Filter2d,
SANITY_CHECK(dst, 1);
}
PERF_TEST_P(TestFilter2d, Filter2d_ovx,
PERF_TEST_P(TestFilter2d, DISABLED_Filter2d_ovx,
Combine(
Values(Size(320, 240), sz1080p),
Values(3, 5),
......
......@@ -26,7 +26,7 @@ PERF_TEST_P(Size_MatType, pyrDown, testing::Combine(
SANITY_CHECK(dst, eps, error_type);
}
PERF_TEST_P(Size_MatType, pyrDown_ovx, testing::Combine(
PERF_TEST_P(Size_MatType, DISABLED_pyrDown_ovx, testing::Combine(
testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD),
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)
)
......
......@@ -48,7 +48,7 @@ PERF_TEST_P( TestWarpAffine, WarpAffine,
#endif
}
PERF_TEST_P(TestWarpAffine, WarpAffine_ovx,
PERF_TEST_P(TestWarpAffine, DISABLED_WarpAffine_ovx,
Combine(
Values(szVGA, sz720p, sz1080p),
InterType::all(),
......@@ -116,7 +116,7 @@ PERF_TEST_P( TestWarpPerspective, WarpPerspective,
#endif
}
PERF_TEST_P(TestWarpPerspective, WarpPerspective_ovx,
PERF_TEST_P(TestWarpPerspective, DISABLED_WarpPerspective_ovx,
Combine(
Values(szVGA, sz720p, sz1080p),
InterType::all(),
......
This diff is collapsed.
This diff is collapsed.
......@@ -3,6 +3,7 @@
// of this distribution and at http://opencv.org/license.html
#include "precomp.hpp"
#include "opencl_kernels_imgproc.hpp"
#include "color.hpp"
namespace cv
......
......@@ -3,63 +3,17 @@
// of this distribution and at http://opencv.org/license.html
#include "opencv2/imgproc.hpp"
#include "opencv2/core/utility.hpp"
#include <limits>
#include "opencl_kernels_imgproc.hpp"
#include "hal_replacement.hpp"
#include "opencv2/core/hal/intrin.hpp"
#include "opencv2/core/softfloat.hpp"
#define CV_DESCALE(x,n) (((x) + (1 << ((n)-1))) >> (n))
namespace cv
{
//constants for conversion from/to RGB and Gray, YUV, YCrCb according to BT.601
const float B2YF = 0.114f;
const float G2YF = 0.587f;
const float R2YF = 0.299f;
enum
{
gray_shift = 15,
yuv_shift = 14,
xyz_shift = 12,
R2Y = 4899, // == R2YF*16384
G2Y = 9617, // == G2YF*16384
B2Y = 1868, // == B2YF*16384
RY15 = 9798, // == R2YF*32768 + 0.5
GY15 = 19235, // == G2YF*32768 + 0.5
BY15 = 3735, // == B2YF*32768 + 0.5
BLOCK_SIZE = 256
};
template<typename _Tp> struct ColorChannel
{
typedef float worktype_f;
static _Tp max() { return std::numeric_limits<_Tp>::max(); }
static _Tp half() { return (_Tp)(max()/2 + 1); }
};
template<> struct ColorChannel<float>
{
typedef float worktype_f;
static float max() { return 1.f; }
static float half() { return 0.5f; }
};
/*template<> struct ColorChannel<double>
{
typedef double worktype_f;
static double max() { return 1.; }
static double half() { return 0.5; }
};*/
namespace cv {
//
// Helper functions
//
namespace {
namespace impl {
#include "color.simd_helpers.hpp"
inline bool isHSV(int code)
{
......@@ -213,40 +167,9 @@ inline int uIndex(int code)
}
} // namespace::
using namespace impl;
template<int i0, int i1 = -1, int i2 = -1>
struct Set
{
static bool contains(int i)
{
return (i == i0 || i == i1 || i == i2);
}
};
template<int i0, int i1>
struct Set<i0, i1, -1>
{
static bool contains(int i)
{
return (i == i0 || i == i1);
}
};
template<int i0>
struct Set<i0, -1, -1>
{
static bool contains(int i)
{
return (i == i0);
}
};
enum SizePolicy
{
TO_YUV, FROM_YUV, NONE
};
template< typename VScn, typename VDcn, typename VDepth, SizePolicy sizePolicy = NONE >
/*template< typename VScn, typename VDcn, typename VDepth, SizePolicy sizePolicy = NONE >
struct CvtHelper
{
CvtHelper(InputArray _src, OutputArray _dst, int dcn)
......@@ -286,7 +209,7 @@ struct CvtHelper
Mat src, dst;
int depth, scn;
Size dstSz;
};
};*/
#ifdef HAVE_OPENCL
......@@ -384,49 +307,7 @@ struct OclHelper
#endif
///////////////////////////// Top-level template function ////////////////////////////////
template <typename Cvt>
class CvtColorLoop_Invoker : public ParallelLoopBody
{
typedef typename Cvt::channel_type _Tp;
public:
CvtColorLoop_Invoker(const uchar * src_data_, size_t src_step_, uchar * dst_data_, size_t dst_step_, int width_, const Cvt& _cvt) :
ParallelLoopBody(), src_data(src_data_), src_step(src_step_), dst_data(dst_data_), dst_step(dst_step_),
width(width_), cvt(_cvt)
{
}
virtual void operator()(const Range& range) const CV_OVERRIDE
{
CV_TRACE_FUNCTION();
const uchar* yS = src_data + static_cast<size_t>(range.start) * src_step;
uchar* yD = dst_data + static_cast<size_t>(range.start) * dst_step;
for( int i = range.start; i < range.end; ++i, yS += src_step, yD += dst_step )
cvt(reinterpret_cast<const _Tp*>(yS), reinterpret_cast<_Tp*>(yD), width);
}
private:
const uchar * src_data;
const size_t src_step;
uchar * dst_data;
const size_t dst_step;
const int width;
const Cvt& cvt;
const CvtColorLoop_Invoker& operator= (const CvtColorLoop_Invoker&);
};
template <typename Cvt>
void CvtColorLoop(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, const Cvt& cvt)
{
parallel_for_(Range(0, height),
CvtColorLoop_Invoker<Cvt>(src_data, src_step, dst_data, dst_step, width, cvt),
(width * height) / static_cast<double>(1<<16));
}
#if defined (HAVE_IPP) && (IPP_VERSION_X100 >= 700)
# define NEED_IPP 1
......
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
#define CV_DESCALE(x,n) (((x) + (1 << ((n)-1))) >> (n))
namespace {
//constants for conversion from/to RGB and Gray, YUV, YCrCb according to BT.601
static const float B2YF = 0.114f;
static const float G2YF = 0.587f;
static const float R2YF = 0.299f;
enum
{
gray_shift = 15,
yuv_shift = 14,
xyz_shift = 12,
R2Y = 4899, // == R2YF*16384
G2Y = 9617, // == G2YF*16384
B2Y = 1868, // == B2YF*16384
RY15 = 9798, // == R2YF*32768 + 0.5
GY15 = 19235, // == G2YF*32768 + 0.5
BY15 = 3735, // == B2YF*32768 + 0.5
BLOCK_SIZE = 256
};
template<typename _Tp> struct ColorChannel
{
typedef float worktype_f;
static inline _Tp max() { return std::numeric_limits<_Tp>::max(); }
static inline _Tp half() { return (_Tp)(max()/2 + 1); }
};
template<> struct ColorChannel<float>
{
typedef float worktype_f;
static inline float max() { return 1.f; }
static inline float half() { return 0.5f; }
};
/*template<> struct ColorChannel<double>
{
typedef double worktype_f;
static double max() { return 1.; }
static double half() { return 0.5; }
};*/
template<int i0, int i1 = -1, int i2 = -1>
struct Set
{
static inline bool contains(int i)
{
return (i == i0 || i == i1 || i == i2);
}
};
template<int i0, int i1>
struct Set<i0, i1, -1>
{
static inline bool contains(int i)
{
return (i == i0 || i == i1);
}
};
template<int i0>
struct Set<i0, -1, -1>
{
static inline bool contains(int i)
{
return (i == i0);
}
};
enum SizePolicy
{
TO_YUV, FROM_YUV, NONE
};
template< typename VScn, typename VDcn, typename VDepth, SizePolicy sizePolicy = NONE >
struct CvtHelper
{
CvtHelper(InputArray _src, OutputArray _dst, int dcn)
{
CV_Assert(!_src.empty());
int stype = _src.type();
scn = CV_MAT_CN(stype), depth = CV_MAT_DEPTH(stype);
CV_Check(scn, VScn::contains(scn), "Invalid number of channels in input image");
CV_Check(dcn, VDcn::contains(dcn), "Invalid number of channels in output image");
CV_CheckDepth(depth, VDepth::contains(depth), "Unsupported depth of input image");
if (_src.getObj() == _dst.getObj()) // inplace processing (#6653)
_src.copyTo(src);
else
src = _src.getMat();
Size sz = src.size();
switch (sizePolicy)
{
case TO_YUV:
CV_Assert( sz.width % 2 == 0 && sz.height % 2 == 0);
dstSz = Size(sz.width, sz.height / 2 * 3);
break;
case FROM_YUV:
CV_Assert( sz.width % 2 == 0 && sz.height % 3 == 0);
dstSz = Size(sz.width, sz.height * 2 / 3);
break;
case NONE:
default:
dstSz = sz;
break;
}
_dst.create(dstSz, CV_MAKETYPE(depth, dcn));
dst = _dst.getMat();
}
Mat src, dst;
int depth, scn;
Size dstSz;
};
///////////////////////////// Top-level template function ////////////////////////////////
template <typename Cvt>
class CvtColorLoop_Invoker : public ParallelLoopBody
{
typedef typename Cvt::channel_type _Tp;
public:
CvtColorLoop_Invoker(const uchar * src_data_, size_t src_step_, uchar * dst_data_, size_t dst_step_, int width_, const Cvt& _cvt) :
ParallelLoopBody(), src_data(src_data_), src_step(src_step_), dst_data(dst_data_), dst_step(dst_step_),
width(width_), cvt(_cvt)
{
}
virtual void operator()(const Range& range) const CV_OVERRIDE
{
CV_TRACE_FUNCTION();
const uchar* yS = src_data + static_cast<size_t>(range.start) * src_step;
uchar* yD = dst_data + static_cast<size_t>(range.start) * dst_step;
for( int i = range.start; i < range.end; ++i, yS += src_step, yD += dst_step )
cvt(reinterpret_cast<const _Tp*>(yS), reinterpret_cast<_Tp*>(yD), width);
}
private:
const uchar * src_data;
const size_t src_step;
uchar * dst_data;
const size_t dst_step;
const int width;
const Cvt& cvt;
CvtColorLoop_Invoker(const CvtColorLoop_Invoker&); // = delete;
const CvtColorLoop_Invoker& operator= (const CvtColorLoop_Invoker&); // = delete;
};
template <typename Cvt> static inline
void CvtColorLoop(const uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height, const Cvt& cvt)
{
CV_AVX_GUARD
parallel_for_(Range(0, height),
CvtColorLoop_Invoker<Cvt>(src_data, src_step, dst_data, dst_step, width, cvt),
(width * height) / static_cast<double>(1<<16));
}
} //namespace
This diff is collapsed.
......@@ -9,6 +9,10 @@
\**********************************************************************************/
#include "precomp.hpp"
#include "opencl_kernels_imgproc.hpp"
#include "opencv2/core/hal/intrin.hpp"
#include "opencv2/core/softfloat.hpp"
#include "color.hpp"
using cv::softfloat;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -45,17 +45,13 @@
namespace cv
{
#if CV_TRY_AVX2
int RowVec_32f_AVX(const float* src0, const float* _kx, float* dst, int width, int cn, int _ksize);
int SymmColumnVec_32f_Symm_AVX(const float** src, const float* ky, float* dst, float delta, int width, int ksize2);
int SymmColumnVec_32f_Unsymm_AVX(const float** src, const float* ky, float* dst, float delta, int width, int ksize2);
#endif
#ifdef HAVE_OPENCL
bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, int ddepth,
InputArray _kernelX, InputArray _kernelY, Point anchor,
double delta, int borderType );
#endif
void preprocess2DKernel(const Mat& kernel, std::vector<Point>& coords, std::vector<uchar>& coeffs);
}
#endif
......
......@@ -9,10 +9,7 @@
#ifndef _CV_FIXEDPOINT_HPP_
#define _CV_FIXEDPOINT_HPP_
#include "opencv2/core/softfloat.hpp"
namespace
{
namespace {
class fixedpoint64
{
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -137,5 +137,5 @@ public abstract class BaseLoaderCallback implements LoaderCallbackInterface {
}
protected Context mAppContext;
private final static String TAG = "OpenCVLoader/BaseLoaderCallback";
private final static String TAG = "OCV/BaseLoaderCallback";
}
This diff is collapsed.
......@@ -99,6 +99,8 @@ public class OpenCVTestCase extends TestCase {
protected Mat rgbLena;
protected Mat grayChess;
protected Mat gray255_32f_3d;
protected Mat v1;
protected Mat v2;
......@@ -149,6 +151,8 @@ public class OpenCVTestCase extends TestCase {
rgbLena = Imgcodecs.imread(OpenCVTestRunner.LENA_PATH);
grayChess = Imgcodecs.imread(OpenCVTestRunner.CHESS_PATH, 0);
gray255_32f_3d = new Mat(new int[]{matSize, matSize, matSize}, CvType.CV_32F, new Scalar(255.0));
v1 = new Mat(1, 3, CvType.CV_32F);
v1.put(0, 0, 1.0, 3.0, 2.0);
v2 = new Mat(1, 3, CvType.CV_32F);
......@@ -184,6 +188,7 @@ public class OpenCVTestCase extends TestCase {
rgba128.release();
rgbLena.release();
grayChess.release();
gray255_32f_3d.release();
v1.release();
v2.release();
......@@ -442,8 +447,24 @@ public class OpenCVTestCase extends TestCase {
assertEquals(msg, expected.z, actual.z, eps);
}
static private boolean dimensionsEqual(Mat expected, Mat actual) {
if (expected.dims() != actual.dims()) {
return false;
}
if (expected.dims() > 2) {
for (int i = 0; i < expected.dims(); i++) {
if (expected.size(i) != actual.size(i)) {
return false;
}
}
return true;
} else {
return expected.cols() == actual.cols() && expected.rows() == actual.rows();
}
}
static private void compareMats(Mat expected, Mat actual, boolean isEqualityMeasured) {
if (expected.type() != actual.type() || expected.cols() != actual.cols() || expected.rows() != actual.rows()) {
if (expected.type() != actual.type() || !dimensionsEqual(expected, actual)) {
throw new UnsupportedOperationException("Can not compare " + expected + " and " + actual);
}
......@@ -471,7 +492,7 @@ public class OpenCVTestCase extends TestCase {
}
static private void compareMats(Mat expected, Mat actual, double eps, boolean isEqualityMeasured) {
if (expected.type() != actual.type() || expected.cols() != actual.cols() || expected.rows() != actual.rows()) {
if (expected.type() != actual.type() || !dimensionsEqual(expected, actual)) {
throw new UnsupportedOperationException("Can not compare " + expected + " and " + actual);
}
......
......@@ -95,7 +95,7 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize, OpticalFlowPyrLK_full, testing::Combine(
typedef tuple<std::string, int, tuple<int, int>, int> Path_Idx_NPoints_WSize_t;
typedef TestBaseWithParam<Path_Idx_NPoints_WSize_t> Path_Idx_NPoints_WSize;
PERF_TEST_P(Path_Idx_NPoints_WSize, OpticalFlowPyrLK_ovx, testing::Combine(
PERF_TEST_P(Path_Idx_NPoints_WSize, DISABLED_OpticalFlowPyrLK_ovx, testing::Combine(
testing::Values<std::string>("cv/optflow/frames/VGA_%02d.png", "cv/optflow/frames/720p_%02d.png"),
testing::Range(1, 3),
testing::Values(make_tuple(9, 9), make_tuple(15, 15)),
......
......@@ -1590,6 +1590,10 @@ void handleMessage(GstElement * pipeline)
while(gst_bus_have_pending(bus)) {
msg = gst_bus_pop(bus);
if (!msg || !GST_IS_MESSAGE(msg))
{
continue;
}
if(gst_is_missing_plugin_message(msg))
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment