├── imgs
├── gcs.jpg
├── example01
│ ├── 02.jpg
│ ├── 03.jpg
│ ├── 04.jpg
│ ├── 05.jpg
│ ├── 06.jpg
│ ├── 07.jpg
│ └── t1.png
└── example02
│ ├── 01.jpg
│ ├── 02.jpg
│ ├── 03.jpg
│ ├── 04.jpg
│ ├── 05.jpg
│ ├── 06.jpg
│ ├── 07.jpg
│ └── test6.jpg
├── README.md
├── readmes
├── example02.md
└── example01.md
├── sheet_scan_example02.py
├── sheet_scan_example01.py
└── LICENSE
/imgs/gcs.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/gcs.jpg
--------------------------------------------------------------------------------
/imgs/example01/02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example01/02.jpg
--------------------------------------------------------------------------------
/imgs/example01/03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example01/03.jpg
--------------------------------------------------------------------------------
/imgs/example01/04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example01/04.jpg
--------------------------------------------------------------------------------
/imgs/example01/05.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example01/05.jpg
--------------------------------------------------------------------------------
/imgs/example01/06.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example01/06.jpg
--------------------------------------------------------------------------------
/imgs/example01/07.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example01/07.jpg
--------------------------------------------------------------------------------
/imgs/example01/t1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example01/t1.png
--------------------------------------------------------------------------------
/imgs/example02/01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example02/01.jpg
--------------------------------------------------------------------------------
/imgs/example02/02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example02/02.jpg
--------------------------------------------------------------------------------
/imgs/example02/03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example02/03.jpg
--------------------------------------------------------------------------------
/imgs/example02/04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example02/04.jpg
--------------------------------------------------------------------------------
/imgs/example02/05.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example02/05.jpg
--------------------------------------------------------------------------------
/imgs/example02/06.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example02/06.jpg
--------------------------------------------------------------------------------
/imgs/example02/07.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example02/07.jpg
--------------------------------------------------------------------------------
/imgs/example02/test6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qindongliang/answer_sheet_scan/HEAD/imgs/example02/test6.jpg
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # answer_sheet_scan
2 | 使用python3+opencv3实现的一些识别答题卡的例子
3 |
4 | 由于工作需要,最近在研究关于如何通过程序识别答题卡的客观题的答案,之前虽然接触过python,但对于计算机视觉这一块却完全是一个陌生的领域,经过各种调研,发现网上大多数的例子都是采用的OpenCV这个开源库来做的,OpenCV是计算机视觉领域的处理的一个非常优秀的开源库,原生由C++编写,也提供了各个主流编程语言的接口支持,这里选择python完全是因为python在计算机科学领域有着压倒性的优势和生态系统,所以使用它毫无疑问,最快上手的方式莫过于直接阅读网上已有的例子或者轮子了,通过阅读源码以问题驱动的方式来学习和研究某一项技术是比较高效的一种方式。
5 |
6 | ## 答题卡识别例子
7 |
8 | [01案例-点我查看详细介绍](https://github.com/qindongliang/answer_sheet_scan/blob/master/readmes/example01.md)
9 |
10 | [02案例-点我查看详细介绍](https://github.com/qindongliang/answer_sheet_scan/blob/master/readmes/example02.md)
11 |
12 |
13 |
14 |
15 |
16 | ## 博客相关
17 |
18 | (1)[微信公众号(woshigcs):同步更新](https://github.com/qindongliang/answer_sheet_scan/blob/master/imgs/gcs.jpg)
19 |
20 | (2)[个人站点(2018之后,同步更新)](http://8090nixi.com/)
21 |
22 | (3)[腾讯云社区,自动同步公众号文章]()
23 |
24 | (4)[csdn : (暂时同步更新)](https://blog.csdn.net/u010454030)
25 |
26 | (5)[iteye(2018.05月之前所有的文章,之后弃用)]()
27 |
28 |
29 |
30 |
31 |
32 |
33 | ## 我的公众号(woshigcs)
34 |
35 | 有问题可关注我的公众号留言咨询
36 |
37 | 
38 |
39 |
40 |
--------------------------------------------------------------------------------
/readmes/example02.md:
--------------------------------------------------------------------------------
1 | # answer_sheet_scan
2 | 使用python3+opencv3实现的一些识别答题卡的例子
3 |
4 | ## 识别例子02
5 |
6 | 例子02是[ayoungprogrammer](http://blog.ayoungprogrammer.com/2013/03/tutorial-creating-multiple-choice.html/)博客上参考作者原版C++代码和思路,然后改造成python版本的,先在本地运行成功之后,然后加上自己的理解,给大多数核心代码加上了详细的中文注释,并在每一个关键阶段都会弹出具体的窗体展示识别流程,这样便于大家更能详细的看到核心部分的细节,感兴趣的同学,可以自己在再尝试加一些更细部分的debug弹窗。
7 |
8 | 本地PyCharm运行后一些截图:
9 |
10 | (1)原图
11 |
12 | 
13 |
14 |
15 | (2)灰度后的图
16 |
17 | 
18 |
19 |
20 | (3)自适应二值化后的图
21 |
22 | 
23 |
24 |
25 | (4)标记轮廓后的原图
26 |
27 | 
28 |
29 |
30 | (5)提取答题内容区后的图
31 |
32 | 
33 |
34 |
35 | (6)对答题内容区进行自适应二值化后的图
36 |
37 | 
38 |
39 |
40 | (7)标记答案后的图
41 |
42 | 
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/readmes/example01.md:
--------------------------------------------------------------------------------
1 | # answer_sheet_scan
2 | 使用python3+opencv3实现的一些识别答题卡的例子
3 |
4 | ## 识别例子01
5 |
6 | 例子01是参考:[pyimagesearch](https://www.pyimagesearch.com/2016/10/03/bubble-sheet-multiple-choice-scanner-and-test-grader-using-omr-python-and-opencv/)网站上一个识别例子,参考作者的源码,先在本地运行成功之后,然后加上自己的理解,给大多数核心代码加上了详细的中文注释,并在每一个关键阶段都会弹出具体的窗体展示识别流程,这样便于大家更能详细的看到核心部分的细节,感兴趣的同学,可以自己在再尝试加一些更细部分的debug弹窗。
7 |
8 | 例子01的在我本地PyCharm运行后一些截图:
9 |
10 | (1)原图
11 |
12 | 
13 |
14 |
15 | (2)灰度+高斯模糊后的图
16 |
17 | 
18 |
19 |
20 | (3)使用边缘检测后的图
21 |
22 | 
23 |
24 |
25 | (4)透视变换后提取指定答题区域的灰度图
26 |
27 | 
28 |
29 |
30 | (5)使用ostu的二值化后的图
31 |
32 | 
33 |
34 |
35 | (6)识别答案成功后的图
36 |
37 | 
38 |
39 |
40 | (7)标记出做对和做错的图并计算得分
41 |
42 | 
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/sheet_scan_example02.py:
--------------------------------------------------------------------------------
1 | # -*- coding:utf-8 -*-
2 | import matplotlib.pyplot as plt
3 | from imutils.perspective import four_point_transform
4 | from imutils import contours
5 | import numpy as np
6 | import imutils
7 |
8 | import cv2 as cv
9 |
10 | # 加载原图,可在项目imgs/example02目录下找到
11 | img=cv.imread("E:\\tmp\\test6.jpg")
12 |
13 | # 打印原图
14 | cv.imshow("orgin",img)
15 |
16 | # 灰度化
17 | gray=cv.cvtColor(img,cv.COLOR_BGR2GRAY)
18 |
19 | # 打印灰度图
20 | cv.imshow("gray",gray)
21 |
22 | # 高斯滤波,清除一些杂点
23 | blur=cv.GaussianBlur(gray,(3,3),0)
24 |
25 | # 自适应二值化算法
26 | thresh2 = cv.adaptiveThreshold(blur,255,cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY_INV,131,4)
27 |
28 | # 打印二值化后的图
29 | cv.imshow("thresh2",thresh2)
30 |
31 | # 寻找轮廓
32 | image, cts, hierarchy = cv.findContours(thresh2, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
33 |
34 | # 打印找到的轮廓
35 | print("轮廓数:",len(cts))
36 |
37 | # 对拷贝的原图进行轮廓标记
38 | contour_flagged=cv.drawContours(img.copy(), cts, -1, (0, 0, 255), 3)
39 | # 打印轮廓图
40 | cv.imshow("contours_flagged", contour_flagged)
41 | # 按像素面积降序排序
42 | list = sorted(cts, key=cv.contourArea, reverse=True)
43 |
44 | # 遍历轮廓
45 | for ct in list:
46 | # 周长,第1个参数是轮廓,第二个参数代表是否是闭环的图形
47 | peri = 0.01 * cv.arcLength(ct, True)
48 | # 获取多边形的所有定点,如果是四个定点,就代表是矩形
49 | approx = cv.approxPolyDP(ct, peri, True)
50 | # 只考虑矩形
51 | if len(approx) == 4:
52 |
53 |
54 |
55 |
56 |
57 | # 从原图中提取所需的矫正图片
58 | ox = four_point_transform(img, approx.reshape(4, 2))
59 | # 从原图中提取所需的矫正图片
60 | tx = four_point_transform(gray, approx.reshape(4, 2))
61 |
62 | # 打印矫正后的灰度图
63 | cv.imshow("tx",tx)
64 |
65 | # 对矫正图进行高斯模糊
66 | blur = cv.GaussianBlur(tx, (3, 3), 0)
67 |
68 | # 对矫正图做自适应二值化
69 | thresh2 = cv.adaptiveThreshold(blur, 255, cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY_INV, 131, 4)
70 |
71 | # 打印矫正后的二值化图
72 | cv.imshow("tx_thresh2", thresh2)
73 |
74 | # 获取轮廓
75 | r_image, r_cts, r_hierarchy = cv.findContours(thresh2, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
76 |
77 | # 打印得到轮廓数量
78 | print("第二层轮廓数:", len(r_cts))
79 |
80 | # 用于存储答案的python list变量
81 | question_list=[]
82 | for r_ct in r_cts :
83 | # 转为矩形,分别获取 x,y坐标,及矩形的宽和高
84 | x, y, w, h = cv.boundingRect(r_ct)
85 |
86 | # 过滤掉不符合答案坐标和长宽的选项
87 | if x>2 and y>2 and w>20 and h>20 :
88 | # cv.drawContours(ox, r_ct, -1, (0, 0, 255), 1)
89 | question_list.append(r_ct)
90 |
91 | print("答案总数:",len(question_list))
92 |
93 | # 按坐标从上到下排序
94 | questionCnts = contours.sort_contours(question_list, method="top-to-bottom")[0]
95 |
96 | # 使用np函数,按5个元素,生成一个集合
97 | for (q, i) in enumerate(np.arange(0, len(questionCnts), 5)):
98 |
99 | # 每一个行5个答案,从左到右排序
100 | cnts = contours.sort_contours(questionCnts[i:i + 5])[0]
101 |
102 | # 存储一行题里面的每个答案
103 | ans_list = []
104 | for (j, cc) in enumerate(cnts):
105 |
106 | # 生成全黑画布
107 | mask = np.zeros(thresh2.shape, dtype="uint8")
108 | # 将每一个答案按轮廓写上去,并将填充颜色设置成白色
109 | tpp = cv.drawContours(mask, [cc], -1, 255, -1)
110 | # 两个图片做位运算
111 | mask = cv.bitwise_and(thresh2, thresh2, mask=mask)
112 | # 统计每个答案的像素
113 | total = cv.countNonZero(mask)
114 |
115 | # 添加到集合里面
116 | ans_list.append( (total,j) )
117 |
118 | # 按像素大小排序
119 | ans_list=sorted(ans_list,key=lambda x:x[0],reverse=True)
120 |
121 | max_ans_num=ans_list[0][1]
122 | max_ans_size=ans_list[0][0]
123 | print("答案序号:",max_ans_num,"列表:",ans_list)
124 |
125 | # 给选中答案,标记成红色
126 | cv.drawContours(ox, cnts[max_ans_num], -1, (0, 0, 255), 2)
127 |
128 |
129 |
130 |
131 | cv.imshow("answer_flagged", ox)
132 |
133 |
134 | # 最大的轮廓就是我们想要的,之后的就可以结束循环了
135 | break
136 |
137 |
138 |
139 | # 阻塞等待窗体关闭
140 | cv.waitKey(0)
141 |
142 |
143 |
--------------------------------------------------------------------------------
/sheet_scan_example01.py:
--------------------------------------------------------------------------------
1 | # -*- coding:utf-8 -*-
2 | from imutils.perspective import four_point_transform
3 | from imutils import contours
4 | import numpy as np
5 | import imutils
6 | import cv2 as cv
7 |
8 |
9 | ANSWER_KEY_SCORE = {0: 1, 1: 4, 2: 0, 3: 3, 4: 1}
10 |
11 |
12 | ANSWER_KEY = {0: "A", 1: "B", 2: "C", 3: "D", 4: "E"}
13 |
14 | # 加载一个图片到opencv中
15 | img = cv.imread('E:\\tmp\\t1.png')
16 |
17 | cv.imshow("orgin",img)
18 |
19 | #转化成灰度图片
20 | gray=cv.cvtColor(img,cv.COLOR_BGR2GRAY)
21 |
22 | cv.imshow("gray",gray)
23 |
24 | gaussian_bulr = cv.GaussianBlur(gray, (5, 5), 0) # 高斯模糊
25 |
26 | cv.imshow("gaussian",gaussian_bulr)
27 |
28 |
29 | edged=cv.Canny(gaussian_bulr,75,200) # 边缘检测,灰度值小于2参这个值的会被丢弃,大于3参这个值会被当成边缘,在中间的部分,自动检测
30 |
31 | cv.imshow("edged",edged)
32 |
33 | # 寻找轮廓
34 | image, cts, hierarchy = cv.findContours( edged.copy(), cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
35 |
36 | # 给轮廓加标记,便于我们在原图里面观察,注意必须是原图才能画出红色,灰度图是没有颜色的
37 | # cv.drawContours(img, cts, -1, (0,0,255), 3)
38 |
39 | # 按面积大小对所有的轮廓排序
40 | list=sorted(cts,key=cv.contourArea,reverse=True)
41 |
42 | print("寻找轮廓的个数:",len(cts))
43 | cv.imshow("draw_contours",img)
44 |
45 | # 正确题的个数
46 | correct_count=0
47 |
48 | for c in list:
49 | # 周长,第1个参数是轮廓,第二个参数代表是否是闭环的图形
50 | peri=0.01*cv.arcLength(c,True)
51 | # 获取多边形的所有定点,如果是四个定点,就代表是矩形
52 | approx=cv.approxPolyDP(c,peri,True)
53 | # 打印定点个数
54 | print("顶点个数:",len(approx))
55 |
56 | if len(approx)==4: #矩形
57 | # 透视变换提取原图内容部分
58 | ox_sheet = four_point_transform(img, approx.reshape(4, 2))
59 | # 透视变换提取灰度图内容部分
60 | tx_sheet = four_point_transform(gray, approx.reshape(4, 2))
61 |
62 | cv.imshow("ox", ox_sheet)
63 | cv.imshow("tx", tx_sheet)
64 | # 使用ostu二值化算法对灰度图做一个二值化处理
65 | ret,thresh2 = cv.threshold(tx_sheet, 0, 255,cv.THRESH_BINARY_INV | cv.THRESH_OTSU)
66 | cv.imshow("ostu", thresh2)
67 |
68 | # 继续寻找轮廓
69 | r_image, r_cnt, r_hierarchy = cv.findContours(thresh2.copy(), cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
70 |
71 | print("找到轮廓个数:",len(r_cnt))
72 |
73 | # 使用红色标记所有的轮廓
74 | # cv.drawContours(ox_sheet,r_cnt,-1,(0,0,255),2)
75 |
76 | # 把所有找到的轮廓,给标记出来
77 |
78 | questionCnts = []
79 | for cxx in r_cnt:
80 | # 通过矩形,标记每一个指定的轮廓
81 | x, y, w, h = cv.boundingRect(cxx)
82 | ar = w / float(h)
83 |
84 |
85 | if w >= 20 and h >= 20 and ar >= 0.9 and ar <= 1.1:
86 | # 使用红色标记,满足指定条件的图形
87 | # cv.rectangle(ox_sheet, (x, y), (x + w, y + h), (0, 0, 255), 2)
88 | # 把每个选项,保存下来
89 | questionCnts.append(cxx)
90 |
91 | cv.imshow("ox_1", ox_sheet)
92 | # 按坐标从上到下排序
93 | questionCnts = contours.sort_contours(questionCnts, method="top-to-bottom")[0]
94 |
95 | # 使用np函数,按5个元素,生成一个集合
96 | for (q, i) in enumerate(np.arange(0, len(questionCnts), 5)):
97 |
98 | # 获取按从左到右的排序后的5个元素
99 | cnts = contours.sort_contours(questionCnts[i:i + 5])[0]
100 |
101 | bubble_rows=[]
102 |
103 | # 遍历每一个选项
104 | for (j, c) in enumerate(cnts):
105 |
106 | # 生成一个大小与透视图一样的全黑背景图布
107 | mask = np.zeros(tx_sheet.shape, dtype="uint8")
108 | # 将指定的轮廓+白色的填充写到画板上,255代表亮度值,亮度=255的时候,颜色是白色,等于0的时候是黑色
109 | cv.drawContours(mask, [c], -1, 255, -1)
110 | # 做两个图片做位运算,把每个选项独自显示到画布上,为了统计非0像素值使用,这部分像素最大的其实就是答案
111 | mask = cv.bitwise_and(thresh2, thresh2, mask=mask)
112 | # cv.imshow("c" + str(i), mask)
113 | # 获取每个答案的像素值
114 | total = cv.countNonZero(mask)
115 | # 存到一个数组里面,tuple里面的参数分别是,像素大小和答案的序号值
116 | # print(total,j)
117 | bubble_rows.append((total,j))
118 |
119 |
120 |
121 | bubble_rows=sorted(bubble_rows,key=lambda x: x[0],reverse=True)
122 | # 选择的答案序号
123 | choice_num=bubble_rows[0][1]
124 | print("答案:{} 数据: {}".format(ANSWER_KEY.get(choice_num),bubble_rows))
125 |
126 |
127 | fill_color=None
128 |
129 | # 如果做对就加1
130 | if ANSWER_KEY_SCORE.get(q) == choice_num:
131 | fill_color = (0, 255, 0) #正确 绿色
132 | correct_count = correct_count+1
133 | else:
134 | fill_color = (0, 0, 255) #错误 红色
135 |
136 | cv.drawContours(ox_sheet, cnts[choice_num], -1, fill_color, 2)
137 |
138 |
139 |
140 | cv.imshow("answer_flagged", ox_sheet)
141 |
142 | text1 = "total: " + str(len(ANSWER_KEY)) + ""
143 |
144 | text2 = "right: " + str(correct_count)
145 |
146 | text3 = "score: " + str(correct_count*1.0/len(ANSWER_KEY)*100)+""
147 |
148 | font = cv.FONT_HERSHEY_SIMPLEX
149 | cv.putText(ox_sheet, text1 + " " + text2+" "+text3, (10, 30), font, 0.5, (0, 0, 255), 2)
150 |
151 | cv.imshow("score", ox_sheet)
152 |
153 | break
154 |
155 |
156 |
157 |
158 | cv.waitKey(0)
159 |
160 |
161 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------