Skip to content

Commit 8493867

Browse files
authored
ImgDetection text label (#1314)
* Added name to ImgDetection * RVC4 FW: Add name to ImgDetection * RVC2 FW: Add name to ImgDetection * RVC2 FW: Fix build * Address PR comments * Bump rvc4 fw
1 parent 25987fc commit 8493867

File tree

10 files changed

+13
-9
lines changed

10 files changed

+13
-9
lines changed

bindings/python/src/pipeline/datatype/ImgDetectionsBindings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void bind_imgdetections(pybind11::module& m, void* pCallstack) {
3636
// Metadata / raw
3737
imgDetection.def(py::init<>())
3838
.def_readwrite("label", &ImgDetection::label)
39+
.def_readwrite("name", &ImgDetection::name)
3940
.def_readwrite("confidence", &ImgDetection::confidence)
4041
.def_readwrite("xmin", &ImgDetection::xmin)
4142
.def_readwrite("ymin", &ImgDetection::ymin)

cmake/Depthai/DepthaiDeviceRVC4Config.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set(DEPTHAI_DEVICE_RVC4_MATURITY "snapshot")
44

55
# "version if applicable"
66
# set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+93f7b75a885aa32f44c5e9f53b74470c49d2b1af")
7-
set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+e0e0596fead6a181e5dea4628058199c79ca892a")
7+
set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+c3853e7a42792202633735a204a1b45758371781")

cmake/Depthai/DepthaiDeviceSideConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")
33

44
# "full commit hash of device side binary"
5-
set(DEPTHAI_DEVICE_SIDE_COMMIT "4f0b0f3219b701b8e5408eea19648a8d0ec06fa7")
5+
set(DEPTHAI_DEVICE_SIDE_COMMIT "93eeaff81d82368bbe2c326465b1528f8ae93444")
66

77
# "version if applicable"
88
set(DEPTHAI_DEVICE_SIDE_VERSION "")

include/depthai/common/DetectionParserOptions.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "depthai/common/DetectionNetworkType.hpp"
44
#include "depthai/utility/Serialization.hpp"
5+
#include "depthai/common/optional.hpp"
56

67
namespace dai {
78

@@ -18,6 +19,7 @@ struct DetectionParserOptions {
1819

1920
/// YOLO specific network properties
2021
int classes;
22+
std::optional<std::vector<std::string>> classNames;
2123
int coordinates;
2224
std::vector<float> anchors;
2325
std::map<std::string, std::vector<int>> anchorMasks;
@@ -26,6 +28,6 @@ struct DetectionParserOptions {
2628
float iouThreshold;
2729
};
2830

29-
DEPTHAI_SERIALIZE_EXT(DetectionParserOptions, nnFamily, subtype, confidenceThreshold, classes, coordinates, anchors, anchorMasks, anchorsV2, iouThreshold);
31+
DEPTHAI_SERIALIZE_EXT(DetectionParserOptions, nnFamily, subtype, confidenceThreshold, classes, classNames, coordinates, anchors, anchorMasks, anchorsV2, iouThreshold);
3032

3133
} // namespace dai

include/depthai/pipeline/datatype/ImgDetections.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ namespace dai {
1111

1212
struct ImgDetection {
1313
uint32_t label = 0;
14+
std::string name;
1415
float confidence = 0.f;
1516
float xmin = 0.f;
1617
float ymin = 0.f;
1718
float xmax = 0.f;
1819
float ymax = 0.f;
1920
};
2021

21-
DEPTHAI_SERIALIZE_EXT(ImgDetection, label, confidence, xmin, ymin, xmax, ymax);
22+
DEPTHAI_SERIALIZE_EXT(ImgDetection, label, name, confidence, xmin, ymin, xmax, ymax);
2223

2324
/**
2425
* ImgDetections message. Carries normalized detection results

include/depthai/pipeline/node/DetectionParser.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ class DetectionParser : public DeviceNodeCRTP<DeviceNode, DetectionParser, Detec
163163
void setNNArchiveOther(const NNArchive& nnArchive);
164164
void setConfig(const dai::NNArchiveVersionedConfig& config);
165165

166-
std::optional<std::vector<std::string>> mClasses;
167166
std::optional<NNArchive> mArchive;
168167

169168
std::optional<NNArchiveVersionedConfig> archiveConfig;

include/depthai/properties/DetectionParserProperties.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include "depthai/common/DetectionParserOptions.hpp"
66
#include "depthai/common/TensorInfo.hpp"
7-
#include "depthai/common/optional.hpp"
87
#include "depthai/properties/Properties.hpp"
98

109
namespace dai {

protos/ImgDetections.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ message ImgDetections {
1111
common.ImgTransformation transformation = 5;
1212
}
1313

14-
1514
message ImgDetection {
1615
uint32 label = 1;
1716
float confidence = 2;
1817
float xmin = 3;
1918
float ymin = 4;
2019
float xmax = 5;
2120
float ymax = 6;
21+
string name = 7;
2222
}

src/pipeline/node/DetectionParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,11 @@ int DetectionParser::getNumClasses() const {
212212
}
213213

214214
std::optional<std::vector<std::string>> DetectionParser::getClasses() const {
215-
return mClasses;
215+
return properties.parser.classNames;
216216
}
217217

218218
void DetectionParser::setClasses(const std::vector<std::string>& classes) {
219-
mClasses = classes;
219+
properties.parser.classNames = classes;
220220
}
221221

222222
/// Get coordianate size

src/utility/ProtoSerialize.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ std::unique_ptr<google::protobuf::Message> getProtoMessage(const SpatialImgDetec
260260
// populate SpatialImgDetection.ImgDetection from struct inheritance
261261
proto::img_detections::ImgDetection* imgDetection = spatialImgDetection->mutable_detection();
262262
imgDetection->set_label(detection.label);
263+
imgDetection->set_name(detection.name);
263264
imgDetection->set_confidence(detection.confidence);
264265
imgDetection->set_xmin(detection.xmin);
265266
imgDetection->set_ymin(detection.ymin);
@@ -381,6 +382,7 @@ std::unique_ptr<google::protobuf::Message> getProtoMessage(const ImgDetections*
381382
for(const auto& detection : message->detections) {
382383
proto::img_detections::ImgDetection* imgDetection = imgDetections->add_detections();
383384
imgDetection->set_label(detection.label);
385+
imgDetection->set_name(detection.name);
384386
imgDetection->set_confidence(detection.confidence);
385387
imgDetection->set_xmin(detection.xmin);
386388
imgDetection->set_ymin(detection.ymin);

0 commit comments

Comments
 (0)