使用Opencv对摄像头进行录相

VideoCapture video0(0);
	int vh = 480; int vw = 640;
	video0.set(CV_CAP_PROP_FRAME_WIDTH,vw);
	video0.set(CV_CAP_PROP_FRAME_HEIGHT, vh);

	Mat img0;
	namedWindow("video", 0);
	Size vs(static_cast<int>(vw), static_cast<int>(vh));
	
	VideoWriter videowr("test0.avi",CV_FOURCC('M','J','P','G'),25,vs);
	
	if (!videowr.isOpened())
	{
		cout << "初始化VideoWriter失败!" << endl;
		return;
	}
	while (true)
	{
		video0.read(img0);
		imshow("video", img0);
		videowr.write(img0);
		int c = cvWaitKey(5);
		if (c==27)
		{
			break;
		}
		
	}
	destroyWindow("video");
	videowr.release();

Delphi-OpenCV (master) OpenCV version - 2.4.6 Development environment - Delphi XE2-XE4 Contributors: Laentir Valetov email:laex@bk.ru Mikhail Grigorev email: sleuthhound@gmail.com How to install: 1.Download the archive Delphi-OpenCV-master.zip 2.Unzip it to a convenient directory, thus get the following directory structure <Directory, such as 'C:\OpenCV' or just 'C:\' - <PROJECT_ROOT>> <Delphi-OpenCV-master> <bin> <include> <samples> 3.Add the search path for the modules of the project in Delphi IDE (Tools-Options-Delphi Options-Library-Library path) <PROJECT_ROOT>\Delphi-OpenCV-master\Include <PROJECT_ROOT>\Delphi-OpenCV-master\Include\core <PROJECT_ROOT>\Delphi-OpenCV-master\Include\highgui <PROJECT_ROOT>\Delphi-OpenCV-master\Include\imgproc <PROJECT_ROOT>\Delphi-OpenCV-master\Include\legacy <PROJECT_ROOT>\Delphi-OpenCV-master\Include\nonfree <PROJECT_ROOT>\Delphi-OpenCV-master\Include\objdetect <PROJECT_ROOT>\Delphi-OpenCV-master\Include\calib3d <PROJECT_ROOT>\Delphi-OpenCV-master\Include\contrib <PROJECT_ROOT>\Delphi-OpenCV-master\Include\video where <PROJECT_ROOT> directory, which was unzipped project. 4.You can unzip files subdirectory of the project without . Then the directory structure of the project is as follows: <Directory, such as 'C:\OpenCV' - <PROJECT_ROOT>> <bin> <include> <samples> and path <PROJECT_ROOT>\Include <PROJECT_ROOT>\Include\core <PROJECT_ROOT>\Include\highgui <PROJECT_ROOT>\Include\imgproc <PROJECT_ROOT>\Include\legacy <PROJECT_ROOT>\Include\nonfree <PROJECT_ROOT>\Include\objdetect <PROJECT_ROOT>\Include\calib3d <PROJECT_ROOT>\Include\contrib <PROJECT_ROOT>\Include\video 5.Open in Delphi IDE and compile: <PROJECT_ROOT>\samples\LibDemo.groupproj <PROJECT_ROOT>\samples\MultiDemo.groupproj <PROJECT_ROOT>\samples\VCLDemo.groupproj
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值