【BAT】批量测试运行结果
来源:互联网 发布:价格监控软件开发 编辑:程序博客网 时间:2024/05/22 06:52
目录(?)[+]
经常用到批处理,但还是各种不熟。记录一些写的小文件,以后方便查询~
生成文件目录
将文件(及子文件下的图片)写入list.txt
- @echo off&setlocal enabledelayedexpansion
- for /r %%i in (*.jpg *.png *.tif) do (
- echo %%i >>list.txt
- )
- pause
测试文件,统计结果
使用test.exe测试list.txt中的文件,并记录结果,测试失败会输出“decoding failed”
- @echo off
- set /a passed=0
- set /a all=0
- del /f /s /q result.txt
- for %%p in (*.jpg *.png) do Release\test.exe %%p --more >>list.txt
- for /f "delims=" %%i in (result.txt) do (
- echo %%i
- if not "%%i"=="decoding failed" set /a passed=passed+1
- set /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 未经允许请勿用于商业用途)
- 【BAT】批量测试运行结果
- 【BAT】批量测试运行结果
- bat+sqlcmd 批量运行脚本
- 运行maven下的settings.bat文件的结果
- bat批量运行脚本-文件移动-复制-环境变量修改
- MyBatis批量大数据测试的一些结果
- 【matlab】关于批量随机生成数据和批量保存运行结果
- bat批量修改后缀名
- bat批量解压文件
- bat批量重命名文件
- bat批量编译demo
- bat 实现批量备份文件
- bat 批量重命名
- 利用 NUnit 类库运行单元测试并获取测试结果
- 运行结果
- Bat批量处理文件教程
- 批量改文件名的bat
- android 批量安装卸载bat
- Winsock之WinInet
- 【数据结构】图
- _stdcall与_cdecl的区别(函数调用方式)
- CentOS下安装JDK7
- 一个数组中除了两个数字之外,其余数字都出现了两次,找出这两个数字
- 【BAT】批量测试运行结果
- 项目三
- string模块2 - maketrans()
- VMware虚拟机NAT模式的具体配置
- 讲解关于centos配置apache+php安装
- double类型保留两位小数
- 单链表操作 written by myself
- hdu 4558 剑侠情缘
- Eclipse配置PyDev插件