1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00

Compare commits

...

6 Commits

Author SHA1 Message Date
Liubov Batanina 898c639f6a Added ngraph::op::v6::MVN
original commit: 8d29a902e4
2021-03-12 22:20:03 +03:00
Liubov Batanina 9cf89fbe89 Added ngraph::op::v4::Interpolation
original commit: 95ab9468c1
2021-03-12 22:19:43 +03:00
APrigarina 130257f8e7 fix false positive detection
original commit: 125cc79c17
2021-03-05 11:40:37 +03:00
Liubov Batanina fd5337d532 Determine layout
original commit: 94533e12eb
2021-03-04 15:02:44 +03:00
Alexander Alekhin 0fe0a0237a OpenCV version '-openvino' 2021-03-03 16:07:58 +03:00
Alexander Alekhin 6291503793 dnn: use OpenVINO 2021.3 defines 2021-03-03 16:07:58 +03:00
7 changed files with 82 additions and 13 deletions
+2 -2
View File
@@ -135,9 +135,9 @@ endif()
if(INF_ENGINE_TARGET)
if(NOT INF_ENGINE_RELEASE)
message(WARNING "InferenceEngine version has not been set, 2021.2 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.")
message(WARNING "InferenceEngine version has not been set, 2021.3 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.")
endif()
set(INF_ENGINE_RELEASE "2021020000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2020.1.0.2 -> 2020010002)")
set(INF_ENGINE_RELEASE "2021030000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2020.1.0.2 -> 2020010002)")
set_target_properties(${INF_ENGINE_TARGET} PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "HAVE_INF_ENGINE=1;INF_ENGINE_RELEASE=${INF_ENGINE_RELEASE}"
)
@@ -8,7 +8,7 @@
#define CV_VERSION_MAJOR 4
#define CV_VERSION_MINOR 5
#define CV_VERSION_REVISION 2
#define CV_VERSION_STATUS "-pre"
#define CV_VERSION_STATUS "-openvino"
#define CVAUX_STR_EXP(__A) #__A
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
+6
View File
@@ -772,8 +772,14 @@ static InferenceEngine::Layout estimateLayout(const Mat& m)
{
if (m.dims == 4)
return InferenceEngine::Layout::NCHW;
else if (m.dims == 3)
return InferenceEngine::Layout::CHW;
else if (m.dims == 2)
return InferenceEngine::Layout::NC;
else if (m.dims == 1)
return InferenceEngine::Layout::C;
else if (m.dims == 5)
return InferenceEngine::Layout::NCDHW;
else
return InferenceEngine::Layout::ANY;
}
+8
View File
@@ -403,7 +403,15 @@ public:
const std::vector<Ptr<BackendNode> >& nodes) CV_OVERRIDE
{
auto& ieInpNode = nodes[0].dynamicCast<InfEngineNgraphNode>()->node;
#if INF_ENGINE_VER_MAJOR_LE(INF_ENGINE_RELEASE_2021_2)
auto mvn = std::make_shared<ngraph::op::MVN>(ieInpNode, acrossChannels, normVariance, eps);
#else
int64_t start_axis = acrossChannels ? 1 : 2;
std::vector<int64_t> axes_v(ieInpNode->get_shape().size() - start_axis);
std::iota(axes_v.begin(), axes_v.end(), start_axis);
auto axes = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{axes_v.size()}, axes_v.data());
auto mvn = std::make_shared<ngraph::op::v6::MVN>(ieInpNode, axes, normVariance, eps, ngraph::op::MVNEpsMode::INSIDE_SQRT);
#endif
return Ptr<BackendNode>(new InfEngineNgraphNode(mvn));
}
#endif // HAVE_DNN_NGRAPH
+32
View File
@@ -267,6 +267,7 @@ public:
{
auto& ieInpNode = nodes[0].dynamicCast<InfEngineNgraphNode>()->node;
#if INF_ENGINE_VER_MAJOR_LE(INF_ENGINE_RELEASE_2021_2)
ngraph::op::InterpolateAttrs attrs;
attrs.pads_begin.push_back(0);
attrs.pads_end.push_back(0);
@@ -285,6 +286,37 @@ public:
std::vector<int64_t> shape = {outHeight, outWidth};
auto out_shape = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, shape.data());
auto interp = std::make_shared<ngraph::op::Interpolate>(ieInpNode, out_shape, attrs);
#else
ngraph::op::v4::Interpolate::InterpolateAttrs attrs;
if (interpolation == "nearest") {
attrs.mode = ngraph::op::v4::Interpolate::InterpolateMode::nearest;
attrs.coordinate_transformation_mode = ngraph::op::v4::Interpolate::CoordinateTransformMode::half_pixel;
} else if (interpolation == "bilinear") {
attrs.mode = ngraph::op::v4::Interpolate::InterpolateMode::linear_onnx;
attrs.coordinate_transformation_mode = ngraph::op::v4::Interpolate::CoordinateTransformMode::asymmetric;
} else {
CV_Error(Error::StsNotImplemented, format("Unsupported interpolation: %s", interpolation.c_str()));
}
attrs.shape_calculation_mode = ngraph::op::v4::Interpolate::ShapeCalcMode::sizes;
if (alignCorners) {
attrs.coordinate_transformation_mode = ngraph::op::v4::Interpolate::CoordinateTransformMode::align_corners;
}
attrs.nearest_mode = ngraph::op::v4::Interpolate::NearestMode::round_prefer_floor;
std::vector<int64_t> shape = {outHeight, outWidth};
auto out_shape = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, shape.data());
auto& input_shape = ieInpNode->get_shape();
CV_Assert_N(input_shape[2] != 0, input_shape[3] != 0);
std::vector<float> scales = {static_cast<float>(outHeight) / input_shape[2], static_cast<float>(outWidth) / input_shape[3]};
auto scales_shape = std::make_shared<ngraph::op::Constant>(ngraph::element::f32, ngraph::Shape{2}, scales.data());
auto axes = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{2}, std::vector<int64_t>{2, 3});
auto interp = std::make_shared<ngraph::op::v4::Interpolate>(ieInpNode, out_shape, scales_shape, axes, attrs);
#endif
return Ptr<BackendNode>(new InfEngineNgraphNode(interp));
}
#endif // HAVE_DNN_NGRAPH
+3 -2
View File
@@ -29,10 +29,11 @@
#define INF_ENGINE_RELEASE_2020_4 2020040000
#define INF_ENGINE_RELEASE_2021_1 2021010000
#define INF_ENGINE_RELEASE_2021_2 2021020000
#define INF_ENGINE_RELEASE_2021_3 2021030000
#ifndef INF_ENGINE_RELEASE
#warning("IE version have not been provided via command-line. Using 2021.2 by default")
#define INF_ENGINE_RELEASE INF_ENGINE_RELEASE_2021_2
#warning("IE version have not been provided via command-line. Using 2021.3 by default")
#define INF_ENGINE_RELEASE INF_ENGINE_RELEASE_2021_3
#endif
#define INF_ENGINE_VER_MAJOR_GT(ver) (((INF_ENGINE_RELEASE) / 10000) > ((ver) / 10000))
+30 -8
View File
@@ -235,9 +235,11 @@ vector<Vec3d> QRDetect::searchHorizontalLines()
vector<Point2f> QRDetect::separateVerticalLines(const vector<Vec3d> &list_lines)
{
CV_TRACE_FUNCTION();
for (int coeff_epsilon = 1; coeff_epsilon < 10; coeff_epsilon++)
const double min_dist_between_points = 10.0;
const double max_ratio = 1.0;
for (int coeff_epsilon_i = 1; coeff_epsilon_i < 101; ++coeff_epsilon_i)
{
const float coeff_epsilon = coeff_epsilon_i * 0.1f;
vector<Point2f> point2f_result = extractVerticalLines(list_lines, eps_horizontal * coeff_epsilon);
if (!point2f_result.empty())
{
@@ -247,9 +249,23 @@ vector<Point2f> QRDetect::separateVerticalLines(const vector<Vec3d> &list_lines)
point2f_result, 3, labels,
TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 10, 0.1),
3, KMEANS_PP_CENTERS, centers);
if (compactness == 0)
double min_dist = std::numeric_limits<double>::max();
for (size_t i = 0; i < centers.size(); i++)
{
double dist = norm(centers[i] - centers[(i+1) % centers.size()]);
if (dist < min_dist)
{
min_dist = dist;
}
}
if (min_dist < min_dist_between_points)
{
continue;
if (compactness > 0)
}
double mean_compactness = compactness / point2f_result.size();
double ratio = mean_compactness / min_dist;
if (ratio < max_ratio)
{
return point2f_result;
}
@@ -456,7 +472,6 @@ bool QRDetect::localization()
vector<Point2f> list_lines_y = separateVerticalLines(list_lines_x);
if( list_lines_y.empty() ) { return false; }
vector<Point2f> centers;
Mat labels;
kmeans(list_lines_y, 3, labels,
TermCriteria( TermCriteria::EPS + TermCriteria::COUNT, 10, 0.1),
@@ -464,7 +479,7 @@ bool QRDetect::localization()
fixationPoints(localization_points);
bool suare_flag = false, local_points_flag = false;
bool square_flag = false, local_points_flag = false;
double triangle_sides[3];
double triangle_perim, square_area, img_square_area;
if (localization_points.size() == 3)
@@ -482,14 +497,14 @@ bool QRDetect::localization()
if (square_area > (img_square_area * 0.2))
{
suare_flag = true;
square_flag = true;
}
}
else
{
local_points_flag = true;
}
if ((suare_flag || local_points_flag) && purpose == SHRINKING)
if ((square_flag || local_points_flag) && purpose == SHRINKING)
{
localization_points.clear();
bin_barcode = resized_bin_barcode.clone();
@@ -1962,6 +1977,13 @@ bool QRDecode::createSpline(vector<vector<Point2f> > &spline_lines)
}
}
}
for (int i = 0; i < NUM_SIDES; i++)
{
if (spline_lines[i].size() == 0)
{
return false;
}
}
return true;
}