当前位置:   article > 正文

答题卡识别

答题卡识别

 © Fu Xianjun. All Rights Reserved

分别进行预处理,轮廓检测轮廓排序,透视变换寻找圆圈轮廓输出每个轮廓,对比答案

  1. import cv2
  2. import numpy as np
  3. def cv_show(name,img):
  4. cv2.imshow(name,img)
  5. cv2.waitKey(0)
  6. cv2.destroyAllWindows()
  7. def order_points(pts):
  8. rect = np.zeros((4,2),dtype = "float32")#初始化同样大小的图像变量
  9. s = pts.sum(axis=1)#根据y坐标,提取参数
  10. rect[0] = pts[np.argmin(s)]
  11. rect[2] = pts[np.argmax(s)]
  12. d = np.diff(pts,axis=1)
  13. rect[1] = pts[np.argmin(d)]
  14. rect[3] = pts[np.argmax(d)]
  15. return rect
  16. def four_point_transform(img,pts):
  17. rect = order_points(pts)
  18. (tl,tr,br,bl) = rect
  19. widthA = np.sqrt((br[0]-bl[0])**2+(br[1]-bl[1])**2)
  20. w
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/812044
推荐阅读
相关标签
  

闽ICP备14008679号