2017-09-20 291 views
0

我想知道这里有什么问题?0xC0000005:访问冲突读取位置0xFFFFFFFFFFFFFFFF。当使用glob从opencv

String path = "Z:\\Cs585\\HW2\\draft\\hw2-kim\\hw2-kim\\assets\\*.jpg"; 
//String path = "assets\\*.jpg"; 
vector<String> fn; 
glob(path, fn, false); 
vector<Mat> handTemplates; 
for (auto filename : fn){ 
    Mat temp_hand = imread(filename); 
    handTemplates.push_back(temp_hand); 
} 

它崩溃并在vector<Mat> handTemplates;行提供访问冲突。

基本上,main.cpp是在Z:\Cs585\HW2\draft\hw2-kim\hw2-kim目录和图像,我想打开使用imread以批处理方式是在它的文件夹里面名为assets

有什么想法? enter image description here

enter image description here

更新: 然而,访问图像逐一作品:

vector<Mat> handTemplates; 

Mat fist_hand = imread("assets\\fist.jpg"); 
handTemplates.push_back(fist_hand); 

Mat full_hand = imread("assets\\full_hand.jpg"); 
handTemplates.push_back(full_hand); 

Mat thumbs_up_hand = imread("assets\\thumbs_up.jpg"); 
handTemplates.push_back(thumbs_up_hand); 

Mat victory_hand = imread("assets\\victory.jpg"); 
handTemplates.push_back(victory_hand); 
+1

你使用的是Windows吗?如果是这样的话,我认为你正在使用ATL/MFC的String类而不是[std :: string](https://stackoverflow.com/a/26536198/501196)或[cv :: String](http:/ /docs.opencv.org/trunk/d1/d8f/classcv_1_1String.html) – yms

+0

那么是什么让它正确?你能纠正一行吗? –

+3

“路径”正确吗?在文件名通配符之前只有一个反斜杠。 – 1201ProgramAlarm

回答

0

你的代码工作完全正常,我!这是你的代码的完全副本吗?因为这里缺少\assets\*.jpg

+0

哦,不,这是一个错误。我有\\并仍然有相同的错误!我要更新这个问题 –

相关问题