1

I wonder what is wrong here?

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);
}

It crashes and gives access violation at vector<Mat> handTemplates; line.

basically, main.cpp is in Z:\Cs585\HW2\draft\hw2-kim\hw2-kim directory and images which I want to open using imread in batch fashion are in the folder inside it named assets.

Any thoughts? enter image description here

enter image description here

Update: However, accessing images one by one works:

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);
Mona Jalal
  • 34,860
  • 64
  • 239
  • 408
  • 1
    Are you using Windows? If that is the case, I think you are taking ATL/MFC String class instead of [std::string](https://stackoverflow.com/a/26536198/501196) or [cv::String](http://docs.opencv.org/trunk/d1/d8f/classcv_1_1String.html) – yms Sep 20 '17 at 03:32
  • so what makes it correct? can you correct it in a line? – Mona Jalal Sep 20 '17 at 03:48
  • 3
    Is `path` right? You only have one backslash before the filename wildcard. – 1201ProgramAlarm Sep 20 '17 at 04:31
  • Odds are `String` is `cv::String`, which should be OK, but it could be colliding with `System::String` if the .Net library's been pulled in. @1201 's on a good path, though. – user4581301 Sep 20 '17 at 04:39
  • I'll try this one and let you know. As far as remember, I also tried cv::String. I know that glob method requires cv::String. – Mona Jalal Sep 20 '17 at 14:28
  • "Ill try this one and let you know" Over a year later, no word from OP. Rip. – Chuck Oct 19 '18 at 18:41

0 Answers0