ISVP-SDK  3.12.0
Ingenic Smart Video Platform SDK
Modules | Data Structures | Typedefs | Functions

IVS intelligent analysis common API. More...

Collaboration diagram for IMP_IVS:

Modules

 MoveDetection
 motion detection interface
 

Data Structures

struct  IMPIVSInterface
 

Typedefs

typedef struct IMPIVSInterface IMPIVSInterface
 IVS common interface.
 

Functions

int IMP_IVS_CreateGroup (int GrpNum)
 Create IVS group. More...
 
int IMP_IVS_DestroyGroup (int GrpNum)
 Destroy IVS group. More...
 
int IMP_IVS_CreateChn (int ChnNum, IMPIVSInterface *handler)
 Create IVS channel to one algorithm entity. More...
 
int IMP_IVS_DestroyChn (int ChnNum)
 Destroy IVS channel. More...
 
int IMP_IVS_RegisterChn (int GrpNum, int ChnNum)
 Register one ivs channel to an ivs group. More...
 
int IMP_IVS_UnRegisterChn (int ChnNum)
 Unregister one ivs channel from its registered ivs group. More...
 
int IMP_IVS_StartRecvPic (int ChnNum)
 Channel starts receiving picture(s) More...
 
int IMP_IVS_StopRecvPic (int ChnNum)
 Channel stops receiving picture(s) More...
 
int IMP_IVS_PollingResult (int ChnNum, int timeoutMs)
 Whether the blocking judge can or can not get the result of IVS function. More...
 
int IMP_IVS_GetResult (int ChnNum, void **result)
 Get IVS algorithm check result. More...
 
int IMP_IVS_ReleaseResult (int ChnNum, void *result)
 Release IVS algorithm check result. More...
 
int IMP_IVS_ReleaseData (void *vaddr)
 Release IVS function to calculate the resources result. More...
 
int IMP_IVS_GetParam (int chnNum, void *param)
 Get the algorithm parameter held by the channel indexed by ChnNum. More...
 
int IMP_IVS_SetParam (int chnNum, void *param)
 Set the algorithm parameter held by the channel indexed by ChnNum. More...
 

Detailed Description

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;
ret = IMP_IVS_CreateGroup(grp_num);
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

IMPCell framesource_cell = {DEV_ID_FS, IVS_FS_CHN, 0};
IMPCell ivs_cell = {DEV_ID_IVS, 0, 0};
ret = IMP_System_Bind(&framesource_cell, &ivs_cell);
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++) {
ret = IMP_IVS_PollingResult(0, IMP_IVS_DEFAULT_TIMEOUTMS);
if (ret < 0) {
IMP_LOG_ERR(TAG, "IMP_IVS_PollingResult(%d, %d) failed\n", 0, IMP_IVS_DEFAULT_TIMEOUTMS);
return -1;
}
ret = IMP_IVS_GetResult(0, (void **)&result);
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);
ret = IMP_IVS_ReleaseResult(0, (void *)result);
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);
IMP_System_UnBind(&framesource_cell, &ivs_cell);
sample_ivs_move_exit(0);
sample_framesource_exit(IVS_FS_CHN);
sample_system_exit();

Function Documentation

int IMP_IVS_CreateChn ( int  ChnNum,
IMPIVSInterface handler 
)

Create IVS channel to one algorithm entity.

Parameters
[in]ChnNumIVS channel number, advice being equal to algorithm index
[in]handlerIVS algorithm handler, an entity of one algorithm interface.
Return values
0success
1failed
int IMP_IVS_CreateGroup ( int  GrpNum)

Create IVS group.

Parameters
[in]GrpNumIVS group number
Return values
0success
1failed
int IMP_IVS_DestroyChn ( int  ChnNum)

Destroy IVS channel.

Parameters
[in]ChnNumivs channel number
Return values
0success
1failed
int IMP_IVS_DestroyGroup ( int  GrpNum)

Destroy IVS group.

Parameters
[in]GrpNumIVS group number
Return values
0success
1failed
int IMP_IVS_GetParam ( int  chnNum,
void *  param 
)

Get the algorithm parameter held by the channel indexed by ChnNum.

Parameters
[in]ChnNumIVS channel number
[in]paramalgorithm parameter (virtual address pointer).
Return values
0success
1failed
int IMP_IVS_GetResult ( int  ChnNum,
void **  result 
)

Get IVS algorithm check result.

Parameters
[in]ChnNumIVS channel number
[in]resultthe result to one check process of the algorithm registerd to the ivs channel(ChnNum)
Return values
0success
1failed
Remarks
According to different functions of IVS binding channel, the output might be different (corresponding results).
int IMP_IVS_PollingResult ( int  ChnNum,
int  timeoutMs 
)

Whether the blocking judge can or can not get the result of IVS function.

Parameters
[in]ChnNumivs channel number
[in]timeoutmax wait timeļ¼Œunit:ms;IMP_IVS_DEFAULT_TIMEOUTMS:internel wait time,0:no wait, >0: customer set wait time
Return values
0success
1failed
Remarks
Only when the channel is created then the parameter IMPIVSInterface structure (in the ProcessAsync member) returns 0, that can help to say that the return function is working properly, so the PollingResult return function can be a success.
int IMP_IVS_RegisterChn ( int  GrpNum,
int  ChnNum 
)

Register one ivs channel to an ivs group.

Parameters
[in]GrpNumIVS group number
[in]ChnNumIVS channel number
Return values
0success
1failed
Remarks
ChnNum is the registered Channel to the Group(GrpNum)
int IMP_IVS_ReleaseData ( void *  vaddr)

Release IVS function to calculate the resources result.

Parameters
[in]vaddrthe released frame's virtual address
Return values
0success
1failed
Remarks
if libimp is used, it is a must to use the free_data of IVS function.
int IMP_IVS_ReleaseResult ( int  ChnNum,
void *  result 
)

Release IVS algorithm check result.

Parameters
[in]GrpNumIVS group number
[in]ChnNumIVS channel number
[in]resultthe result to one check process of the algorithm registerd to the ivs channel which num is ChnNum
Return values
0success
1failed
Remarks
According to different functions of IVS binding channel, it might Release different result resource for its output.
int IMP_IVS_SetParam ( int  chnNum,
void *  param 
)

Set the algorithm parameter held by the channel indexed by ChnNum.

Parameters
[in]ChnNumIVS channel number
[in]paramalgorithm parameter pointer.
Return values
0success
1failed
int IMP_IVS_StartRecvPic ( int  ChnNum)

Channel starts receiving picture(s)

Parameters
[in]ChnNumivs channel number
Return values
0success
1failed
Remarks
ChnNum is the Channel which starts receiving pictures
int IMP_IVS_StopRecvPic ( int  ChnNum)

Channel stops receiving picture(s)

Parameters
[in]ChnNumivs channel number
Return values
0success
1failed
Remarks
ChnNum is the Channel which stops receiving pictures
int IMP_IVS_UnRegisterChn ( int  ChnNum)

Unregister one ivs channel from its registered ivs group.

Parameters
[in]ChnNumIVS channel number
Return values
0success
1failed