目前正在添加移动侦测功能,因为DM368 RDK内没有移动侦测的文档,对这部分功能有点迷茫。
通过跟踪代码,大概流程是AVSERVER init调用VIDEO_motionCreate()-->VIDEO_motionTskMain()-->VIDEO_motionTskRun();
可是我将motion的motionenable和motioncenable都打开赋值为1,可是程序依然无法进入motionTskRun,无响应的打印信息;
跟踪代码,程序跑到OSA_bufGetFull()红色部分就返回了。
求教:1、是否有DM368 Motion detect的相应文档;2、motion detect由OSA_bufGetFull()出错返回,可能原因为何?
int VIDEO_motionTskRun()
{
int status, motionVal, inBufId;
OSA_BufInfo *pMotionBufInfo;
ALG_MotionDetectRunPrm tMotionDetectPrm;
ALG_MotionDetectRunStatus tMotionDetectStatus;
static int motionDetectCnt = 0;
status = OSA_bufGetFull(&gVIDEO_ctrl.motionStream.bufMotionIn, &inBufId, OSA_TIMEOUT_FOREVER);
if(status!=OSA_SOK) {
OSA_ERROR("OSA_bufGetFull()\n");
return status;
}
#ifdef AVSERVER_DEBUG_VIDEO_MOTION_THR
OSA_printf(" MOTION: Get Buf %d \n", inBufId);
#endif
pMotionBufInfo = OSA_bufGetBufInfo(&gVIDEO_ctrl.motionStream.bufMotionIn, inBufId);
#ifdef AVSERVER_DEBUG_VIDEO_MOTION_THR
OSA_printf(" MOTION: pMotionBufInfo->width = %d \n", pMotionBufInfo->width);
OSA_printf(" MOTION: pMotionBufInfo->height = %d \n", pMotionBufInfo->height);
#endif
/*Do detect and alarm here */
AVSERVER_lock();
tMotionDetectPrm.mbMvInfo = pMotionBufInfo->virtAddr;
tMotionDetectPrm.ImageWidth = pMotionBufInfo->width;
tMotionDetectPrm.ImageHeight = pMotionBufInfo->height;
tMotionDetectPrm.isKeyFrame = pMotionBufInfo->isKeyFrame;
tMotionDetectPrm.codecType = pMotionBufInfo->codecType;
tMotionDetectPrm.isDateTimeDraw = 0;
tMotionDetectPrm.motionenable = gVIDEO_ctrl.motionStream.motionEnable;
tMotionDetectPrm.motioncenable = gVIDEO_ctrl.motionStream.motionCEnable;
tMotionDetectPrm.motioncvalue = gVIDEO_ctrl.motionStream.motionCValue;
tMotionDetectPrm.motionlevel = gVIDEO_ctrl.motionStream.motionLevel;
tMotionDetectPrm.motionsens = gVIDEO_ctrl.motionStream.motionCValue;
tMotionDetectPrm.windowWidth = (tMotionDetectPrm.ImageWidth / ALG_MOTION_DETECT_HORZ_REGIONS);
tMotionDetectPrm.windowHeight = (tMotionDetectPrm.ImageHeight / ALG_MOTION_DETECT_VERT_REGIONS);
tMotionDetectPrm.blockNum = gVIDEO_ctrl.motionStream.motionBlock;
AVSERVER_unlock();
//tMotionDetectStatus structure will have the status for motion detected for each selected window.
if(tMotionDetectPrm.motionenable == 1)
{
OSA_prfBegin(&gAVSERVER_ctrl.motionPrf);
motionVal = ALG_motionDetectRun(gVIDEO_ctrl.motionStream.algMotionHndl, &tMotionDetectPrm,&tMotionDetectStatus);
OSA_prfEnd(&gAVSERVER_ctrl.motionPrf, 1);
if(motionVal == ALG_MOTION_S_DETECT)
{
#ifdef AVSERVER_DEBUG_VIDEO_MOTION_THR
OSA_printf(" MOTION: DETECTED \n");
#endif
/* send motion dectect once in 5 frames to avoid too many messages */
if(motionDetectCnt>5)
motionDetectCnt=0;
if((gAVSERVER_config.alarmEnable)&&(motionDetectCnt==0)) {
// SendAlarmMotionrDetect(VIDEO_streamGetJPGSerialNum());
}
motionDetectCnt++;
}
else
{
#ifdef AVSERVER_DEBUG_VIDEO_MOTION_THR
OSA_printf(" MOTION: NOT DETECTED \n");
#endif
motionDetectCnt=0;
}
}
OSA_bufPutEmpty(&gVIDEO_ctrl.motionStream.bufMotionIn, inBufId);
#ifdef AVSERVER_DEBUG_VIDEO_MOTION_THR
OSA_printf(" MOTION: Put Buf %d \n", inBufId);
#endif
return status;
}