mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge pull request #28749 from Prasadayus:NMS-empty-detection-fix
Nms empty detection fix #28749 Requires opencv_extra: https://github.com/opencv/opencv_extra/pull/1330 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
committed by
GitHub
parent
e59506bbf5
commit
47ac80995f
@@ -6,6 +6,7 @@
|
||||
// Third party copyrights are property of their respective owners.
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "npy_blob.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
@@ -104,4 +105,32 @@ TEST(SoftNMS, Accuracy)
|
||||
}
|
||||
}
|
||||
|
||||
// Test NMS -> Reshape with zero detections using ONNX model.
|
||||
// NMS with dynamic output shapes is only supported by the new engine.
|
||||
TEST(NMS, ZeroDetections_Reshape)
|
||||
{
|
||||
auto engine_forced = static_cast<cv::dnn::EngineType>(
|
||||
cv::utils::getConfigurationParameterSizeT("OPENCV_FORCE_DNN_ENGINE", cv::dnn::ENGINE_AUTO));
|
||||
if (engine_forced == cv::dnn::ENGINE_CLASSIC)
|
||||
{
|
||||
applyTestTag(CV_TEST_TAG_DNN_SKIP_PARSER);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string onnxmodel = findDataFile("dnn/onnx/models/nms_reshape_empty.onnx");
|
||||
cv::dnn::Net net = cv::dnn::readNetFromONNX(onnxmodel);
|
||||
ASSERT_FALSE(net.empty());
|
||||
|
||||
Mat boxes = blobFromNPY(findDataFile("dnn/onnx/data/input_nms_reshape_empty_0.npy"));
|
||||
Mat scores = blobFromNPY(findDataFile("dnn/onnx/data/input_nms_reshape_empty_1.npy"));
|
||||
net.setInput(boxes, "boxes");
|
||||
net.setInput(scores, "scores");
|
||||
|
||||
std::vector<Mat> outs;
|
||||
net.forward(outs, std::vector<String>{"output"});
|
||||
ASSERT_EQ(outs.size(), (size_t)1);
|
||||
Mat ref = blobFromNPY(findDataFile("dnn/onnx/data/output_nms_reshape_empty.npy"));
|
||||
normAssert(ref, outs[0], "NMS_ZeroDetections_Reshape");
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user