2017-09-20 28 views
0

ここで何が間違っているのだろうか?0xC0000005:0xFFFFFFFFFFFFFFFFの場所を読み取るアクセス違反。 OpenCVからglobを使用する場合

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.cppZ:\Cs585\HW2\draft\hw2-kim\hw2-kimディレクトリにあり、imreadをバッチ方式で開きたい画像は、assetsというフォルダ内にあります。

どのような考えですか? enter image description here

enter image description here

更新: ただし、アクセスした画像1作品ずつ:

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を使用していますか?その場合、[std :: string](https://stackoverflow.com/a/26536198/501196)または[cv :: String](http://)の代わりにATL/MFC Stringクラスを使用していると思います。 /docs.opencv.org/trunk/d1/d8f/classcv_1_1String.html) – yms

+0

それで何が正しいのですか?それをラインで修正できますか? –

+3

'path'は正しいですか?ファイル名のワイルドカードの前にバックスラッシュが1つだけあります。 – 1201ProgramAlarm

答えて

0

あなたのコードは私のために完全に正常に動作しています!これはあなたのコードの正確なコピーですか?ここには\がありませんので、assets\*.jpgがあります。

+0

ああ、それは間違いだった。私は\\と同じエラーがまだあります!私は質問を更新するつもりです –

関連する問題