本帖最后由 flashercs 于 2024-11-9 17:54 编辑
python有很多库可用.
powershell可以用paddleSharp库.https://github.com/sdcb/PaddleSh ... tation-detection.md- # 指定PaddleSharp.dll的路径
- Add-Type -Path '.\OpenCvSharp.dll', '.\Sdcb.PaddleInference.dll', '.\Sdcb.RotationDetector.dll'
- if (-not $?) { return }
- # 要检测的OCR图片
- $pics = @(
- '.\pics\ocr_test1.png'
- '.\pics\ocr_test2.jpg'
- '.\pics\ocr_test3.jpg'
-
- )
- try {
- $detector = [Sdcb.RotationDetector.PaddleRotationDetector]::new([Sdcb.RotationDetector.RotationDetectionModel]::EmbeddedDefault)
- foreach ($pic in $pics) {
- try {
- $mat = [OpenCvSharp.Cv2]::ImRead($pic)
- $rotationResult = $detector.Run($mat)
- $pic
- $rotationResult.Rotation | Write-Host -ForegroundColor Green
- $null = $rotationResult.RestoreRotationInPlace($mat)
- $null = $mat.SaveImage($pic + '_restore_rotation' + [IO.Path]::GetExtension($pic))
- } finally {
- if ($mat) { $mat.Dispose(); $mat = $null; }
- }
- trap {}
- }
- } finally {
- if ($detector) { $detector.Dispose() }
- }
- trap {}
复制代码
|