Skip to content

Commit d9bf522

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 7e845a3 + 93dc067 commit d9bf522

File tree

8 files changed

+59
-15
lines changed

8 files changed

+59
-15
lines changed

3rdparty/libpng/CMakeLists.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ endif(MSVC)
7777
add_library(${PNG_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs} ${lib_hdrs})
7878
target_link_libraries(${PNG_LIBRARY} ${ZLIB_LIBRARIES})
7979

80-
ocv_warnings_disable(CMAKE_C_FLAGS -Wundef -Wcast-align -Wimplicit-fallthrough -Wunused-parameter -Wsign-compare)
81-
ocv_warnings_disable(CMAKE_C_FLAGS -Wnull-pointer-subtraction) # clang15
82-
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-but-set-variable) # clang15
80+
ocv_warnings_disable(CMAKE_C_FLAGS -Wundef -Wcast-align -Wimplicit-fallthrough -Wunused-parameter -Wsign-compare
81+
-Wmaybe-uninitialized
82+
-Wnull-pointer-subtraction # clang15
83+
-Wunused-but-set-variable # clang15
84+
)
8385

8486
set_target_properties(${PNG_LIBRARY}
8587
PROPERTIES OUTPUT_NAME ${PNG_LIBRARY}

3rdparty/libtiff/CMakeLists.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,10 @@ ocv_warnings_disable(CMAKE_C_FLAGS -Wno-unused-but-set-variable -Wmissing-protot
452452
-Wcast-align -Wshadow -Wno-maybe-uninitialized -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
453453
-Wmisleading-indentation
454454
-Wimplicit-fallthrough
455+
-Wunused-parameter # clang
456+
-Warray-parameter
457+
-Wstrict-prototypes # clang15
455458
)
456-
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang
457-
ocv_warnings_disable(CMAKE_C_FLAGS -Wstrict-prototypes) # clang15
458459
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations -Wunused-parameter -Wmissing-prototypes
459460
-Wundef # tiffiop.h: #if __clang_major__ >= 4
460461
)

apps/traincascade/cascadeclassifier.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ bool CvCascadeClassifier::train( const string _cascadeDirName,
252252
fs << "}";
253253
}
254254
// save current stage
255-
char buf[10];
255+
char buf[32];
256256
sprintf(buf, "%s%d", "stage", i );
257257
string stageFilename = dirName + buf + ".xml";
258258
FileStorage fs( stageFilename, FileStorage::WRITE );

modules/dnn/src/onnx/onnx_importer.cpp

+21-3
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,18 @@ class ONNXImporter
197197
void parseOperatorSet();
198198

199199
const std::string str_domain_ai_onnx = "ai.onnx";
200+
201+
202+
bool useLegacyNames;
203+
bool getParamUseLegacyNames()
204+
{
205+
bool param = utils::getConfigurationParameterBool("OPENCV_DNN_ONNX_USE_LEGACY_NAMES", false);
206+
return param;
207+
}
208+
const std::string extractNodeName(const opencv_onnx::NodeProto& node_proto);
200209
};
201210

211+
202212
class ONNXLayerHandler : public detail::LayerHandler
203213
{
204214
public:
@@ -233,6 +243,7 @@ ONNXImporter::ONNXImporter(Net& net, const char *onnxFile)
233243
: layerHandler(DNN_DIAGNOSTICS_RUN ? new ONNXLayerHandler(this) : nullptr)
234244
, dstNet(net)
235245
, onnx_opset(0)
246+
, useLegacyNames(getParamUseLegacyNames())
236247
{
237248
hasDynamicShapes = false;
238249
CV_Assert(onnxFile);
@@ -256,6 +267,7 @@ ONNXImporter::ONNXImporter(Net& net, const char* buffer, size_t sizeBuffer)
256267
: layerHandler(DNN_DIAGNOSTICS_RUN ? new ONNXLayerHandler(this) : nullptr)
257268
, dstNet(net)
258269
, onnx_opset(0)
270+
, useLegacyNames(getParamUseLegacyNames())
259271
{
260272
hasDynamicShapes = false;
261273
CV_LOG_DEBUG(NULL, "DNN/ONNX: processing in-memory ONNX model (" << sizeBuffer << " bytes)");
@@ -278,6 +290,7 @@ ONNXImporter::ONNXImporter(Net& net, const char* buffer, size_t sizeBuffer)
278290
populateNet();
279291
}
280292

293+
281294
inline void replaceLayerParam(LayerParams& layerParams, const String& oldKey, const String& newKey)
282295
{
283296
if (layerParams.has(oldKey)) {
@@ -909,11 +922,14 @@ const ONNXImporter::DispatchMap& ONNXImporter::getDispatchMap(const opencv_onnx:
909922
return it->second;
910923
}
911924

912-
const std::string& extractNodeName(const opencv_onnx::NodeProto& node_proto)
925+
const std::string ONNXImporter::extractNodeName(const opencv_onnx::NodeProto& node_proto)
913926
{
927+
// We need to rework DNN outputs API, this is a workaround for #21698
914928
if (node_proto.has_name() && !node_proto.name().empty())
915929
{
916-
return node_proto.name();
930+
if (useLegacyNames)
931+
return node_proto.name();
932+
return cv::format("onnx_node!%s", node_proto.name().c_str());
917933
}
918934
for (int i = 0; i < node_proto.output_size(); ++i)
919935
{
@@ -923,7 +939,9 @@ const std::string& extractNodeName(const opencv_onnx::NodeProto& node_proto)
923939
// the second method is to use an empty string in place of an input or output name.
924940
if (!name.empty())
925941
{
926-
return name;
942+
if (useLegacyNames)
943+
return name.c_str();
944+
return cv::format("onnx_node_output_%d!%s", i, name.c_str());
927945
}
928946
}
929947
CV_Error(Error::StsAssert, "Couldn't deduce Node name.");

modules/dnn/test/test_int8_layers.cpp

+20-2
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,32 @@ TEST_P(Test_Int8_layers, Mish)
265265
testLayer("mish", "ONNX", 0.0015, 0.0025);
266266
}
267267

268-
TEST_P(Test_Int8_layers, Softmax)
268+
TEST_P(Test_Int8_layers, Softmax_Caffe)
269269
{
270270
testLayer("layer_softmax", "Caffe", 0.0011, 0.0036);
271+
}
272+
TEST_P(Test_Int8_layers, Softmax_keras_TF)
273+
{
271274
testLayer("keras_softmax", "TensorFlow", 0.00093, 0.0027);
275+
}
276+
TEST_P(Test_Int8_layers, Softmax_slim_TF)
277+
{
272278
testLayer("slim_softmax", "TensorFlow", 0.0016, 0.0034);
279+
}
280+
TEST_P(Test_Int8_layers, Softmax_slim_v2_TF)
281+
{
273282
testLayer("slim_softmax_v2", "TensorFlow", 0.0029, 0.017);
283+
}
284+
TEST_P(Test_Int8_layers, Softmax_ONNX)
285+
{
274286
testLayer("softmax", "ONNX", 0.0016, 0.0028);
287+
}
288+
TEST_P(Test_Int8_layers, Softmax_log_ONNX)
289+
{
275290
testLayer("log_softmax", "ONNX", 0.014, 0.025);
291+
}
292+
TEST_P(Test_Int8_layers, DISABLED_Softmax_unfused_ONNX) // FIXIT Support 'Identity' layer for outputs (#22022)
293+
{
276294
testLayer("softmax_unfused", "ONNX", 0.0009, 0.0021);
277295
}
278296

@@ -389,7 +407,7 @@ TEST_P(Test_Int8_layers, Slice_strided_tf)
389407
testLayer("strided_slice", "TensorFlow", 0.008, 0.0142);
390408
}
391409

392-
TEST_P(Test_Int8_layers, Slice_onnx)
410+
TEST_P(Test_Int8_layers, DISABLED_Slice_onnx) // FIXIT Support 'Identity' layer for outputs (#22022)
393411
{
394412
testLayer("slice", "ONNX", 0.0046, 0.0077);
395413
}

modules/dnn/test/test_onnx_importer.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,11 @@ TEST_P(Test_ONNX_layers, Quantized_Constant)
18551855
testONNXModels("quantized_constant", npy, 0.002, 0.008);
18561856
}
18571857

1858+
TEST_P(Test_ONNX_layers, OutputRegistration)
1859+
{
1860+
testONNXModels("output_registration", npy, 0, 0, false, true, 2);
1861+
}
1862+
18581863
INSTANTIATE_TEST_CASE_P(/*nothing*/, Test_ONNX_layers, dnnBackendsAndTargets());
18591864

18601865
class Test_ONNX_nets : public Test_ONNX_layers

modules/ts/src/ts_gtest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8718,7 +8718,7 @@ static void StackLowerThanAddress(const void* ptr, bool* result) {
87188718
// Make sure AddressSanitizer does not tamper with the stack here.
87198719
GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
87208720
static bool StackGrowsDown() {
8721-
int dummy;
8721+
int dummy = 0;
87228722
bool result;
87238723
StackLowerThanAddress(&dummy, &result);
87248724
return result;

modules/video/src/tracking/tracker_dasiamrpn.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void TrackerDaSiamRPNImpl::trackerInit(Mat img)
160160
dnn::blobFromImage(zCrop, blob, 1.0, Size(trackState.exemplarSize, trackState.exemplarSize), Scalar(), trackState.swapRB, false, CV_32F);
161161
siamRPN.setInput(blob);
162162
Mat out1;
163-
siamRPN.forward(out1, "63");
163+
siamRPN.forward(out1, "onnx_node_output_0!63");
164164

165165
siamKernelCL1.setInput(out1);
166166
siamKernelR1.setInput(out1);
@@ -169,8 +169,8 @@ void TrackerDaSiamRPNImpl::trackerInit(Mat img)
169169
Mat r1 = siamKernelR1.forward();
170170
std::vector<int> r1_shape = { 20, 256, 4, 4 }, cls1_shape = { 10, 256, 4, 4 };
171171

172-
siamRPN.setParam(siamRPN.getLayerId("65"), 0, r1.reshape(0, r1_shape));
173-
siamRPN.setParam(siamRPN.getLayerId("68"), 0, cls1.reshape(0, cls1_shape));
172+
siamRPN.setParam(siamRPN.getLayerId("onnx_node_output_0!65"), 0, r1.reshape(0, r1_shape));
173+
siamRPN.setParam(siamRPN.getLayerId("onnx_node_output_0!68"), 0, cls1.reshape(0, cls1_shape));
174174
}
175175

176176
bool TrackerDaSiamRPNImpl::update(InputArray image, Rect& boundingBox)

0 commit comments

Comments
 (0)