python图像差分法目标检测_OpenCV实现帧差法检测运动目标

今天的目标是用OpenCV实现对运动目标的检测,这里选用三帧帧差法。代码如下:

#include

#include

#include

#include

#include

double Threshold_index=0;

const int CONTOUR_MAX_AERA = 200;

void trackbar(int pos)

{

Threshold_index=(double)pos;

}

int main(int argc, char* argv[])

{

CvCapture *capture=cvCaptureFromCAM(0);

int n_cnt=0;

IplImage *img=NULL,

*img_gray1=NULL,

*img_gray2=NULL,

*img_gray3=NULL,

*img_diff1=NULL,

*img_diff2=NULL,

*img_diff_and=NULL,

*img_binary=NULL,

*img_dilate=NULL;

CvMemStorage *stor;

CvSeq *cont;

stor=cvCreateMemStorage(0);

cont=cvCreateSeq(CV_SEQ_ELTYPE_POINT,sizeof(CvSeq),sizeof(CvPoint),stor);

cvNamedWindow("t

你可能感兴趣的:(python图像差分法目标检测)