| 1021 | } |
| 1022 | |
| 1023 | long ImageSearchAlgorithms::FindStrEx(std::map<point_t, ocr_rec_t> &ps, const vector<wstring> &vstr, |
| 1024 | std::wstring &retstr) { |
| 1025 | // 描述:查找屏幕指定位置的字符(或者字符串)位置,返回所有出现的坐标(注意与FindStr接口的区别)!!! |
| 1026 | //----------------------步骤----------------- |
| 1027 | // step 1. 获取指定位置的字符及坐标信息 |
| 1028 | // step 2. 拼接字符,形成完整字符串 str |
| 1029 | // step 2.对每个目标字符 ti , 查找其在str中的位置,并记录 index(如果存在) |
| 1030 | // step 4.根据index ,获取其坐标,并将坐标转化为字符串,拼接到返回值 |
| 1031 | // step 5. 回到第3步 |
| 1032 | |
| 1033 | retstr.clear(); |
| 1034 | |
| 1035 | std::vector<ocr_text_span_t> spans; |
| 1036 | const std::wstring str = build_ocr_text_spans(ps, spans); |
| 1037 | |
| 1038 | int find_ct = 0; |
| 1039 | for (size_t i = 0; i < vstr.size(); ++i) { |
| 1040 | if (vstr[i].empty()) |
| 1041 | continue; |
| 1042 | |
| 1043 | size_t search_from = 0; |
| 1044 | do { |
| 1045 | const size_t index = str.find(vstr[i], search_from); |
| 1046 | if (index == std::wstring::npos) |
| 1047 | break; |
| 1048 | |
| 1049 | const ocr_text_span_t *span = find_ocr_text_span(spans, index); |
| 1050 | if (span != nullptr) { |
| 1051 | retstr += std::to_wstring(i); |
| 1052 | retstr += L","; |
| 1053 | retstr += std::to_wstring(span->point.x + _x1 + _dx); |
| 1054 | retstr += L","; |
| 1055 | retstr += std::to_wstring(span->point.y + _y1 + _dy); |
| 1056 | retstr += L"|"; |
| 1057 | ++find_ct; |
| 1058 | if (find_ct > _max_return_obj_ct) |
| 1059 | goto _quick_return; |
| 1060 | } |
| 1061 | |
| 1062 | search_from = index + 1; |
| 1063 | } while (1); |
| 1064 | } |
| 1065 | _quick_return: |
| 1066 | if (!retstr.empty() && retstr.back() == L'|') |
| 1067 | retstr.pop_back(); |
| 1068 | return find_ct; |
| 1069 | } |
| 1070 | |
| 1071 | long ImageSearchAlgorithms::FindLine(std::wstring &outStr) { |
| 1072 | outStr.clear(); |
nothing calls this directly
no test coverage detected