IVS intelligent analysis common API.
More...
IVS intelligent analysis common API.
1 Concept
IMP IVS's main goal is to provide users with a number of embedded intelligent analysis algorithm to SDK interface.
1.1 IMPIVSInterface
IMPIVSInterface is the common algorithm interface, the Specific algorithm through the implementation of this interface and pass it to the IVS IMP to achieve the purpose of running the specific algorithm in SDK.
For a channel to be an algorithm that can run the carrier, the Channel has to be into the SDK. To do so, we need to transmit the specific implementation of the general algorithm to the specific interface of this Channel.
IMPIVSInterface member parameter is the init member parameter, it is a must to include int (*free_data)(void *data) member, and assigned to IMP_IVS_ReleaseDa in order to avoid a lock (out).
2 Using method
Motion detection, as an example, reference: sample-move_c.c document.
Step.1 Init system, call sample_system_init() realized in examples.
All applications should be initialized only one time.
step.2 Init framesource, if it is already created, you can just use it( continue with the process) if it is not created, call sample_framesource_init(IVS_FS_CHN, &fs_chn_attr)
step.3 Create IVS group
Multiple algorithm can be used to share a channel group, also can partly use the channel group reference: sample_ivs_move_init() function.
int sample_ivs_move_init(int grp_num)
{
int ret = 0;
if (ret < 0) {
IMP_LOG_ERR(TAG, "IMP_IVS_CreateGroup(%d) failed\n", grp_num);
return -1;
}
return 0;
}
step.4 Bind IVS group to Framesource group
if (ret < 0) {
IMP_LOG_ERR(TAG, "Bind FrameSource channel%d and ivs0 failed\n", IVS_FS_CHN);
return -1;
}
step.5 Enable Framesource and channel algorithm. Advice : ivs index is equal to ivs channel num in order to make it more convenient to use them.
ret = sample_framesource_streamon(IVS_FS_CHN);
if (ret < 0) {
IMP_LOG_ERR(TAG, "ImpStreamOn failed\n");
return -1;
}
ret = sample_ivs_move_start(0, 0, &inteface);
if (ret < 0) {
IMP_LOG_ERR(TAG, "sample_ivs_move_start(0, 0) failed\n");
return -1;
}
step.6 Get algorithm result
Obtain the results and release the results must be strictly corresponding, can not be interrupted in the middle.
for (i = 0; i < NR_FRAMES_TO_IVS; i++) {
if (ret < 0) {
IMP_LOG_ERR(TAG, "IMP_IVS_PollingResult(%d, %d) failed\n", 0, IMP_IVS_DEFAULT_TIMEOUTMS);
return -1;
}
if (ret < 0) {
IMP_LOG_ERR(TAG, "IMP_IVS_GetResult(%d) failed\n", 0);
return -1;
}
IMP_LOG_INFO(TAG, "frame[%d], result->ret=%d\n", i, result->ret);
if (ret < 0) {
IMP_LOG_ERR(TAG, "IMP_IVS_ReleaseResult(%d) failed\n", 0);
return -1;
}
}
step.7
sample_ivs_move_stop(0, inteface);
sample_framesource_streamoff(1);
sample_ivs_move_exit(0);
sample_framesource_exit(IVS_FS_CHN);
sample_system_exit();
Create IVS channel to one algorithm entity.
- Parameters
-
[in] | ChnNum | IVS channel number, advice being equal to algorithm index |
[in] | handler | IVS algorithm handler, an entity of one algorithm interface. |
- Return values
-
int IMP_IVS_CreateGroup |
( |
int |
GrpNum | ) |
|
Create IVS group.
- Parameters
-
[in] | GrpNum | IVS group number |
- Return values
-
int IMP_IVS_DestroyChn |
( |
int |
ChnNum | ) |
|
Destroy IVS channel.
- Parameters
-
[in] | ChnNum | ivs channel number |
- Return values
-
int IMP_IVS_DestroyGroup |
( |
int |
GrpNum | ) |
|
Destroy IVS group.
- Parameters
-
[in] | GrpNum | IVS group number |
- Return values
-
int IMP_IVS_GetParam |
( |
int |
chnNum, |
|
|
void * |
param |
|
) |
| |
Get the algorithm parameter held by the channel indexed by ChnNum.
- Parameters
-
[in] | ChnNum | IVS channel number |
[in] | param | algorithm parameter (virtual address pointer). |
- Return values
-
int IMP_IVS_GetResult |
( |
int |
ChnNum, |
|
|
void ** |
result |
|
) |
| |
Get IVS algorithm check result.
- Parameters
-
[in] | ChnNum | IVS channel number |
[in] | result | the result to one check process of the algorithm registerd to the ivs channel(ChnNum) |
- Return values
-
int IMP_IVS_PollingResult |
( |
int |
ChnNum, |
|
|
int |
timeoutMs |
|
) |
| |
Whether the blocking judge can or can not get the result of IVS function.
- Parameters
-
[in] | ChnNum | ivs channel number |
[in] | timeout | max wait timeļ¼unit:ms;IMP_IVS_DEFAULT_TIMEOUTMS:internel wait time,0:no wait, >0: customer set wait time |
- Return values
-
int IMP_IVS_RegisterChn |
( |
int |
GrpNum, |
|
|
int |
ChnNum |
|
) |
| |
Register one ivs channel to an ivs group.
- Parameters
-
[in] | GrpNum | IVS group number |
[in] | ChnNum | IVS channel number |
- Return values
-
int IMP_IVS_ReleaseData |
( |
void * |
vaddr | ) |
|
Release IVS function to calculate the resources result.
- Parameters
-
[in] | vaddr | the released frame's virtual address |
- Return values
-
int IMP_IVS_ReleaseResult |
( |
int |
ChnNum, |
|
|
void * |
result |
|
) |
| |
Release IVS algorithm check result.
- Parameters
-
[in] | GrpNum | IVS group number |
[in] | ChnNum | IVS channel number |
[in] | result | the result to one check process of the algorithm registerd to the ivs channel which num is ChnNum |
- Return values
-
int IMP_IVS_SetParam |
( |
int |
chnNum, |
|
|
void * |
param |
|
) |
| |
Set the algorithm parameter held by the channel indexed by ChnNum.
- Parameters
-
[in] | ChnNum | IVS channel number |
[in] | param | algorithm parameter pointer. |
- Return values
-
int IMP_IVS_StartRecvPic |
( |
int |
ChnNum | ) |
|
Channel starts receiving picture(s)
- Parameters
-
[in] | ChnNum | ivs channel number |
- Return values
-
int IMP_IVS_StopRecvPic |
( |
int |
ChnNum | ) |
|
Channel stops receiving picture(s)
- Parameters
-
[in] | ChnNum | ivs channel number |
- Return values
-
int IMP_IVS_UnRegisterChn |
( |
int |
ChnNum | ) |
|
Unregister one ivs channel from its registered ivs group.
- Parameters
-
[in] | ChnNum | IVS channel number |
- Return values
-