admin
2023-01-02 954ead41d9391bca28a3cc4f9592f73f25b3bbc8
ConsoleApplication/CurrentPriceCapture.cpp
@@ -325,16 +325,33 @@
         int y = wrect.top + 50;
         PostMessage(win, WM_MOUSEWHEEL, 0, MAKEWORD(x, y));
         Sleep(1000);
         cv::Mat oimg = CaptureUtil::capture(win);
         list<CurrentPriceData> codes = capture(oimg,openCLExcuter);
         for (list<CurrentPriceData>::iterator ele = codes.begin();ele != codes.end();ele++) {
            string code = (*ele).code;
            if (codesSet.count(code) == 0&&stof((*ele).price)>0) {
               codesSet.insert(code);
               flist.push_back(*ele);
         int re_try_count = 0;
         while (re_try_count < 3) {
            int invalid_price_count = 0;
            re_try_count++;
            cv::Mat oimg = CaptureUtil::capture(win);
            list<CurrentPriceData> codes = capture(oimg, openCLExcuter);
            for (list<CurrentPriceData>::iterator ele = codes.begin(); ele != codes.end(); ele++) {
               string code = (*ele).code;
               if (codesSet.count(code) == 0 && stof((*ele).price) > 0) {
                  codesSet.insert(code);
                  flist.push_back(*ele);
               }
               else if (stof((*ele).price) <= 0) {
                  // 获取的价格无效
                  invalid_price_count++;
               }
            }
            codes.clear();
            if (invalid_price_count <= 1) {
               // 无效价格代码数量小于1个就退出
               break;
            }
            else {
               Sleep(500);
            }
         }
         codes.clear();
         Sleep(50);
   }
   return flist;