简体   繁体   中英

let user input image destination through console OpenCV c++

I have tried several ways to implement a way to let user input the file destination of a imagefile, so it can be loaded in a Mat . I cant figure out how to do it. I am learning OpenCV through their guides, but i cant find any information about how to load an image through console.

This is the code i have so far, but its not working..

Mat src
string path;
cout << "Load nyt billede" << endl<<"Fildist(Hele filstien): ";

cin >> path;
src=imread(path, CV_LOAD_IMAGE_GRAYSCALE);

imwrite("test", src);
system("pause");

cin >>将停止在空格处解析,请使用std::getline()代替:

std::getline(std::cin, path);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM