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显示图像的路径

相对路径:
要把图片存储在工程文件路径下:
opencv显示图像的路径

相关代码

//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;
}

运行结果
opencv显示图像的路径

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2021-04-21
  • 2021-05-19
猜你喜欢
  • 2021-09-07
  • 2021-10-11
  • 2022-12-23
  • 2022-12-23
  • 2021-06-24
  • 2021-11-02
  • 2022-12-23
相关资源
相似解决方案