1 #include
2 #include
3 #include //时间函数头
4 #include "opencv.hpp"
5
6 /**7 * A program to detect motion in front of an USB camera using OpenCV.8 **/
9
10 int main(int argc, char **argv) {11 int detectThreshold = 19; //运动检测预设值(时间)
12 if (argc >= 2) { //判断参数是否充足判断
13 detectThreshold = atoi(argv[1]);14 printf("=== Motion detection threshold has been set to: [%d] ===\n", detectThreshold);15 }16
17 /*init 摄影机*/
18 CvCapture* pCapture = cvCreateCameraCapture(0);19 if (NULL ==pCapture) {20 fprintf(stderr, "Can't initialize webcam!\n");21 return 1;22 }23 cvSetCaptureProperty(pCapture, CV_CAP_PROP_FRAME_WIDTH, 640);24 cvSetCaptureProperty(pCapture, CV_CAP_PROP_FRAME_HEIGHT, 480);25 cvSetCaptureProperty(pCapture, CV_CAP_PROP_BRIGHTNESS, 20);26 cvSetCaptureProperty(pCapture, CV_CAP_PROP