添加二维码检测的缓存机制以及它的启动参数(默认使用)
This commit is contained in:
@@ -102,4 +102,6 @@ foxglove # 启动foxbridge
|
||||
启动键盘控制:
|
||||
`ros2 run teleop_twist_keyboard teleop_twist_keyboard `
|
||||
|
||||
运行二维码检测(无缓存版):
|
||||
`ros2 run qr_detection qr_dete_depth_node --ros-args -p use_buffer:=false`
|
||||
# 五、日志
|
||||
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
MinimalHbmemSubscriber()
|
||||
: Node("qr_detection"), detect_qr_code_(true) // 默认检测二维码
|
||||
{
|
||||
use_buffer = this->declare_parameter("use_buffer", true); // 声明参数,默认使用缓存
|
||||
// 订阅 /aurora/rgb/image_raw(sensor_msgs::msg::Image 格式)
|
||||
subscription_image_ =
|
||||
this->create_subscription<sensor_msgs::msg::Image>(
|
||||
@@ -85,6 +86,7 @@ private:
|
||||
RCLCPP_INFO(this->get_logger(), "Decoded %s symbol \"%s\"",
|
||||
symbol->get_type_name().c_str(), symbol->get_data().c_str());
|
||||
}
|
||||
qr_results_buff_ = qr_results; // 更新缓存
|
||||
} else {
|
||||
qr_results = "QR Code not detected";
|
||||
RCLCPP_INFO(this->get_logger(), "QR Code not detected");
|
||||
@@ -92,7 +94,12 @@ private:
|
||||
|
||||
// 发布 QR 结果
|
||||
auto message = std_msgs::msg::String();
|
||||
message.data = qr_results;
|
||||
if (use_buffer){
|
||||
message.data = qr_results_buff_;
|
||||
}
|
||||
else{
|
||||
message.data = qr_results;
|
||||
}
|
||||
publisher_->publish(message);
|
||||
}
|
||||
|
||||
@@ -118,8 +125,12 @@ private:
|
||||
// QR code results 发布器
|
||||
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr publisher_;
|
||||
|
||||
// 参数
|
||||
bool use_buffer;
|
||||
// 二维码检测标志位
|
||||
bool detect_qr_code_;
|
||||
// 二维码检测结果缓存
|
||||
std::string qr_results_buff_;
|
||||
};
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
|
||||
Reference in New Issue
Block a user