I want to use PowerShell and Programs that come with windows 7 to do OCR, in this code, I miss a wrong, objImage is null, I can`t know why
$imagePath = "F:\image.png"
Test-Path -Path "F:\image.png"
Start-Service -Name "stisvc"
$objOCR = New-Object -ComObject Wia.ImageFile
$objImage = $objOCR.LoadFile($imagePath)
if ($objImage -ne $null) {
$ocrResult = $objImage.OCR()
if ($ocrResult.Text -ne $null) {
Write-Host "Result:"
Write-Host $ocrResult.Text
}
else {
Write-Host "OCR Wasted。"
}
}
else {
Write-Host "Can not load Image"
}
check path is true
I try to start WIA in Line 3, and check path, and Check WIA's dependencies,I expect to solve this question or find a new way to do OCR by using no rely on third-party libraries