织梦CMS - 轻松建站从此开始!

罗索

opencv,动态目标检测

落鹤生 发布于 2014-08-16 23:48 点击:次 
本文的主要工作包括:在图像预处理阶段,本文采用HSV色彩空间 减轻了目标阴影对目标提取的影响,采用中值滤波器去掉了椒盐噪声,采用图像二值化使图像变的简单,采用图像学去噪中的腐蚀和膨胀分别提取消除图像噪声和填 充图像空洞。
TAG: 目标检测  

可以从静态场景中检测出移动的物体,并对目标进行标记和计数。本文的主要工作包括:在图像预处理阶段,本文采用HSV色彩空间 减轻了目标阴影对目标提取的影响,采用中值滤波器去掉了椒盐噪声,采用图像二值化使图像变的简单,采用图像学去噪中的腐蚀和膨胀分别提取消除图像噪声和填 充图像空洞。在动态目标识别的阶段,采用三帧差分法提取出动态的目标,并用更新运动历史图像的方法来减轻重影现象。最后通过在原图像帧中画矩形框的方式来 标记动态目标的位置,并显示当前运动目标的个数,以及当前帧率、系统运行时间、当前帧数等系统信息。

 gra.h

  1. #ifndef GRA_H_INCLUDED 
  2. #define GRA_H_INCLUDED 
  3.  
  4. #endif // GRA2_H_INCLUDED 
  5. #include <iostream> 
  6. #include <stdio.h> 
  7. #include <stdlib.h> 
  8. #include <string.h> 
  9. #include <assert.h> 
  10. #include <math.h> 
  11. #include <float.h> 
  12. #include <limits.h> 
  13. #include <time.h> 
  14. #include <ctype.h> 
  15. #include <opencv2/opencv.hpp> 
  16.  
  17. using namespace std; 
  18. using namespace cv; 
  19.  
  20.  
  21. //声明函数 
  22. void bgrToGray(IplImage *src,IplImage *dst); 
  23. IplImage* doPyrDown( IplImage* src ); 
  24. IplImage* doPyrUp( IplImage* src ); 
  25. void graAbsDiff(IplImage* src1,IplImage* src2,IplImage* dst); 
  26. void graZero(IplImage* src); 
  27. void graAdd(IplImage* src1,IplImage* src2,IplImage* dst); 
  28.  
  29.  
  30.  
  31. //转化为灰度图,传入三通道的图像,返回单通道的图像 
  32. void bgrToGray(IplImage *src,IplImage *dst) 
  33.  
  34.  
  35.     if(src==NULL) 
  36.     { 
  37.         printf("bgrToGray传入的图像为空"); 
  38.         return
  39.     } 
  40.     int i,j,k,avg; 
  41.     int height,width,step,channels; 
  42.     uchar *data,*dstdata; 
  43.     height=src->height; 
  44.     width=src->width; 
  45.     step=src->widthStep; 
  46.     channels=src->nChannels; 
  47.     data=(uchar*)src->imageData; 
  48.     dstdata=(uchar*)dst->imageData; 
  49.  
  50.  
  51.     for(i=0; i<height; i++) 
  52.     { 
  53.         for(j=0; j<width; j++) 
  54.         { 
  55.             //for(k=0; k<lena->nChannels; k++) 
  56.             // {  
  57.             avg=0.072169*data[ i * step+ j * channels + 1]
  58. +0.715160*data[ i *step+ j * channels + 2]
  59. +0.212671*data[ i *step+ j *channels + 3]; 
  60.             //data[i*lena->widthStep+j*lena->nChannels+k]=
  61. 255-data[ i * lena->widthStep+ j * lena->nChannels + k]; 
  62.             // } 
  63.  
  64.             dstdata[i*dst->widthStep+j]=avg; 
  65.  
  66.         } 
  67.     } 
  68.  
  69.  
  70. IplImage* doPyrDown( IplImage* src ) 
  71.     IplImage* result = cvCreateImage( cvSize( src -> width/2, src -> height/2 )
  72. , src -> depth, src -> nChannels ); 
  73.     //库函数调用cvPyrDown 
  74.     cvPyrDown( src, result, CV_GAUSSIAN_5x5 );  //高斯变换 
  75.  
  76.     return  result; 
  77. IplImage* doPyrUp( IplImage* src ) 
  78.     IplImage* result = cvCreateImage( cvSize( src -> width*2, src -> height*2 )
  79. , src -> depth, src -> nChannels ); 
  80.     cvPyrUp( src, result, CV_GAUSSIAN_5x5 ); 
  81.  
  82.     return result; 
  83.  
  84.  
  85. //两个图像矩阵之差的绝对值 
  86. void graAbsDiff(IplImage* src1,IplImage* src2,IplImage* dst) 
  87.     if(src1==NULL||src2==NULL) 
  88.     { 
  89.         printf("graAbsDiff传入的图像为空"); 
  90.         return
  91.     } 
  92.     int i,j,k; 
  93.     int height,width,step,channels; 
  94.     uchar *dataSrc1,*dataSrc2,*dataDst; 
  95.     height=src1->height; 
  96.     width=src1->width; 
  97.     step=src1->widthStep; 
  98.     channels=src1->nChannels; 
  99.     dataSrc1=(uchar*)src1->imageData; 
  100.     dataSrc2=(uchar*)src2->imageData; 
  101.     dataDst=(uchar*)dst->imageData; 
  102.     // dstdata=(uchar*)dst->imageData; 
  103.     //printf("\ngraZero(IplImage* src): 将要清零的图像通道为%d",channels); 
  104.  
  105.     for(i=0; i<height; i++) 
  106.     { 
  107.         for(j=0; j<width; j++) 
  108.         { 
  109.             for(k=0; k<channels; k++) 
  110.             { 
  111. dataDst[i*step+j*channels+k]=abs(dataSrc1[i*step+j*channels+k]
  112. -dataSrc2[i*step+j*channels+k]); 
  113.             } 
  114.         } 
  115.     } 
  116.  
  117. //清零矩阵值 
  118. void graZero(IplImage* src) 
  119.     if(src==NULL) 
  120.     { 
  121.         printf("graZero传入的图像为空"); 
  122.         return
  123.     } 
  124.     int i,j,k; 
  125.     int height,width,step,channels; 
  126.     uchar *data,*dstdata; 
  127.     height=src->height; 
  128.     width=src->width; 
  129.     step=src->widthStep; 
  130.     channels=src->nChannels; 
  131.     data=(uchar*)src->imageData; 
  132.     // dstdata=(uchar*)dst->imageData; 
  133.     //printf("\ngraZero(IplImage* src): 将要清零的图像通道为%d",channels); 
  134.  
  135.     for(i=0; i<height; i++) 
  136.     { 
  137.         for(j=0; j<width; j++) 
  138.         { 
  139.             for(k=0; k<channels; k++) 
  140.             { 
  141.                 data[i*step+j*channels+k]=0; 
  142.             } 
  143.         } 
  144.     } 
  145.  
  146. //计算两个数组的元素级的和 
  147. void graAdd(IplImage* src1,IplImage* src2,IplImage* dst) 
  148.     if(src1==NULL||src2==NULL) 
  149.     { 
  150.         printf("graAbsDiff传入的图像为空"); 
  151.         return
  152.     } 
  153.     int i,j,k; 
  154.     int height,width,step,channels; 
  155.     uchar *dataSrc1,*dataSrc2,*dataDst; 
  156.     height=src1->height; 
  157.     width=src1->width; 
  158.     step=src1->widthStep; 
  159.     channels=src1->nChannels; 
  160.     dataSrc1=(uchar*)src1->imageData; 
  161.     dataSrc2=(uchar*)src2->imageData; 
  162.     dataDst=(uchar*)dst->imageData; 
  163.     // dstdata=(uchar*)dst->imageData; 
  164.     //printf("\ngraZero(IplImage* src): 将要清零的图像通道为%d",channels); 
  165.  
  166.     for(i=0; i<height; i++) 
  167.     { 
  168.         for(j=0; j<width; j++) 
  169.         { 
  170.             for(k=0; k<channels; k++) 
  171.             { 
  172. dataDst[i*step+j*channels+k]=abs(dataSrc1[i*step+j*channels+k]
  173. +dataSrc2[i*step+j*channels+k]); 
  174.             } 
  175.         } 
  176.     } 
  177.  
  178.  
  179. //二值化处理 
  180. void graThreshold(IplImage* src1,IplImage* dst,double threshold,double max_value) 
  181.     if(src1==NULL) 
  182.     { 
  183.         printf("\ngraThreshold没有传入图像"); 
  184.         return ; 
  185.     } 
  186.     int i,j,k; 
  187.     int height,width,step,channels; 
  188.     uchar *dataSrc1,*dataDst; 
  189.     height=src1->height; 
  190.     width=src1->width; 
  191.     step=src1->widthStep; 
  192.     channels=src1->nChannels; 
  193.     if(channels!=1) 
  194.     { 
  195.         printf("将要把彩色图像二值化"); 
  196.         bgrToGray(src1,dst); 
  197.     } 
  198.     dataSrc1=(uchar*)src1->imageData; 
  199.     dataDst=(uchar*)dst->imageData; 
  200.     // dstdata=(uchar*)dst->imageData; 
  201.     //printf("\ngraZero(IplImage* src): 将要清零的图像通道为%d",channels); 
  202.  
  203.     for(i=0; i<height; i++) 
  204.     { 
  205.         for(j=0; j<width; j++) 
  206.         { 
  207.  
  208.             if(dataSrc1[i*step+j]>threshold) 
  209.             { 
  210.                 dataDst[i*step+j]=max_value; 
  211.             } 
  212.             else 
  213.             { 
  214.                 dataDst[i*step+j]=0; 
  215.             } 
  216.         } 
  217.     } 
  218.  
  219. //中值滤波 
  220. bool graFilterMid(IplImage* &image,int k) 
  221.     if(image==NULL) 
  222.     { 
  223.         printf("\nFilterMid没有传入图像"); 
  224.         return false
  225.     } 
  226.     uchar *ImagePix=(uchar *)image->imageData; 
  227.     int m=(k-1)/2; 
  228.     for(int x=m; x<image->height-m; ++x) 
  229.     { 
  230.         for(int y=m; y<image->width-m; ++y) 
  231.         { 
  232.             uchar PixArray[100]; 
  233.             int t=0; 
  234.             for(int i=-m; i<m+1; ++i) 
  235.             { 
  236.                 for(int j=-m; j<m+1; j++) 
  237.                 { 
  238. PixArray[t++]=((uchar *)image->imageData)[(x+i)*image->widthStep+y+j]; 
  239.                 } 
  240.             } 
  241.  
  242.  
  243.             //冒泡排序 
  244.             for(int i=0; i<k*k-1; ++i) 
  245.                 for(int j=0; j<k*k-i-1; ++j) 
  246.                 { 
  247.                     if(PixArray[j]>PixArray[j+1]) 
  248.                     { 
  249.                         uchar k=PixArray[j]; 
  250.                         PixArray[j]=PixArray[j+1]; 
  251.                         PixArray[j+1]=k; 
  252.                     } 
  253.                 } 
  254.             ImagePix[x*image->widthStep+y]=PixArray[(k*k-1)/2]; 
  255.         } 
  256.     } 
  257.     return true
  258. void saturate_SV(IplImage* image) 
  259.     for(int y = 0; y < image -> height; ++y) 
  260.     { 
  261.         //ptr指针指向第y行的起始位置 
  262.         uchar* ptr=(uchar*)( 
  263. image -> imageData + y * image->widthStep);//(字节类型指针:uchar*) 
  264.         //改变S和V在x维的值 
  265.         for(int x = 0; x < image -> width; ++x) 
  266.         { 
  267.             //ptr[3 * x + 0] =180; 
  268.             //ptr[3 * x + 1] =0; 
  269.             ptr[3 * x + 2] =255; 
  270.         } 
  271.     } 

main.cpp

  1. #include "gra.h" 
  2.  
  3. using namespace cv; 
  4. using namespace std; 
  5.  
  6. // various tracking parameters (in seconds) 
  7. const double MHI_DURATION = 0.5; 
  8. const double MAX_TIME_DELTA = 0.5; 
  9. const double MIN_TIME_DELTA = 0.05; 
  10. const int N = 3; 
  11. int num=0; 
  12.  
  13. //设置当目标区域的面积大于某个值时才画矩形框 
  14. const int CONTOUR_MAX_AERA = 1600; 
  15.  
  16. // ring pFrame buffer 
  17. IplImage **buf = 0; 
  18. int last = 0; 
  19.  
  20. // 临时图像 
  21. IplImage *mhi = 0; // MHI: motion history image 
  22.  
  23. int filter = CV_GAUSSIAN_5x5; 
  24.  
  25. CvPoint pt[4]; 
  26.  
  27.  
  28. int main(int argc, char** argv) 
  29.     printf("程序开始,按ESC可以退出程序"); 
  30.     IplImage *pFrame = NULL; 
  31.     IplImage *pFrame1 = NULL; 
  32.  
  33.     int inMonitor=0; 
  34.     int num=0; 
  35.     float fps; 
  36.     char str[5]; 
  37.     double t = 0; 
  38.     int countsInMonitor=0; 
  39.     double runT=clock(); 
  40.     char runTime[10]; 
  41.     double runT2; 
  42.     char* str3; 
  43.     int seconds=0; 
  44.     IplImage* motion = 0; 
  45.     CvCapture* pCapture = 0; 
  46.  
  47.     int width,height; 
  48.  
  49.     if(argc>2) 
  50.     { 
  51.         fprintf(stderr, "Usage: bkgrd [video_file_name]\n"); 
  52.         return -1; 
  53.     } 
  54.     //如果没有传入参数,则读取摄像头 
  55.     if (argc ==1) 
  56.     { 
  57.         if( !(pCapture = cvCaptureFromCAM(-1))) 
  58.         { 
  59.             fprintf(stderr, "Can not open camera.\n"); 
  60.             return -2; 
  61.         } 
  62.     } 
  63.  
  64.     //打开视频文件 
  65.     if(argc == 2) 
  66.         if( !(pCapture = cvCaptureFromFile(argv[1]))) 
  67.         { 
  68.             fprintf(stderr, "Can not open video file %s\n", argv[1]); 
  69.             return -2; 
  70.         } 
  71.  
  72.  
  73.     if( pCapture ) 
  74.     { 
  75.  
  76.  
  77.         pFrame=cvQueryFrame( pCapture ); 
  78.         IplImage *silh1,*silh2,*silh; 
  79.         pFrame1 = cvCreateImage( cvSize(pFrame->width,pFrame->height), 8, 3 ); 
  80.         width=pFrame->width; 
  81.         height=pFrame->height; 
  82.  
  83.         //标记监控区域 
  84.         CvPoint pt1_Rect; 
  85.         CvPoint pt2_Rect; 
  86.         CvPoint pt3_Rect; 
  87.         CvPoint pt4_Rect; 
  88.         pt1_Rect.x=(1.0/5)*width; 
  89.         pt1_Rect.y=0; 
  90.         pt2_Rect.x=(1.0/5)*width; 
  91.         pt2_Rect.y=pFrame->height; 
  92.         pt3_Rect.x=(4.0/5)*width; 
  93.         pt3_Rect.y=0; 
  94.         pt4_Rect.x=(4.0/5)*width; 
  95.         pt4_Rect.y=pFrame->height; 
  96.         int thickness=1; 
  97.         int line_type=8; 
  98.         CvScalar color=CV_RGB(100,100,100); 
  99.         //设定监控区域 
  100.         CvRect ROI_rect; 
  101.         ROI_rect.x=pt1_Rect.x; 
  102.         ROI_rect.y=pt1_Rect.y; 
  103.         ROI_rect.width=pt3_Rect.x-pt1_Rect.x; 
  104.         ROI_rect.height=pt2_Rect.y-pt1_Rect.y; 
  105.         //有东西进入监控区域是输入的信息 
  106.         char warnings[20]; 
  107.  
  108.  
  109.  
  110.         silh1 = cvCreateImage( cvSize(pFrame->width,pFrame->height), 8, 1 ); 
  111.         silh2 = cvCreateImage( cvSize(pFrame->width,pFrame->height), 8, 1 ); 
  112.         silh = cvCreateImage( cvSize(pFrame->width,pFrame->height), 8, 1 ); 
  113.         cvNamedWindow("Motion",CV_WINDOW_AUTOSIZE); 
  114.         cvMoveWindow("Motion",100,100); 
  115.         for(;;) 
  116.         { 
  117.             t = (double)getTickCount(); 
  118.             num++; 
  119.  
  120.             if( !cvGrabFrame( pCapture )) 
  121.                 break
  122.             pFrame = cvRetrieveFrame( pCapture ); 
  123.  
  124.             if( pFrame ) 
  125.             { 
  126.                 if( !motion ) 
  127.                 { 
  128. motion = cvCreateImage( cvSize(pFrame->width,pFrame->height), 8, 1 ); 
  129. cvZero( motion ); 
  130. motion->origin = pFrame->origin; 
  131.                 } 
  132.             } 
  133.  
  134. //update_mhi( image, motion); 
  135. //clock()返回处理器调用某个进程或函数所花费的时间。 
  136.  
  137. double timestamp = clock()/100.; // get current time in seconds 
  138. CvSize size = cvSize(pFrame->width,pFrame->height); // get current frame size 
  139.             int i, j, idx1, idx2,idx3; 
  140.  
  141.             uchar val; 
  142.             float temp; 
  143.             IplImage* pyr = cvCreateImage(cvSize((size.width & -2)/2
  144. , (size.height & -2)/2), 8, 1 ); 
  145.             CvMemStorage *stor; 
  146.             CvSeq *cont, *result, *squares; 
  147.             CvSeqReader reader; 
  148.  
  149.             //如果mhi的值为空。创建mhi,buf。第一次进入循环时运行 
  150.             if( !mhi || mhi->width != size.width || mhi->height != size.height ) 
  151.             { 
  152.                 if( buf == 0 ) 
  153.                 { 
  154.                     buf = (IplImage**)malloc(N*sizeof(buf[0])); 
  155.                     memset( buf, 0, N*sizeof(buf[0])); 
  156.                 } 
  157.  
  158.                 for( i = 0; i < N; i++ ) 
  159.                 { 
  160.                     cvReleaseImage( &buf[i] ); 
  161.                     buf[i] = cvCreateImage(size, IPL_DEPTH_8U, 1 ); 
  162.                     printf("sd"); 
  163.                     cvZero( buf[i] ); 
  164.                 } 
  165.                 cvReleaseImage( &mhi ); 
  166.                 mhi = cvCreateImage( size, IPL_DEPTH_32F, 1 ); 
  167.                 cvZero( mhi ); // clear MHI at the beginning 
  168.             } // end of if(mhi) 
  169.  
  170.             cvCvtColor(pFrame,pFrame1,CV_BGR2HSV); 
  171.             saturate_SV(pFrame1); 
  172.             cvCvtColor(pFrame1,pFrame1,CV_HSV2BGR); 
  173.             //cvCvtColor( pFrame, buf[last], CV_BGR2GRAY ); // convert frame to grayscale 
  174.             bgrToGray( pFrame1, buf[last]); 
  175.             idx1 = last; 
  176.             idx2 = (last + 1) % N; // index of (last - (N-1))th frame 
  177.             idx3=(idx2+1)%N; 
  178.             last = idx3; 
  179.             cvShowImage("asda",pFrame1); 
  180.             // 做帧差 
  181. //cvShowImage("asd",buf[idx1]); 
  182.  
  183. graAbsDiff( buf[idx1], buf[idx2], silh1 ); // get difference between frames 
  184. graAbsDiff( buf[idx2], buf[idx3], silh2 ); // get difference between frames 
  185. graAdd(silh1,silh2,silh); 
  186.             cvShowImage("aaaa",silh); 
  187.             // 对差图像做二值化 
  188.             graThreshold( silh, silh, 50, 255); // and threshold it 
  189.  
  190.             //去掉影像(silhouette) 以更新运动历史图像 
  191. cvUpdateMotionHistory( silh, mhi, timestamp, MHI_DURATION ); // update MHI 
  192.  
  193.             // convert MHI to blue 8u image 
  194.             //线性变换数组,把MHI变为8位的图像 
  195.             cvCvtScale( mhi, motion, 255./MHI_DURATION, 
  196.                         (MHI_DURATION - timestamp)*255./MHI_DURATION ); 
  197.  
  198.  
  199.             // 中值滤波,消除小的噪声 
  200.             graFilterMid(motion,3); 
  201.             // cvShowImage("中值滤波之后",motion); 
  202.             // 向下采样,去掉噪声 
  203.             //cvPyrDown( motion, pyr, 7 ); 
  204.             pyr=doPyrDown(motion); 
  205.             cvDilate( pyr, pyr, 0, 1 );  // 做膨胀操作,消除目标的不连续空洞 
  206.             //cvPyrUp( pyr, motion, 7 ); 
  207.             motion=doPyrUp(pyr); 
  208.  
  209.  
  210.             cvSetImageROI(motion,ROI_rect); 
  211.             // 
  212.             // 下面的程序段用来找到轮廓 
  213.             // 
  214.             // Create dynamic structure and sequence. 
  215.             stor = cvCreateMemStorage(0); 
  216. cont = cvCreateSeq(CV_SEQ_ELTYPE_POINT, sizeof(CvSeq), sizeof(CvPoint) , stor); 
  217.  
  218.             // 找到所有轮廓 
  219.             cvFindContours( motion, stor, &cont, sizeof(CvContour), 
  220. CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0)); 
  221.             /* 
  222.                 for(;cont;cont = cont->h_next) 
  223.                 { 
  224. // Number point must be more than or equal to 6 (for cvFitEllipse_32f). 
  225. if( cont->total < 6 ) 
  226. continue; 
  227.  
  228. // Draw current contour. 
  229. cvDrawContours(image,cont,CV_RGB(255,0,0),CV_RGB(255,0,0),0,1, 8, cvPoint(0,0)); 
  230. }  // end of for-loop: "cont" 
  231.             */ 
  232.  
  233.             cvResetImageROI(motion); 
  234.             cvSetImageROI(pFrame,ROI_rect); 
  235.             // 直接使用CONTOUR中的矩形来画轮廓 
  236.             countsInMonitor=0; 
  237.             for(; cont; cont = cont->h_next) 
  238.             { 
  239.                 CvRect r = ((CvContour*)cont)->rect; 
  240.                 if(r.height * r.width > CONTOUR_MAX_AERA) // 面积小的方形抛弃掉 
  241.                 { 
  242.                     cvRectangle( pFrame, cvPoint(r.x,r.y), 
  243.                                  cvPoint(r.x + r.width, r.y + r.height), 
  244.                                  CV_RGB(255,0,0), 1, CV_AA,0); 
  245.                     inMonitor=1; 
  246.                     countsInMonitor++; 
  247.                 } 
  248.  
  249.             } 
  250.  
  251.             // free memory 
  252.             cvReleaseMemStorage(&stor); 
  253.             cvReleaseImage( &pyr ); 
  254.  
  255.             cvResetImageROI(pFrame); 
  256.             //用来显示当前第几帧 
  257.             CvFont font; 
  258.             cvInitFont( &font, CV_FONT_HERSHEY_SIMPLEX,0.5, 0.5, 0, 1, 1); 
  259.  
  260.  
  261.             //显示fps 
  262.             t = ((double)cvGetTickCount() - t) / getTickFrequency(); 
  263.             fps = 1.00 / t; 
  264.             //sprintf(str, "%5f", fps); 
  265.             sprintf(str,"fps: %.1f",fps); 
  266. //addTail(str," f/s "); 
  267. //putText(pFrame, str, Point(0,30), FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0,0,255)); 
  268. cvPutText(pFrame, str , cvPoint(20,pFrame->height-20), &font, CV_RGB(255,0,0)); 
  269.  
  270.             //显示运行时间 
  271.             runT2=clock(); 
  272.             seconds=(int)runT2/1000; 
  273.             sprintf(runTime,"time: %ds",seconds); 
  274. cvPutText(pFrame, runTime, cvPoint(100,pFrame->height-20), &font, CV_RGB(255,0,0)); 
  275.  
  276.             char texta[10]; 
  277.             //把int型num转化为字符串 
  278.             sprintf(texta,"%dth frame",num); 
  279.             //addTail(texta," frame"); 
  280. cvPutText(pFrame, texta , cvPoint(200,pFrame->height-20), &font, CV_RGB(255,0,0)); 
  281.  
  282.             //如果有人进入则提醒 
  283.             if(inMonitor==1) 
  284.             { 
  285. sprintf(warnings,"%d in monitor area",countsInMonitor); 
  286. cvPutText(pFrame, warnings , cvPoint(0.25*width,height-60), &font, CV_RGB(255,0,0)); 
  287.             } 
  288.  
  289.             //标记监控区域 
  290.             cvLine( pFrame, pt1_Rect, pt2_Rect,color ,thickness, line_type, 0 ); 
  291.             cvLine( pFrame, pt3_Rect, pt4_Rect,color ,thickness, line_type, 0 ); 
  292.  
  293.             cvShowImage( "Motion", pFrame ); 
  294.             inMonitor=0; 
  295.             if( cvWaitKey(10) >= 0 ) 
  296.                 break
  297.         } 
  298.         cvReleaseCapture( &pCapture ); 
  299.         cvDestroyWindow( "Motion" ); 
  300.         printf("\n程序结束,一共运行了%d s",seconds); 
  301.     } 
  302.  
  303.     return 0; 

 

(lawdong)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201408/17029.html]
本文出处:博客园 作者:lawdong 原文
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容