From 0af1c4250f1e5667908c0055b48763c4361cb8a3 Mon Sep 17 00:00:00 2001 From: Alberto Tudela Date: Tue, 13 Dec 2022 12:10:38 +0100 Subject: [PATCH] Remove hardcoded COCO labels size --- CHANGELOG.rst | 1 + include/object_detection_openvino/objectDetectionVPU.hpp | 3 --- src/objectDetectionVPU.cpp | 8 ++++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4f3d310..963589c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,7 @@ Changelog for package object_detection_openvino ------------------ * First ROS2 (Galactic) version. * Update to OpenVino 2021.4. +* Remove hardcoded COCO labels size. 3.2.2 (26-05-2022) ------------------ diff --git a/include/object_detection_openvino/objectDetectionVPU.hpp b/include/object_detection_openvino/objectDetectionVPU.hpp index ecbd975..7abb70c 100644 --- a/include/object_detection_openvino/objectDetectionVPU.hpp +++ b/include/object_detection_openvino/objectDetectionVPU.hpp @@ -44,9 +44,6 @@ // OpenCV #include -/// The number of the labels in the COCO database. -#define COCO_CLASSES 80 - /// Typedef for easier readability. typedef std::chrono::duration> ms; diff --git a/src/objectDetectionVPU.cpp b/src/objectDetectionVPU.cpp index 882792c..1b42132 100644 --- a/src/objectDetectionVPU.cpp +++ b/src/objectDetectionVPU.cpp @@ -289,11 +289,11 @@ void ObjectDetectionVPU::color_point_callback( object.ymax = object.ymax > color_height ? color_height : object.ymax; // Color of the class - int offset = object.classId * 123457 % COCO_CLASSES; + int offset = object.classId * 123457 % labels_.size(); float color_rgb[3]; - color_rgb[0] = get_color(2, offset, COCO_CLASSES); - color_rgb[1] = get_color(1, offset, COCO_CLASSES); - color_rgb[2] = get_color(0, offset, COCO_CLASSES); + color_rgb[0] = get_color(2, offset, labels_.size()); + color_rgb[1] = get_color(1, offset, labels_.size()); + color_rgb[2] = get_color(0, offset, labels_.size()); // Create detection2D and push to array vision_msgs::msg::Detection2D detection_2d;