
求助批處理實(shí)現(xiàn)圖片ocr歸類一堆001.jpg002.jpg003.jpg……我用convert截取頂部 然后ocr識(shí)別導(dǎo)出tmp.txt如果txt有銀行二字,就截取底部指定位置,ocr識(shí)別出數(shù)字保存到tmp2.txt 并將這個(gè)數(shù)字新建文件夾,將被截取的圖片放進(jìn)去。否則,否則就將圖片直接放到上一個(gè)新建的文件夾中。
現(xiàn)在的問題是,就算tmp.txt沒有銀行二字,他也是會(huì)執(zhí)行else 之前的步驟。nclick="copycode($('code0'));">復(fù)制代碼
- @echo off
- Setlocal enabledelayedexpansion
- FOR /D %%a IN (*) DO (
- echo %%~fa
- cd /d %%~fa
- for /r %%i in (*.jpg) do (
- convert.exe -crop 2470x180+20+193 %%i tmp.jpg
- tesseract tmp.jpg tmp -l chi_sim
- findstr /i 銀行 tmp.txt >nul
- if errorlevel 1 (convert -crop 555x80+505+370 %%i tmp2.jpg
- tesseract.exe tmp2.jpg tmp2 -l chi_sim
- ping -n 2 127.0.0.1>nul
- set /P file=<tmp2.txt
- mkdir !file!
- move %%i !file!
- ) else ( set /P file=<tmp2.txt
- move %%i !file!)
- )
- )
- pause

