pipeline works but might be slow on runtime

This commit is contained in:
2023-03-21 14:08:41 +05:30
parent 987530bbfe
commit cf0fdc175b
7 changed files with 59 additions and 31 deletions
+7 -7
View File
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.5)
project(yolov4_msg)
project(yolov3_msg)
# Find dependencies
#find_package(ament_cmake REQUIRED)
@@ -9,26 +9,26 @@ find_package(rclpy REQUIRED)
find_package(std_msgs REQUIRED)
# Create the executable
#add_executable(yolov4_msg yolov4_msg.py)
#add_executable(yolov3_msg yolov3_msg.py)
# Set the permissions of the Python script to be executable
find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(yolov4_msg
rosidl_generate_interfaces(yolov3_msg
"msg/BoundingBox.msg"
"msg/BoundingBoxes.msg"
DEPENDENCIES builtin_interfaces std_msgs
)
# Link the executable with the necessary libraries
#ament_target_dependencies(yolov4_msg rclpy)
#ament_target_dependencies(yolov3_msg rclpy)
# Install the executable
#install(TARGETS yolov4_msg DESTINATION lib/yolov4_msg)
#install(TARGETS yolov3_msg DESTINATION lib/yolov3_msg)
# Install the script, setup.py, and package.xml files
#install(PROGRAMS yolov4_msg.py
#install(PROGRAMS yolov3_msg.py
# DESTINATION lib/yolov3_on_bag)
#install(FILES package.xml
# DESTINATION share/yolov3_on_bag)
@@ -39,7 +39,7 @@ rosidl_generate_interfaces(yolov4_msg
# Package information
#ament_package()
#add_executable(yolov4_msg yolov4_msg.py)
#add_executable(yolov3_msg yolov3_msg.py)
ament_export_dependencies(rosidl_default_runtime)
+5 -1
View File
@@ -41,7 +41,7 @@ from utils.plots import Annotator, colors, save_one_box
from utils.torch_utils import select_device, time_sync
from utils.augmentations import Albumentations, augment_hsv, copy_paste, letterbox
import numpy as np
from yolov4_msg.msg import BoundingBox, BoundingBoxes
from yolov3_msg.msg import BoundingBox, BoundingBoxes
from rclpy.clock import Clock
@torch.no_grad()
@@ -152,6 +152,8 @@ def run(weights=ROOT / 'yolov3.pt', # model.pt path(s)
LOGGER.info(f'{s}Done. ({t3 - t2:.3f}s)')
# Stream results
im0 = annotator.result()
if update:
strip_optimizer(weights) # update model (to fix SourceChangeWarning)
# cv2.imwrite(save_path, im0)
return im0, bounding_boxes_msg
@@ -177,6 +179,8 @@ class DetectOnBag(Node):
detected_img, bboxes = run('src/yolov3/runs/train/exp14/weights/best.pt', cv_image)
self.detected_img_pub.publish(self.numpy_array_to_image_msg(detected_img))
bboxes.image_header = msg.header
bboxes.header.stamp = msg.header.stamp
bboxes.header.frame_id = 'detection'
self.bboxes_pub.publish(bboxes)
def numpy_array_to_image_msg(self, numpy_array):
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<package format="3">
<name>yolov4_msg</name>
<name>yolov3_msg</name>
<version>0.1.0</version>
<description>
This is a ROS2 package for running yolov3 on rosbag