Commit f5b212a9 authored by Alexander Alekhin's avatar Alexander Alekhin

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

parents e31eb461 cae2992a
...@@ -56,7 +56,7 @@ macro(ocv_optimization_process_obsolete_option legacy_flag OPT legacy_warn) ...@@ -56,7 +56,7 @@ macro(ocv_optimization_process_obsolete_option legacy_flag OPT legacy_warn)
message(STATUS " Behaviour of this option is not backward compatible") message(STATUS " Behaviour of this option is not backward compatible")
message(STATUS " Refer to 'CPU_BASELINE'/'CPU_DISPATCH' CMake options documentation") message(STATUS " Refer to 'CPU_BASELINE'/'CPU_DISPATCH' CMake options documentation")
endif() endif()
if("${legacy_flag}") if("${${legacy_flag}}")
if(NOT ";${CPU_BASELINE_REQUIRE};" MATCHES ";${OPT};") if(NOT ";${CPU_BASELINE_REQUIRE};" MATCHES ";${OPT};")
set(CPU_BASELINE_REQUIRE "${CPU_BASELINE_REQUIRE};${OPT}" CACHE STRING "${HELP_CPU_BASELINE_REQUIRE}" FORCE) set(CPU_BASELINE_REQUIRE "${CPU_BASELINE_REQUIRE};${OPT}" CACHE STRING "${HELP_CPU_BASELINE_REQUIRE}" FORCE)
endif() endif()
......
...@@ -2291,10 +2291,15 @@ void testDivideChecks(const Mat& dst) ...@@ -2291,10 +2291,15 @@ void testDivideChecks(const Mat& dst)
{ {
for (int x = 0; x < dst.cols; x++) for (int x = 0; x < dst.cols; x++)
{ {
if (x == 2) if ((x % 4) == 2)
{ {
EXPECT_EQ(0, dst.at<T>(y, x)) << "dst(" << y << ", " << x << ") = " << dst.at<T>(y, x); EXPECT_EQ(0, dst.at<T>(y, x)) << "dst(" << y << ", " << x << ") = " << dst.at<T>(y, x);
} }
else
{
EXPECT_TRUE(0 == cvIsNaN((double)dst.at<T>(y, x))) << "dst(" << y << ", " << x << ") = " << dst.at<T>(y, x);
EXPECT_TRUE(0 == cvIsInf((double)dst.at<T>(y, x))) << "dst(" << y << ", " << x << ") = " << dst.at<T>(y, x);
}
} }
} }
} }
...@@ -2308,11 +2313,11 @@ void testDivideChecksFP(const Mat& dst) ...@@ -2308,11 +2313,11 @@ void testDivideChecksFP(const Mat& dst)
{ {
for (int x = 0; x < dst.cols; x++) for (int x = 0; x < dst.cols; x++)
{ {
if (y == 0 && x == 2) if ((y % 3) == 0 && (x % 4) == 2)
{ {
EXPECT_TRUE(cvIsNaN(dst.at<T>(y, x))) << "dst(" << y << ", " << x << ") = " << dst.at<T>(y, x); EXPECT_TRUE(cvIsNaN(dst.at<T>(y, x))) << "dst(" << y << ", " << x << ") = " << dst.at<T>(y, x);
} }
else if (x == 2) else if ((x % 4) == 2)
{ {
EXPECT_TRUE(cvIsInf(dst.at<T>(y, x))) << "dst(" << y << ", " << x << ") = " << dst.at<T>(y, x); EXPECT_TRUE(cvIsInf(dst.at<T>(y, x))) << "dst(" << y << ", " << x << ") = " << dst.at<T>(y, x);
} }
...@@ -2329,24 +2334,40 @@ template <> inline void testDivideChecks<float>(const Mat& dst) { testDivideChec ...@@ -2329,24 +2334,40 @@ template <> inline void testDivideChecks<float>(const Mat& dst) { testDivideChec
template <> inline void testDivideChecks<double>(const Mat& dst) { testDivideChecksFP<double>(dst); } template <> inline void testDivideChecks<double>(const Mat& dst) { testDivideChecksFP<double>(dst); }
template <typename T, bool isUMat> static inline template <typename T> static inline
void testDivide() void testDivide(bool isUMat, double scale, bool largeSize, bool tailProcessing, bool roi)
{ {
Mat src1, src2; Mat src1, src2;
testDivideInitData<T>(src1, src2); testDivideInitData<T>(src1, src2);
ASSERT_FALSE(src1.empty()); ASSERT_FALSE(src2.empty()); ASSERT_FALSE(src1.empty()); ASSERT_FALSE(src2.empty());
if (largeSize)
{
repeat(src1.clone(), 1, 8, src1);
repeat(src2.clone(), 1, 8, src2);
}
if (tailProcessing)
{
src1 = src1(Rect(0, 0, src1.cols - 1, src1.rows));
src2 = src2(Rect(0, 0, src2.cols - 1, src2.rows));
}
if (!roi && tailProcessing)
{
src1 = src1.clone();
src2 = src2.clone();
}
Mat dst; Mat dst;
if (!isUMat) if (!isUMat)
{ {
cv::divide(src1, src2, dst); cv::divide(src1, src2, dst, scale);
} }
else else
{ {
UMat usrc1, usrc2, udst; UMat usrc1, usrc2, udst;
src1.copyTo(usrc1); src1.copyTo(usrc1);
src2.copyTo(usrc2); src2.copyTo(usrc2);
cv::divide(usrc1, usrc2, udst); cv::divide(usrc1, usrc2, udst, scale);
udst.copyTo(dst); udst.copyTo(dst);
} }
...@@ -2360,14 +2381,46 @@ void testDivide() ...@@ -2360,14 +2381,46 @@ void testDivide()
} }
} }
TEST(Core_DivideRules, type_32s) { testDivide<int, false>(); } typedef tuple<bool, double, bool, bool, bool> DivideRulesParam;
TEST(UMat_Core_DivideRules, type_32s) { testDivide<int, true>(); } typedef testing::TestWithParam<DivideRulesParam> Core_DivideRules;
TEST(Core_DivideRules, type_16s) { testDivide<short, false>(); }
TEST(UMat_Core_DivideRules, type_16s) { testDivide<short, true>(); } TEST_P(Core_DivideRules, type_32s)
TEST(Core_DivideRules, type_32f) { testDivide<float, false>(); } {
TEST(UMat_Core_DivideRules, type_32f) { testDivide<float, true>(); } DivideRulesParam param = GetParam();
TEST(Core_DivideRules, type_64f) { testDivide<double, false>(); } testDivide<int>(get<0>(param), get<1>(param), get<2>(param), get<3>(param), get<4>(param));
TEST(UMat_Core_DivideRules, type_64f) { testDivide<double, true>(); } }
TEST_P(Core_DivideRules, type_16s)
{
DivideRulesParam param = GetParam();
testDivide<short>(get<0>(param), get<1>(param), get<2>(param), get<3>(param), get<4>(param));
}
TEST_P(Core_DivideRules, type_32f)
{
DivideRulesParam param = GetParam();
testDivide<float>(get<0>(param), get<1>(param), get<2>(param), get<3>(param), get<4>(param));
}
TEST_P(Core_DivideRules, type_64f)
{
DivideRulesParam param = GetParam();
testDivide<double>(get<0>(param), get<1>(param), get<2>(param), get<3>(param), get<4>(param));
}
INSTANTIATE_TEST_CASE_P(/* */, Core_DivideRules, testing::Combine(
/* isMat */ testing::Values(false),
/* scale */ testing::Values(1.0, 5.0),
/* largeSize */ testing::Bool(),
/* tail */ testing::Bool(),
/* roi */ testing::Bool()
));
INSTANTIATE_TEST_CASE_P(UMat, Core_DivideRules, testing::Combine(
/* isMat */ testing::Values(true),
/* scale */ testing::Values(1.0, 5.0),
/* largeSize */ testing::Bool(),
/* tail */ testing::Bool(),
/* roi */ testing::Bool()
));
TEST(Core_MinMaxIdx, rows_overflow) TEST(Core_MinMaxIdx, rows_overflow)
......
...@@ -1898,7 +1898,7 @@ struct Net::Impl ...@@ -1898,7 +1898,7 @@ struct Net::Impl
nextEltwiseLayer = nextData->layerInstance.dynamicCast<EltwiseLayer>(); nextEltwiseLayer = nextData->layerInstance.dynamicCast<EltwiseLayer>();
if( !nextEltwiseLayer.empty() && pinsToKeep.count(lpNext) == 0 && if( !nextEltwiseLayer.empty() && pinsToKeep.count(lpNext) == 0 &&
nextData->inputBlobsId.size() == 2 ) nextData && nextData->inputBlobsId.size() == 2 )
{ {
LayerData *eltwiseData = nextData; LayerData *eltwiseData = nextData;
......
...@@ -74,6 +74,17 @@ PERF_TEST_P_(Perf_Objdetect_Not_QRCode, detect) ...@@ -74,6 +74,17 @@ PERF_TEST_P_(Perf_Objdetect_Not_QRCode, detect)
RNG rng; RNG rng;
rng.fill(not_qr_code, RNG::UNIFORM, Scalar(0), Scalar(1)); rng.fill(not_qr_code, RNG::UNIFORM, Scalar(0), Scalar(1));
} }
if (type_gen == "chessboard")
{
uint8_t next_pixel = 0;
for (int r = 0; r < not_qr_code.rows * not_qr_code.cols; r++)
{
int i = r / not_qr_code.cols;
int j = r % not_qr_code.cols;
not_qr_code.ptr<uchar>(i)[j] = next_pixel;
next_pixel = 255 - next_pixel;
}
}
QRCodeDetector qrcode; QRCodeDetector qrcode;
TEST_CYCLE() ASSERT_FALSE(qrcode.detect(not_qr_code, corners)); TEST_CYCLE() ASSERT_FALSE(qrcode.detect(not_qr_code, corners));
...@@ -96,6 +107,17 @@ PERF_TEST_P_(Perf_Objdetect_Not_QRCode, decode) ...@@ -96,6 +107,17 @@ PERF_TEST_P_(Perf_Objdetect_Not_QRCode, decode)
RNG rng; RNG rng;
rng.fill(not_qr_code, RNG::UNIFORM, Scalar(0), Scalar(1)); rng.fill(not_qr_code, RNG::UNIFORM, Scalar(0), Scalar(1));
} }
if (type_gen == "chessboard")
{
uint8_t next_pixel = 0;
for (int r = 0; r < not_qr_code.rows * not_qr_code.cols; r++)
{
int i = r / not_qr_code.cols;
int j = r % not_qr_code.cols;
not_qr_code.ptr<uchar>(i)[j] = next_pixel;
next_pixel = 255 - next_pixel;
}
}
QRCodeDetector qrcode; QRCodeDetector qrcode;
TEST_CYCLE() ASSERT_TRUE(qrcode.decode(not_qr_code, corners, straight_barcode).empty()); TEST_CYCLE() ASSERT_TRUE(qrcode.decode(not_qr_code, corners, straight_barcode).empty());
...@@ -105,8 +127,9 @@ PERF_TEST_P_(Perf_Objdetect_Not_QRCode, decode) ...@@ -105,8 +127,9 @@ PERF_TEST_P_(Perf_Objdetect_Not_QRCode, decode)
INSTANTIATE_TEST_CASE_P(/*nothing*/, Perf_Objdetect_Not_QRCode, INSTANTIATE_TEST_CASE_P(/*nothing*/, Perf_Objdetect_Not_QRCode,
::testing::Combine( ::testing::Combine(
::testing::Values("zero", "random"), ::testing::Values("zero", "random", "chessboard"),
::testing::Values(Size(640, 480), Size(1280, 720), Size(1920, 1080)) ::testing::Values(Size(640, 480), Size(1280, 720),
Size(1920, 1080), Size(3840, 2160))
)); ));
} }
......
This diff is collapsed.
...@@ -348,7 +348,9 @@ struct CvCaptureCAM_V4L CV_FINAL : public CvCapture ...@@ -348,7 +348,9 @@ struct CvCaptureCAM_V4L CV_FINAL : public CvCapture
/*********************** Implementations ***************************************/ /*********************** Implementations ***************************************/
CvCaptureCAM_V4L::CvCaptureCAM_V4L() : deviceHandle(-1), bufferIndex(-1) CvCaptureCAM_V4L::CvCaptureCAM_V4L() : deviceHandle(-1), bufferIndex(-1)
{} {
memset(&timestamp, 0, sizeof(timestamp));
}
CvCaptureCAM_V4L::~CvCaptureCAM_V4L() { CvCaptureCAM_V4L::~CvCaptureCAM_V4L() {
streaming(false); streaming(false);
...@@ -1739,7 +1741,6 @@ double CvCaptureCAM_V4L::getProperty(int property_id) const ...@@ -1739,7 +1741,6 @@ double CvCaptureCAM_V4L::getProperty(int property_id) const
return value; return value;
} }
} }
return -1.0;
} }
bool CvCaptureCAM_V4L::icvSetFrameSize(int _width, int _height) bool CvCaptureCAM_V4L::icvSetFrameSize(int _width, int _height)
......
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