摄像头操作实例

摄像头操作实例_第1张图片


 VideoCapture cap(0); //打开默认的0号摄像头
	if (!cap.isOpened())
		return -1;
	Mat edges;
	namedWindow("edges", 1);
	for(;;)
	{
		Mat frame;
		cap >> frame;
		cvtColor(frame, edges, CV_BGR2GRAY);
		GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
		Canny(edges, edges, 0, 30, 3);
		imshow("edges", edges);
		if (waitKey(30) >= 0) break;
	}


你可能感兴趣的:(摄像头操作实例)