Giter Site home page Giter Site logo

camark / answer-sheet-scan Goto Github PK

View Code? Open in Web Editor NEW

This project forked from inuyasha2012/answer-sheet-scan

0.0 0.0 0.0 3.23 MB

answersheet scan or recognition by computer camera 电脑摄像头识别答题卡,可能是最灵活准确率最高的摄像头答题卡扫描开源实现

License: MIT License

Python 100.00%

answer-sheet-scan's Introduction

电脑摄像头扫描答题卡

可能是最灵活准确率最高的摄像头答题卡扫描开源实现

主要参考

应用场景

答题卡铺在桌子上,椅子上,键盘上(如测试图片),豆腐上等等随便你,然后拿起摄像头对着答题卡。。。,识别单选答题卡效率最高!

市面上开源代码主要缺点

  • 代码里面都有选项距离等等相关硬参数,从而导致摄像头扫描或照片识别效率低下
  • 答题卡太简单,易于识别,但是实际使用中不可能有如此简单的答题卡,比如用HoughCircle检测圆形选项框,选项一多,直接坑爹
  • 答题卡太复杂,在答题卡上加了一堆定位图形,比如答题卡是3列20排,定位图形足足有23个,累死编制答题卡的人

所以,answer-sheet-scan基本上是市面上答题卡识别准确率最高的开源代码

整个流程如下,详细请看代码注释

  • 打开摄像头扫描答题卡,看,是这个挫样

  • 把这个比较挫的图片进行二值化腐蚀膨胀边缘检测,变成了这样,还是很挫

  • 计算轮廓,并且看最大轮廓是否具有4个顶点,如果有的话,就OK了

  • 纠偏,把斜的图片变正,看上去终于不挫了

  • 调整图片的亮度,方便二值化

  • 通过二值化膨胀腐蚀再二值化,获得涂写的区域

  • 通过二值化膨胀腐蚀,获得所有的选项框加题号区域

  • 依据面积大小和其他条件提取合适的轮廓,与涂写区域重叠

  • 依据轮廓左上角坐标从上而下排序轮廓,若1排有3题,每题4个选项,则认为前5个轮廓是第1题,其中第1个轮廓是题号,第6-10个轮廓是第2题,其中第6个轮廓是题号

  • 根据提取的轮廓的左上角坐标和长宽,计算轮廓区域内的白点个数,白点个数低于某个阈值,初步认为是选择了该选项

其他

其他细节(例如选项框轮廓个数检测)详见代码以及注释

如何使用

  • 安装opencv2
  • 安装imutils
  • 运行请 $ python main.py
  • 测试请 $ python tests/test_sheet.py

answer-sheet-scan's People

Contributors

inuyasha2012 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.