Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
199ddff1
Commit
199ddff1
authored
Jul 18, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
parents
985e5014
002904e4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
109 additions
and
390 deletions
+109
-390
CMakeLists.txt
modules/calib3d/CMakeLists.txt
+3
-0
perf_undistort.cpp
modules/calib3d/perf/perf_undistort.cpp
+19
-0
undistort.avx2.cpp
modules/calib3d/src/undistort.avx2.cpp
+0
-194
undistort.dispatch.cpp
modules/calib3d/src/undistort.dispatch.cpp
+22
-128
undistort.hpp
modules/calib3d/src/undistort.hpp
+0
-59
undistort.simd.hpp
modules/calib3d/src/undistort.simd.hpp
+0
-0
all_layers.hpp
modules/dnn/include/opencv2/dnn/all_layers.hpp
+1
-0
dnn.hpp
modules/dnn/include/opencv2/dnn/dnn.hpp
+1
-1
dnn.cpp
modules/dnn/src/dnn.cpp
+7
-0
slice_layer.cpp
modules/dnn/src/layers/slice_layer.cpp
+5
-3
tf_importer.cpp
modules/dnn/src/tensorflow/tf_importer.cpp
+3
-0
test_misc.cpp
modules/dnn/test/test_misc.cpp
+20
-0
test_onnx_importer.cpp
modules/dnn/test/test_onnx_importer.cpp
+1
-1
test_tf_importer.cpp
modules/dnn/test/test_tf_importer.cpp
+5
-0
thresh.cpp
modules/imgproc/src/thresh.cpp
+22
-4
No files found.
modules/calib3d/CMakeLists.txt
View file @
199ddff1
set
(
the_description
"Camera Calibration and 3D Reconstruction"
)
set
(
the_description
"Camera Calibration and 3D Reconstruction"
)
ocv_add_dispatched_file
(
undistort SSE2 AVX2
)
set
(
debug_modules
""
)
set
(
debug_modules
""
)
if
(
DEBUG_opencv_calib3d
)
if
(
DEBUG_opencv_calib3d
)
list
(
APPEND debug_modules opencv_highgui
)
list
(
APPEND debug_modules opencv_highgui
)
...
...
modules/calib3d/perf/perf_undistort.cpp
0 → 100644
View file @
199ddff1
// 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 "perf_precomp.hpp"
namespace
opencv_test
{
PERF_TEST
(
Undistort
,
InitUndistortMap
)
{
Size
size_w_h
(
512
+
3
,
512
);
Mat
k
(
3
,
3
,
CV_32FC1
);
Mat
d
(
1
,
14
,
CV_64FC1
);
Mat
dst
(
size_w_h
,
CV_32FC2
);
declare
.
in
(
k
,
d
,
WARMUP_RNG
).
out
(
dst
);
TEST_CYCLE
()
initUndistortRectifyMap
(
k
,
d
,
noArray
(),
k
,
size_w_h
,
CV_32FC2
,
dst
,
noArray
());
SANITY_CHECK_NOTHING
();
}
}
modules/calib3d/src/undistort.avx2.cpp
deleted
100644 → 0
View file @
985e5014
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
#include "undistort.hpp"
namespace
cv
{
int
initUndistortRectifyMapLine_AVX
(
float
*
m1f
,
float
*
m2f
,
short
*
m1
,
ushort
*
m2
,
double
*
matTilt
,
const
double
*
ir
,
double
&
_x
,
double
&
_y
,
double
&
_w
,
int
width
,
int
m1type
,
double
k1
,
double
k2
,
double
k3
,
double
k4
,
double
k5
,
double
k6
,
double
p1
,
double
p2
,
double
s1
,
double
s2
,
double
s3
,
double
s4
,
double
u0
,
double
v0
,
double
fx
,
double
fy
)
{
int
j
=
0
;
static
const
__m256d
__one
=
_mm256_set1_pd
(
1.0
);
static
const
__m256d
__two
=
_mm256_set1_pd
(
2.0
);
const
__m256d
__matTilt_00
=
_mm256_set1_pd
(
matTilt
[
0
]);
const
__m256d
__matTilt_10
=
_mm256_set1_pd
(
matTilt
[
3
]);
const
__m256d
__matTilt_20
=
_mm256_set1_pd
(
matTilt
[
6
]);
const
__m256d
__matTilt_01
=
_mm256_set1_pd
(
matTilt
[
1
]);
const
__m256d
__matTilt_11
=
_mm256_set1_pd
(
matTilt
[
4
]);
const
__m256d
__matTilt_21
=
_mm256_set1_pd
(
matTilt
[
7
]);
const
__m256d
__matTilt_02
=
_mm256_set1_pd
(
matTilt
[
2
]);
const
__m256d
__matTilt_12
=
_mm256_set1_pd
(
matTilt
[
5
]);
const
__m256d
__matTilt_22
=
_mm256_set1_pd
(
matTilt
[
8
]);
for
(;
j
<=
width
-
4
;
j
+=
4
,
_x
+=
4
*
ir
[
0
],
_y
+=
4
*
ir
[
3
],
_w
+=
4
*
ir
[
6
])
{
// Question: Should we load the constants first?
__m256d
__w
=
_mm256_div_pd
(
__one
,
_mm256_set_pd
(
_w
+
3
*
ir
[
6
],
_w
+
2
*
ir
[
6
],
_w
+
ir
[
6
],
_w
));
__m256d
__x
=
_mm256_mul_pd
(
_mm256_set_pd
(
_x
+
3
*
ir
[
0
],
_x
+
2
*
ir
[
0
],
_x
+
ir
[
0
],
_x
),
__w
);
__m256d
__y
=
_mm256_mul_pd
(
_mm256_set_pd
(
_y
+
3
*
ir
[
3
],
_y
+
2
*
ir
[
3
],
_y
+
ir
[
3
],
_y
),
__w
);
__m256d
__x2
=
_mm256_mul_pd
(
__x
,
__x
);
__m256d
__y2
=
_mm256_mul_pd
(
__y
,
__y
);
__m256d
__r2
=
_mm256_add_pd
(
__x2
,
__y2
);
__m256d
__2xy
=
_mm256_mul_pd
(
__two
,
_mm256_mul_pd
(
__x
,
__y
));
__m256d
__kr
=
_mm256_div_pd
(
#if CV_FMA3
_mm256_fmadd_pd
(
_mm256_fmadd_pd
(
_mm256_fmadd_pd
(
_mm256_set1_pd
(
k3
),
__r2
,
_mm256_set1_pd
(
k2
)),
__r2
,
_mm256_set1_pd
(
k1
)),
__r2
,
__one
),
_mm256_fmadd_pd
(
_mm256_fmadd_pd
(
_mm256_fmadd_pd
(
_mm256_set1_pd
(
k6
),
__r2
,
_mm256_set1_pd
(
k5
)),
__r2
,
_mm256_set1_pd
(
k4
)),
__r2
,
__one
)
#else
_mm256_add_pd
(
__one
,
_mm256_mul_pd
(
_mm256_add_pd
(
_mm256_mul_pd
(
_mm256_add_pd
(
_mm256_mul_pd
(
_mm256_set1_pd
(
k3
),
__r2
),
_mm256_set1_pd
(
k2
)),
__r2
),
_mm256_set1_pd
(
k1
)),
__r2
)),
_mm256_add_pd
(
__one
,
_mm256_mul_pd
(
_mm256_add_pd
(
_mm256_mul_pd
(
_mm256_add_pd
(
_mm256_mul_pd
(
_mm256_set1_pd
(
k6
),
__r2
),
_mm256_set1_pd
(
k5
)),
__r2
),
_mm256_set1_pd
(
k4
)),
__r2
))
#endif
);
__m256d
__r22
=
_mm256_mul_pd
(
__r2
,
__r2
);
#if CV_FMA3
__m256d
__xd
=
_mm256_fmadd_pd
(
__x
,
__kr
,
_mm256_add_pd
(
_mm256_fmadd_pd
(
_mm256_set1_pd
(
p1
),
__2xy
,
_mm256_mul_pd
(
_mm256_set1_pd
(
p2
),
_mm256_fmadd_pd
(
__two
,
__x2
,
__r2
))),
_mm256_fmadd_pd
(
_mm256_set1_pd
(
s1
),
__r2
,
_mm256_mul_pd
(
_mm256_set1_pd
(
s2
),
__r22
))));
__m256d
__yd
=
_mm256_fmadd_pd
(
__y
,
__kr
,
_mm256_add_pd
(
_mm256_fmadd_pd
(
_mm256_set1_pd
(
p1
),
_mm256_fmadd_pd
(
__two
,
__y2
,
__r2
),
_mm256_mul_pd
(
_mm256_set1_pd
(
p2
),
__2xy
)),
_mm256_fmadd_pd
(
_mm256_set1_pd
(
s3
),
__r2
,
_mm256_mul_pd
(
_mm256_set1_pd
(
s4
),
__r22
))));
__m256d
__vecTilt2
=
_mm256_fmadd_pd
(
__matTilt_20
,
__xd
,
_mm256_fmadd_pd
(
__matTilt_21
,
__yd
,
__matTilt_22
));
#else
__m256d
__xd
=
_mm256_add_pd
(
_mm256_mul_pd
(
__x
,
__kr
),
_mm256_add_pd
(
_mm256_add_pd
(
_mm256_mul_pd
(
_mm256_set1_pd
(
p1
),
__2xy
),
_mm256_mul_pd
(
_mm256_set1_pd
(
p2
),
_mm256_add_pd
(
__r2
,
_mm256_mul_pd
(
__two
,
__x2
)))),
_mm256_add_pd
(
_mm256_mul_pd
(
_mm256_set1_pd
(
s1
),
__r2
),
_mm256_mul_pd
(
_mm256_set1_pd
(
s2
),
__r22
))));
__m256d
__yd
=
_mm256_add_pd
(
_mm256_mul_pd
(
__y
,
__kr
),
_mm256_add_pd
(
_mm256_add_pd
(
_mm256_mul_pd
(
_mm256_set1_pd
(
p1
),
_mm256_add_pd
(
__r2
,
_mm256_mul_pd
(
__two
,
__y2
))),
_mm256_mul_pd
(
_mm256_set1_pd
(
p2
),
__2xy
)),
_mm256_add_pd
(
_mm256_mul_pd
(
_mm256_set1_pd
(
s3
),
__r2
),
_mm256_mul_pd
(
_mm256_set1_pd
(
s4
),
__r22
))));
__m256d
__vecTilt2
=
_mm256_add_pd
(
_mm256_add_pd
(
_mm256_mul_pd
(
__matTilt_20
,
__xd
),
_mm256_mul_pd
(
__matTilt_21
,
__yd
)),
__matTilt_22
);
#endif
__m256d
__invProj
=
_mm256_blendv_pd
(
_mm256_div_pd
(
__one
,
__vecTilt2
),
__one
,
_mm256_cmp_pd
(
__vecTilt2
,
_mm256_setzero_pd
(),
_CMP_EQ_OQ
));
#if CV_FMA3
__m256d
__u
=
_mm256_fmadd_pd
(
__matTilt_00
,
__xd
,
_mm256_fmadd_pd
(
__matTilt_01
,
__yd
,
__matTilt_02
));
__u
=
_mm256_fmadd_pd
(
_mm256_mul_pd
(
_mm256_set1_pd
(
fx
),
__invProj
),
__u
,
_mm256_set1_pd
(
u0
));
__m256d
__v
=
_mm256_fmadd_pd
(
__matTilt_10
,
__xd
,
_mm256_fmadd_pd
(
__matTilt_11
,
__yd
,
__matTilt_12
));
__v
=
_mm256_fmadd_pd
(
_mm256_mul_pd
(
_mm256_set1_pd
(
fy
),
__invProj
),
__v
,
_mm256_set1_pd
(
v0
));
#else
__m256d
__u
=
_mm256_add_pd
(
_mm256_add_pd
(
_mm256_mul_pd
(
__matTilt_00
,
__xd
),
_mm256_mul_pd
(
__matTilt_01
,
__yd
)),
__matTilt_02
);
__u
=
_mm256_add_pd
(
_mm256_mul_pd
(
_mm256_mul_pd
(
_mm256_set1_pd
(
fx
),
__invProj
),
__u
),
_mm256_set1_pd
(
u0
));
__m256d
__v
=
_mm256_add_pd
(
_mm256_add_pd
(
_mm256_mul_pd
(
__matTilt_10
,
__xd
),
_mm256_mul_pd
(
__matTilt_11
,
__yd
)),
__matTilt_12
);
__v
=
_mm256_add_pd
(
_mm256_mul_pd
(
_mm256_mul_pd
(
_mm256_set1_pd
(
fy
),
__invProj
),
__v
),
_mm256_set1_pd
(
v0
));
#endif
if
(
m1type
==
CV_32FC1
)
{
_mm_storeu_ps
(
&
m1f
[
j
],
_mm256_cvtpd_ps
(
__u
));
_mm_storeu_ps
(
&
m2f
[
j
],
_mm256_cvtpd_ps
(
__v
));
}
else
if
(
m1type
==
CV_32FC2
)
{
__m128
__u_float
=
_mm256_cvtpd_ps
(
__u
);
__m128
__v_float
=
_mm256_cvtpd_ps
(
__v
);
_mm_storeu_ps
(
&
m1f
[
j
*
2
],
_mm_unpacklo_ps
(
__u_float
,
__v_float
));
_mm_storeu_ps
(
&
m1f
[
j
*
2
+
4
],
_mm_unpackhi_ps
(
__u_float
,
__v_float
));
}
else
// m1type == CV_16SC2
{
__u
=
_mm256_mul_pd
(
__u
,
_mm256_set1_pd
(
INTER_TAB_SIZE
));
__v
=
_mm256_mul_pd
(
__v
,
_mm256_set1_pd
(
INTER_TAB_SIZE
));
__m128i
__iu
=
_mm256_cvtpd_epi32
(
__u
);
__m128i
__iv
=
_mm256_cvtpd_epi32
(
__v
);
static
const
__m128i
__INTER_TAB_SIZE_m1
=
_mm_set1_epi32
(
INTER_TAB_SIZE
-
1
);
__m128i
__m2
=
_mm_add_epi32
(
_mm_mullo_epi32
(
_mm_and_si128
(
__iv
,
__INTER_TAB_SIZE_m1
),
_mm_set1_epi32
(
INTER_TAB_SIZE
)),
_mm_and_si128
(
__iu
,
__INTER_TAB_SIZE_m1
));
__m2
=
_mm_packus_epi32
(
__m2
,
__m2
);
_mm_maskstore_epi64
((
long
long
int
*
)
&
m2
[
j
],
_mm_set_epi32
(
0
,
0
,
0xFFFFFFFF
,
0xFFFFFFFF
),
__m2
);
// gcc4.9 does not support _mm256_set_m128
// __m256i __m1 = _mm256_set_m128i(__iv, __iu);
__m256i
__m1
=
_mm256_setzero_si256
();
__m1
=
_mm256_inserti128_si256
(
__m1
,
__iu
,
0
);
__m1
=
_mm256_inserti128_si256
(
__m1
,
__iv
,
1
);
__m1
=
_mm256_srai_epi32
(
__m1
,
INTER_BITS
);
// v3 v2 v1 v0 u3 u2 u1 u0 (int32_t)
static
const
__m256i
__permute_mask
=
_mm256_set_epi32
(
7
,
3
,
6
,
2
,
5
,
1
,
4
,
0
);
__m1
=
_mm256_permutevar8x32_epi32
(
__m1
,
__permute_mask
);
// v3 u3 v2 u2 v1 u1 v0 u0 (int32_t)
__m1
=
_mm256_packs_epi32
(
__m1
,
__m1
);
// x x x x v3 u3 v2 u2 x x x x v1 u1 v0 u0 (int16_t)
_mm_storeu_si128
((
__m128i
*
)
&
m1
[
j
*
2
],
_mm256_extracti128_si256
(
_mm256_permute4x64_epi64
(
__m1
,
(
2
<<
2
)
+
0
),
0
));
}
}
_mm256_zeroupper
();
return
j
;
}
}
/* End of file */
modules/calib3d/src/undistort.cpp
→
modules/calib3d/src/undistort.
dispatch.
cpp
View file @
199ddff1
...
@@ -42,11 +42,16 @@
...
@@ -42,11 +42,16 @@
#include "precomp.hpp"
#include "precomp.hpp"
#include "distortion_model.hpp"
#include "distortion_model.hpp"
#include "undistort.hpp"
#include "calib3d_c_api.h"
#include "calib3d_c_api.h"
cv
::
Mat
cv
::
getDefaultNewCameraMatrix
(
InputArray
_cameraMatrix
,
Size
imgsize
,
#include "undistort.simd.hpp"
#include "undistort.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content
namespace
cv
{
Mat
getDefaultNewCameraMatrix
(
InputArray
_cameraMatrix
,
Size
imgsize
,
bool
centerPrincipalPoint
)
bool
centerPrincipalPoint
)
{
{
Mat
cameraMatrix
=
_cameraMatrix
.
getMat
();
Mat
cameraMatrix
=
_cameraMatrix
.
getMat
();
...
@@ -63,134 +68,22 @@ cv::Mat cv::getDefaultNewCameraMatrix( InputArray _cameraMatrix, Size imgsize,
...
@@ -63,134 +68,22 @@ cv::Mat cv::getDefaultNewCameraMatrix( InputArray _cameraMatrix, Size imgsize,
return
newCameraMatrix
;
return
newCameraMatrix
;
}
}
class
initUndistortRectifyMapComputer
:
public
cv
::
ParallelLoopBody
namespace
{
{
Ptr
<
ParallelLoopBody
>
getInitUndistortRectifyMapComputer
(
Size
_size
,
Mat
&
_map1
,
Mat
&
_map2
,
int
_m1type
,
public
:
const
double
*
_ir
,
Matx33d
&
_matTilt
,
initUndistortRectifyMapComputer
(
cv
::
Size
_size
,
cv
::
Mat
&
_map1
,
cv
::
Mat
&
_map2
,
int
_m1type
,
const
double
*
_ir
,
cv
::
Matx33d
&
_matTilt
,
double
_u0
,
double
_v0
,
double
_fx
,
double
_fy
,
double
_u0
,
double
_v0
,
double
_fx
,
double
_fy
,
double
_k1
,
double
_k2
,
double
_p1
,
double
_p2
,
double
_k1
,
double
_k2
,
double
_p1
,
double
_p2
,
double
_k3
,
double
_k4
,
double
_k5
,
double
_k6
,
double
_k3
,
double
_k4
,
double
_k5
,
double
_k6
,
double
_s1
,
double
_s2
,
double
_s3
,
double
_s4
)
double
_s1
,
double
_s2
,
double
_s3
,
double
_s4
)
:
size
(
_size
),
{
map1
(
_map1
),
CV_INSTRUMENT_REGION
();
map2
(
_map2
),
m1type
(
_m1type
),
ir
(
_ir
),
matTilt
(
_matTilt
),
u0
(
_u0
),
v0
(
_v0
),
fx
(
_fx
),
fy
(
_fy
),
k1
(
_k1
),
k2
(
_k2
),
p1
(
_p1
),
p2
(
_p2
),
k3
(
_k3
),
k4
(
_k4
),
k5
(
_k5
),
k6
(
_k6
),
s1
(
_s1
),
s2
(
_s2
),
s3
(
_s3
),
s4
(
_s4
)
{
#if CV_TRY_AVX2
useAVX2
=
cv
::
checkHardwareSupport
(
CV_CPU_AVX2
);
#endif
}
void
operator
()(
const
cv
::
Range
&
range
)
const
CV_OVERRIDE
{
const
int
begin
=
range
.
start
;
const
int
end
=
range
.
end
;
for
(
int
i
=
begin
;
i
<
end
;
i
++
)
CV_CPU_DISPATCH
(
getInitUndistortRectifyMapComputer
,
(
_size
,
_map1
,
_map2
,
_m1type
,
_ir
,
_matTilt
,
_u0
,
_v0
,
_fx
,
_fy
,
_k1
,
_k2
,
_p1
,
_p2
,
_k3
,
_k4
,
_k5
,
_k6
,
_s1
,
_s2
,
_s3
,
_s4
),
{
CV_CPU_DISPATCH_MODES_ALL
);
float
*
m1f
=
map1
.
ptr
<
float
>
(
i
);
}
float
*
m2f
=
map2
.
empty
()
?
0
:
map2
.
ptr
<
float
>
(
i
);
}
short
*
m1
=
(
short
*
)
m1f
;
ushort
*
m2
=
(
ushort
*
)
m2f
;
double
_x
=
i
*
ir
[
1
]
+
ir
[
2
],
_y
=
i
*
ir
[
4
]
+
ir
[
5
],
_w
=
i
*
ir
[
7
]
+
ir
[
8
];
int
j
=
0
;
if
(
m1type
==
CV_16SC2
)
CV_Assert
(
m1
!=
NULL
&&
m2
!=
NULL
);
else
if
(
m1type
==
CV_32FC1
)
CV_Assert
(
m1f
!=
NULL
&&
m2f
!=
NULL
);
else
CV_Assert
(
m1
!=
NULL
);
#if CV_TRY_AVX2
if
(
useAVX2
)
j
=
cv
::
initUndistortRectifyMapLine_AVX
(
m1f
,
m2f
,
m1
,
m2
,
matTilt
.
val
,
ir
,
_x
,
_y
,
_w
,
size
.
width
,
m1type
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
p1
,
p2
,
s1
,
s2
,
s3
,
s4
,
u0
,
v0
,
fx
,
fy
);
#endif
for
(
;
j
<
size
.
width
;
j
++
,
_x
+=
ir
[
0
],
_y
+=
ir
[
3
],
_w
+=
ir
[
6
]
)
{
double
w
=
1.
/
_w
,
x
=
_x
*
w
,
y
=
_y
*
w
;
double
x2
=
x
*
x
,
y2
=
y
*
y
;
double
r2
=
x2
+
y2
,
_2xy
=
2
*
x
*
y
;
double
kr
=
(
1
+
((
k3
*
r2
+
k2
)
*
r2
+
k1
)
*
r2
)
/
(
1
+
((
k6
*
r2
+
k5
)
*
r2
+
k4
)
*
r2
);
double
xd
=
(
x
*
kr
+
p1
*
_2xy
+
p2
*
(
r2
+
2
*
x2
)
+
s1
*
r2
+
s2
*
r2
*
r2
);
double
yd
=
(
y
*
kr
+
p1
*
(
r2
+
2
*
y2
)
+
p2
*
_2xy
+
s3
*
r2
+
s4
*
r2
*
r2
);
cv
::
Vec3d
vecTilt
=
matTilt
*
cv
::
Vec3d
(
xd
,
yd
,
1
);
double
invProj
=
vecTilt
(
2
)
?
1.
/
vecTilt
(
2
)
:
1
;
double
u
=
fx
*
invProj
*
vecTilt
(
0
)
+
u0
;
double
v
=
fy
*
invProj
*
vecTilt
(
1
)
+
v0
;
if
(
m1type
==
CV_16SC2
)
{
int
iu
=
cv
::
saturate_cast
<
int
>
(
u
*
cv
::
INTER_TAB_SIZE
);
int
iv
=
cv
::
saturate_cast
<
int
>
(
v
*
cv
::
INTER_TAB_SIZE
);
m1
[
j
*
2
]
=
(
short
)(
iu
>>
cv
::
INTER_BITS
);
m1
[
j
*
2
+
1
]
=
(
short
)(
iv
>>
cv
::
INTER_BITS
);
m2
[
j
]
=
(
ushort
)((
iv
&
(
cv
::
INTER_TAB_SIZE
-
1
))
*
cv
::
INTER_TAB_SIZE
+
(
iu
&
(
cv
::
INTER_TAB_SIZE
-
1
)));
}
else
if
(
m1type
==
CV_32FC1
)
{
m1f
[
j
]
=
(
float
)
u
;
m2f
[
j
]
=
(
float
)
v
;
}
else
{
m1f
[
j
*
2
]
=
(
float
)
u
;
m1f
[
j
*
2
+
1
]
=
(
float
)
v
;
}
}
}
}
private
:
void
initUndistortRectifyMap
(
InputArray
_cameraMatrix
,
InputArray
_distCoeffs
,
cv
::
Size
size
;
cv
::
Mat
&
map1
;
cv
::
Mat
&
map2
;
int
m1type
;
const
double
*
ir
;
cv
::
Matx33d
&
matTilt
;
double
u0
;
double
v0
;
double
fx
;
double
fy
;
double
k1
;
double
k2
;
double
p1
;
double
p2
;
double
k3
;
double
k4
;
double
k5
;
double
k6
;
double
s1
;
double
s2
;
double
s3
;
double
s4
;
#if CV_TRY_AVX2
bool
useAVX2
;
#endif
};
void
cv
::
initUndistortRectifyMap
(
InputArray
_cameraMatrix
,
InputArray
_distCoeffs
,
InputArray
_matR
,
InputArray
_newCameraMatrix
,
InputArray
_matR
,
InputArray
_newCameraMatrix
,
Size
size
,
int
m1type
,
OutputArray
_map1
,
OutputArray
_map2
)
Size
size
,
int
m1type
,
OutputArray
_map1
,
OutputArray
_map2
)
{
{
...
@@ -263,16 +156,16 @@ void cv::initUndistortRectifyMap( InputArray _cameraMatrix, InputArray _distCoef
...
@@ -263,16 +156,16 @@ void cv::initUndistortRectifyMap( InputArray _cameraMatrix, InputArray _distCoef
double
tauY
=
distCoeffs
.
cols
+
distCoeffs
.
rows
-
1
>=
14
?
distPtr
[
13
]
:
0.
;
double
tauY
=
distCoeffs
.
cols
+
distCoeffs
.
rows
-
1
>=
14
?
distPtr
[
13
]
:
0.
;
// Matrix for trapezoidal distortion of tilted image sensor
// Matrix for trapezoidal distortion of tilted image sensor
cv
::
Matx33d
matTilt
=
cv
::
Matx33d
::
eye
();
Matx33d
matTilt
=
Matx33d
::
eye
();
cv
::
detail
::
computeTiltProjectionMatrix
(
tauX
,
tauY
,
&
matTilt
);
detail
::
computeTiltProjectionMatrix
(
tauX
,
tauY
,
&
matTilt
);
parallel_for_
(
Range
(
0
,
size
.
height
),
i
nitUndistortRectifyMapComputer
(
parallel_for_
(
Range
(
0
,
size
.
height
),
*
getI
nitUndistortRectifyMapComputer
(
size
,
map1
,
map2
,
m1type
,
ir
,
matTilt
,
u0
,
v0
,
size
,
map1
,
map2
,
m1type
,
ir
,
matTilt
,
u0
,
v0
,
fx
,
fy
,
k1
,
k2
,
p1
,
p2
,
k3
,
k4
,
k5
,
k6
,
s1
,
s2
,
s3
,
s4
));
fx
,
fy
,
k1
,
k2
,
p1
,
p2
,
k3
,
k4
,
k5
,
k6
,
s1
,
s2
,
s3
,
s4
));
}
}
void
cv
::
undistort
(
InputArray
_src
,
OutputArray
_dst
,
InputArray
_cameraMatrix
,
void
undistort
(
InputArray
_src
,
OutputArray
_dst
,
InputArray
_cameraMatrix
,
InputArray
_distCoeffs
,
InputArray
_newCameraMatrix
)
InputArray
_distCoeffs
,
InputArray
_newCameraMatrix
)
{
{
CV_INSTRUMENT_REGION
();
CV_INSTRUMENT_REGION
();
...
@@ -319,6 +212,7 @@ void cv::undistort( InputArray _src, OutputArray _dst, InputArray _cameraMatrix,
...
@@ -319,6 +212,7 @@ void cv::undistort( InputArray _src, OutputArray _dst, InputArray _cameraMatrix,
}
}
}
}
}
CV_IMPL
void
CV_IMPL
void
cvUndistort2
(
const
CvArr
*
srcarr
,
CvArr
*
dstarr
,
const
CvMat
*
Aarr
,
const
CvMat
*
dist_coeffs
,
const
CvMat
*
newAarr
)
cvUndistort2
(
const
CvArr
*
srcarr
,
CvArr
*
dstarr
,
const
CvMat
*
Aarr
,
const
CvMat
*
dist_coeffs
,
const
CvMat
*
newAarr
)
...
...
modules/calib3d/src/undistort.hpp
deleted
100644 → 0
View file @
985e5014
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef OPENCV_CALIB3D_UNDISTORT_HPP
#define OPENCV_CALIB3D_UNDISTORT_HPP
namespace
cv
{
#if CV_TRY_AVX2
int
initUndistortRectifyMapLine_AVX
(
float
*
m1f
,
float
*
m2f
,
short
*
m1
,
ushort
*
m2
,
double
*
matTilt
,
const
double
*
ir
,
double
&
_x
,
double
&
_y
,
double
&
_w
,
int
width
,
int
m1type
,
double
k1
,
double
k2
,
double
k3
,
double
k4
,
double
k5
,
double
k6
,
double
p1
,
double
p2
,
double
s1
,
double
s2
,
double
s3
,
double
s4
,
double
u0
,
double
v0
,
double
fx
,
double
fy
);
#endif
}
#endif // OPENCV_CALIB3D_UNDISTORT_HPP
/* End of file */
modules/calib3d/src/undistort.simd.hpp
0 → 100644
View file @
199ddff1
This diff is collapsed.
Click to expand it.
modules/dnn/include/opencv2/dnn/all_layers.hpp
View file @
199ddff1
...
@@ -366,6 +366,7 @@ CV__DNN_INLINE_NS_BEGIN
...
@@ -366,6 +366,7 @@ CV__DNN_INLINE_NS_BEGIN
*/
*/
std
::
vector
<
std
::
vector
<
Range
>
>
sliceRanges
;
std
::
vector
<
std
::
vector
<
Range
>
>
sliceRanges
;
int
axis
;
int
axis
;
int
num_split
;
static
Ptr
<
SliceLayer
>
create
(
const
LayerParams
&
params
);
static
Ptr
<
SliceLayer
>
create
(
const
LayerParams
&
params
);
};
};
...
...
modules/dnn/include/opencv2/dnn/dnn.hpp
View file @
199ddff1
...
@@ -383,7 +383,7 @@ CV__DNN_INLINE_NS_BEGIN
...
@@ -383,7 +383,7 @@ CV__DNN_INLINE_NS_BEGIN
/** @brief Dump net to String
/** @brief Dump net to String
* @returns String with structure, hyperparameters, backend, target and fusion
* @returns String with structure, hyperparameters, backend, target and fusion
* To see correct backend, target and fusion run after forward().
*
Call method after setInput().
To see correct backend, target and fusion run after forward().
*/
*/
CV_WRAP
String
dump
();
CV_WRAP
String
dump
();
/** @brief Dump net structure, hyperparameters, backend, target and fusion to dot file
/** @brief Dump net structure, hyperparameters, backend, target and fusion to dot file
...
...
modules/dnn/src/dnn.cpp
View file @
199ddff1
...
@@ -2979,6 +2979,13 @@ String parseLayerParams(const String& name, const LayerParams& lp) {
...
@@ -2979,6 +2979,13 @@ String parseLayerParams(const String& name, const LayerParams& lp) {
String
Net
::
dump
()
String
Net
::
dump
()
{
{
CV_Assert
(
!
empty
());
CV_Assert
(
!
empty
());
if
(
impl
->
netInputLayer
->
inputsData
.
empty
())
CV_Error
(
Error
::
StsError
,
"Requested set input"
);
if
(
!
impl
->
netWasAllocated
)
impl
->
setUpNet
();
std
::
ostringstream
out
;
std
::
ostringstream
out
;
std
::
map
<
int
,
LayerData
>&
map
=
impl
->
layers
;
std
::
map
<
int
,
LayerData
>&
map
=
impl
->
layers
;
int
prefBackend
=
impl
->
preferableBackend
;
int
prefBackend
=
impl
->
preferableBackend
;
...
...
modules/dnn/src/layers/slice_layer.cpp
View file @
199ddff1
...
@@ -61,6 +61,7 @@ public:
...
@@ -61,6 +61,7 @@ public:
{
{
setParamsFrom
(
params
);
setParamsFrom
(
params
);
axis
=
params
.
get
<
int
>
(
"axis"
,
1
);
axis
=
params
.
get
<
int
>
(
"axis"
,
1
);
num_split
=
params
.
get
<
int
>
(
"num_split"
,
0
);
if
(
params
.
has
(
"slice_point"
))
if
(
params
.
has
(
"slice_point"
))
{
{
CV_Assert
(
!
params
.
has
(
"begin"
)
&&
!
params
.
has
(
"size"
)
&&
!
params
.
has
(
"end"
));
CV_Assert
(
!
params
.
has
(
"begin"
)
&&
!
params
.
has
(
"size"
)
&&
!
params
.
has
(
"end"
));
...
@@ -141,9 +142,10 @@ public:
...
@@ -141,9 +142,10 @@ public:
else
// Divide input blob on equal parts by axis.
else
// Divide input blob on equal parts by axis.
{
{
CV_Assert
(
0
<=
axis
&&
axis
<
inpShape
.
size
());
CV_Assert
(
0
<=
axis
&&
axis
<
inpShape
.
size
());
CV_Assert
(
requiredOutputs
>
0
&&
inpShape
[
axis
]
%
requiredOutputs
==
0
);
int
splits
=
num_split
?
num_split
:
requiredOutputs
;
inpShape
[
axis
]
/=
requiredOutputs
;
CV_Assert
(
splits
>
0
&&
inpShape
[
axis
]
%
splits
==
0
);
outputs
.
resize
(
requiredOutputs
,
inpShape
);
inpShape
[
axis
]
/=
splits
;
outputs
.
resize
(
splits
,
inpShape
);
}
}
return
false
;
return
false
;
}
}
...
...
modules/dnn/src/tensorflow/tf_importer.cpp
View file @
199ddff1
...
@@ -1410,6 +1410,9 @@ void TFImporter::populateNet(Net dstNet)
...
@@ -1410,6 +1410,9 @@ void TFImporter::populateNet(Net dstNet)
axis
=
toNCHW
(
axis
);
axis
=
toNCHW
(
axis
);
layerParams
.
set
(
"axis"
,
axis
);
layerParams
.
set
(
"axis"
,
axis
);
if
(
hasLayerAttr
(
layer
,
"num_split"
))
layerParams
.
set
(
"num_split"
,
getLayerAttr
(
layer
,
"num_split"
).
i
());
int
id
=
dstNet
.
addLayer
(
name
,
"Slice"
,
layerParams
);
int
id
=
dstNet
.
addLayer
(
name
,
"Slice"
,
layerParams
);
layer_id
[
name
]
=
id
;
layer_id
[
name
]
=
id
;
...
...
modules/dnn/test/test_misc.cpp
View file @
199ddff1
...
@@ -78,6 +78,26 @@ TEST(readNet, Regression)
...
@@ -78,6 +78,26 @@ TEST(readNet, Regression)
EXPECT_FALSE
(
net
.
empty
());
EXPECT_FALSE
(
net
.
empty
());
}
}
typedef
testing
::
TestWithParam
<
tuple
<
Backend
,
Target
>
>
dump
;
TEST_P
(
dump
,
Regression
)
{
const
int
backend
=
get
<
0
>
(
GetParam
());
const
int
target
=
get
<
1
>
(
GetParam
());
Net
net
=
readNet
(
findDataFile
(
"dnn/squeezenet_v1.1.prototxt"
),
findDataFile
(
"dnn/squeezenet_v1.1.caffemodel"
,
false
));
int
size
[]
=
{
1
,
3
,
227
,
227
};
Mat
input
=
cv
::
Mat
::
ones
(
4
,
size
,
CV_32F
);
net
.
setInput
(
input
);
net
.
setPreferableBackend
(
backend
);
net
.
setPreferableTarget
(
target
);
EXPECT_FALSE
(
net
.
dump
().
empty
());
net
.
forward
();
EXPECT_FALSE
(
net
.
dump
().
empty
());
}
INSTANTIATE_TEST_CASE_P
(
/**/
,
dump
,
dnnBackendsAndTargets
());
class
FirstCustomLayer
CV_FINAL
:
public
Layer
class
FirstCustomLayer
CV_FINAL
:
public
Layer
{
{
public
:
public
:
...
...
modules/dnn/test/test_onnx_importer.cpp
View file @
199ddff1
...
@@ -605,7 +605,7 @@ TEST_P(Test_ONNX_nets, Resnet34_kinetics)
...
@@ -605,7 +605,7 @@ TEST_P(Test_ONNX_nets, Resnet34_kinetics)
if
(
target
!=
DNN_TARGET_CPU
)
if
(
target
!=
DNN_TARGET_CPU
)
throw
SkipTestException
(
"Only CPU is supported"
);
throw
SkipTestException
(
"Only CPU is supported"
);
String
onnxmodel
=
findDataFile
(
"dnn/resnet-34_kinetics.onnx"
);
String
onnxmodel
=
findDataFile
(
"dnn/resnet-34_kinetics.onnx"
,
false
);
Mat
image0
=
imread
(
findDataFile
(
"dnn/dog416.png"
));
Mat
image0
=
imread
(
findDataFile
(
"dnn/dog416.png"
));
Mat
image1
=
imread
(
findDataFile
(
"dnn/street.png"
));
Mat
image1
=
imread
(
findDataFile
(
"dnn/street.png"
));
...
...
modules/dnn/test/test_tf_importer.cpp
View file @
199ddff1
...
@@ -350,6 +350,11 @@ TEST_P(Test_TensorFlow_layers, l2_normalize_3d)
...
@@ -350,6 +350,11 @@ TEST_P(Test_TensorFlow_layers, l2_normalize_3d)
runTensorFlowNet
(
"l2_normalize_3d"
);
runTensorFlowNet
(
"l2_normalize_3d"
);
}
}
TEST_P
(
Test_TensorFlow_layers
,
Split
)
{
runTensorFlowNet
(
"split"
);
}
class
Test_TensorFlow_nets
:
public
DNNTestLayer
{};
class
Test_TensorFlow_nets
:
public
DNNTestLayer
{};
TEST_P
(
Test_TensorFlow_nets
,
MobileNet_SSD
)
TEST_P
(
Test_TensorFlow_nets
,
MobileNet_SSD
)
...
...
modules/imgproc/src/thresh.cpp
View file @
199ddff1
...
@@ -1142,6 +1142,9 @@ getThreshVal_Otsu_8u( const Mat& _src )
...
@@ -1142,6 +1142,9 @@ getThreshVal_Otsu_8u( const Mat& _src )
const
int
N
=
256
;
const
int
N
=
256
;
int
i
,
j
,
h
[
N
]
=
{
0
};
int
i
,
j
,
h
[
N
]
=
{
0
};
#if CV_ENABLE_UNROLLED
int
h_unrolled
[
3
][
N
]
=
{};
#endif
for
(
i
=
0
;
i
<
size
.
height
;
i
++
)
for
(
i
=
0
;
i
<
size
.
height
;
i
++
)
{
{
const
uchar
*
src
=
_src
.
ptr
()
+
step
*
i
;
const
uchar
*
src
=
_src
.
ptr
()
+
step
*
i
;
...
@@ -1150,9 +1153,9 @@ getThreshVal_Otsu_8u( const Mat& _src )
...
@@ -1150,9 +1153,9 @@ getThreshVal_Otsu_8u( const Mat& _src )
for
(
;
j
<=
size
.
width
-
4
;
j
+=
4
)
for
(
;
j
<=
size
.
width
-
4
;
j
+=
4
)
{
{
int
v0
=
src
[
j
],
v1
=
src
[
j
+
1
];
int
v0
=
src
[
j
],
v1
=
src
[
j
+
1
];
h
[
v0
]
++
;
h
[
v1
]
++
;
h
[
v0
]
++
;
h
_unrolled
[
0
]
[
v1
]
++
;
v0
=
src
[
j
+
2
];
v1
=
src
[
j
+
3
];
v0
=
src
[
j
+
2
];
v1
=
src
[
j
+
3
];
h
[
v0
]
++
;
h
[
v1
]
++
;
h
_unrolled
[
1
][
v0
]
++
;
h_unrolled
[
2
]
[
v1
]
++
;
}
}
#endif
#endif
for
(
;
j
<
size
.
width
;
j
++
)
for
(
;
j
<
size
.
width
;
j
++
)
...
@@ -1161,7 +1164,12 @@ getThreshVal_Otsu_8u( const Mat& _src )
...
@@ -1161,7 +1164,12 @@ getThreshVal_Otsu_8u( const Mat& _src )
double
mu
=
0
,
scale
=
1.
/
(
size
.
width
*
size
.
height
);
double
mu
=
0
,
scale
=
1.
/
(
size
.
width
*
size
.
height
);
for
(
i
=
0
;
i
<
N
;
i
++
)
for
(
i
=
0
;
i
<
N
;
i
++
)
{
#if CV_ENABLE_UNROLLED
h
[
i
]
+=
h_unrolled
[
0
][
i
]
+
h_unrolled
[
1
][
i
]
+
h_unrolled
[
2
][
i
];
#endif
mu
+=
i
*
(
double
)
h
[
i
];
mu
+=
i
*
(
double
)
h
[
i
];
}
mu
*=
scale
;
mu
*=
scale
;
double
mu1
=
0
,
q1
=
0
;
double
mu1
=
0
,
q1
=
0
;
...
@@ -1206,6 +1214,9 @@ getThreshVal_Triangle_8u( const Mat& _src )
...
@@ -1206,6 +1214,9 @@ getThreshVal_Triangle_8u( const Mat& _src )
const
int
N
=
256
;
const
int
N
=
256
;
int
i
,
j
,
h
[
N
]
=
{
0
};
int
i
,
j
,
h
[
N
]
=
{
0
};
#if CV_ENABLE_UNROLLED
int
h_unrolled
[
3
][
N
]
=
{};
#endif
for
(
i
=
0
;
i
<
size
.
height
;
i
++
)
for
(
i
=
0
;
i
<
size
.
height
;
i
++
)
{
{
const
uchar
*
src
=
_src
.
ptr
()
+
step
*
i
;
const
uchar
*
src
=
_src
.
ptr
()
+
step
*
i
;
...
@@ -1214,9 +1225,9 @@ getThreshVal_Triangle_8u( const Mat& _src )
...
@@ -1214,9 +1225,9 @@ getThreshVal_Triangle_8u( const Mat& _src )
for
(
;
j
<=
size
.
width
-
4
;
j
+=
4
)
for
(
;
j
<=
size
.
width
-
4
;
j
+=
4
)
{
{
int
v0
=
src
[
j
],
v1
=
src
[
j
+
1
];
int
v0
=
src
[
j
],
v1
=
src
[
j
+
1
];
h
[
v0
]
++
;
h
[
v1
]
++
;
h
[
v0
]
++
;
h
_unrolled
[
0
]
[
v1
]
++
;
v0
=
src
[
j
+
2
];
v1
=
src
[
j
+
3
];
v0
=
src
[
j
+
2
];
v1
=
src
[
j
+
3
];
h
[
v0
]
++
;
h
[
v1
]
++
;
h
_unrolled
[
1
][
v0
]
++
;
h_unrolled
[
2
]
[
v1
]
++
;
}
}
#endif
#endif
for
(
;
j
<
size
.
width
;
j
++
)
for
(
;
j
<
size
.
width
;
j
++
)
...
@@ -1227,6 +1238,13 @@ getThreshVal_Triangle_8u( const Mat& _src )
...
@@ -1227,6 +1238,13 @@ getThreshVal_Triangle_8u( const Mat& _src )
int
temp
;
int
temp
;
bool
isflipped
=
false
;
bool
isflipped
=
false
;
#if CV_ENABLE_UNROLLED
for
(
i
=
0
;
i
<
N
;
i
++
)
{
h
[
i
]
+=
h_unrolled
[
0
][
i
]
+
h_unrolled
[
1
][
i
]
+
h_unrolled
[
2
][
i
];
}
#endif
for
(
i
=
0
;
i
<
N
;
i
++
)
for
(
i
=
0
;
i
<
N
;
i
++
)
{
{
if
(
h
[
i
]
>
0
)
if
(
h
[
i
]
>
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment