教學版程式在下面請打開
#include <iostream> #include <map> #include <string> #include <opencv2/opencv.hpp> using namespace std; using namespace cv; int main() { cout << "使用C++ STL map,類似python的dict:[key],[value]\n"; map<string string=""> f; f["angel"] = "2.png"; f["david"] = "3.png"; f["baby"] = "baby.png"; f.insert(pair<string, string>("dog", "dog.jpg")); f.insert(pair<string, string>("enigma", "general_enigma.png")); map<string, string>::iterator i; for (i = f.begin(); i != f.end(); i++) { cout << i->first << "==>" << i->second << endl; Mat im = imread(i->second); imshow("map", im); waitKey(3000); } destroyAllWindows(); return 0; }
沒有留言:
張貼留言