Skip to content

Commit

Permalink
Integration of custom message completed. Although it is hard coded un…
Browse files Browse the repository at this point in the history
…til the JSONparsing is completed. The custom message might change to an array of detected objects
  • Loading branch information
DavidGuamanDavila committed Jan 10, 2024
1 parent 4c372dd commit 2f6d005
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/object_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Image_Finder {
Image_Finder() : nh_("") {
// Subscribe to camera topic publishing data
sub_img_ = nh_.subscribe("/camera/color/image_raw", 1, &Image_Finder::imageCallback, this);
publisher = nh_.advertise<geometry_msgs::Vector3>("/raw_image_copy", 1);
publisher = nh_.advertise<object_detection_pkg::ObjDetected>("/raw_image_copy", 1);
}

// Function to continue the life of the node
Expand Down Expand Up @@ -87,16 +87,19 @@ class Image_Finder {
}

void publishImageInfo(const sensor_msgs::Image::ConstPtr& msg) {
// Create a Vector3 message to publish image info
geometry_msgs::Vector3 image_info_msg;
image_info_msg.x = static_cast<double>(msg->width);
image_info_msg.y = static_cast<double>(msg->height);
// Assuming you want to publish encoding information in the z field
// Modify this part if you want to publish other information
image_info_msg.z = 0.0; // You can replace 0.0 with encoding information

// Publish the message
publisher.publish(image_info_msg);
// Create an instance of the custom message
object_detection_pkg::ObjDetected custom_message;

// Fill in the custom message fields with hard-coded values
custom_message.class_name = "Buoy";
custom_message.confidence = 0.48662763833999634;
custom_message.x_min = 0;
custom_message.x_max = 113;
custom_message.y_min = 235;
custom_message.y_max = 450;

// Publish the custom message
publisher.publish(custom_message);
}
};

Expand Down

0 comments on commit 2f6d005

Please sign in to comment.