1
A
回答
2
可以变换从笛卡尔图像坐标系极坐标系为OCR程序准备圆形路径文本图像。此功能logPolar()
可以提供帮助。
这里有一些步骤来准备大圆路径文字图片:
- 使用
HoughCircles()
找到圈的中心。 - 获取平均值并做一些抵消,所以得到中心。
- (Optinal)从中心裁剪图像的正方形。
- 执行
logPolar()
,然后根据需要旋转它。
的croped图像:
后logPolar()
和rotate()
我Python3-OpenCV3.3
代码这里提出,也许有帮助。
#!/usr/bin/python3
# 2017.10.10 12:44:37 CST
# 2017.10.10 14:08:57 CST
import cv2
import numpy as np
##(1) Read and resize the original image(too big)
img = cv2.imread("circle.png")
img = cv2.resize(img, (W//4, H//4))
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
## (2) Detect circles
circles = cv2.HoughCircles(gray, method=cv2.HOUGH_GRADIENT, dp=1, minDist=3, circles=None, param1=200, param2=100, minRadius = 200, maxRadius=0)
## make canvas
canvas = img.copy()
## (3) Get the mean of centers and do offset
circles = np.int0(np.array(circles))
x,y,r = 0,0,0
for ptx,pty, radius in circles[0]:
cv2.circle(canvas, (ptx,pty), radius, (0,255,0), 1, 16)
x += ptx
y += pty
r += radius
cnt = len(circles[0])
x = x//cnt
y = y//cnt
r = r//cnt
x+=5
y-=7
## (4) Draw the labels in red
for r in range(100, r, 20):
cv2.circle(canvas, (x,y), r, (0, 0, 255), 3, cv2.LINE_AA)
cv2.circle(canvas, (x,y), 3, (0,0,255), -1)
## (5) Crop the image
dr = r + 20
croped = img[y-dr:y+dr+1, x-dr:x+dr+1].copy()
## (6) logPolar and rotate
polar = cv2.logPolar(croped, (dr,dr),80, cv2.WARP_FILL_OUTLIERS)
rotated = cv2.rotate(polar, cv2.ROTATE_90_COUNTERCLOCKWISE)
## (7) Display the result
cv2.imshow("Canvas", canvas)
cv2.imshow("croped", croped)
cv2.imshow("polar", polar)
cv2.imshow("rotated", rotated)
cv2.waitKey();cv2.destroyAllWindows()
相关问题
- 1. 准备用于OCR的复杂图像
- 2. 图像路径文本框
- 3. 删除图像背景(ID卡)并为OCR做好准备
- 4. Selenium循环通过Ocr过程,直到Captcha图像文本解决
- 5. OCR:图像到文本?
- 6. 循环准备statments
- 7. 运行脚本时for循环准备
- 8. 为iPhone应用程序创建循环路径
- 9. JQuery准备无限循环
- 10. 根据缩略图从路径中循环显示图像
- 11. 如何获得svg的循环路径?
- 12. 如何链接到循环内部的嵌套路径路径?
- 13. 图最短路径无限循环
- 14. 动态图像路径不上设备
- 15. 从图像中提取文本。 OCR
- 16. 如何将文本转换为路径?
- 17. 与jquery循环的图像周围的圆路径
- 18. 循环通过路径列表保存在文本文件
- 19. 如何在asp.net中为java脚本提供图像路径mvc
- 20. 如何在应用程序配置文件中设置图像文件路径?
- 21. 图像路径文件夹
- 22. 图像的文件路径
- 23. 如何在应用程序设置中存储图像路径?
- 24. 如何在我的应用程序中保存图像(路径)?
- 25. 如何在eclipse rcp应用程序中获取图像路径
- 26. CAEmitterLayer - kCAEmitterLayerCircle,循环路径?
- 27. Cocos2d - 拖动图像时遵循路径
- 28. 如何计算定向非循环图的关键路径?
- 29. 如何获得图中最短的循环路径?
- 30. 如何在Android中使用OCR从图像中读取文本
也许你可以旋转图像并一次读一点点? – theGleep