Skip to content

Commit 2ba0bd3

Browse files
Added frame ID field for detection results
1 parent 7e48e49 commit 2ba0bd3

File tree

7 files changed

+46
-19
lines changed

7 files changed

+46
-19
lines changed

ObjectDetector_interface_class.pdf

162 Bytes
Binary file not shown.

README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# **ObjectDetector interface C++ library**
88

9-
**v1.0.1**
9+
**v1.1.0**
1010

1111
------
1212

@@ -52,10 +52,11 @@
5252

5353
**Table 1** - Library versions.
5454

55-
| Version | Release date | What's new |
56-
| ------- | ------------ | --------------------------------------- |
57-
| 1.0.0 | 17.07.2023 | First version. |
58-
| 1.0.1 | 17.07.2023 | - 3rdparty variable name mistake fixed. |
55+
| Version | Release date | What's new |
56+
| ------- | ------------ | --------------------------------------------- |
57+
| 1.0.0 | 17.07.2023 | First version. |
58+
| 1.0.1 | 17.07.2023 | - 3rdparty variable name mistake fixed. |
59+
| 1.1.0 | 18.07.2023 | - Added frame ID field for detection results. |
5960

6061

6162

@@ -528,6 +529,8 @@ typedef struct Object
528529
{
529530
/// Object ID. Must be uniques for particular object.
530531
int id{0};
532+
/// Frame ID. Must be the same as frame ID of processed video frame.
533+
int frameId{0};
531534
/// Object type. Depends on implementation.
532535
int type{0};
533536
/// Object rectangle width, pixels.
@@ -549,17 +552,18 @@ typedef struct Object
549552

550553
**Table 4** - Object structure fields description.
551554

552-
| Field | Type | Description |
553-
| ------ | ----- | ------------------------------------------------------------ |
554-
| id | int | Object ID. Must be uniques for particular object. Object detector must assign unique ID for each detected object. This is necessary for control algorithms to distinguish different objects from frame to frame. |
555-
| type | int | Object type. Depends on implementation. For example detection neural networks can detect multiple type of objects. |
556-
| width | int | Object rectangle width, pixels. Must be MIN_OBJECT_WIDTH <= width <= MAX_OBJECT_WIDTH (see **ObjectDetectorParam** enum description). |
557-
| height | int | Object rectangle height, pixels. Must be MIN_OBJECT_HEIGHT <= height <= MAX_OBJECT_HEIGHT (see **ObjectDetectorParam** enum description). |
558-
| x | int | Object rectangle top-left horizontal coordinate, pixels. |
559-
| y | int | Object rectangle top-left vertical coordinate, pixels. |
560-
| vX | float | Horizontal component of object velocity, +-pixels/frame. if it possible object detector should estimate object velocity on video frames. |
561-
| vY | float | Vertical component of object velocity, +-pixels/frame. if it possible object detector should estimate object velocity on video frames. |
562-
| p | float | Detection probability from 0 (minimum) to 1 (maximum). Must be p >= MIN_DETECTION_PROPABILITY (see **ObjectDetectorParam** enum description). |
555+
| Field | Type | Description |
556+
| ------- | ----- | ------------------------------------------------------------ |
557+
| id | int | Object ID. Must be uniques for particular object. Object detector must assign unique ID for each detected object. This is necessary for control algorithms to distinguish different objects from frame to frame. |
558+
| frameId | int | Frame ID. Must be the same as frame ID of processed video frame. |
559+
| type | int | Object type. Depends on implementation. For example detection neural networks can detect multiple type of objects. |
560+
| width | int | Object rectangle width, pixels. Must be MIN_OBJECT_WIDTH <= width <= MAX_OBJECT_WIDTH (see **ObjectDetectorParam** enum description). |
561+
| height | int | Object rectangle height, pixels. Must be MIN_OBJECT_HEIGHT <= height <= MAX_OBJECT_HEIGHT (see **ObjectDetectorParam** enum description). |
562+
| x | int | Object rectangle top-left horizontal coordinate, pixels. |
563+
| y | int | Object rectangle top-left vertical coordinate, pixels. |
564+
| vX | float | Horizontal component of object velocity, +-pixels/frame. if it possible object detector should estimate object velocity on video frames. |
565+
| vY | float | Vertical component of object velocity, +-pixels/frame. if it possible object detector should estimate object velocity on video frames. |
566+
| p | float | Detection probability from 0 (minimum) to 1 (maximum). Must be p >= MIN_DETECTION_PROPABILITY (see **ObjectDetectorParam** enum description). |
563567

564568

565569

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.13)
66
## LIBRARY-PROJECT
77
## name and version
88
###############################################################################
9-
project(ObjectDetector VERSION 1.0.0 LANGUAGES CXX)
9+
project(ObjectDetector VERSION 1.1.0 LANGUAGES CXX)
1010

1111

1212

src/ObjectDetector.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ void cr::detector::ObjectDetectorParams::encode(
9595
for (int i = 0; i < numObjects; ++i)
9696
{
9797
memcpy(&data[pos], &objects[i].id, 4); pos += 4;
98+
memcpy(&data[pos], &objects[i].frameId, 4); pos += 4;
9899
memcpy(&data[pos], &objects[i].type, 4); pos += 4;
99100
memcpy(&data[pos], &objects[i].width, 4); pos += 4;
100101
memcpy(&data[pos], &objects[i].height, 4); pos += 4;
@@ -245,6 +246,7 @@ void cr::detector::ObjectDetectorParams::encode(
245246
for (int i = 0; i < numObjects; ++i)
246247
{
247248
memcpy(&data[pos], &objects[i].id, 4); pos += 4;
249+
memcpy(&data[pos], &objects[i].frameId, 4); pos += 4;
248250
memcpy(&data[pos], &objects[i].type, 4); pos += 4;
249251
memcpy(&data[pos], &objects[i].width, 4); pos += 4;
250252
memcpy(&data[pos], &objects[i].height, 4); pos += 4;
@@ -477,6 +479,7 @@ bool cr::detector::ObjectDetectorParams::decode(uint8_t* data)
477479
{
478480
cr::detector::Object obj;
479481
memcpy(&obj.id, &data[pos], 4); pos += 4;
482+
memcpy(&obj.frameId, &data[pos], 4); pos += 4;
480483
memcpy(&obj.type, &data[pos], 4); pos += 4;
481484
memcpy(&obj.width, &data[pos], 4); pos += 4;
482485
memcpy(&obj.height, &data[pos], 4); pos += 4;

src/ObjectDetector.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ typedef struct Object
1616
{
1717
/// Object ID. Must be uniques for particular object.
1818
int id{0};
19+
/// Frame ID. Must be the same as frame ID of processed video frame.
20+
int frameId{0};
1921
/// Object type. Depends on implementation.
2022
int type{0};
2123
/// Object rectangle width, pixels.

src/ObjectDetectorVersion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#define OBJECT_DETECTOR_MAJOR_VERSION 1
4-
#define OBJECT_DETECTOR_MINOR_VERSION 0
4+
#define OBJECT_DETECTOR_MINOR_VERSION 1
55
#define OBJECT_DETECTOR_PATCH_VERSION 0
66

7-
#define OBJECT_DETECTOR_VERSION "1.0.0"
7+
#define OBJECT_DETECTOR_VERSION "1.1.0"

test/main.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ bool copyTest()
110110
{
111111
Object obj;
112112
obj.id = rand() % 255;
113+
obj.frameId = rand() % 255;
113114
obj.type = rand() % 255;
114115
obj.width = rand() % 255;
115116
obj.height = rand() % 255;
@@ -247,6 +248,11 @@ bool copyTest()
247248
cout << "in.objects[" << i << "].id" << endl;
248249
return false;
249250
}
251+
if (in.objects[i].frameId != out.objects[i].frameId)
252+
{
253+
cout << "in.objects[" << i << "].frameId" << endl;
254+
return false;
255+
}
250256
if (in.objects[i].type != out.objects[i].type)
251257
{
252258
cout << "in.objects[" << i << "].type" << endl;
@@ -333,6 +339,7 @@ bool encodeDecodeTest()
333339
{
334340
Object obj;
335341
obj.id = rand() % 255;
342+
obj.frameId = rand() % 255;
336343
obj.type = rand() % 255;
337344
obj.width = rand() % 255;
338345
obj.height = rand() % 255;
@@ -487,6 +494,11 @@ bool encodeDecodeTest()
487494
cout << "in.objects[" << i << "].id" << endl;
488495
return false;
489496
}
497+
if (in.objects[i].frameId != out.objects[i].frameId)
498+
{
499+
cout << "in.objects[" << i << "].frameId" << endl;
500+
return false;
501+
}
490502
if (in.objects[i].type != out.objects[i].type)
491503
{
492504
cout << "in.objects[" << i << "].type" << endl;
@@ -815,6 +827,7 @@ bool encodeDecodeWithMaskTest()
815827
{
816828
Object obj;
817829
obj.id = rand() % 255;
830+
obj.frameId = rand() % 255;
818831
obj.type = rand() % 255;
819832
obj.width = rand() % 255;
820833
obj.height = rand() % 255;
@@ -995,6 +1008,11 @@ bool encodeDecodeWithMaskTest()
9951008
cout << "in.objects[" << i << "].id" << endl;
9961009
return false;
9971010
}
1011+
if (in.objects[i].frameId != out.objects[i].frameId)
1012+
{
1013+
cout << "in.objects[" << i << "].frameId" << endl;
1014+
return false;
1015+
}
9981016
if (in.objects[i].type != out.objects[i].type)
9991017
{
10001018
cout << "in.objects[" << i << "].type" << endl;

0 commit comments

Comments
 (0)