Skip to content

Commit

Permalink
fix: segmentation fault when set color setting
Browse files Browse the repository at this point in the history
  • Loading branch information
mbsaloka committed Jun 6, 2024
1 parent f30aec8 commit 2c81127
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
5 changes: 4 additions & 1 deletion include/ninshiki_cpp/node/ninshiki_cpp_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ class NinshikiCppNode

NinshikiCppNode(
rclcpp::Node::SharedPtr node, const std::string & path,
int frequency, shisen_cpp::Options options);
int frequency, shisen_cpp::Options options,
std::shared_ptr<DnnDetector> dnn_detection,
std::shared_ptr<ColorDetector> color_detection,
std::shared_ptr<LBPDetector> lbp_detection);
void publish();
void set_detection(
std::shared_ptr<DnnDetector> dnn_detection,
Expand Down
1 change: 0 additions & 1 deletion src/ninshiki_cpp/config/utils/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <iomanip>
#include <string>


namespace ninshiki_cpp
{
Config::Config(const std::string & path) : path(path) {}
Expand Down
18 changes: 6 additions & 12 deletions src/ninshiki_cpp/node/ninshiki_cpp_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ namespace ninshiki_cpp::node

NinshikiCppNode::NinshikiCppNode(
rclcpp::Node::SharedPtr node, const std::string & path,
int frequency, shisen_cpp::Options options)
: node(node), path(path), dnn_detection(nullptr), color_detection(nullptr), lbp_detection(nullptr)
int frequency, shisen_cpp::Options options,
std::shared_ptr<DnnDetector> dnn_detection,
std::shared_ptr<ColorDetector> color_detection,
std::shared_ptr<LBPDetector> lbp_detection)
: node(node), path(path), dnn_detection(dnn_detection),
color_detection(color_detection), lbp_detection(lbp_detection)
{
detected_object_publisher = node->create_publisher<DetectedObjects>(
get_node_prefix() + "/dnn_detection", 10);
Expand Down Expand Up @@ -78,16 +82,6 @@ void NinshikiCppNode::publish()
lbp_detection->detection_result.detected_objects.clear();
}

void NinshikiCppNode::set_detection(
std::shared_ptr<DnnDetector> dnn_detection,
std::shared_ptr<ColorDetector> color_detection,
std::shared_ptr<LBPDetector> lbp_detection)
{
this->dnn_detection = dnn_detection;
this->color_detection = color_detection;
this->lbp_detection = lbp_detection;
}

std::string NinshikiCppNode::get_node_prefix()
{
return "ninshiki_cpp";
Expand Down
8 changes: 3 additions & 5 deletions src/ninshiki_cpp_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,15 @@ int main(int argc, char ** argv)
return 1;
}

auto node = std::make_shared<rclcpp::Node>("ninshiki_cpp");
auto ninshiki_cpp_node = std::make_shared<ninshiki_cpp::node::NinshikiCppNode>(
node, path, frequency, options);

auto dnn_detection = std::make_shared<ninshiki_cpp::detector::DnnDetector>(gpu, myriad);
auto color_detection = std::make_shared<ninshiki_cpp::detector::ColorDetector>();
auto lbp_detection = std::make_shared<ninshiki_cpp::detector::LBPDetector>();

color_detection->load_configuration(path);

ninshiki_cpp_node->set_detection(dnn_detection, color_detection, lbp_detection);
auto node = std::make_shared<rclcpp::Node>("ninshiki_cpp");
auto ninshiki_cpp_node = std::make_shared<ninshiki_cpp::node::NinshikiCppNode>(
node, path, frequency, options, dnn_detection, color_detection, lbp_detection);

rclcpp::spin(node);
rclcpp::shutdown();
Expand Down

0 comments on commit 2c81127

Please sign in to comment.