int main(int argc, char* argv[]) { cv::VideoCapture cap; if( argc == 2 ) cap.open(argv[1]); if(!cap.isOpened()) { std::cout<<"[!] Error: cant open camera!"<<std::endl; return -1; } cv::Mat edges; cv::namedWindow("result window", 1); cv::Mat frame, frame2; cap >> frame; while(1) { cap >> frame2; MotionDetection(frame, frame2); } cv::destroyAllWindows(); return 0; }
INT32 UIFlowWndMovie_OnTimer(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray) { NVT_USER_EVT userEvent; static BOOL bFirstPowerOn = TRUE; userEvent = paramArray[0]; switch(userEvent) { case NVTEVT_05SEC_TIMER: if (bFirstPowerOn == TRUE) { bFirstPowerOn = FALSE; if ((GetGsensorPowerOn() == TRUE)&&(!KeyScan_IsHDMIPlugIn())) { debug_msg(">>-----GetGsensorPowerOn ----\r\n"); Ux_PostEvent(NVTEVT_KEY_SHUTTER2, 1, NVTEVT_KEY_PRESS); return NVTEVT_CONSUME; } if ((KeyScan_IsUSBPower())&&(!KeyScan_IsHDMIPlugIn())) { Ux_PostEvent(NVTEVT_KEY_SHUTTER2, 1, NVTEVT_KEY_PRESS); return NVTEVT_CONSUME; } //Ux_PostEvent(NVTEVT_KEY_SHUTTER2, 1, NVTEVT_KEY_PRESS); } #if (_GSENSOR_FUNC_ == ENABLE) KeyScan_DetGSensor(); #endif if (SysGetFlag(FL_MOVIE_MOTION_DET) == MOVIE_MOTIONDET_ON) { if((gMovData.State == MOV_ST_VIEW)||(gMovData.State == (MOV_ST_VIEW|MOV_ST_ZOOM))) { UxCtrl_SetShow(&UIFlowWndMovie_PanelMotionRecCtrl,!UxCtrl_IsShow(&UIFlowWndMovie_PanelMotionRecCtrl)); } // Motion Detect function if (g_uiRecordIngMotionDet==TRUE) { static UINT32 uiMotionDetGo = 0; static UINT32 uiMotionDetStop = 0; if (MotionDetection()==TRUE) { uiMotionDetGo++; if (uiMotionDetGo>=2) { uiMotionDetStop=0; if (!((gMovData.State == MOV_ST_REC)||(gMovData.State == (MOV_ST_REC|MOV_ST_ZOOM)))) { // reset uiMotionDetGo uiMotionDetGo = 0; // press enter key to record video Ux_PostEvent(NVTEVT_KEY_ENTER, 1, NVTEVT_KEY_PRESS); } } } else { uiMotionDetStop++; if (uiMotionDetStop>=2) // 1 sec { uiMotionDetGo=0; } if (uiMotionDetStop>=24) // 10 Sec { uiMotionDetStop = 0; switch(gMovData.State) { case MOV_ST_REC: case MOV_ST_REC|MOV_ST_ZOOM: // stop recording if (FlowMovie_GetRecCurrTime() >= 1) { FlowMovie_StopRec(); } break; } } } } } break; case NVTEVT_1SEC_TIMER: FlowMovie_OnTimer1SecIndex(); //UIFlowWndMovie_Update_Speed(); break; } Ux_DefaultEvent(pCtrl,NVTEVT_TIMER,paramNum,paramArray); return NVTEVT_CONSUME; }