文档角度检测

论文:Image Orientation Estimation with Convolutional Networks 

 

传统Hough transform :

import numpy as np
import cv2
import math
from scipy import ndimage

img_before = cv2.imread('./6ae1.jpg')

cv2.imshow("Before", img_before)    
key = cv2.waitKey(0)

img_gray = cv2.cvtColor(img_before, cv2.COLOR_BGR2GRAY)
img_edges = cv2.Canny(img_gray, 100, 100, apertureSize=3)
lines = cv2.HoughLinesP(img_edges, 1, math.pi / 180.0, 100, minLineLength=100, maxLineGap=5)

angles = []

for x1, y1, x2, y2 in lines[0]:
    cv2.line(img_before, (x1, y1), (x2, y2), (255, 0, 0), 3)
    angle = math.degrees(math.atan2(y2 - y1, x2 - x1))
    angles.append(angle)

median_angle = np.median(angles)
img_rotated = ndimage.rotate(img_before, median_angle)

print ("Angle is {}".format(median_angle))
cv2.imwrite('rotated.jpg', img_rotated) 

论文方法:

传统的使用横线和竖线的检测会引入如上图所示的错误情况。

 

论文使用的训练数据集为Microsoft COCO ,数据增强操作包括,随机变换,对比度变化,高斯噪声。

测试集中去掉一些没有明确方向标注的数据,如下图所示,

论文网络结构使用AlexNet,训练的角度包括±30◦, ±45◦,全部 360◦ ,4角度(0, 90, 180, 270 )这样4种角度分类的模型。

 

实验结果:

 

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值