mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -1,171 +0,0 @@
|
||||
// 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.
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
#ifdef HAVE_IPP_A
|
||||
#include "opencv2/core/ippasync.hpp"
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
using namespace opencv_test;
|
||||
|
||||
namespace opencv_test {
|
||||
namespace ocl {
|
||||
|
||||
PARAM_TEST_CASE(IPPAsync, MatDepth, Channels, hppAccelType)
|
||||
{
|
||||
int type;
|
||||
int cn;
|
||||
int depth;
|
||||
hppAccelType accelType;
|
||||
|
||||
Mat matrix, result;
|
||||
hppiMatrix * hppMat;
|
||||
hppAccel accel;
|
||||
hppiVirtualMatrix * virtMatrix;
|
||||
hppStatus sts;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
type = CV_MAKE_TYPE(GET_PARAM(0), GET_PARAM(1));
|
||||
depth = GET_PARAM(0);
|
||||
cn = GET_PARAM(1);
|
||||
accelType = GET_PARAM(2);
|
||||
}
|
||||
|
||||
void generateTestData()
|
||||
{
|
||||
Size matrix_Size = randomSize(2, 100);
|
||||
const double upValue = 100;
|
||||
|
||||
matrix = randomMat(matrix_Size, type, -upValue, upValue);
|
||||
}
|
||||
|
||||
void Near(double threshold = 0.0)
|
||||
{
|
||||
EXPECT_MAT_NEAR(matrix, result, threshold);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(IPPAsync, accuracy)
|
||||
{
|
||||
sts = hppCreateInstance(accelType, 0, &accel);
|
||||
if (sts!=HPP_STATUS_NO_ERROR) printf("hppStatus = %d\n",sts);
|
||||
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
||||
|
||||
virtMatrix = hppiCreateVirtualMatrices(accel, 2);
|
||||
|
||||
for (int j = 0; j < test_loop_times; j++)
|
||||
{
|
||||
generateTestData();
|
||||
hppMat = hpp::getHpp(matrix,accel);
|
||||
|
||||
hppScalar a = 3;
|
||||
|
||||
sts = hppiAddC(accel, hppMat, a, 0, virtMatrix[0]);
|
||||
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
||||
sts = hppiSubC(accel, virtMatrix[0], a, 0, virtMatrix[1]);
|
||||
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
||||
|
||||
sts = hppWait(accel, HPP_TIME_OUT_INFINITE);
|
||||
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
||||
|
||||
result = hpp::getMat(virtMatrix[1], accel, cn);
|
||||
|
||||
Near(5.0e-6);
|
||||
|
||||
sts = hppiFreeMatrix(hppMat);
|
||||
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
||||
}
|
||||
|
||||
sts = hppiDeleteVirtualMatrices(accel, virtMatrix);
|
||||
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
||||
sts = hppDeleteInstance(accel);
|
||||
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
||||
}
|
||||
|
||||
PARAM_TEST_CASE(IPPAsyncShared, Channels, hppAccelType)
|
||||
{
|
||||
int cn;
|
||||
int type;
|
||||
hppAccelType accelType;
|
||||
|
||||
Mat matrix, result;
|
||||
hppiMatrix* hppMat;
|
||||
hppAccel accel;
|
||||
hppiVirtualMatrix * virtMatrix;
|
||||
hppStatus sts;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
cn = GET_PARAM(0);
|
||||
accelType = GET_PARAM(1);
|
||||
type=CV_MAKE_TYPE(CV_8U, GET_PARAM(0));
|
||||
}
|
||||
|
||||
void generateTestData()
|
||||
{
|
||||
Size matrix_Size = randomSize(2, 100);
|
||||
hpp32u pitch, size;
|
||||
const int upValue = 100;
|
||||
|
||||
sts = hppQueryMatrixAllocParams(accel, (hpp32u)(matrix_Size.width*cn), (hpp32u)matrix_Size.height, HPP_DATA_TYPE_8U, &pitch, &size);
|
||||
|
||||
matrix = randomMat(matrix_Size, type, 0, upValue);
|
||||
}
|
||||
|
||||
void Near(double threshold = 0.0)
|
||||
{
|
||||
EXPECT_MAT_NEAR(matrix, result, threshold);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(IPPAsyncShared, accuracy)
|
||||
{
|
||||
sts = hppCreateInstance(accelType, 0, &accel);
|
||||
if (sts!=HPP_STATUS_NO_ERROR) printf("hppStatus = %d\n",sts);
|
||||
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
||||
|
||||
virtMatrix = hppiCreateVirtualMatrices(accel, 2);
|
||||
|
||||
for (int j = 0; j < test_loop_times; j++)
|
||||
{
|
||||
generateTestData();
|
||||
hppMat = hpp::getHpp(matrix,accel);
|
||||
|
||||
hppScalar a = 3;
|
||||
|
||||
sts = hppiAddC(accel, hppMat, a, 0, virtMatrix[0]);
|
||||
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
||||
sts = hppiSubC(accel, virtMatrix[0], a, 0, virtMatrix[1]);
|
||||
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
||||
|
||||
sts = hppWait(accel, HPP_TIME_OUT_INFINITE);
|
||||
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
||||
|
||||
result = hpp::getMat(virtMatrix[1], accel, cn);
|
||||
|
||||
Near(0);
|
||||
|
||||
sts = hppiFreeMatrix(hppMat);
|
||||
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
||||
}
|
||||
|
||||
sts = hppiDeleteVirtualMatrices(accel, virtMatrix);
|
||||
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
||||
sts = hppDeleteInstance(accel);
|
||||
CV_Assert(sts==HPP_STATUS_NO_ERROR);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(IppATest, IPPAsyncShared, Combine(Values(1, 2, 3, 4),
|
||||
Values( HPP_ACCEL_TYPE_CPU, HPP_ACCEL_TYPE_GPU)));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(IppATest, IPPAsync, Combine(Values(CV_8U, CV_16U, CV_16S, CV_32F),
|
||||
Values(1, 2, 3, 4),
|
||||
Values( HPP_ACCEL_TYPE_CPU, HPP_ACCEL_TYPE_GPU)));
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -141,4 +141,14 @@ TEST(Core_LPSolver, regression_cycling){
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(Core_LPSolver, issue_12337)
|
||||
{
|
||||
Mat A=(cv::Mat_<double>(3,1)<<3,1,2);
|
||||
Mat B=(cv::Mat_<double>(3,4)<<1,1,3,30,2,2,5,24,4,1,2,36);
|
||||
EXPECT_ANY_THROW(Mat1f z_float; cv::solveLP(A, B, z_float));
|
||||
EXPECT_NO_THROW(Mat1d z_double; cv::solveLP(A, B, z_double));
|
||||
EXPECT_ANY_THROW(Mat1i z_int; cv::solveLP(A, B, z_int));
|
||||
//need to update interface: EXPECT_ANY_THROW(Mat1b z_8u; cv::solveLP(A, B, z_8u));
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
@@ -1872,4 +1872,63 @@ TEST(Core_Split, crash_12171)
|
||||
EXPECT_EQ(2, dst2.ptr<uchar>(1)[1]);
|
||||
}
|
||||
|
||||
struct CustomType // like cv::Keypoint
|
||||
{
|
||||
Point2f pt;
|
||||
float size;
|
||||
float angle;
|
||||
float response;
|
||||
int octave;
|
||||
int class_id;
|
||||
};
|
||||
|
||||
static void test_CustomType(InputArray src_, OutputArray dst_)
|
||||
{
|
||||
Mat src = src_.getMat();
|
||||
ASSERT_EQ(sizeof(CustomType), src.elemSize());
|
||||
CV_CheckTypeEQ(src.type(), CV_MAKETYPE(CV_8U, sizeof(CustomType)), "");
|
||||
|
||||
CustomType* kpt = NULL;
|
||||
{
|
||||
Mat dst = dst_.getMat();
|
||||
for (size_t i = 0; i < dst.total(); i++)
|
||||
{
|
||||
kpt = dst.ptr<CustomType>(0) + i;
|
||||
kpt->octave = (int)i;
|
||||
}
|
||||
}
|
||||
const int N = (int)src.total();
|
||||
dst_.create(1, N * 2, rawType<CustomType>());
|
||||
Mat dst = dst_.getMat();
|
||||
for (size_t i = N; i < dst.total(); i++)
|
||||
{
|
||||
kpt = dst.ptr<CustomType>(0) + i;
|
||||
kpt->octave = -(int)i;
|
||||
}
|
||||
#if 0 // Compilation error
|
||||
CustomType& kpt = dst.at<CustomType>(0, 5);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(Core_InputArray, support_CustomType)
|
||||
{
|
||||
std::vector<CustomType> kp1(5);
|
||||
std::vector<CustomType> kp2(3);
|
||||
test_CustomType(rawIn(kp1), rawOut(kp2));
|
||||
ASSERT_EQ((size_t)10, kp2.size());
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
EXPECT_EQ(i, kp2[i].octave);
|
||||
}
|
||||
for (int i = 3; i < 5; i++)
|
||||
{
|
||||
EXPECT_EQ(0, kp2[i].octave);
|
||||
}
|
||||
for (int i = 5; i < 10; i++)
|
||||
{
|
||||
EXPECT_EQ(-i, kp2[i].octave);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user