mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Merge branch 4.x
This commit is contained in:
@@ -3481,7 +3481,7 @@ TEST_P(NonZeroSupportedMatDepth, hasNonZero)
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
NonZero,
|
||||
NonZeroSupportedMatDepth,
|
||||
testing::Values(perf::MatDepth(CV_16F), CV_16BF, CV_Bool, CV_64U, CV_64S, CV_32U)
|
||||
testing::Values(CV_16BF, CV_Bool, CV_64U, CV_64S, CV_32U)
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -3498,7 +3498,7 @@ TEST_P(LutNotSupportedMatDepth, lut)
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
Lut,
|
||||
LutNotSupportedMatDepth,
|
||||
testing::Values(perf::MatDepth(CV_16F), CV_16BF, CV_Bool, CV_64U, CV_64S, CV_32U)
|
||||
testing::Values(CV_16BF, CV_Bool, CV_64U, CV_64S, CV_32U)
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -3526,4 +3526,103 @@ INSTANTIATE_TEST_CASE_P(
|
||||
testing::Values(perf::MatDepth(CV_16F), CV_16BF, CV_Bool, CV_64U, CV_64S, CV_32U)
|
||||
);
|
||||
|
||||
CV_ENUM(LutMatType, CV_8U, CV_16U, CV_16F, CV_32S, CV_32F, CV_64F)
|
||||
|
||||
struct Core_LUT: public testing::TestWithParam<LutMatType>
|
||||
{
|
||||
template<typename T, int ch>
|
||||
cv::Mat referenceWithType(cv::Mat input, cv::Mat table)
|
||||
{
|
||||
cv::Mat ref(input.size(), CV_MAKE_TYPE(table.type(), ch));
|
||||
for (int i = 0; i < input.rows; i++)
|
||||
{
|
||||
for (int j = 0; j < input.cols; j++)
|
||||
{
|
||||
if(ch == 1)
|
||||
{
|
||||
ref.at<T>(i, j) = table.at<T>(input.at<uchar>(i, j));
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec<T, ch> val;
|
||||
for (int k = 0; k < ch; k++)
|
||||
{
|
||||
val[k] = table.at<T>(input.at<Vec<uchar, ch>>(i, j)[k]);
|
||||
}
|
||||
ref.at<Vec<T, ch>>(i, j) = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ref;
|
||||
}
|
||||
|
||||
template<int ch = 1>
|
||||
cv::Mat reference(cv::Mat input, cv::Mat table)
|
||||
{
|
||||
if (table.type() == CV_8U)
|
||||
{
|
||||
return referenceWithType<uchar, ch>(input, table);
|
||||
}
|
||||
else if (table.type() == CV_16U)
|
||||
{
|
||||
return referenceWithType<ushort, ch>(input, table);
|
||||
}
|
||||
else if (table.type() == CV_16F)
|
||||
{
|
||||
return referenceWithType<ushort, ch>(input, table);
|
||||
}
|
||||
else if (table.type() == CV_32S)
|
||||
{
|
||||
return referenceWithType<int, ch>(input, table);
|
||||
}
|
||||
else if (table.type() == CV_32F)
|
||||
{
|
||||
return referenceWithType<float, ch>(input, table);
|
||||
}
|
||||
else if (table.type() == CV_64F)
|
||||
{
|
||||
return referenceWithType<double, ch>(input, table);
|
||||
}
|
||||
|
||||
return cv::Mat();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Core_LUT, accuracy)
|
||||
{
|
||||
int type = GetParam();
|
||||
cv::Mat input(117, 113, CV_8UC1);
|
||||
randu(input, 0, 256);
|
||||
|
||||
cv::Mat table(1, 256, CV_MAKE_TYPE(type, 1));
|
||||
randu(table, 0, 127);
|
||||
|
||||
cv::Mat output;
|
||||
cv::LUT(input, table, output);
|
||||
|
||||
cv::Mat gt = reference(input, table);
|
||||
|
||||
ASSERT_EQ(0, cv::norm(output, gt, cv::NORM_INF));
|
||||
}
|
||||
|
||||
TEST_P(Core_LUT, accuracy_multi)
|
||||
{
|
||||
int type = (int)GetParam();
|
||||
cv::Mat input(117, 113, CV_8UC3);
|
||||
randu(input, 0, 256);
|
||||
|
||||
cv::Mat table(1, 256, CV_MAKE_TYPE(type, 1));
|
||||
randu(table, 0, 127);
|
||||
|
||||
cv::Mat output;
|
||||
cv::LUT(input, table, output);
|
||||
|
||||
cv::Mat gt = reference<3>(input, table);
|
||||
|
||||
ASSERT_EQ(0, cv::norm(output, gt, cv::NORM_INF));
|
||||
}
|
||||
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/**/, Core_LUT, LutMatType::all());
|
||||
|
||||
}} // namespace
|
||||
|
||||
@@ -2263,6 +2263,27 @@ TEST(Core_Eigen, eigen2cv_check_Mat_type)
|
||||
EXPECT_ANY_THROW(eigen2cv(eigen_A, d_mat));
|
||||
//EXPECT_EQ(CV_64FC1, d_mat.type());
|
||||
}
|
||||
|
||||
TEST(Core_Eigen, cv2eigen_check_RowMajor)
|
||||
{
|
||||
Mat A(3, 2, CV_32FC1, Scalar::all(0));
|
||||
A.at<float>(0,0) = 1.0;
|
||||
A.at<float>(0,1) = 2.0;
|
||||
A.at<float>(1,0) = 3.0;
|
||||
A.at<float>(1,1) = 4.0;
|
||||
A.at<float>(2,0) = 5.0;
|
||||
A.at<float>(2,1) = 6.0;
|
||||
|
||||
Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> eigen_A;
|
||||
EXPECT_NO_THROW(cv2eigen(A, eigen_A));
|
||||
|
||||
ASSERT_EQ(1.0, eigen_A(0, 0));
|
||||
ASSERT_EQ(2.0, eigen_A(0, 1));
|
||||
ASSERT_EQ(3.0, eigen_A(1, 0));
|
||||
ASSERT_EQ(4.0, eigen_A(1, 1));
|
||||
ASSERT_EQ(5.0, eigen_A(2, 0));
|
||||
ASSERT_EQ(6.0, eigen_A(2, 1));
|
||||
}
|
||||
#endif // HAVE_EIGEN
|
||||
|
||||
#ifdef OPENCV_EIGEN_TENSOR_SUPPORT
|
||||
|
||||
Reference in New Issue
Block a user