⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 video.cpp

📁 opencv codes in C++ (linux and eclipse)
💻 CPP
字号:
//opencv C++ code to create a video#include "cv.h" #include "highgui.h" #include<stdio.h>	/* creating video from the image */int main(){  	int key;  	IplImage* img = cvCreateImage(cvSize(500,500), 8, 3);  /*create new image to display line and rectangle*/ 	IplImage* outimg = 0; 	 	CvPoint x1 = cvPoint(250,0); /*coordinates of the line */ 	CvPoint y1 = cvPoint (250,495);  	CvScalar color = CV_RGB(255,255,0);  /*line color */     	cvLine(img, x1,y1,color,20,CV_AA,0); /*line, CV_AA means Anti Aliasing*/     CvVideoWriter *writer = 0; //pointer for out put video		int fps = 20;  	int frameW = 500; 	int frameH = 500; 		writer=cvCreateVideoWriter("output.avi",CV_FOURCC('D','I','V','X'),fps,cvSize(frameW,frameH));       	 	for (int i = 100; i<=300; i++) 	{ 		 		  		 CvPoint a1 = cvPoint(i,350-i); 		 CvPoint b1 = cvPoint (i+100,450-i);  		  		 cvRectangle( img, a1, b1, CV_RGB(204,255,255), CV_FILLED ); 		 cvNamedWindow("Line",1); 		 cvShowImage("Line", img); 		 key = cvWaitKey(2); 		 outimg =cvCloneImage(img); 		 		 cvRectangle( img, a1, b1, CV_RGB(0,0,0), CV_FILLED ); 		 cvLine(img, x1,y1,color,20,CV_AA,0);  		  		 cvWaitKey(100); 		 /*frame */  		 		 cvWriteFrame(writer,outimg);	  		 } 	cvWaitKey(0);  	/* destroy and release image*/ 	cvDestroyWindow( "Line" ); 	 	cvReleaseImage( &img); 	cvReleaseVideoWriter( &writer );/*releasing the Video writer*/ 	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -