cv::String class usage examples - OpenCV 문자열 클래스 사용 예제
OpenCV 2019. 7. 13. 17:12 |반응형
Below code shows how to use cv::String class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <opencv2/opencv.hpp> using namespace std; using namespace cv; int main(int argc, char** argv) { const char* str = "Open Source Computer Vision"; String str1("Hello World"); String str2(str, str+11); String str3 = "Software Engineer"; cout << "str1: " << str1 << endl << "str2: " << str2 << endl << "str3: " << str3 << endl << endl; cout << "*str1.begin(): " << *str1.begin() << endl; cout << "str1[1]: " << str1[1] << endl; cout << "*(str1.end()-1): " << *(str1.end()-1) << endl << endl; cout << "str2.size(): " << str2.size() << endl; cout << "str2.length(): " << str2.length() << endl; cout << "str2.empty(): " << str2.empty() << endl; cout << "str3.find(\"ng\"): " << str3.find("ng") << endl << endl; cout << "format(\"%s %d\", str3.c_str(), 100): " << format("%s %d", str3.c_str(), 100) << endl; cout << "str3.toLowerCase(): " << str3.toLowerCase() << endl; cout << "str3.substr(2, 4): " << str3.substr(2, 4) << endl << endl; str1.swap(str3); cout << "str1.swap(str3)" << endl; cout << "- str1: " << str1 << endl << "- str3: " << str3 << endl; str1.clear(); cout << "str1.clear()" << endl; cout << "- str1: " << endl; return 0; } | cs |
반응형