【BAT】批量測試回合結果

來源:互聯網
上載者:User

經常用到批處理,但還是各種不熟。記錄一些寫的小檔案,以後方便查詢~

組建檔案目錄將檔案(及子檔案下的圖片)寫入list.txt
@echo off&setlocal enabledelayedexpansionfor /r %%i in (*.jpg *.png *.tif) do (echo %%i >>list.txt)pause

測試檔案,統計結果使用test.exe測試list.txt中的檔案,並記錄結果,測試失敗會輸出“decoding failed”

@echo offset /a passed=0set /a all=0del /f /s /q result.txtfor %%p in (*.jpg *.png) do Release\test.exe %%p --more >>list.txtfor /f "delims=" %%i in (result.txt) do ( echo %%iif not "%%i"=="decoding failed" set /a passed=passed+1set /a all=all+1)echo %passed% passed in %all% pictures

test.exe 可以接受幾種選擇性參數:

int main(int argc, char** argv) {  if (argc <= 1) {    cout << "Usage: " << argv[0] << " [OPTION]... <IMAGE>..." << endl         << "Read barcodes from each IMAGE file." << endl         << endl         << "Options:" << endl         << "  (-h|--hybrid)             use the hybrid binarizer (default)" << endl         << "  (-g|--global)             use the global binarizer" << endl         << "  (-v|--verbose)            chattier results printing" << endl         << "  --more                    display more information about the barcode" << endl         << "  --test-mode               compare IMAGEs against text files" << endl         << "  --try-harder              spend more time to try to find a barcode" << endl         << "  --search-multi            search for more than one bar code" << endl         << endl         << "Example usage:" << endl         << "  zxing --test-mode *.jpg" << endl         << endl;    return 1;  }  int total = 0;  int gonly = 0;  int honly = 0;  int both = 0;  int neither = 0;  for (int i = 1; i < argc; i++) {    string filename = argv[i];    if (filename.compare("--verbose") == 0 ||        filename.compare("-v") == 0) {      verbose = true;      continue;    }    if (filename.compare("--hybrid") == 0 ||        filename.compare("-h") == 0) {      use_hybrid = true;      continue;    }    if (filename.compare("--global") == 0 ||        filename.compare("-g") == 0) {      use_global = true;      continue;    }    if (filename.compare("--more") == 0) {      more = true;      continue;    }    if (filename.compare("--test-mode") == 0) {      test_mode = true;      continue;    }    if (filename.compare("--try-harder") == 0) {      try_harder = true;      continue;    }    if (filename.compare("--search-multi") == 0){      search_multi = true;      continue;    }    if (filename.length() > 3 &&        (filename.substr(filename.length() - 3, 3).compare("txt") == 0 ||         filename.substr(filename.length() - 3, 3).compare("bin") == 0)) {      continue;    }    if (!use_global && !use_hybrid) {      use_global = use_hybrid = true;    }    if (test_mode) {      cerr << "Testing: " << filename << endl;    }    Ref<LuminanceSource> source;    try {      source = ImageReaderSource::create(filename);    } catch (const zxing::IllegalArgumentException &e) {      cerr << e.what() << " (ignoring)" << endl;      continue;    }    string expected = read_expected(filename);    int gresult = 1;    int hresult = 1;    if (use_hybrid) {      hresult = read_image(source, true, expected);    }    if (use_global && (verbose || hresult != 0)) {      gresult = read_image(source, false, expected);      if (!verbose && gresult != 0) {        cout << "decoding failed" << endl;      }    }    gresult = gresult == 0;    hresult = hresult == 0;    gonly += gresult && !hresult;    honly += hresult && !gresult;    both += gresult && hresult;    neither += !gresult && !hresult;    total = total + 1;  }  if (test_mode) {    cout << endl         << "Summary:" << endl         << " " << total << " images tested total," << endl         << " " << (honly + both)  << " passed hybrid, " << (gonly + both)         << " passed global, " << both << " pass both, " << endl         << " " << honly << " passed only hybrid, " << gonly         << " passed only global, " << neither << " pass neither." << endl;  }  return 0;}
(轉載請註明作者和出處:http://blog.csdn.net/xiaowei_cqu 未經允許請勿用於商業用途)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.