【OpenCV3经典编程100例】(01)载入、显示和保存图像

载入图像imread()、显示图像imshow()、保存图像imwrite().

一、C++示例代码

包含头文件,命名空间,标配三句话

//包含头文件
#include <opencv2/opencv.hpp>
//命名空间
using namespace cv;
using namespace std;

开源代码

//包含头文件
#include <opencv2/opencv.hpp>
//命名空间
using namespace cv;
using namespace std;
//主函数
int main()
{
	//【1】载入图像
	Mat image = imread("F:\\opencvtest\\testImage\\beauty.png");
	//【2】显示图像
	imshow("示例01", image);
	//【3】保存图像
	imwrite("F:\\opencvtest\\resultImage\\beauty.png", image);

	waitKey(0);
	return 0;
}

运行截图




猜你喜欢

转载自blog.csdn.net/misterjiajia/article/details/80273783