打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
OpenCV读取图片路径的几种写法

比如用 imread() 读取这个文件夹下的test.jpg


可以有下面几种方法


#include<iostream>
#include<string.h>
#include<math.h>
#include<vector>
#include<opencv2/opencv.hpp>
#include<opencv2/highgui.hpp>
#include <opencv2/highgui/highgui_c.h>  

using namespace cv;

int main(int argc, char* argv[])
{
Mat img;

//-- 1 --双右斜线法  
//string imgpath = "D:\\Study\\Picture\\test2.jpg";  
//-- 2 --双左斜线法  
//string imgpath = "D://Study//Picture//test2.jpg";  
//-- 3 --单左斜线法  
//string imgpath = "D:/Study/Picture/test2.jpg";  
//-- 4 --以上三种混合法  
//string imgpath = "D: /Study//Picture\\test2.jpg";  
//-- 5 --相对路径法  把图片放在本文件的当前目录下
//string imgpath = "test2.jpg";  
//-- 6 --命令行参数法  
string imgpath = argv[1];

img = imread(imgpath, 1);
imshow("img", img);

waitKey(0);
return 0;
}

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
OpenCV读图函数imread的书写姿势
OpenCV Demo
OpenCV探索之路(二):图像处理的基础知识点串烧
在VS2008下安装openCV
OpenCV4Android开发之旅(三)
windows下安装opencv
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服