opencv显示图像的路径
绝对路径:
Mat image = imread(“D:\appdata\005.png”); //读入图像的绝对路径
Mat image = imread(“D:\\appdata\\005.png”); //读入图像的绝对路径
或者 //Mat image = imread(“D:/appdata/005.png”); //读入图像的绝对路径
相关代码
//opencv显示图片
#include "stdafx.h"
#include <opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat image = imread("D:\\appdata\\005.png"); //读入图像的绝对路径(方式1)
//Mat image = imread("D:/appdata/005.png"); //读入图像的绝对路径 (方式2)
//Mat image = imread("005.png"); //读入图像的相对路径
imshow("005", image); //显示图片
waitKey(0);
return 0;
}
运行结果
相对路径:
要把图片存储在工程文件路径下:
相关代码
//opencv显示图片
#include "stdafx.h"
#include <opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
//Mat image = imread("D:\\appdata\\005.png"); //读入图像的绝对路径
//Mat image = imread("D:/appdata/005.png"); //读入图像的绝对路径
Mat image = imread("005.png"); //读入图像的相对路径
imshow("005", image); //显示图片
waitKey(0);
return 0;
}
运行结果