1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

Merge pull request #12674 from dmatveev:gapi_upd270918

* Update G-API code base to 27-Sep-18

Changes mostly improve standalone build support

* G-API code base update 28-09-2018

* Windows/Documentation warnings should be fixed
* Fixed stability issues in Fluid backend
* Fixed precompiled headers issues in G-API source files

* G-API code base update 28-09-18 EOD

* Fixed several static analysis issues
* Fixed issues found when G-API is built in a standalone mode
This commit is contained in:
Dmitry Matveev
2018-09-28 18:42:09 +03:00
committed by Alexander Alekhin
parent 66fdddc339
commit 2c6ab65476
64 changed files with 981 additions and 223 deletions
@@ -5,4 +5,5 @@
// Copyright (C) 2018 Intel Corporation
#include "test_precomp.hpp"
#include "gapi_core_tests_inl.hpp"
@@ -5,4 +5,5 @@
// Copyright (C) 2018 Intel Corporation
#include "test_precomp.hpp"
#include "gapi_imgproc_tests_inl.hpp"
@@ -5,4 +5,5 @@
// Copyright (C) 2018 Intel Corporation
#include "test_precomp.hpp"
#include "gapi_operators_tests_inl.hpp"
@@ -5,6 +5,7 @@
// Copyright (C) 2018 Intel Corporation
#include "test_precomp.hpp"
#include "../common/gapi_operators_tests.hpp"
#include "opencv2/gapi/cpu/core.hpp"
+4 -4
View File
@@ -50,7 +50,7 @@ TEST(FluidBuffer, InputTest)
const cv::Size buffer_size = {8,8};
cv::Mat in_mat = cv::Mat::eye(buffer_size, CV_8U);
cv::gapi::fluid::Buffer buffer(in_mat, true);
cv::gapi::fluid::Buffer buffer(to_own(in_mat), true);
cv::gapi::fluid::View view = buffer.mkView(1, 0, {}, false);
view.priv().reset(1);
int this_y = 0;
@@ -152,7 +152,7 @@ TEST(FluidBuffer, OutputTest)
const cv::Size buffer_size = {8,16};
cv::Mat out_mat = cv::Mat(buffer_size, CV_8U);
cv::gapi::fluid::Buffer buffer(out_mat, false);
cv::gapi::fluid::Buffer buffer(to_own(out_mat), false);
int num_writes = 0;
while (num_writes < buffer_size.height)
{
@@ -417,7 +417,7 @@ TEST(Fluid, MultipleReaders_DifferentLatency)
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
}
TEST(Fluid, DISABLED_MultipleOutputs)
TEST(Fluid, MultipleOutputs)
{
// in -> AddC -> a -> AddC ------------------> out1
// `--> Id7x7 --> b --> AddC -> out2
@@ -464,7 +464,7 @@ TEST(Fluid, EmptyOutputMatTest)
}
struct LPISequenceTest : public TestWithParam<int>{};
TEST_P(LPISequenceTest, DISABLED_LPISequenceTest)
TEST_P(LPISequenceTest, LPISequenceTest)
{
// in -> AddC -> a -> Blur (2lpi) -> out
@@ -4,6 +4,8 @@
//
// Copyright (C) 2018 Intel Corporation
#include "test_precomp.hpp"
#include <iomanip>
#include "gapi_fluid_test_kernels.hpp"
#include <opencv2/gapi/core.hpp>
+223
View File
@@ -33,12 +33,46 @@ TEST(OwnMat, Create)
ASSERT_NE(m.data, nullptr);
ASSERT_EQ((cv::gapi::own::Size{m.cols, m.rows}), size);
ASSERT_EQ(m.total(), static_cast<size_t>(size.height*size.width));
ASSERT_EQ(m.type(), CV_8UC1);
ASSERT_EQ(m.depth(), CV_8U);
ASSERT_EQ(m.channels(), 1);
ASSERT_EQ(m.elemSize(), sizeof(uint8_t));
ASSERT_EQ(m.step, sizeof(uint8_t) * m.cols);
}
TEST(OwnMat, CreateOverload)
{
auto size = cv::gapi::own::Size{32,16};
Mat m;
m.create(size.height,size.width, CV_8UC1);
ASSERT_NE(m.data, nullptr);
ASSERT_EQ((cv::Size{m.cols, m.rows}), size);
ASSERT_EQ(m.total(), static_cast<size_t>(size.height*size.width));
ASSERT_EQ(m.type(), CV_8UC1);
ASSERT_EQ(m.depth(), CV_8U);
ASSERT_EQ(m.channels(), 1);
ASSERT_EQ(m.elemSize(), sizeof(uint8_t));
ASSERT_EQ(m.step, sizeof(uint8_t) * m.cols);
}
TEST(OwnMat, Create3chan)
{
auto size = cv::Size{32,16};
Mat m;
m.create(size, CV_8UC3);
ASSERT_NE(m.data, nullptr);
ASSERT_EQ((cv::Size{m.cols, m.rows}), size);
ASSERT_EQ(m.type(), CV_8UC3);
ASSERT_EQ(m.depth(), CV_8U);
ASSERT_EQ(m.channels(), 3);
ASSERT_EQ(m.elemSize(), 3 * sizeof(uint8_t));
ASSERT_EQ(m.step, 3* sizeof(uint8_t) * m.cols);
}
struct NonEmptyMat {
cv::gapi::own::Size size{32,16};
Mat m;
@@ -160,5 +194,194 @@ TEST(OwnMatConversion, WithStep)
<< (cvMat != cvMatFromOwn);
}
TEST(OwnMat, PtrWithStep)
{
constexpr int width = 8;
constexpr int height = 8;
constexpr int stepInPixels = 16;
std::array<int, height * stepInPixels> data;
for (size_t i = 0; i < data.size(); i++)
{
data[i] = static_cast<int>(i);
}
Mat mat(height, width, CV_32S, data.data(), stepInPixels * sizeof(int));
EXPECT_EQ(& data[0], reinterpret_cast<int*>(mat.ptr(0)));
EXPECT_EQ(& data[1], reinterpret_cast<int*>(mat.ptr(0, 1)));
EXPECT_EQ(& data[stepInPixels], reinterpret_cast<int*>(mat.ptr(1)));
EXPECT_EQ(& data[stepInPixels +1], reinterpret_cast<int*>(mat.ptr(1,1)));
auto const& cmat = mat;
EXPECT_EQ(& data[0], reinterpret_cast<const int*>(cmat.ptr(0)));
EXPECT_EQ(& data[1], reinterpret_cast<const int*>(cmat.ptr(0, 1)));
EXPECT_EQ(& data[stepInPixels], reinterpret_cast<const int*>(cmat.ptr(1)));
EXPECT_EQ(& data[stepInPixels +1], reinterpret_cast<const int*>(cmat.ptr(1,1)));
}
TEST(OwnMat, CopyToWithStep)
{
constexpr int width = 8;
constexpr int height = 8;
constexpr int stepInPixels = 16;
std::array<int, height * stepInPixels> data;
for (size_t i = 0; i < data.size(); i++)
{
data[i] = static_cast<int>(i);
}
Mat mat(height, width, CV_32S, data.data(), stepInPixels * sizeof(int));
Mat dst;
mat.copyTo(dst);
EXPECT_NE(mat.data, dst.data);
EXPECT_EQ(0, cv::countNonZero(to_ocv(mat) != to_ocv(dst)))
<< to_ocv(mat) << std::endl
<< (to_ocv(mat) != to_ocv(dst));
}
TEST(OwnMat, ScalarAssign32SC1)
{
constexpr int width = 8;
constexpr int height = 8;
constexpr int stepInPixels = 16;
std::array<int, height * stepInPixels> data;
for (size_t i = 0; i < data.size(); i++)
{
data[i] = static_cast<int>(i);
}
Mat mat(height, width, CV_32S, data.data(), stepInPixels * sizeof(data[0]));
mat = cv::gapi::own::Scalar{-1};
std::array<int, height * stepInPixels> expected;
for (size_t row = 0; row < height; row++)
{
for (size_t col = 0; col < stepInPixels; col++)
{
auto index = row*stepInPixels + col;
expected[index] = col < width ? -1 : static_cast<int>(index);
}
}
auto cmp_result_mat = (cv::Mat{height, stepInPixels, CV_32S, data.data()} != cv::Mat{height, stepInPixels, CV_32S, expected.data()});
EXPECT_EQ(0, cv::countNonZero(cmp_result_mat))
<< cmp_result_mat << std::endl;
}
TEST(OwnMat, ScalarAssign8UC1)
{
constexpr int width = 8;
constexpr int height = 8;
constexpr int stepInPixels = 16;
std::array<uchar, height * stepInPixels> data;
for (size_t i = 0; i < data.size(); i++)
{
data[i] = static_cast<uchar>(i);
}
Mat mat(height, width, CV_8U, data.data(), stepInPixels * sizeof(data[0]));
mat = cv::gapi::own::Scalar{-1};
std::array<uchar, height * stepInPixels> expected;
for (size_t row = 0; row < height; row++)
{
for (size_t col = 0; col < stepInPixels; col++)
{
auto index = row*stepInPixels + col;
expected[index] = col < width ? cv::saturate_cast<uchar>(-1) : static_cast<uchar>(index);
}
}
auto cmp_result_mat = (cv::Mat{height, stepInPixels, CV_8U, data.data()} != cv::Mat{height, stepInPixels, CV_8U, expected.data()});
EXPECT_EQ(0, cv::countNonZero(cmp_result_mat))
<< cmp_result_mat << std::endl;
}
TEST(OwnMat, ScalarAssign8UC3)
{
constexpr auto cv_type = CV_8SC3;
constexpr int channels = 3;
constexpr int width = 8;
constexpr int height = 8;
constexpr int stepInPixels = 16;
std::array<schar, height * stepInPixels * channels> data;
for (size_t i = 0; i < data.size(); i+= channels)
{
data[i + 0] = static_cast<schar>(10 * i + 0);
data[i + 1] = static_cast<schar>(10 * i + 1);
data[i + 2] = static_cast<schar>(10 * i + 2);
}
Mat mat(height, width, cv_type, data.data(), channels * stepInPixels * sizeof(data[0]));
mat = cv::gapi::own::Scalar{-10, -11, -12};
std::array<schar, data.size()> expected;
for (size_t row = 0; row < height; row++)
{
for (size_t col = 0; col < stepInPixels; col++)
{
int index = static_cast<int>(channels * (row*stepInPixels + col));
expected[index + 0] = static_cast<schar>(col < width ? -10 : 10 * index + 0);
expected[index + 1] = static_cast<schar>(col < width ? -11 : 10 * index + 1);
expected[index + 2] = static_cast<schar>(col < width ? -12 : 10 * index + 2);
}
}
auto cmp_result_mat = (cv::Mat{height, stepInPixels, cv_type, data.data()} != cv::Mat{height, stepInPixels, cv_type, expected.data()});
EXPECT_EQ(0, cv::countNonZero(cmp_result_mat))
<< cmp_result_mat << std::endl
<< "data : " << std::endl
<< cv::Mat{height, stepInPixels, cv_type, data.data()} << std::endl
<< "expected : " << std::endl
<< cv::Mat{height, stepInPixels, cv_type, expected.data()} << std::endl;
}
TEST(OwnMat, ROIView)
{
constexpr int width = 8;
constexpr int height = 8;
constexpr int stepInPixels = 16;
std::array<uchar, height * stepInPixels> data;
for (size_t i = 0; i < data.size(); i++)
{
data[i] = static_cast<uchar>(i);
}
// std::cout<<cv::Mat{height, stepInPixels, CV_8U, data.data()}<<std::endl;
std::array<uchar, 4 * 4> expected;
for (size_t row = 0; row < 4; row++)
{
for (size_t col = 0; col < 4; col++)
{
expected[row*4 +col] = static_cast<uchar>(stepInPixels * (2 + row) + 2 + col);
}
}
Mat mat(height, width, CV_8U, data.data(), stepInPixels * sizeof(data[0]));
Mat roi_view (mat, cv::gapi::own::Rect{2,2,4,4});
// std::cout<<cv::Mat{4, 4, CV_8U, expected.data()}<<std::endl;
//
auto expected_cv_mat = cv::Mat{4, 4, CV_8U, expected.data()};
auto cmp_result_mat = (to_ocv(roi_view) != expected_cv_mat);
EXPECT_EQ(0, cv::countNonZero(cmp_result_mat))
<< cmp_result_mat << std::endl
<< to_ocv(roi_view) << std::endl
<< expected_cv_mat << std::endl;
}
} // namespace opencv_test