From 1a1948a1759cdf4bd62c09e0d1fb6bdea09652e3 Mon Sep 17 00:00:00 2001 From: Jayn <694728662@qq.com> Date: Sat, 14 Nov 2015 11:54:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=94=E8=B5=9B=E4=BB=85=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=BA=A4=E9=80=9A=E7=81=AF=E6=A3=80=E6=B5=8B=EF=BC=8C=E6=94=BE?= =?UTF-8?q?=E5=BC=83=E6=A0=87=E5=BF=97=E7=89=8C=E6=A3=80=E6=B5=8B=E8=AF=86?= =?UTF-8?q?=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 保存比赛视频 --- Main_TrafficSignRecognition.cpp | 35 +++++++++++++++++++-------------- traffic.h | 4 ++-- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Main_TrafficSignRecognition.cpp b/Main_TrafficSignRecognition.cpp index b812a5f..6a3ad0b 100644 --- a/Main_TrafficSignRecognition.cpp +++ b/Main_TrafficSignRecognition.cpp @@ -576,8 +576,8 @@ int main() RectBlueSVM.load("src//RectBlueTSR.xml"); } - openMP_MultiThreadVideo(); - //openMP_MultiThreadCamera(); + //openMP_MultiThreadVideo(); + openMP_MultiThreadCamera(); cvReleaseMat(&g_mat); system("pause"); } @@ -778,7 +778,11 @@ void openMP_MultiThreadCamera() Drogonfly_ImgRead p; p.Camera_Intial(); #if IS_SAVE - CvVideoWriter *writer = cvCreateVideoWriter("cameraCapture6.avi",CV_FOURCC('X','V','I','D'),10,Size(800,600),1); + SYSTEMTIME stTime; + GetLocalTime(&stTime); + char *videoPath = new char[100];// "D:/123.dat"; + sprintf(videoPath, "CamraVideo//Video_%04d%02d%02d%02d%02d%02d.avi", stTime.wYear, stTime.wMonth, stTime.wDay, stTime.wHour, stTime.wMinute, stTime.wSecond); + CvVideoWriter *writer = cvCreateVideoWriter(videoPath,CV_FOURCC('X','V','I','D'),10,Size(800,600),1); #endif IplImage * src_frame,*copyFrame; @@ -789,17 +793,18 @@ void openMP_MultiThreadCamera() src_frame=p.Camera2IplImage(); float TSRSend[5]={0,0,0,0,0};//store the traffic signs recognition result float TLDSend[3]={0,0,0};//store the traffic lights detection result - IplImage* frame=cvCreateImage(Size(800,600),src_frame->depth,src_frame->nChannels); + //IplImage* frame=cvCreateImage(Size(800,600),src_frame->depth,src_frame->nChannels); int start=cvGetTickCount(); - if(!frame)break; + if(!src_frame)break; //MultiThread #if ISDEBUG_TL cvNamedWindow("imgseg"); #endif //copyFrame=cvCloneImage(frame); - copyFrame=cvCreateImage(Size(frame->width,frame->height),frame->depth,frame->nChannels); - cvResize(src_frame,frame); - cvCopy(frame,copyFrame); + copyFrame=cvCreateImage(Size(800,600),src_frame->depth,src_frame->nChannels); + //cvResize(src_frame,frame); + //cvCopy(frame,copyFrame); + cvResize(src_frame,copyFrame); #if OPENMP #pragma omp parallel sections @@ -817,7 +822,7 @@ void openMP_MultiThreadCamera() } } #else - TSRecognitionPerFrame(frame,TSRSend); + //TSRecognitionPerFrame(frame,TSRSend); TLDetectionPerFrame(copyFrame,TLDSend); #endif @@ -827,15 +832,15 @@ void openMP_MultiThreadCamera() cvShowImage("TL",resize_TLR); cvWaitKey(5); //show the detection result of TSR - namedWindow("TSR"); - imshow("TSR",re_src); - waitKey(5); + //namedWindow("TSR"); + //imshow("TSR",re_src); + //waitKey(5); #endif - + #if IS_SAVE - cvWriteFrame(writer,frame); + cvWriteFrame(writer,copyFrame); #endif - cvReleaseImage(&frame); + //cvReleaseImage(&frame); cvReleaseImage(©Frame); //get the union result for (int i=0;i<5;i++) diff --git a/traffic.h b/traffic.h index 36b22df..ca64601 100644 --- a/traffic.h +++ b/traffic.h @@ -7,8 +7,8 @@ #include #include -#define IS_SAVE 0 //ͷɼϢǷ񱣴 -#define OPENMP 1//ǷʹOPENMPд +#define IS_SAVE 1 //ͷɼϢǷ񱣴 +#define OPENMP 0//ǷʹOPENMPд #define ISDEBUG_TL 0//ʱмͼϢ(Traffic Light) #define ISDEBUG_TS 0//ʱмͼϢ(Traffic Sign) #define IS_SHOW_RESULT 1//Ƿʾ,ʾͼٶȸ