opencv4.1.1(2)视频格式转换并显示

本例程功能捕获本地摄像头图像,转换格式并显示。

#include
#include
#include
#include

using namespace cv;
using namespace std;


void main(int argc, char** argv)
{
	VideoCapture mVideoCap(0);
	Mat capMat;
	Mat gray, HSV, YUV, Lab, img32;

	while (1)
	{
		mVideoCap.read(capMat);
		if (!capMat.empty())
		{
			capMat.convertTo(img32,CV_32F,1.0/255);
			cvtColor(img32,HSV,COLOR_BGR2HSV);
			cvtColor(img32, YUV, COLOR_BGR2YUV);
			cvtColor(img32, Lab, COLOR_BGR2Lab);
			cvtColor(img32, gray, COLOR_BGR2GRAY);

			imshow("img32", img32);
			imshow("HSV", HSV);
			imshow("YUV", YUV);
			imshow("Lab", Lab);
			imshow("gray", gray);
			waitKey(1);
		}
	}
	
	return ;
}

你可能感兴趣的:(图像识别,opencv,计算机视觉,人工智能)