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
e82e672a
Commit
e82e672a
authored
Dec 05, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
parents
09b3dcb6
6fbf6f8b
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
302 additions
and
330 deletions
+302
-330
opencv.bib
doc/opencv.bib
+0
-11
py_hdr.markdown
doc/py_tutorials/py_photo/py_hdr/py_hdr.markdown
+2
-4
hdr_imaging.markdown
doc/tutorials/photo/hdr_imaging/hdr_imaging.markdown
+1
-1
arithm.cpp
modules/core/src/arithm.cpp
+43
-37
all_layers.hpp
modules/dnn/include/opencv2/dnn/all_layers.hpp
+9
-0
dnn.hpp
modules/dnn/include/opencv2/dnn/dnn.hpp
+3
-0
version.hpp
modules/dnn/include/opencv2/dnn/version.hpp
+1
-1
perf_net.cpp
modules/dnn/perf/perf_net.cpp
+0
-17
dnn.cpp
modules/dnn/src/dnn.cpp
+105
-0
init.cpp
modules/dnn/src/init.cpp
+1
-0
const_layer.cpp
modules/dnn/src/layers/const_layer.cpp
+68
-0
tf_importer.cpp
modules/dnn/src/tensorflow/tf_importer.cpp
+22
-5
test_caffe_importer.cpp
modules/dnn/test/test_caffe_importer.cpp
+5
-3
test_common.hpp
modules/dnn/test/test_common.hpp
+18
-86
test_googlenet.cpp
modules/dnn/test/test_googlenet.cpp
+11
-4
test_ie_models.cpp
modules/dnn/test/test_ie_models.cpp
+6
-22
test_misc.cpp
modules/dnn/test/test_misc.cpp
+0
-2
test_tf_importer.cpp
modules/dnn/test/test_tf_importer.cpp
+1
-0
imgproc.hpp
modules/imgproc/include/opencv2/imgproc.hpp
+1
-1
photo.hpp
modules/photo/include/opencv2/photo.hpp
+0
-37
tonemap.cpp
modules/photo/src/tonemap.cpp
+0
-88
test_hdr.cpp
modules/photo/test/test_hdr.cpp
+0
-6
perf_matchers.cpp
modules/stitching/perf/perf_matchers.cpp
+1
-1
hdr_imaging.cpp
samples/cpp/tutorial_code/photo/hdr_imaging/hdr_imaging.cpp
+1
-1
HDRImagingDemo.java
.../java/tutorial_code/photo/hdr_imaging/HDRImagingDemo.java
+2
-2
hdr_imaging.py
...les/python/tutorial_code/photo/hdr_imaging/hdr_imaging.py
+1
-1
No files found.
doc/opencv.bib
View file @
e82e672a
...
...
@@ -180,17 +180,6 @@
volume = {9},
publisher = {Walter de Gruyter}
}
@inproceedings{DD02,
author = {Durand, Fr{\'e}do and Dorsey, Julie},
title = {Fast bilateral filtering for the display of high-dynamic-range images},
booktitle = {ACM Transactions on Graphics (TOG)},
year = {2002},
pages = {257--266},
volume = {21},
number = {3},
publisher = {ACM},
url = {https://www.researchgate.net/profile/Julie_Dorsey/publication/220184746_Fast_Bilateral_Filtering_for_the_Display_of_High_-_dynamic_-_range_Images/links/54566b000cf26d5090a95f96/Fast-Bilateral-Filtering-for-the-Display-of-High-dynamic-range-Images.pdf}
}
@inproceedings{DM03,
author = {Drago, Fr{\'e}d{\'e}ric and Myszkowski, Karol and Annen, Thomas and Chiba, Norishige},
title = {Adaptive logarithmic mapping for displaying high contrast scenes},
...
...
doc/py_tutorials/py_photo/py_hdr/py_hdr.markdown
View file @
e82e672a
...
...
@@ -85,10 +85,8 @@ we will later have to clip the data in order to avoid overflow.
@code{.py}
# Tonemap HDR image
tonemap1 = cv.createTonemap
Durand
(gamma=2.2)
tonemap1 = cv.createTonemap(gamma=2.2)
res_debevec = tonemap1.process(hdr_debevec.copy())
tonemap2 = cv.createTonemapDurand(gamma=1.3)
res_robertson = tonemap2.process(hdr_robertson.copy())
@endcode
### 4. Merge exposures using Mertens fusion
...
...
@@ -173,5 +171,5 @@ Additional Resources
Exercises
---------
1.
Try all tonemap algorithms: cv::TonemapDrago, cv::Tonemap
Durand, cv::Tonemap
Mantiuk and cv::TonemapReinhard
1.
Try all tonemap algorithms: cv::TonemapDrago, cv::TonemapMantiuk and cv::TonemapReinhard
2.
Try changing the parameters in the HDR calibration and tonemap methods.
doc/tutorials/photo/hdr_imaging/hdr_imaging.markdown
View file @
e82e672a
...
...
@@ -171,7 +171,7 @@ Now it's time to look at the results. Note that HDR image can't be stored in one
formats, so we save it to Radiance image (.hdr). Also all HDR imaging functions return results in
[
0, 1
]
range so we should multiply result by 255.
You can try other tonemap algorithms: cv::TonemapDrago, cv::Tonemap
Durand, cv::Tonemap
Mantiuk and cv::TonemapReinhard
You can try other tonemap algorithms: cv::TonemapDrago, cv::TonemapMantiuk and cv::TonemapReinhard
You can also adjust the parameters in the HDR calibration and tonemap methods for your own photos.
Results
...
...
modules/core/src/arithm.cpp
View file @
e82e672a
...
...
@@ -1333,7 +1333,7 @@ struct InRange_SIMD
}
};
#if CV_SIMD
128
#if CV_SIMD
template
<>
struct
InRange_SIMD
<
uchar
>
...
...
@@ -1342,16 +1342,17 @@ struct InRange_SIMD<uchar>
uchar
*
dst
,
int
len
)
const
{
int
x
=
0
;
const
int
width
=
v_uint8
x16
::
nlanes
;
const
int
width
=
v_uint8
::
nlanes
;
for
(;
x
<=
len
-
width
;
x
+=
width
)
{
v_uint8
x16
values
=
v
_load
(
src1
+
x
);
v_uint8
x16
low
=
v
_load
(
src2
+
x
);
v_uint8
x16
high
=
v
_load
(
src3
+
x
);
v_uint8
values
=
vx
_load
(
src1
+
x
);
v_uint8
low
=
vx
_load
(
src2
+
x
);
v_uint8
high
=
vx
_load
(
src3
+
x
);
v_store
(
dst
+
x
,
(
values
>=
low
)
&
(
high
>=
values
));
}
vx_cleanup
();
return
x
;
}
};
...
...
@@ -1363,16 +1364,17 @@ struct InRange_SIMD<schar>
uchar
*
dst
,
int
len
)
const
{
int
x
=
0
;
const
int
width
=
v_int8
x16
::
nlanes
;
const
int
width
=
v_int8
::
nlanes
;
for
(;
x
<=
len
-
width
;
x
+=
width
)
{
v_int8
x16
values
=
v
_load
(
src1
+
x
);
v_int8
x16
low
=
v
_load
(
src2
+
x
);
v_int8
x16
high
=
v
_load
(
src3
+
x
);
v_int8
values
=
vx
_load
(
src1
+
x
);
v_int8
low
=
vx
_load
(
src2
+
x
);
v_int8
high
=
vx
_load
(
src3
+
x
);
v_store
((
schar
*
)(
dst
+
x
),
(
values
>=
low
)
&
(
high
>=
values
));
}
vx_cleanup
();
return
x
;
}
};
...
...
@@ -1384,20 +1386,21 @@ struct InRange_SIMD<ushort>
uchar
*
dst
,
int
len
)
const
{
int
x
=
0
;
const
int
width
=
v_uint16
x8
::
nlanes
*
2
;
const
int
width
=
v_uint16
::
nlanes
*
2
;
for
(;
x
<=
len
-
width
;
x
+=
width
)
{
v_uint16
x8
values1
=
v
_load
(
src1
+
x
);
v_uint16
x8
low1
=
v
_load
(
src2
+
x
);
v_uint16
x8
high1
=
v
_load
(
src3
+
x
);
v_uint16
values1
=
vx
_load
(
src1
+
x
);
v_uint16
low1
=
vx
_load
(
src2
+
x
);
v_uint16
high1
=
vx
_load
(
src3
+
x
);
v_uint16
x8
values2
=
v_load
(
src1
+
x
+
v_uint16x8
::
nlanes
);
v_uint16
x8
low2
=
v_load
(
src2
+
x
+
v_uint16x8
::
nlanes
);
v_uint16
x8
high2
=
v_load
(
src3
+
x
+
v_uint16x8
::
nlanes
);
v_uint16
values2
=
vx_load
(
src1
+
x
+
v_uint16
::
nlanes
);
v_uint16
low2
=
vx_load
(
src2
+
x
+
v_uint16
::
nlanes
);
v_uint16
high2
=
vx_load
(
src3
+
x
+
v_uint16
::
nlanes
);
v_store
(
dst
+
x
,
v_pack
((
values1
>=
low1
)
&
(
high1
>=
values1
),
(
values2
>=
low2
)
&
(
high2
>=
values2
)));
}
vx_cleanup
();
return
x
;
}
};
...
...
@@ -1409,20 +1412,21 @@ struct InRange_SIMD<short>
uchar
*
dst
,
int
len
)
const
{
int
x
=
0
;
const
int
width
=
(
int
)
v_int16
x8
::
nlanes
*
2
;
const
int
width
=
(
int
)
v_int16
::
nlanes
*
2
;
for
(;
x
<=
len
-
width
;
x
+=
width
)
{
v_int16
x8
values1
=
v
_load
(
src1
+
x
);
v_int16
x8
low1
=
v
_load
(
src2
+
x
);
v_int16
x8
high1
=
v
_load
(
src3
+
x
);
v_int16
values1
=
vx
_load
(
src1
+
x
);
v_int16
low1
=
vx
_load
(
src2
+
x
);
v_int16
high1
=
vx
_load
(
src3
+
x
);
v_int16
x8
values2
=
v_load
(
src1
+
x
+
v_int16x8
::
nlanes
);
v_int16
x8
low2
=
v_load
(
src2
+
x
+
v_int16x8
::
nlanes
);
v_int16
x8
high2
=
v_load
(
src3
+
x
+
v_int16x8
::
nlanes
);
v_int16
values2
=
vx_load
(
src1
+
x
+
v_int16
::
nlanes
);
v_int16
low2
=
vx_load
(
src2
+
x
+
v_int16
::
nlanes
);
v_int16
high2
=
vx_load
(
src3
+
x
+
v_int16
::
nlanes
);
v_store
((
schar
*
)(
dst
+
x
),
v_pack
((
values1
>=
low1
)
&
(
high1
>=
values1
),
(
values2
>=
low2
)
&
(
high2
>=
values2
)));
}
vx_cleanup
();
return
x
;
}
};
...
...
@@ -1434,20 +1438,21 @@ struct InRange_SIMD<int>
uchar
*
dst
,
int
len
)
const
{
int
x
=
0
;
const
int
width
=
(
int
)
v_int32
x4
::
nlanes
*
2
;
const
int
width
=
(
int
)
v_int32
::
nlanes
*
2
;
for
(;
x
<=
len
-
width
;
x
+=
width
)
{
v_int32
x4
values1
=
v
_load
(
src1
+
x
);
v_int32
x4
low1
=
v
_load
(
src2
+
x
);
v_int32
x4
high1
=
v
_load
(
src3
+
x
);
v_int32
values1
=
vx
_load
(
src1
+
x
);
v_int32
low1
=
vx
_load
(
src2
+
x
);
v_int32
high1
=
vx
_load
(
src3
+
x
);
v_int32
x4
values2
=
v_load
(
src1
+
x
+
v_int32x4
::
nlanes
);
v_int32
x4
low2
=
v_load
(
src2
+
x
+
v_int32x4
::
nlanes
);
v_int32
x4
high2
=
v_load
(
src3
+
x
+
v_int32x4
::
nlanes
);
v_int32
values2
=
vx_load
(
src1
+
x
+
v_int32
::
nlanes
);
v_int32
low2
=
vx_load
(
src2
+
x
+
v_int32
::
nlanes
);
v_int32
high2
=
vx_load
(
src3
+
x
+
v_int32
::
nlanes
);
v_pack_store
(
dst
+
x
,
v_reinterpret_as_u16
(
v_pack
((
values1
>=
low1
)
&
(
high1
>=
values1
),
(
values2
>=
low2
)
&
(
high2
>=
values2
))));
}
vx_cleanup
();
return
x
;
}
};
...
...
@@ -1459,20 +1464,21 @@ struct InRange_SIMD<float>
uchar
*
dst
,
int
len
)
const
{
int
x
=
0
;
const
int
width
=
(
int
)
v_float32
x4
::
nlanes
*
2
;
const
int
width
=
(
int
)
v_float32
::
nlanes
*
2
;
for
(;
x
<=
len
-
width
;
x
+=
width
)
{
v_float32
x4
values1
=
v
_load
(
src1
+
x
);
v_float32
x4
low1
=
v
_load
(
src2
+
x
);
v_float32
x4
high1
=
v
_load
(
src3
+
x
);
v_float32
values1
=
vx
_load
(
src1
+
x
);
v_float32
low1
=
vx
_load
(
src2
+
x
);
v_float32
high1
=
vx
_load
(
src3
+
x
);
v_float32
x4
values2
=
v_load
(
src1
+
x
+
v_float32x4
::
nlanes
);
v_float32
x4
low2
=
v_load
(
src2
+
x
+
v_float32x4
::
nlanes
);
v_float32
x4
high2
=
v_load
(
src3
+
x
+
v_float32x4
::
nlanes
);
v_float32
values2
=
vx_load
(
src1
+
x
+
v_float32
::
nlanes
);
v_float32
low2
=
vx_load
(
src2
+
x
+
v_float32
::
nlanes
);
v_float32
high2
=
vx_load
(
src3
+
x
+
v_float32
::
nlanes
);
v_pack_store
(
dst
+
x
,
v_pack
(
v_reinterpret_as_u32
((
values1
>=
low1
)
&
(
high1
>=
values1
)),
v_reinterpret_as_u32
((
values2
>=
low2
)
&
(
high2
>=
values2
))));
}
vx_cleanup
();
return
x
;
}
};
...
...
modules/dnn/include/opencv2/dnn/all_layers.hpp
View file @
e82e672a
...
...
@@ -77,6 +77,15 @@ CV__DNN_INLINE_NS_BEGIN
static
Ptr
<
Layer
>
create
(
const
LayerParams
&
params
);
};
/**
* Constant layer produces the same data blob at an every forward pass.
*/
class
CV_EXPORTS
ConstLayer
:
public
Layer
{
public
:
static
Ptr
<
Layer
>
create
(
const
LayerParams
&
params
);
};
//! LSTM recurrent layer
class
CV_EXPORTS
LSTMLayer
:
public
Layer
{
...
...
modules/dnn/include/opencv2/dnn/dnn.hpp
View file @
e82e672a
...
...
@@ -88,6 +88,9 @@ CV__DNN_INLINE_NS_BEGIN
DNN_TARGET_FPGA
};
CV_EXPORTS
std
::
vector
<
std
::
pair
<
Backend
,
Target
>
>
getAvailableBackends
();
CV_EXPORTS
std
::
vector
<
Target
>
getAvailableTargets
(
Backend
be
);
/** @brief This class provides all data needed to initialize layer.
*
* It includes dictionary with scalar params (which can be read by using Dict interface),
...
...
modules/dnn/include/opencv2/dnn/version.hpp
View file @
e82e672a
...
...
@@ -6,7 +6,7 @@
#define OPENCV_DNN_VERSION_HPP
/// Use with major OpenCV version only.
#define OPENCV_DNN_API_VERSION 20181
121
#define OPENCV_DNN_API_VERSION 20181
205
#if !defined CV_DOXYGEN && !defined CV_DNN_DONT_ADD_INLINE_NS
#define CV__DNN_INLINE_NS __CV_CAT(dnn4_v, OPENCV_DNN_API_VERSION)
...
...
modules/dnn/perf/perf_net.cpp
View file @
e82e672a
...
...
@@ -31,23 +31,6 @@ public:
void
processNet
(
std
::
string
weights
,
std
::
string
proto
,
std
::
string
halide_scheduler
,
const
Mat
&
input
,
const
std
::
string
&
outputLayer
=
""
)
{
if
(
backend
==
DNN_BACKEND_OPENCV
&&
(
target
==
DNN_TARGET_OPENCL
||
target
==
DNN_TARGET_OPENCL_FP16
))
{
#if defined(HAVE_OPENCL)
if
(
!
cv
::
ocl
::
useOpenCL
())
#endif
{
throw
cvtest
::
SkipTestException
(
"OpenCL is not available/disabled in OpenCV"
);
}
}
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE
&&
target
==
DNN_TARGET_MYRIAD
)
{
if
(
!
checkIETarget
(
DNN_TARGET_MYRIAD
))
{
throw
SkipTestException
(
"Myriad is not available/disabled in OpenCV"
);
}
}
randu
(
input
,
0.0
f
,
1.0
f
);
weights
=
findDataFile
(
weights
,
false
);
...
...
modules/dnn/src/dnn.cpp
View file @
e82e672a
...
...
@@ -85,6 +85,111 @@ using std::map;
using
std
::
make_pair
;
using
std
::
set
;
//==================================================================================================
class
BackendRegistry
{
public
:
typedef
std
::
vector
<
std
::
pair
<
Backend
,
Target
>
>
BackendsList
;
const
BackendsList
&
getBackends
()
const
{
return
backends
;
}
static
BackendRegistry
&
getRegistry
()
{
static
BackendRegistry
impl
;
return
impl
;
}
private
:
BackendRegistry
()
{
#ifdef HAVE_HALIDE
backends
.
push_back
(
std
::
make_pair
(
DNN_BACKEND_HALIDE
,
DNN_TARGET_CPU
));
# ifdef HAVE_OPENCL
if
(
cv
::
ocl
::
useOpenCL
())
backends
.
push_back
(
std
::
make_pair
(
DNN_BACKEND_HALIDE
,
DNN_TARGET_OPENCL
));
# endif
#endif // HAVE_HALIDE
#ifdef HAVE_INF_ENGINE
if
(
checkIETarget
(
DNN_TARGET_CPU
))
backends
.
push_back
(
std
::
make_pair
(
DNN_BACKEND_INFERENCE_ENGINE
,
DNN_TARGET_CPU
));
if
(
checkIETarget
(
DNN_TARGET_MYRIAD
))
backends
.
push_back
(
std
::
make_pair
(
DNN_BACKEND_INFERENCE_ENGINE
,
DNN_TARGET_MYRIAD
));
if
(
checkIETarget
(
DNN_TARGET_FPGA
))
backends
.
push_back
(
std
::
make_pair
(
DNN_BACKEND_INFERENCE_ENGINE
,
DNN_TARGET_FPGA
));
# ifdef HAVE_OPENCL
if
(
cv
::
ocl
::
useOpenCL
()
&&
ocl
::
Device
::
getDefault
().
isIntel
())
{
if
(
checkIETarget
(
DNN_TARGET_OPENCL
))
backends
.
push_back
(
std
::
make_pair
(
DNN_BACKEND_INFERENCE_ENGINE
,
DNN_TARGET_OPENCL
));
if
(
checkIETarget
(
DNN_TARGET_OPENCL_FP16
))
backends
.
push_back
(
std
::
make_pair
(
DNN_BACKEND_INFERENCE_ENGINE
,
DNN_TARGET_OPENCL_FP16
));
}
# endif
#endif // HAVE_INF_ENGINE
#ifdef HAVE_OPENCL
if
(
cv
::
ocl
::
useOpenCL
())
{
backends
.
push_back
(
std
::
make_pair
(
DNN_BACKEND_OPENCV
,
DNN_TARGET_OPENCL
));
backends
.
push_back
(
std
::
make_pair
(
DNN_BACKEND_OPENCV
,
DNN_TARGET_OPENCL_FP16
));
}
#endif
backends
.
push_back
(
std
::
make_pair
(
DNN_BACKEND_OPENCV
,
DNN_TARGET_CPU
));
#ifdef HAVE_VULKAN
backends
.
push_back
(
std
::
make_pair
(
DNN_BACKEND_VKCOM
,
DNN_TARGET_VULKAN
));
// TODO Add device check
#endif
}
static
inline
bool
checkIETarget
(
int
target
)
{
#ifndef HAVE_INF_ENGINE
return
false
;
#else
cv
::
dnn
::
Net
net
;
cv
::
dnn
::
LayerParams
lp
;
net
.
addLayerToPrev
(
"testLayer"
,
"Identity"
,
lp
);
net
.
setPreferableBackend
(
cv
::
dnn
::
DNN_BACKEND_INFERENCE_ENGINE
);
net
.
setPreferableTarget
(
target
);
static
int
inpDims
[]
=
{
1
,
2
,
3
,
4
};
net
.
setInput
(
cv
::
Mat
(
4
,
&
inpDims
[
0
],
CV_32FC1
,
cv
::
Scalar
(
0
)));
try
{
net
.
forward
();
}
catch
(...)
{
return
false
;
}
return
true
;
#endif
}
BackendsList
backends
;
};
std
::
vector
<
std
::
pair
<
Backend
,
Target
>
>
getAvailableBackends
()
{
return
BackendRegistry
::
getRegistry
().
getBackends
();
}
std
::
vector
<
Target
>
getAvailableTargets
(
Backend
be
)
{
if
(
be
==
DNN_BACKEND_DEFAULT
)
be
=
(
Backend
)
PARAM_DNN_BACKEND_DEFAULT
;
std
::
vector
<
Target
>
result
;
const
BackendRegistry
::
BackendsList
all_backends
=
getAvailableBackends
();
for
(
BackendRegistry
::
BackendsList
::
const_iterator
i
=
all_backends
.
begin
();
i
!=
all_backends
.
end
();
++
i
)
{
if
(
i
->
first
==
be
)
result
.
push_back
(
i
->
second
);
}
return
result
;
}
//==================================================================================================
namespace
{
typedef
std
::
vector
<
MatShape
>
ShapesVec
;
...
...
modules/dnn/src/init.cpp
View file @
e82e672a
...
...
@@ -112,6 +112,7 @@ void initializeLayerFactory()
CV_DNN_REGISTER_LAYER_CLASS
(
Dropout
,
BlankLayer
);
CV_DNN_REGISTER_LAYER_CLASS
(
Identity
,
BlankLayer
);
CV_DNN_REGISTER_LAYER_CLASS
(
Silence
,
BlankLayer
);
CV_DNN_REGISTER_LAYER_CLASS
(
Const
,
ConstLayer
);
CV_DNN_REGISTER_LAYER_CLASS
(
Crop
,
CropLayer
);
CV_DNN_REGISTER_LAYER_CLASS
(
Eltwise
,
EltwiseLayer
);
...
...
modules/dnn/src/layers/const_layer.cpp
0 → 100644
View file @
e82e672a
// 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.
// Copyright (C) 2018, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
#include "../precomp.hpp"
#include "layers_common.hpp"
#ifdef HAVE_OPENCL
#include "opencl_kernels_dnn.hpp"
#endif
namespace
cv
{
namespace
dnn
{
class
ConstLayerImpl
CV_FINAL
:
public
ConstLayer
{
public
:
ConstLayerImpl
(
const
LayerParams
&
params
)
{
setParamsFrom
(
params
);
CV_Assert
(
blobs
.
size
()
==
1
);
}
virtual
bool
getMemoryShapes
(
const
std
::
vector
<
MatShape
>
&
inputs
,
const
int
requiredOutputs
,
std
::
vector
<
MatShape
>
&
outputs
,
std
::
vector
<
MatShape
>
&
internals
)
const
CV_OVERRIDE
{
CV_Assert
(
inputs
.
empty
());
outputs
.
assign
(
1
,
shape
(
blobs
[
0
]));
return
false
;
}
#ifdef HAVE_OPENCL
bool
forward_ocl
(
InputArrayOfArrays
inps
,
OutputArrayOfArrays
outs
,
OutputArrayOfArrays
internals
)
{
std
::
vector
<
UMat
>
outputs
;
outs
.
getUMatVector
(
outputs
);
if
(
outs
.
depth
()
==
CV_16S
)
convertFp16
(
blobs
[
0
],
outputs
[
0
]);
else
blobs
[
0
].
copyTo
(
outputs
[
0
]);
return
true
;
}
#endif
void
forward
(
InputArrayOfArrays
inputs_arr
,
OutputArrayOfArrays
outputs_arr
,
OutputArrayOfArrays
internals_arr
)
CV_OVERRIDE
{
CV_TRACE_FUNCTION
();
CV_TRACE_ARG_VALUE
(
name
,
"name"
,
name
.
c_str
());
CV_OCL_RUN
(
IS_DNN_OPENCL_TARGET
(
preferableTarget
),
forward_ocl
(
inputs_arr
,
outputs_arr
,
internals_arr
))
std
::
vector
<
Mat
>
outputs
;
outputs_arr
.
getMatVector
(
outputs
);
blobs
[
0
].
copyTo
(
outputs
[
0
]);
}
};
Ptr
<
Layer
>
ConstLayer
::
create
(
const
LayerParams
&
params
)
{
return
Ptr
<
Layer
>
(
new
ConstLayerImpl
(
params
));
}
}}
// namespace cv::dnn
modules/dnn/src/tensorflow/tf_importer.cpp
View file @
e82e672a
...
...
@@ -1266,14 +1266,31 @@ void TFImporter::populateNet(Net dstNet)
axis
=
toNCHW
(
axis
);
layerParams
.
set
(
"axis"
,
axis
);
int
id
=
dstNet
.
addLayer
(
name
,
"Concat"
,
layerParams
);
layer_id
[
name
]
=
id
;
// input(0) or input(n-1) is concat_dim
int
from
=
(
type
==
"Concat"
?
1
:
0
);
int
to
=
(
type
==
"Concat"
?
layer
.
input_size
()
:
layer
.
input_size
()
-
1
);
// input(0) or input(n-1) is concat_dim
for
(
int
ii
=
from
;
ii
<
to
;
ii
++
)
{
Pin
inp
=
parsePin
(
layer
.
input
(
ii
));
if
(
layer_id
.
find
(
inp
.
name
)
==
layer_id
.
end
())
{
// There are constant inputs.
LayerParams
lp
;
lp
.
name
=
inp
.
name
;
lp
.
type
=
"Const"
;
lp
.
blobs
.
resize
(
1
);
blobFromTensor
(
getConstBlob
(
layer
,
value_id
,
ii
),
lp
.
blobs
.
back
());
CV_Assert_N
(
!
lp
.
blobs
[
0
].
empty
(),
lp
.
blobs
[
0
].
type
()
==
CV_32F
);
int
constInpId
=
dstNet
.
addLayer
(
lp
.
name
,
lp
.
type
,
lp
);
layer_id
[
lp
.
name
]
=
constInpId
;
}
}
int
id
=
dstNet
.
addLayer
(
name
,
"Concat"
,
layerParams
);
layer_id
[
name
]
=
id
;
for
(
int
ii
=
from
;
ii
<
to
;
ii
++
)
{
Pin
inp
=
parsePin
(
layer
.
input
(
ii
));
...
...
modules/dnn/test/test_caffe_importer.cpp
View file @
e82e672a
...
...
@@ -300,10 +300,11 @@ INSTANTIATE_TEST_CASE_P(/**/, Reproducibility_ResNet50,
typedef
testing
::
TestWithParam
<
Target
>
Reproducibility_SqueezeNet_v1_1
;
TEST_P
(
Reproducibility_SqueezeNet_v1_1
,
Accuracy
)
{
int
targetId
=
GetParam
();
if
(
targetId
==
DNN_TARGET_OPENCL_FP16
)
throw
SkipTestException
(
"This test does not support FP16"
);
Net
net
=
readNetFromCaffe
(
findDataFile
(
"dnn/squeezenet_v1.1.prototxt"
,
false
),
findDataFile
(
"dnn/squeezenet_v1.1.caffemodel"
,
false
));
int
targetId
=
GetParam
();
net
.
setPreferableBackend
(
DNN_BACKEND_OPENCV
);
net
.
setPreferableTarget
(
targetId
);
...
...
@@ -324,7 +325,8 @@ TEST_P(Reproducibility_SqueezeNet_v1_1, Accuracy)
Mat
ref
=
blobFromNPY
(
_tf
(
"squeezenet_v1.1_prob.npy"
));
normAssert
(
ref
,
out
);
}
INSTANTIATE_TEST_CASE_P
(
/**/
,
Reproducibility_SqueezeNet_v1_1
,
availableDnnTargets
());
INSTANTIATE_TEST_CASE_P
(
/**/
,
Reproducibility_SqueezeNet_v1_1
,
testing
::
ValuesIn
(
getAvailableTargets
(
DNN_BACKEND_OPENCV
)));
TEST
(
Reproducibility_AlexNet_fp16
,
Accuracy
)
{
...
...
modules/dnn/test/test_common.hpp
View file @
e82e672a
...
...
@@ -191,30 +191,6 @@ static inline void normAssertDetections(cv::Mat ref, cv::Mat out, const char *co
testBoxes
,
comment
,
confThreshold
,
scores_diff
,
boxes_iou_diff
);
}
static
inline
bool
checkIETarget
(
int
target
)
{
#ifndef HAVE_INF_ENGINE
return
false
;
#else
cv
::
dnn
::
Net
net
;
cv
::
dnn
::
LayerParams
lp
;
net
.
addLayerToPrev
(
"testLayer"
,
"Identity"
,
lp
);
net
.
setPreferableBackend
(
cv
::
dnn
::
DNN_BACKEND_INFERENCE_ENGINE
);
net
.
setPreferableTarget
(
target
);
static
int
inpDims
[]
=
{
1
,
2
,
3
,
4
};
net
.
setInput
(
cv
::
Mat
(
4
,
&
inpDims
[
0
],
CV_32FC1
,
cv
::
Scalar
(
0
)));
try
{
net
.
forward
();
}
catch
(...)
{
return
false
;
}
return
true
;
#endif
}
static
inline
bool
readFileInMemory
(
const
std
::
string
&
filename
,
std
::
string
&
content
)
{
std
::
ios
::
openmode
mode
=
std
::
ios
::
in
|
std
::
ios
::
binary
;
...
...
@@ -239,52 +215,36 @@ namespace opencv_test {
using
namespace
cv
::
dnn
;
static
inline
testing
::
internal
::
ParamGenerator
<
tuple
<
Backend
,
Target
>
>
dnnBackendsAndTargets
(
testing
::
internal
::
ParamGenerator
<
tuple
<
Backend
,
Target
>
>
dnnBackendsAndTargets
(
bool
withInferenceEngine
=
true
,
bool
withHalide
=
false
,
bool
withCpuOCV
=
true
,
bool
withVkCom
=
true
)
{
std
::
vector
<
tuple
<
Backend
,
Target
>
>
targets
;
#ifdef HAVE_HALIDE
std
::
vector
<
tuple
<
Backend
,
Target
>
>
targets
;
std
::
vector
<
Target
>
available
;
if
(
withHalide
)
{
targets
.
push_back
(
make_tuple
(
DNN_BACKEND_HALIDE
,
DNN_TARGET_CPU
));
#ifdef HAVE_OPENCL
if
(
cv
::
ocl
::
useOpenCL
())
targets
.
push_back
(
make_tuple
(
DNN_BACKEND_HALIDE
,
DNN_TARGET_OPENCL
));
#endif
available
=
getAvailableTargets
(
DNN_BACKEND_HALIDE
);
for
(
std
::
vector
<
Target
>::
const_iterator
i
=
available
.
begin
();
i
!=
available
.
end
();
++
i
)
targets
.
push_back
(
make_tuple
(
DNN_BACKEND_HALIDE
,
*
i
));
}
#endif
#ifdef HAVE_INF_ENGINE
if
(
withInferenceEngine
)
{
targets
.
push_back
(
make_tuple
(
DNN_BACKEND_INFERENCE_ENGINE
,
DNN_TARGET_CPU
));
#ifdef HAVE_OPENCL
if
(
cv
::
ocl
::
useOpenCL
()
&&
ocl
::
Device
::
getDefault
().
isIntel
())
{
targets
.
push_back
(
make_tuple
(
DNN_BACKEND_INFERENCE_ENGINE
,
DNN_TARGET_OPENCL
));
targets
.
push_back
(
make_tuple
(
DNN_BACKEND_INFERENCE_ENGINE
,
DNN_TARGET_OPENCL_FP16
));
}
#endif
if
(
checkIETarget
(
DNN_TARGET_MYRIAD
))
targets
.
push_back
(
make_tuple
(
DNN_BACKEND_INFERENCE_ENGINE
,
DNN_TARGET_MYRIAD
));
available
=
getAvailableTargets
(
DNN_BACKEND_INFERENCE_ENGINE
);
for
(
std
::
vector
<
Target
>::
const_iterator
i
=
available
.
begin
();
i
!=
available
.
end
();
++
i
)
targets
.
push_back
(
make_tuple
(
DNN_BACKEND_INFERENCE_ENGINE
,
*
i
));
}
#endif
if
(
withCpuOCV
)
targets
.
push_back
(
make_tuple
(
DNN_BACKEND_OPENCV
,
DNN_TARGET_CPU
));
#ifdef HAVE_OPENCL
if
(
cv
::
ocl
::
useOpenCL
())
{
targets
.
push_back
(
make_tuple
(
DNN_BACKEND_OPENCV
,
DNN_TARGET_OPENCL
));
targets
.
push_back
(
make_tuple
(
DNN_BACKEND_OPENCV
,
DNN_TARGET_OPENCL_FP16
));
available
=
getAvailableTargets
(
DNN_BACKEND_OPENCV
);
for
(
std
::
vector
<
Target
>::
const_iterator
i
=
available
.
begin
();
i
!=
available
.
end
();
++
i
)
{
if
(
!
withCpuOCV
&&
*
i
==
DNN_TARGET_CPU
)
continue
;
targets
.
push_back
(
make_tuple
(
DNN_BACKEND_OPENCV
,
*
i
));
}
}
#endif
#ifdef HAVE_VULKAN
if
(
withVkCom
)
targets
.
push_back
(
make_tuple
(
DNN_BACKEND_VKCOM
,
DNN_TARGET_VULKAN
));
#endif
if
(
targets
.
empty
())
// validate at least CPU mode
targets
.
push_back
(
make_tuple
(
DNN_BACKEND_OPENCV
,
DNN_TARGET_CPU
));
return
testing
::
ValuesIn
(
targets
);
...
...
@@ -296,21 +256,6 @@ testing::internal::ParamGenerator<tuple<Backend, Target> > dnnBackendsAndTargets
namespace
opencv_test
{
using
namespace
cv
::
dnn
;
static
inline
testing
::
internal
::
ParamGenerator
<
Target
>
availableDnnTargets
()
{
static
std
::
vector
<
Target
>
targets
;
if
(
targets
.
empty
())
{
targets
.
push_back
(
DNN_TARGET_CPU
);
#ifdef HAVE_OPENCL
if
(
cv
::
ocl
::
useOpenCL
())
targets
.
push_back
(
DNN_TARGET_OPENCL
);
#endif
}
return
testing
::
ValuesIn
(
targets
);
}
class
DNNTestLayer
:
public
TestWithParam
<
tuple
<
Backend
,
Target
>
>
{
public
:
...
...
@@ -339,23 +284,10 @@ public:
}
}
static
void
checkBackend
(
int
backend
,
int
target
,
Mat
*
inp
=
0
,
Mat
*
ref
=
0
)
{
if
(
backend
==
DNN_BACKEND_OPENCV
&&
(
target
==
DNN_TARGET_OPENCL
||
target
==
DNN_TARGET_OPENCL_FP16
))
{
#ifdef HAVE_OPENCL
if
(
!
cv
::
ocl
::
useOpenCL
())
#endif
{
throw
SkipTestException
(
"OpenCL is not available/disabled in OpenCV"
);
}
}
static
void
checkBackend
(
int
backend
,
int
target
,
Mat
*
inp
=
0
,
Mat
*
ref
=
0
)
{
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE
&&
target
==
DNN_TARGET_MYRIAD
)
{
if
(
!
checkIETarget
(
DNN_TARGET_MYRIAD
))
{
throw
SkipTestException
(
"Myriad is not available/disabled in OpenCV"
);
}
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_RELEASE < 2018030000
if
(
inp
&&
ref
&&
inp
->
size
[
0
]
!=
1
)
{
...
...
modules/dnn/test/test_googlenet.cpp
View file @
e82e672a
...
...
@@ -55,9 +55,11 @@ static std::string _tf(TString filename)
typedef
testing
::
TestWithParam
<
Target
>
Reproducibility_GoogLeNet
;
TEST_P
(
Reproducibility_GoogLeNet
,
Batching
)
{
const
int
targetId
=
GetParam
();
if
(
targetId
==
DNN_TARGET_OPENCL_FP16
)
throw
SkipTestException
(
"This test does not support FP16"
);
Net
net
=
readNetFromCaffe
(
findDataFile
(
"dnn/bvlc_googlenet.prototxt"
,
false
),
findDataFile
(
"dnn/bvlc_googlenet.caffemodel"
,
false
));
int
targetId
=
GetParam
();
net
.
setPreferableBackend
(
DNN_BACKEND_OPENCV
);
net
.
setPreferableTarget
(
targetId
);
...
...
@@ -84,9 +86,11 @@ TEST_P(Reproducibility_GoogLeNet, Batching)
TEST_P
(
Reproducibility_GoogLeNet
,
IntermediateBlobs
)
{
const
int
targetId
=
GetParam
();
if
(
targetId
==
DNN_TARGET_OPENCL_FP16
)
throw
SkipTestException
(
"This test does not support FP16"
);
Net
net
=
readNetFromCaffe
(
findDataFile
(
"dnn/bvlc_googlenet.prototxt"
,
false
),
findDataFile
(
"dnn/bvlc_googlenet.caffemodel"
,
false
));
int
targetId
=
GetParam
();
net
.
setPreferableBackend
(
DNN_BACKEND_OPENCV
);
net
.
setPreferableTarget
(
targetId
);
...
...
@@ -113,9 +117,11 @@ TEST_P(Reproducibility_GoogLeNet, IntermediateBlobs)
TEST_P
(
Reproducibility_GoogLeNet
,
SeveralCalls
)
{
const
int
targetId
=
GetParam
();
if
(
targetId
==
DNN_TARGET_OPENCL_FP16
)
throw
SkipTestException
(
"This test does not support FP16"
);
Net
net
=
readNetFromCaffe
(
findDataFile
(
"dnn/bvlc_googlenet.prototxt"
,
false
),
findDataFile
(
"dnn/bvlc_googlenet.caffemodel"
,
false
));
int
targetId
=
GetParam
();
net
.
setPreferableBackend
(
DNN_BACKEND_OPENCV
);
net
.
setPreferableTarget
(
targetId
);
...
...
@@ -143,6 +149,7 @@ TEST_P(Reproducibility_GoogLeNet, SeveralCalls)
normAssert
(
outs
[
0
],
ref
,
""
,
1E-4
,
1E-2
);
}
INSTANTIATE_TEST_CASE_P
(
/**/
,
Reproducibility_GoogLeNet
,
availableDnnTargets
());
INSTANTIATE_TEST_CASE_P
(
/**/
,
Reproducibility_GoogLeNet
,
testing
::
ValuesIn
(
getAvailableTargets
(
DNN_BACKEND_OPENCV
)));
}}
// namespace
modules/dnn/test/test_ie_models.cpp
View file @
e82e672a
...
...
@@ -203,7 +203,8 @@ TEST_P(DNNTestOpenVINO, models)
std
::
map
<
std
::
string
,
cv
::
Mat
>
inputsMap
;
std
::
map
<
std
::
string
,
cv
::
Mat
>
ieOutputsMap
,
cvOutputsMap
;
// Single Myriad device cannot be shared across multiple processes.
resetMyriadDevice
();
if
(
target
==
DNN_TARGET_MYRIAD
)
resetMyriadDevice
();
runIE
(
target
,
xmlPath
,
binPath
,
inputsMap
,
ieOutputsMap
);
runCV
(
target
,
xmlPath
,
binPath
,
inputsMap
,
cvOutputsMap
);
...
...
@@ -245,27 +246,10 @@ static testing::internal::ParamGenerator<String> intelModels()
return
ValuesIn
(
modelsNames
);
}
static
testing
::
internal
::
ParamGenerator
<
Target
>
dnnDLIETargets
()
{
std
::
vector
<
Target
>
targets
;
targets
.
push_back
(
DNN_TARGET_CPU
);
#ifdef HAVE_OPENCL
if
(
cv
::
ocl
::
useOpenCL
()
&&
ocl
::
Device
::
getDefault
().
isIntel
())
{
targets
.
push_back
(
DNN_TARGET_OPENCL
);
targets
.
push_back
(
DNN_TARGET_OPENCL_FP16
);
}
#endif
if
(
checkIETarget
(
DNN_TARGET_MYRIAD
))
targets
.
push_back
(
DNN_TARGET_MYRIAD
);
if
(
checkIETarget
(
DNN_TARGET_FPGA
))
targets
.
push_back
(
DNN_TARGET_FPGA
);
return
testing
::
ValuesIn
(
targets
);
}
INSTANTIATE_TEST_CASE_P
(
/**/
,
DNNTestOpenVINO
,
Combine
(
dnnDLIETargets
(),
intelModels
()
));
INSTANTIATE_TEST_CASE_P
(
/**/
,
DNNTestOpenVINO
,
Combine
(
testing
::
ValuesIn
(
getAvailableTargets
(
DNN_BACKEND_INFERENCE_ENGINE
)),
intelModels
())
);
}}
#endif // HAVE_INF_ENGINE
modules/dnn/test/test_misc.cpp
View file @
e82e672a
...
...
@@ -157,8 +157,6 @@ TEST_P(setInput, normalization)
const
int
target
=
get
<
1
>
(
get
<
3
>
(
GetParam
()));
const
bool
kSwapRB
=
true
;
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE
&&
target
==
DNN_TARGET_MYRIAD
&&
!
checkIETarget
(
DNN_TARGET_MYRIAD
))
throw
SkipTestException
(
"Myriad is not available/disabled in OpenCV"
);
if
(
backend
==
DNN_BACKEND_OPENCV
&&
target
==
DNN_TARGET_OPENCL_FP16
&&
dtype
!=
CV_32F
)
throw
SkipTestException
(
""
);
if
(
backend
==
DNN_BACKEND_VKCOM
&&
dtype
!=
CV_32F
)
...
...
modules/dnn/test/test_tf_importer.cpp
View file @
e82e672a
...
...
@@ -136,6 +136,7 @@ TEST_P(Test_TensorFlow_layers, padding)
runTensorFlowNet
(
"padding_same"
);
runTensorFlowNet
(
"padding_valid"
);
runTensorFlowNet
(
"spatial_padding"
);
runTensorFlowNet
(
"keras_pad_concat"
);
}
TEST_P
(
Test_TensorFlow_layers
,
eltwise_add_mul
)
...
...
modules/imgproc/include/opencv2/imgproc.hpp
View file @
e82e672a
...
...
@@ -4659,7 +4659,7 @@ LineIterator it2 = it;
vector<Vec3b> buf(it.count);
for(int i = 0; i < it.count; i++, ++it)
buf[i] = *(const Vec3b)*it;
buf[i] = *(const Vec3b
*
)*it;
// alternative way of iterating through the line
for(int i = 0; i < it2.count; i++, ++it2)
...
...
modules/photo/include/opencv2/photo.hpp
View file @
e82e672a
...
...
@@ -376,43 +376,6 @@ results, default value is 0.85.
*/
CV_EXPORTS_W
Ptr
<
TonemapDrago
>
createTonemapDrago
(
float
gamma
=
1.0
f
,
float
saturation
=
1.0
f
,
float
bias
=
0.85
f
);
/** @brief This algorithm decomposes image into two layers: base layer and detail layer using bilateral filter
and compresses contrast of the base layer thus preserving all the details.
This implementation uses regular bilateral filter from opencv.
Saturation enhancement is possible as in ocvTonemapDrago.
For more information see @cite DD02 .
*/
class
CV_EXPORTS_W
TonemapDurand
:
public
Tonemap
{
public
:
CV_WRAP
virtual
float
getSaturation
()
const
=
0
;
CV_WRAP
virtual
void
setSaturation
(
float
saturation
)
=
0
;
CV_WRAP
virtual
float
getContrast
()
const
=
0
;
CV_WRAP
virtual
void
setContrast
(
float
contrast
)
=
0
;
CV_WRAP
virtual
float
getSigmaSpace
()
const
=
0
;
CV_WRAP
virtual
void
setSigmaSpace
(
float
sigma_space
)
=
0
;
CV_WRAP
virtual
float
getSigmaColor
()
const
=
0
;
CV_WRAP
virtual
void
setSigmaColor
(
float
sigma_color
)
=
0
;
};
/** @brief Creates TonemapDurand object
@param gamma gamma value for gamma correction. See createTonemap
@param contrast resulting contrast on logarithmic scale, i. e. log(max / min), where max and min
are maximum and minimum luminance values of the resulting image.
@param saturation saturation enhancement value. See createTonemapDrago
@param sigma_space bilateral filter sigma in color space
@param sigma_color bilateral filter sigma in coordinate space
*/
CV_EXPORTS_W
Ptr
<
TonemapDurand
>
createTonemapDurand
(
float
gamma
=
1.0
f
,
float
contrast
=
4.0
f
,
float
saturation
=
1.0
f
,
float
sigma_space
=
2.0
f
,
float
sigma_color
=
2.0
f
);
/** @brief This is a global tonemapping operator that models human visual system.
...
...
modules/photo/src/tonemap.cpp
View file @
e82e672a
...
...
@@ -193,94 +193,6 @@ Ptr<TonemapDrago> createTonemapDrago(float gamma, float saturation, float bias)
return
makePtr
<
TonemapDragoImpl
>
(
gamma
,
saturation
,
bias
);
}
class
TonemapDurandImpl
CV_FINAL
:
public
TonemapDurand
{
public
:
TonemapDurandImpl
(
float
_gamma
,
float
_contrast
,
float
_saturation
,
float
_sigma_color
,
float
_sigma_space
)
:
name
(
"TonemapDurand"
),
gamma
(
_gamma
),
contrast
(
_contrast
),
saturation
(
_saturation
),
sigma_color
(
_sigma_color
),
sigma_space
(
_sigma_space
)
{
}
void
process
(
InputArray
_src
,
OutputArray
_dst
)
CV_OVERRIDE
{
CV_INSTRUMENT_REGION
();
Mat
src
=
_src
.
getMat
();
CV_Assert
(
!
src
.
empty
());
_dst
.
create
(
src
.
size
(),
CV_32FC3
);
Mat
img
=
_dst
.
getMat
();
Ptr
<
Tonemap
>
linear
=
createTonemap
(
1.0
f
);
linear
->
process
(
src
,
img
);
Mat
gray_img
;
cvtColor
(
img
,
gray_img
,
COLOR_RGB2GRAY
);
Mat
log_img
;
log_
(
gray_img
,
log_img
);
Mat
map_img
;
bilateralFilter
(
log_img
,
map_img
,
-
1
,
sigma_color
,
sigma_space
);
double
min
,
max
;
minMaxLoc
(
map_img
,
&
min
,
&
max
);
float
scale
=
contrast
/
static_cast
<
float
>
(
max
-
min
);
exp
(
map_img
*
(
scale
-
1.0
f
)
+
log_img
,
map_img
);
log_img
.
release
();
mapLuminance
(
img
,
img
,
gray_img
,
map_img
,
saturation
);
pow
(
img
,
1.0
f
/
gamma
,
img
);
}
float
getGamma
()
const
CV_OVERRIDE
{
return
gamma
;
}
void
setGamma
(
float
val
)
CV_OVERRIDE
{
gamma
=
val
;
}
float
getSaturation
()
const
CV_OVERRIDE
{
return
saturation
;
}
void
setSaturation
(
float
val
)
CV_OVERRIDE
{
saturation
=
val
;
}
float
getContrast
()
const
CV_OVERRIDE
{
return
contrast
;
}
void
setContrast
(
float
val
)
CV_OVERRIDE
{
contrast
=
val
;
}
float
getSigmaColor
()
const
CV_OVERRIDE
{
return
sigma_color
;
}
void
setSigmaColor
(
float
val
)
CV_OVERRIDE
{
sigma_color
=
val
;
}
float
getSigmaSpace
()
const
CV_OVERRIDE
{
return
sigma_space
;
}
void
setSigmaSpace
(
float
val
)
CV_OVERRIDE
{
sigma_space
=
val
;
}
void
write
(
FileStorage
&
fs
)
const
CV_OVERRIDE
{
writeFormat
(
fs
);
fs
<<
"name"
<<
name
<<
"gamma"
<<
gamma
<<
"contrast"
<<
contrast
<<
"sigma_color"
<<
sigma_color
<<
"sigma_space"
<<
sigma_space
<<
"saturation"
<<
saturation
;
}
void
read
(
const
FileNode
&
fn
)
CV_OVERRIDE
{
FileNode
n
=
fn
[
"name"
];
CV_Assert
(
n
.
isString
()
&&
String
(
n
)
==
name
);
gamma
=
fn
[
"gamma"
];
contrast
=
fn
[
"contrast"
];
sigma_color
=
fn
[
"sigma_color"
];
sigma_space
=
fn
[
"sigma_space"
];
saturation
=
fn
[
"saturation"
];
}
protected
:
String
name
;
float
gamma
,
contrast
,
saturation
,
sigma_color
,
sigma_space
;
};
Ptr
<
TonemapDurand
>
createTonemapDurand
(
float
gamma
,
float
contrast
,
float
saturation
,
float
sigma_color
,
float
sigma_space
)
{
return
makePtr
<
TonemapDurandImpl
>
(
gamma
,
contrast
,
saturation
,
sigma_color
,
sigma_space
);
}
class
TonemapReinhardImpl
CV_FINAL
:
public
TonemapReinhard
{
public
:
...
...
modules/photo/test/test_hdr.cpp
View file @
e82e672a
...
...
@@ -105,12 +105,6 @@ TEST(Photo_Tonemap, regression)
result
.
convertTo
(
result
,
CV_8UC3
,
255
);
checkEqual
(
result
,
expected
,
3
,
"Drago"
);
Ptr
<
TonemapDurand
>
durand
=
createTonemapDurand
(
gamma
);
durand
->
process
(
img
,
result
);
loadImage
(
test_path
+
"durand.png"
,
expected
);
result
.
convertTo
(
result
,
CV_8UC3
,
255
);
checkEqual
(
result
,
expected
,
3
,
"Durand"
);
Ptr
<
TonemapReinhard
>
reinhard
=
createTonemapReinhard
(
gamma
);
reinhard
->
process
(
img
,
result
);
loadImage
(
test_path
+
"reinhard.png"
,
expected
);
...
...
modules/stitching/perf/perf_matchers.cpp
View file @
e82e672a
...
...
@@ -280,7 +280,7 @@ PERF_TEST_P( matchVector, affineBestOf2NearestVectorFeatures, testing::Combine(
if
(
pairwise_matches
[
i
].
src_img_idx
<
0
)
continue
;
EXPECT_GT
(
pairwise_matches
[
i
].
matches
.
size
(),
20
0u
);
EXPECT_GT
(
pairwise_matches
[
i
].
matches
.
size
(),
15
0u
);
EXPECT_FALSE
(
pairwise_matches
[
i
].
H
.
empty
());
++
matches_count
;
}
...
...
samples/cpp/tutorial_code/photo/hdr_imaging/hdr_imaging.cpp
View file @
e82e672a
...
...
@@ -35,7 +35,7 @@ int main(int argc, char**argv)
//! [Tonemap HDR image]
Mat
ldr
;
Ptr
<
Tonemap
Durand
>
tonemap
=
createTonemapDurand
(
2.2
f
);
Ptr
<
Tonemap
>
tonemap
=
createTonemap
(
2.2
f
);
tonemap
->
process
(
hdr
,
ldr
);
//! [Tonemap HDR image]
...
...
samples/java/tutorial_code/photo/hdr_imaging/HDRImagingDemo.java
View file @
e82e672a
...
...
@@ -13,7 +13,7 @@ import org.opencv.photo.CalibrateDebevec;
import
org.opencv.photo.MergeDebevec
;
import
org.opencv.photo.MergeMertens
;
import
org.opencv.photo.Photo
;
import
org.opencv.photo.Tonemap
Durand
;
import
org.opencv.photo.Tonemap
;
class
HDRImaging
{
public
void
loadExposureSeq
(
String
path
,
List
<
Mat
>
images
,
List
<
Float
>
times
)
{
...
...
@@ -71,7 +71,7 @@ class HDRImaging {
//! [Tonemap HDR image]
Mat
ldr
=
new
Mat
();
Tonemap
Durand
tonemap
=
Photo
.
createTonemapDurand
(
2.2f
,
4.0f
,
1.0f
,
2.0f
,
2.0
f
);
Tonemap
tonemap
=
Photo
.
createTonemap
(
2.2
f
);
tonemap
.
process
(
hdr
,
ldr
);
//! [Tonemap HDR image]
...
...
samples/python/tutorial_code/photo/hdr_imaging/hdr_imaging.py
View file @
e82e672a
...
...
@@ -40,7 +40,7 @@ hdr = merge_debevec.process(images, times, response)
## [Make HDR image]
## [Tonemap HDR image]
tonemap
=
cv
.
createTonemap
Durand
(
2.2
)
tonemap
=
cv
.
createTonemap
(
2.2
)
ldr
=
tonemap
.
process
(
hdr
)
## [Tonemap HDR image]
...
...
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