Skip to content

Commit cb3903b

Browse files
Version 1.3.0
1 parent 2e494af commit cb3903b

File tree

6 files changed

+125
-36
lines changed

6 files changed

+125
-36
lines changed

Diff for: README.md

+48-19
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ This SDK is designed to integrate IP cameras with the Faceter cloud video survei
1212

1313
**Faceter CloudCam SDK** – modules that implement interaction with the cloud and Faceter applications. The SDK requires a local RTSP stream, which is transmitted to the Faceter cloud using RTSP-push technology
1414

15-
## Faceter CloudCam SDK prebuilt libraries
16-
17-
Prebuilt libraries for different platforms are located in the [latest release](https://github.com/faceterteam/Faceter-CloudCam-SDK/releases/latest)
18-
1915
## Intergration sample
2016

2117
An example of code with stubs describing intergation process is shown in [integration_sample.c](integration_sample.c)
@@ -43,11 +39,10 @@ const char* serialNumber = GetSerialNumber();
4339
4440
ClientSettings settings = {
4541
.cameraModel = "MyModel",
46-
.cameraVendor = "Faceter",
42+
.cameraVendor = "Vision",
4743
.appVersion = "1.0.0",
4844
.firmwareVersion = "Camera_1.0.3",
4945
.hardwareId = "t31_gc2053",
50-
.discoveryPort = 3702,
5146
.certFilePath = "/etc/ssl/certs/ca-certificates.crt",
5247
.confFilePath = "/etc/faceter-camera.conf",
5348
.rtspMainUrl = "rtsp://127.0.0.1/stream=0",
@@ -75,7 +70,6 @@ Returns 0 on success and -1 if some error value occurs
7570
* appVersion - version of the applcation using library ("1.0.0")
7671
* firmwareVersion - camera firmware version ("Camera_1.0.3")
7772
* hardwareId - information about hardware, such as processor and sensor ("t31_gc2053")
78-
* discoveryPort - port used for camera discovery from Faceter application (3702)
7973
* certFilePath - path to the SSL certificate file, used in HTTPS connections ("/etc/ssl/certs/ca-certificates.crt")
8074
* confFilePath - path to the file in the writable location where library will store it's state ("/etc/faceter-camera.conf")
8175
* rtspMainUrl - main stream RTSP url without credentials ("rtsp://127.0.0.1/stream=0")
@@ -201,25 +195,39 @@ typedef enum ObjectType
201195
ObjectAnimal,
202196
ObjectFire,
203197
ObjectSmoke,
204-
ObjectOther
198+
ObjectOther,
199+
ObjectUnknown
205200
} ObjectType;
206201
207-
void FaceterClientOnVideoEvent(VideoEventType eventType, ObjectType objectType,
208-
DetectionAttribute *attributesList, DetectionRect *relativeBoundingRectList,
209-
char* snapshotImage, long int snapshotBytesCount)
202+
typedef struct DetectionGrid
203+
{
204+
int rowsCount;
205+
int colsCount;
206+
int cellsCount;
207+
uint32_t *cells;
208+
} DetectionGrid;
209+
210+
void FaceterClientOnVideoEventStart(int64_t eventTimestampSec, VideoEventType eventType, ObjectType objectType,
211+
DetectionAttribute *attributesList, DetectionGrid detectionGrid,
212+
char* snapshotImage, long int snapshotBytesCount);
213+
214+
void FaceterClientOnVideoEventUpdate(int64_t eventTimestampSec, VideoEventType eventType, ObjectType objectType,
215+
DetectionGrid detectionGrid);
216+
217+
void FaceterClientOnVideoEventEnd(int64_t eventTimestampSec, VideoEventType eventType, ObjectType objectType,
218+
DetectionGrid detectionGrid);
210219
```
211-
Each video event has VideoEventType if can be recognized, otherwise use **VideoEventMotion**.
212-
If object can be detected it's type passed as second parameters, otherwise use **ObjectOther**.
220+
Long time detection events have start point, end point and can be updated between start and end.
221+
Use **FaceterClientOnVideoEventStart**, **FaceterClientOnVideoEventEnd** and **FaceterClientOnVideoEventUpdate** respectively.
222+
Pass event timestamp in seconds since 01.01.1970. Each video event has VideoEventType if can be recognized, otherwise use **VideoEventMotion**. If object can be detected it's type passed as second parameters, otherwise use **ObjectUnknown**.
213223

214224
Also detector may provide object's attributes, that can be passed linked list of **DetectionAttribute**.
215225
Parameter can be NULL if no information about object attributes provided.
216226
DetectionAttribute is key-value structure of string type. Use PushDetectionAttribute to add object attribute.
217227
Helper function PushHumanAttibutes creates DetectionAttribute list for human with gender and age fields.
218228
Helper function PushVehicleAttributes creates DetectionAttribute list for vehicle with type and license plate fields
219229

220-
For describing objects bounding rects use **DetectionRect** list. Parameter can be NULL if no information about rect provided.
221-
Rect coordinates (top left corner, width and height) are relative to image size and must be set as integers in the range [0..99].
222-
For adding next DetectionRect to list PushDetectionRect use PushDetectionRect
230+
For describing cells in grid where object was detected pass DetectionGrid object. It has number of columns, rows and array cells with uint32 numbers. Each bit in this number describe cell. If object detected in cell bit will be 1, otherwise 0.
223231

224232
Last two parameters - camera snapshot of detected event in jpeg format and snapshot bytes count. Can be NULL.
225233

@@ -228,16 +236,37 @@ Last two parameters - camera snapshot of detected event in jpeg format and snaps
228236
long int snapshotJpegBytesCount = 100;
229237
char snapshotJpegImage[snapshotJpegBytesCount];
230238
231-
//simple motion event
232-
FaceterClientOnVideoEvent(VideoEventMotion, ObjectOther, NULL, NULL, NULL, 0);
239+
int64_t nowTime = (int64_t)time(NULL);
240+
DetectionGrid grid = {
241+
.rowsCount = 10,
242+
.colsCount = 16,
243+
.cellsCount = 5
244+
};
245+
grid.cells = malloc(grid.cellsCount * sizeof(int32_t));
246+
grid.cells[2] = 1;
247+
//simple motion event started
248+
FaceterClientOnVideoEventStart(nowTime, VideoEventMotion, ObjectUnknown, NULL, grid, snapshotJpegImage, snapshotJpegBytesCount);
249+
250+
//simple motion event updated periodically
251+
FaceterClientOnVideoEventUpdate(nowTime1, VideoEventMotion, ObjectUnknown, grid1);
252+
FaceterClientOnVideoEventUpdate(nowTime2, VideoEventMotion, ObjectUnknown, grid2);
253+
254+
//simple motion event ended
255+
FaceterClientOnVideoEventEnd(nowTime3, VideoEventMotion, ObjectUnknown, grid3);
233256
234257
//human motion event
235258
DetectionAttribute* humanAttrList = NULL;
236259
PushHumanAttibutes(&humanAttrList, GenderMale, 30);
237260
DetectionRect* humanRect = NULL;
238261
PushDetectionRect(&humanRect, 10, 15, 25, 49);
239-
FaceterClientOnVideoEvent(VideoEventMotion, ObjectHuman, humanAttrList, humanRect, snapshotJpegImage, snapshotJpegBytesCount);
262+
FaceterClientOnVideoEventStart(nowTime, VideoEventMotion, ObjectHuman, humanAttrList, grid, snapshotJpegImage, snapshotJpegBytesCount);
263+
FaceterClientOnVideoEventUpdate(nowTime, VideoEventMotion, ObjectHuman, grid);
264+
FaceterClientOnVideoEventEnd(nowTime, VideoEventMotion, ObjectHuman, grid);
265+
```
266+
267+
One-time events can be passed to SDK with **FaceterClientOnVideoEvent** method
240268

269+
```
241270
//animal motion event
242271
DetectionAttribute* animalAttrList = NULL;
243272
PushDetectionAttribute(&animalAttrList, "kind", "cat");

Diff for: include/CameraConfig.h

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ typedef struct DetectorConfig {
4141

4242
typedef struct OsdConfig {
4343
int isEnabled;
44+
int offsetX;
45+
int offsetY;
46+
char template[50];
4447
} OsdConfig;
4548

4649
typedef struct NightModeConfig {

Diff for: include/ControlFunction.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ typedef enum ClientControlCode {
1818
ControlCodeStreamStatus, /**< update stream status */
1919
ControlCodeSetupWifi, /**< set wifi configuration from param */
2020
ControlCodeStartScanQr, /**< start qr code scanner */
21-
ControlCodeStopScanQr /**< stop qr code scanner */
21+
ControlCodeStopScanQr, /**< stop qr code scanner */
22+
ControlCodeUpdateVideoEvent /**< get detection grid for video event and call FaceterClientOnVideoEventUpdate */
2223
} ClientControlCode;
2324

2425
/*

Diff for: include/DetectionEvents.h

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef DETECTIONEVENTS_H
22
#define DETECTIONEVENTS_H
33

4+
#include <stdint.h>
5+
46
typedef enum AudioEventType
57
{
68
AudioEventCry,
@@ -27,7 +29,8 @@ typedef enum ObjectType
2729
ObjectAnimal,
2830
ObjectFire,
2931
ObjectSmoke,
30-
ObjectOther
32+
ObjectOther,
33+
ObjectUnknown
3134
} ObjectType;
3235

3336
typedef enum HumanGender
@@ -55,6 +58,14 @@ typedef struct DetectionRect
5558
struct DetectionRect* next;
5659
} DetectionRect;
5760

61+
typedef struct DetectionGrid
62+
{
63+
int rowsCount;
64+
int colsCount;
65+
int cellsCount;
66+
uint32_t *cells;
67+
} DetectionGrid;
68+
5869
typedef struct DetectionAttribute
5970
{
6071
char* key;
@@ -71,5 +82,9 @@ void PushHumanAttibutes(DetectionAttribute** top, HumanGender gender, int age);
7182
void PushVehicleAttributes(DetectionAttribute** top, VehicleType vehicleType, const char* licensePlate);
7283
DetectionAttribute* PopDetectionAttribute(DetectionAttribute** top);
7384

85+
const char* VideoEventTypeToStr(VideoEventType eventType);
86+
const char* ObjectTypeToStr(ObjectType objectType);
87+
const char* AudioEventTypeToStr(AudioEventType eventType);
88+
7489

7590
#endif //DETECTIONEVENTS_H

Diff for: include/FaceterClient.h

+30-5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ void FaceterClientSetControlStatus(ClientControlCode controlCode, ClientStatusCo
4242
/*
4343
* Send detected video event to the library
4444
*
45+
* @param eventTimestampSec UTC linux timestamp when event occured
46+
*
4547
* @param eventType type of detected video event.
4648
* If does not matched anything else in the VideoEventType use VideoEventMotion
4749
*
@@ -53,19 +55,42 @@ void FaceterClientSetControlStatus(ClientControlCode controlCode, ClientStatusCo
5355
* PushHumanAttibutes for human attributes,
5456
* PushVehicleAttributes for vehicle attributes
5557
*
56-
* @param relativeBoundingRectList list of detected objects bounding rects in relative coordinates.
57-
* Could be NULL. Use PushDetectionRect for adding next DetectionRect.
58-
* 0 <= x, y, width, height < 100
58+
* @param detectionGrid desribes grid - number of rows, cols and cells, where
59+
* event was detected
5960
*
6061
* @param snapshotImage image of the detected event. Could be NULL
6162
* @param snapshotBytesCount size of snaphot, 0 if snapshotImage is NULL
6263
*
6364
*/
64-
void FaceterClientOnVideoEvent(VideoEventType eventType, ObjectType objectType,
65-
DetectionAttribute *attributesList, DetectionRect *relativeBoundingRectList,
65+
void FaceterClientOnVideoEvent(int64_t eventTimestampSec, VideoEventType eventType, ObjectType objectType,
66+
DetectionAttribute *attributesList, DetectionGrid detectionGrid,
6667
char* snapshotImage, long int snapshotBytesCount);
6768

6869

70+
/*
71+
* Method for start sending long detections
72+
*
73+
* params descripion in FaceterClientOnVideoEvent
74+
*/
75+
void FaceterClientOnVideoEventStart(int64_t eventTimestampSec, VideoEventType eventType, ObjectType objectType,
76+
DetectionAttribute *attributesList, DetectionGrid detectionGrid,
77+
char* snapshotImage, long int snapshotBytesCount);
78+
/*
79+
* Method for update deetction grid for long detection
80+
*
81+
* params descripion in FaceterClientOnVideoEvent
82+
*/
83+
void FaceterClientOnVideoEventUpdate(int64_t eventTimestampSec, VideoEventType eventType, ObjectType objectType,
84+
DetectionGrid detectionGrid);
85+
86+
/*
87+
* Method for end sending long detections
88+
*
89+
* params descripion in FaceterClientOnVideoEvent
90+
*/
91+
void FaceterClientOnVideoEventEnd(int64_t eventTimestampSec, VideoEventType eventType, ObjectType objectType,
92+
DetectionGrid detectionGrid);
93+
6994
/*
7095
* Send detected audio event to the library
7196
*

Diff for: integration_sample.c

+26-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <stdlib.h>
22
#include <string.h>
3+
#include <time.h>
34
#include "FaceterClient.h"
45

56
/*
@@ -34,34 +35,49 @@ void OnMotionDetected()
3435
long int snapshotJpegBytesCount = 100;
3536
char snapshotJpegImage[snapshotJpegBytesCount];
3637

37-
//simple motion event
38-
FaceterClientOnVideoEvent(VideoEventMotion, ObjectOther, NULL, NULL, NULL, 0);
38+
int64_t nowTime = (int64_t)time(NULL);
39+
DetectionGrid grid = {
40+
.rowsCount = 10,
41+
.colsCount = 16,
42+
.cellsCount = 5
43+
};
44+
grid.cells = malloc(grid.cellsCount * sizeof(int32_t));
45+
grid.cells[2] = 1;
46+
//simple motion event started
47+
FaceterClientOnVideoEventStart(nowTime, VideoEventMotion, ObjectUnknown, NULL, grid, snapshotJpegImage, snapshotJpegBytesCount);
48+
49+
//simple motion event updated periodically
50+
FaceterClientOnVideoEventUpdate(nowTime, VideoEventMotion, ObjectUnknown, grid);
51+
FaceterClientOnVideoEventUpdate(nowTime, VideoEventMotion, ObjectUnknown, grid);
52+
53+
//simple motion event ended
54+
FaceterClientOnVideoEventEnd(nowTime, VideoEventMotion, ObjectUnknown, grid);
3955

4056
//human motion event
4157
DetectionAttribute* humanAttrList = NULL;
4258
PushHumanAttibutes(&humanAttrList, GenderMale, 30);
4359
DetectionRect* humanRect = NULL;
4460
PushDetectionRect(&humanRect, 10, 15, 25, 49);
45-
FaceterClientOnVideoEvent(VideoEventMotion, ObjectHuman, humanAttrList, humanRect, snapshotJpegImage, snapshotJpegBytesCount);
61+
FaceterClientOnVideoEventStart(nowTime, VideoEventMotion, ObjectHuman, humanAttrList, grid, snapshotJpegImage, snapshotJpegBytesCount);
62+
FaceterClientOnVideoEventUpdate(nowTime, VideoEventMotion, ObjectHuman, grid);
63+
FaceterClientOnVideoEventEnd(nowTime, VideoEventMotion, ObjectHuman, grid);
4664

4765
//animal motion event
4866
DetectionAttribute* animalAttrList = NULL;
4967
PushDetectionAttribute(&animalAttrList, "kind", "cat");
50-
FaceterClientOnVideoEvent(VideoEventMotion, ObjectAnimal, animalAttrList, NULL, snapshotJpegImage, snapshotJpegBytesCount);
68+
FaceterClientOnVideoEvent(nowTime, VideoEventMotion, ObjectAnimal, animalAttrList, grid, snapshotJpegImage, snapshotJpegBytesCount);
5169

5270
//line crossing event
53-
DetectionRect* crossRects = NULL;
54-
PushDetectionRect(&crossRects, 1, 5, 25, 49);
55-
PushDetectionRect(&crossRects, 30, 45, 5, 17);
56-
FaceterClientOnVideoEvent(VideoEventLineCrossing, ObjectOther, NULL, crossRects, snapshotJpegImage, snapshotJpegBytesCount);
71+
grid.cells[1] = 12345;
72+
FaceterClientOnVideoEvent(nowTime, VideoEventLineCrossing, ObjectOther, NULL, grid, snapshotJpegImage, snapshotJpegBytesCount);
5773

5874
//vehicle line crossing event
5975
DetectionAttribute* vehicleAttrList = NULL;
6076
PushVehicleAttributes(&vehicleAttrList, VehicleCar, "AB123");
61-
FaceterClientOnVideoEvent(VideoEventLineCrossing, ObjectVehicle, vehicleAttrList, NULL, snapshotJpegImage, snapshotJpegBytesCount);
77+
FaceterClientOnVideoEvent(nowTime, VideoEventLineCrossing, ObjectVehicle, vehicleAttrList, grid, snapshotJpegImage, snapshotJpegBytesCount);
6278

6379
//loitering event
64-
FaceterClientOnVideoEvent(VideoEventLoitering, ObjectHuman, NULL, NULL, NULL, 0);
80+
FaceterClientOnVideoEvent(nowTime, VideoEventLoitering, ObjectHuman, NULL, grid, NULL, 0);
6581

6682
//baby cry audio event
6783
FaceterClientOnAudioEvent(AudioEventCry);

0 commit comments

Comments
 (0)