嗨,我正在尝试为图像比较软件制作 GUI。这个想法是用 OPENFILENAME 选择一张图片,然后用 ofn.lpstrFile 获取它的地址,然后为该图片制作一个直方图。所以我使用:
return(ofn.lpstrFile);
我可以计算地址或将其写入 .xml 文件并且地址是正确的,但是当我尝试制作直方图时,它给了我全零。表现得像地址无效。
有任何想法吗 ?
我的代码:
string path=browse(); //getting the string from ofn.lpstrFile
path.c_str();
replace(path.begin(), path.end(), '\\', '/'); //converting backslash to slash also may be the problem
HistCreation(path,root_dir);
和
void HistCreation(string path,string root_dir) {
Mat img;
img = imread(path); // here if i manually enter the address everything works fine, if I insert the path then loads empty image
.
.
.
我也试过
char * cstr = new char[path.length() + 1];
std::strcpy(cstr, path.c_str());
也没有工作