通过字符串读取图片路径

#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
    char path[90];
    string r = "F:";
    string l = r+"/left/a/Left" + to_string(static_cast<long long>(1)) + ".bmp";
    int d = 1;
    sprintf(path, "F:\left\a\Left%d.bmp", d);
    Mat I = imread(l);
    Mat m = imread(path);
    imshow("d", I);
    imshow("w",m);
    waitKey(0);
}
原文地址:https://www.cnblogs.com/hsy1941/p/8024396.html