Skip to content

Commit

Permalink
Retrieve new aruco parameters on next image callback (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsowa committed May 8, 2024
1 parent bd3b18b commit f9677b9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions aruco_opencv/src/aruco_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class ArucoTracker : public rclcpp_lifecycle::LifecycleNode
rclcpp::Time last_msg_stamp_;
bool cam_info_retrieved_ = false;
rclcpp::Time callback_start_time_;
bool new_aruco_params_ = false;

// Aruco
cv::Mat camera_matrix_;
Expand Down Expand Up @@ -329,13 +330,12 @@ class ArucoTracker : public rclcpp_lifecycle::LifecycleNode
}
}

bool aruco_param_changed = false;
for (auto & param : parameters) {
if (param.get_name() == "marker_size") {
marker_size_ = param.as_double();
update_marker_obj_points();
} else if (param.get_name().rfind("aruco", 0) == 0) {
aruco_param_changed = true;
new_aruco_params_ = true;
} else {
// Unknown parameter, ignore
continue;
Expand All @@ -346,12 +346,6 @@ class ArucoTracker : public rclcpp_lifecycle::LifecycleNode
"Parameter \"" << param.get_name() << "\" changed to " << param.value_to_string());
}

if (!aruco_param_changed) {
return result;
}

retrieve_aruco_parameters(*this, detector_parameters_);

return result;
}

Expand Down Expand Up @@ -507,6 +501,11 @@ class ArucoTracker : public rclcpp_lifecycle::LifecycleNode

void process_image(const cv_bridge::CvImageConstPtr & cv_ptr)
{
if (new_aruco_params_) {
new_aruco_params_ = false;
retrieve_aruco_parameters(*this, detector_parameters_);
}

std::vector<int> marker_ids;
std::vector<std::vector<cv::Point2f>> marker_corners;

Expand Down

0 comments on commit f9677b9

Please sign in to comment.