Fix binary compatibility of opencv_gpu
This commit is contained in:

committed by
Andrey Kamaev

parent
ed51162568
commit
e5437e5486
@@ -118,7 +118,7 @@ int main(int argc, char** argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
const std::string keys =
|
||||
const char* keys =
|
||||
"{ h help ? | | Print help}"
|
||||
"{ i info | | Print information about system and exit }"
|
||||
"{ device | -1 | Device on which tests will be executed (-1 means all devices) }"
|
||||
@@ -127,16 +127,16 @@ int main(int argc, char** argv)
|
||||
|
||||
CommandLineParser cmd(argc, (const char**)argv, keys);
|
||||
|
||||
if (cmd.has("help"))
|
||||
if (cmd.get<bool>("help"))
|
||||
{
|
||||
cmd.printMessage();
|
||||
cmd.printParams();
|
||||
return 0;
|
||||
}
|
||||
|
||||
printOsInfo();
|
||||
printCudaInfo();
|
||||
|
||||
if (cmd.has("info"))
|
||||
if (cmd.get<bool>("info"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1543,117 +1543,6 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Compare_Array, testing::Combine(
|
||||
ALL_CMP_CODES,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Compare_Scalar
|
||||
|
||||
namespace
|
||||
{
|
||||
template <template <typename> class Op, typename T>
|
||||
void compareScalarImpl(const cv::Mat& src, cv::Scalar sc, cv::Mat& dst)
|
||||
{
|
||||
Op<T> op;
|
||||
|
||||
const int cn = src.channels();
|
||||
|
||||
dst.create(src.size(), CV_MAKE_TYPE(CV_8U, cn));
|
||||
|
||||
for (int y = 0; y < src.rows; ++y)
|
||||
{
|
||||
for (int x = 0; x < src.cols; ++x)
|
||||
{
|
||||
for (int c = 0; c < cn; ++c)
|
||||
{
|
||||
T src_val = src.at<T>(y, x * cn + c);
|
||||
T sc_val = cv::saturate_cast<T>(sc.val[c]);
|
||||
dst.at<uchar>(y, x * cn + c) = static_cast<uchar>(static_cast<int>(op(src_val, sc_val)) * 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void compareScalarGold(const cv::Mat& src, cv::Scalar sc, cv::Mat& dst, int cmpop)
|
||||
{
|
||||
typedef void (*func_t)(const cv::Mat& src, cv::Scalar sc, cv::Mat& dst);
|
||||
static const func_t funcs[7][6] =
|
||||
{
|
||||
{compareScalarImpl<std::equal_to, unsigned char> , compareScalarImpl<std::greater, unsigned char> , compareScalarImpl<std::greater_equal, unsigned char> , compareScalarImpl<std::less, unsigned char> , compareScalarImpl<std::less_equal, unsigned char> , compareScalarImpl<std::not_equal_to, unsigned char> },
|
||||
{compareScalarImpl<std::equal_to, signed char> , compareScalarImpl<std::greater, signed char> , compareScalarImpl<std::greater_equal, signed char> , compareScalarImpl<std::less, signed char> , compareScalarImpl<std::less_equal, signed char> , compareScalarImpl<std::not_equal_to, signed char> },
|
||||
{compareScalarImpl<std::equal_to, unsigned short>, compareScalarImpl<std::greater, unsigned short>, compareScalarImpl<std::greater_equal, unsigned short>, compareScalarImpl<std::less, unsigned short>, compareScalarImpl<std::less_equal, unsigned short>, compareScalarImpl<std::not_equal_to, unsigned short>},
|
||||
{compareScalarImpl<std::equal_to, short> , compareScalarImpl<std::greater, short> , compareScalarImpl<std::greater_equal, short> , compareScalarImpl<std::less, short> , compareScalarImpl<std::less_equal, short> , compareScalarImpl<std::not_equal_to, short> },
|
||||
{compareScalarImpl<std::equal_to, int> , compareScalarImpl<std::greater, int> , compareScalarImpl<std::greater_equal, int> , compareScalarImpl<std::less, int> , compareScalarImpl<std::less_equal, int> , compareScalarImpl<std::not_equal_to, int> },
|
||||
{compareScalarImpl<std::equal_to, float> , compareScalarImpl<std::greater, float> , compareScalarImpl<std::greater_equal, float> , compareScalarImpl<std::less, float> , compareScalarImpl<std::less_equal, float> , compareScalarImpl<std::not_equal_to, float> },
|
||||
{compareScalarImpl<std::equal_to, double> , compareScalarImpl<std::greater, double> , compareScalarImpl<std::greater_equal, double> , compareScalarImpl<std::less, double> , compareScalarImpl<std::less_equal, double> , compareScalarImpl<std::not_equal_to, double> }
|
||||
};
|
||||
|
||||
funcs[src.depth()][cmpop](src, sc, dst);
|
||||
}
|
||||
}
|
||||
|
||||
PARAM_TEST_CASE(Compare_Scalar, cv::gpu::DeviceInfo, cv::Size, MatType, CmpCode, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
int type;
|
||||
int cmp_code;
|
||||
bool useRoi;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
devInfo = GET_PARAM(0);
|
||||
size = GET_PARAM(1);
|
||||
type = GET_PARAM(2);
|
||||
cmp_code = GET_PARAM(3);
|
||||
useRoi = GET_PARAM(4);
|
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Compare_Scalar, Accuracy)
|
||||
{
|
||||
cv::Mat src = randomMat(size, type);
|
||||
cv::Scalar sc = randomScalar(0.0, 255.0);
|
||||
|
||||
if (src.depth() < CV_32F)
|
||||
{
|
||||
sc.val[0] = cvRound(sc.val[0]);
|
||||
sc.val[1] = cvRound(sc.val[1]);
|
||||
sc.val[2] = cvRound(sc.val[2]);
|
||||
sc.val[3] = cvRound(sc.val[3]);
|
||||
}
|
||||
|
||||
if (src.depth() == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))
|
||||
{
|
||||
try
|
||||
{
|
||||
cv::gpu::GpuMat dst;
|
||||
cv::gpu::compare(loadMat(src), sc, dst, cmp_code);
|
||||
}
|
||||
catch (const cv::Exception& e)
|
||||
{
|
||||
ASSERT_EQ(CV_StsUnsupportedFormat, e.code);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::gpu::GpuMat dst = createMat(size, CV_MAKE_TYPE(CV_8U, src.channels()), useRoi);
|
||||
|
||||
cv::gpu::compare(loadMat(src, useRoi), sc, dst, cmp_code);
|
||||
|
||||
cv::Mat dst_gold;
|
||||
compareScalarGold(src, sc, dst_gold, cmp_code);
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Core, Compare_Scalar, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
TYPES(CV_8U, CV_64F, 1, 4),
|
||||
ALL_CMP_CODES,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Bitwise_Array
|
||||
|
||||
|
@@ -570,7 +570,8 @@ PARAM_TEST_CASE(BruteForceMatcher, cv::gpu::DeviceInfo, NormCode, DescriptorSize
|
||||
|
||||
TEST_P(BruteForceMatcher, Match_Single)
|
||||
{
|
||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(
|
||||
cv::gpu::BruteForceMatcher_GPU_base::DistType((normCode -2) / 2));
|
||||
|
||||
cv::gpu::GpuMat mask;
|
||||
if (useMask)
|
||||
@@ -597,7 +598,8 @@ TEST_P(BruteForceMatcher, Match_Single)
|
||||
|
||||
TEST_P(BruteForceMatcher, Match_Collection)
|
||||
{
|
||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(
|
||||
cv::gpu::BruteForceMatcher_GPU_base::DistType((normCode -2) / 2));
|
||||
|
||||
cv::gpu::GpuMat d_train(train);
|
||||
|
||||
@@ -651,7 +653,8 @@ TEST_P(BruteForceMatcher, Match_Collection)
|
||||
|
||||
TEST_P(BruteForceMatcher, KnnMatch_2_Single)
|
||||
{
|
||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(
|
||||
cv::gpu::BruteForceMatcher_GPU_base::DistType((normCode -2) / 2));
|
||||
|
||||
const int knn = 2;
|
||||
|
||||
@@ -690,7 +693,8 @@ TEST_P(BruteForceMatcher, KnnMatch_2_Single)
|
||||
|
||||
TEST_P(BruteForceMatcher, KnnMatch_3_Single)
|
||||
{
|
||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(
|
||||
cv::gpu::BruteForceMatcher_GPU_base::DistType((normCode -2) / 2));
|
||||
|
||||
const int knn = 3;
|
||||
|
||||
@@ -729,7 +733,8 @@ TEST_P(BruteForceMatcher, KnnMatch_3_Single)
|
||||
|
||||
TEST_P(BruteForceMatcher, KnnMatch_2_Collection)
|
||||
{
|
||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(
|
||||
cv::gpu::BruteForceMatcher_GPU_base::DistType((normCode -2) / 2));
|
||||
|
||||
const int knn = 2;
|
||||
|
||||
@@ -791,7 +796,8 @@ TEST_P(BruteForceMatcher, KnnMatch_2_Collection)
|
||||
|
||||
TEST_P(BruteForceMatcher, KnnMatch_3_Collection)
|
||||
{
|
||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(
|
||||
cv::gpu::BruteForceMatcher_GPU_base::DistType((normCode -2) / 2));
|
||||
|
||||
const int knn = 3;
|
||||
|
||||
@@ -853,7 +859,8 @@ TEST_P(BruteForceMatcher, KnnMatch_3_Collection)
|
||||
|
||||
TEST_P(BruteForceMatcher, RadiusMatch_Single)
|
||||
{
|
||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(
|
||||
cv::gpu::BruteForceMatcher_GPU_base::DistType((normCode -2) / 2));
|
||||
|
||||
const float radius = 1.f / countFactor;
|
||||
|
||||
@@ -902,7 +909,8 @@ TEST_P(BruteForceMatcher, RadiusMatch_Single)
|
||||
|
||||
TEST_P(BruteForceMatcher, RadiusMatch_Collection)
|
||||
{
|
||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(
|
||||
cv::gpu::BruteForceMatcher_GPU_base::DistType((normCode -2) / 2));
|
||||
|
||||
const int n = 3;
|
||||
const float radius = 1.f / countFactor * n;
|
||||
|
Reference in New Issue
Block a user