-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test_panel_simple_detector_plugin and test_data
- Loading branch information
1 parent
3e83096
commit 25a1574
Showing
3 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
detector2d_plugins/test/src/test_panel_simple_detector_plugin.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <ament_index_cpp/get_package_share_directory.hpp> | ||
#include <gtest/gtest.h> | ||
#include <opencv2/opencv.hpp> | ||
#include <detector2d_base/detector2d_base.hpp> | ||
#include <detector2d_param/detector2d_param.hpp> | ||
#include <detector2d_plugins/panel_simple_detector.hpp> | ||
#include <rclcpp/rclcpp.hpp> | ||
|
||
class TestDetector2dClass : public ::testing::Test | ||
{ | ||
protected: | ||
std::unique_ptr<detector2d_plugins::PanelSimpleDetector> target_class_; | ||
std::shared_ptr<detector2d_parameters::ParamListener> param_listener_; | ||
|
||
std::string image_path; | ||
|
||
virtual void SetUp() | ||
{ | ||
rclcpp::init(0, nullptr); | ||
auto node = std::make_shared<rclcpp::Node>("test_node"); | ||
|
||
this->image_path = ament_index_cpp::get_package_share_directory("detector2d_plugins") + | ||
"/test_data/dark_00.png"; | ||
|
||
this->target_class_ = | ||
std::make_unique<detector2d_plugins::PanelSimpleDetector>(); | ||
|
||
this->param_listener_ = | ||
std::make_shared<detector2d_parameters::ParamListener>( | ||
node->get_node_parameters_interface()); | ||
this->target_class_->init(*this->param_listener_); | ||
} | ||
}; | ||
|
||
TEST_F(TestDetector2dClass, test_default) | ||
{ | ||
cv::Mat3b image = cv::imread(this->image_path, cv::IMREAD_COLOR); | ||
auto result = this->target_class_->detect(image); | ||
|
||
// bboxes [0]: 468, 328 | ||
// bboxes [1]: 632, 325 | ||
// bboxes [2]: 882, 345 <-- remove | ||
// bboxes [3]: 797, 298 | ||
// bboxes [4]: 555, 228 | ||
|
||
ASSERT_EQ(result.detections[0].bbox.center.position.x, 468); | ||
ASSERT_EQ(result.detections[0].bbox.center.position.y, 328); | ||
|
||
ASSERT_EQ(result.detections[1].bbox.center.position.x, 632); | ||
ASSERT_EQ(result.detections[1].bbox.center.position.y, 325); | ||
|
||
ASSERT_EQ(result.detections[3].bbox.center.position.x, 797); | ||
ASSERT_EQ(result.detections[3].bbox.center.position.y, 298); | ||
|
||
ASSERT_EQ(result.detections[4].bbox.center.position.x, 555); | ||
ASSERT_EQ(result.detections[4].bbox.center.position.y, 228); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.