-
Notifications
You must be signed in to change notification settings - Fork 0
/
dual.html
327 lines (262 loc) · 31.8 KB
/
dual.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello OpenCV.js</title>
</head>
<body>
<h2>Hello OpenCV.js</h2>
<p id="status">OpenCV.js is loading...</p>
<div>
<div class="inputoutput">
<img id="imageSrc" alt="No Image" />
<div class="caption">imageSrc
<input type="file" id="fileInput" name="file" />
</div>
</div>
<div class="inputoutput">
<canvas id="canvasOutput" ></canvas>
<div class="caption">canvasOutput</div>
</div>
</div>
<div>
<h1 id="e1"> Is that good? </h1>
<button type="button" id="e2">Yes</button>
<button type="button" id="e3">No</button>
<h1 id="e4">Perfect, Enjoy!</h1>
</div>
<div>
<div class="inputoutput">
<canvas id="srcInput" ></canvas>
<div class="caption">srcInput</div>
</div>
<div class="inputoutput">
<canvas id="cropOutput" ></canvas>
<div class="caption">cropOutput</div>
</div>
</div>
<script type="text/javascript">
var annotationJSON = getAnnotation();
var e1 = document.getElementById('e1');
var e2 = document.getElementById('e2');
var e3 = document.getElementById('e3');
var e4 = document.getElementById('e4');
e1.style.visibility = "hidden";
e2.style.visibility = "hidden";
e3.style.visibility = "hidden";
e4.style.visibility = "hidden";
let imgElement = document.getElementById('imageSrc');
let inputElement = document.getElementById('fileInput');
inputElement.addEventListener('change', (e) => {
imgElement.src = URL.createObjectURL(e.target.files[0]);
}, false);
imgElement.onload = function() {
let dstFinal = new cv.Mat();
let finalSize = new cv.Size(1700, 3800);
dstFinal = auto();
e1.style.visibility = "visible";
e2.style.visibility = "visible";
e3.style.visibility = "visible";
e3.addEventListener("click", function() {
dstFinal = manual();
//featureExtractDetect(dstFinal, finalSize) moved to crop(); to account for delay
});
e2.addEventListener("click",
function() {
e4.style.visibility = "visible";
featureExtractDetect(dstFinal, finalSize);
});
};
function auto() {
let src = cv.imread(imgElement);
let dst = new cv.Mat();
let dstt = new cv.Mat();
let ksize = new cv.Size(5,5);
cv.cvtColor(src, dst, cv.COLOR_RGBA2GRAY);
cv.Canny(dst, dst, 75, 200, 3, false);
cv.threshold(dst, dst, 50, 255, cv.THRESH_BINARY);
let contours = new cv.MatVector();
let hierarchy = new cv.Mat();
cv.findContours(dst, contours, hierarchy, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE);
// for (let i = 0; i < contours.size(); ++i) {
// let color = new cv.Scalar(240, 248, 255);
// cv.drawContours(dst, contours, i, color, 5, cv.LINE_8, hierarchy, 100);
// }
let areaarr = [];
for (let i = 0; i < contours.size(); i++) {
areaarr.push(cv.arcLength(contours.get(i), false))
}
areaarr.sort(function(a, b){return a-b});
areaarr.reverse();
newarr = areaarr.slice(0,1);
//console.log(areaarr)
for (let i = 0; i < contours.size(); i++) {
let color = new cv.Scalar(240, 248, 255);
let area = cv.arcLength(contours.get(i), false);
if (newarr.includes(area)) {
realContour = contours.get(i);
//console.log(area)
cv.drawContours(dst, contours, i, color, 5, cv.LINE_8, hierarchy, 100);
}
}
contPeri = cv.arcLength(realContour, true)
contApprox = new cv.Mat();
cv.approxPolyDP(realContour, contApprox, 0.02 * contPeri, true)
let corner1 = new cv.Point(contApprox.data32S[0], contApprox.data32S[1]);
let corner2 = new cv.Point(contApprox.data32S[2], contApprox.data32S[3]);
let corner3 = new cv.Point(contApprox.data32S[4], contApprox.data32S[5]);
let corner4 = new cv.Point(contApprox.data32S[6], contApprox.data32S[7]);
let cornerArray = [{ corner: corner1 }, { corner: corner2 }, { corner: corner3 }, { corner: corner4 }];
cornerArray.sort((item1, item2) => { return (item1.corner.y < item2.corner.y) ? -1 : (item1.corner.y > item2.corner.y) ? 1 : 0; }).slice(0, 5);
let tl = cornerArray[0].corner.x < cornerArray[1].corner.x ? cornerArray[0] : cornerArray[1];
let tr = cornerArray[0].corner.x > cornerArray[1].corner.x ? cornerArray[0] : cornerArray[1];
let bl = cornerArray[2].corner.x < cornerArray[3].corner.x ? cornerArray[2] : cornerArray[3];
let br = cornerArray[2].corner.x > cornerArray[3].corner.x ? cornerArray[2] : cornerArray[3];
let widthBottom = Math.hypot(br.corner.x - bl.corner.x, br.corner.y - bl.corner.y);
let widthTop = Math.hypot(tr.corner.x - tl.corner.x, tr.corner.y - tl.corner.y);
let theWidth = (widthBottom > widthTop) ? widthBottom : widthTop;
let heightRight = Math.hypot(tr.corner.x - br.corner.x, tr.corner.y - br.corner.y);
let heightLeft = Math.hypot(tl.corner.x - bl.corner.x, tr.corner.y - bl.corner.y);
let theHeight = (heightRight > heightLeft) ? heightRight : heightLeft;
let finalDestCoords = cv.matFromArray(4, 1, cv.CV_32FC2, [0, 0, theWidth - 1, 0, theWidth - 1, theHeight - 1, 0, theHeight - 1]); //
let srcCoords = cv.matFromArray(4, 1, cv.CV_32FC2, [tl.corner.x, tl.corner.y, tr.corner.x, tr.corner.y, br.corner.x, br.corner.y, bl.corner.x, bl.corner.y]);
let dsize = new cv.Size(theWidth, theHeight);
let M = cv.getPerspectiveTransform(srcCoords, finalDestCoords)
cv.warpPerspective(src, dstt, M, dsize, cv.INTER_LINEAR, cv.BORDER_CONSTANT, new cv.Scalar());
cv.imshow('canvasOutput', dstt);
src.delete();
dst.delete();
contours.delete();
hierarchy.delete();
return dstt;
}
function manual() {
let imgElement = document.getElementById('imageSrc');
let inputElement = document.getElementById('fileInput');
src = cv.imread(imgElement);
cv.imshow("srcInput", src);
var cornerArray = [];
//let canvasElem = document.querySelector("canvas");
let canvasElem = document.getElementById("srcInput");
canvasElem.addEventListener("mousedown", function(e) {
cornerArray = getMousePosition(canvasElem, e, cornerArray);
console.log(cornerArray)
if (cornerArray.length == 4) {
return crop (src, cornerArray);
}
});
}
function getMousePosition(canvas, event, cornerArray) {
let rect = canvas.getBoundingClientRect();
let x = event.clientX - rect.left;
let y = event.clientY - rect.top;
cornerArray.push([x, y]);
return cornerArray;
}
function crop(src, cornerArray) {
let dstcrop = new cv.Mat();
let a = cornerArray[0];
let b = cornerArray[1];
let c = cornerArray[2];
let d = cornerArray[3];
let corner1 = new cv.Point(a[0], a[1]);
let corner2 = new cv.Point(b[0], b[1]);
let corner3 = new cv.Point(c[0], c[1]);
let corner4 = new cv.Point(d[0], d[1]);
let cropArray = [{ corner: corner1 }, { corner: corner2 }, { corner: corner3 }, { corner: corner4 }];
cropArray.sort((item1, item2) => { return (item1.corner.y < item2.corner.y) ? -1 : (item1.corner.y > item2.corner.y) ? 1 : 0; }).slice(0, 5);
let tl = cropArray[0].corner.x < cropArray[1].corner.x ? cropArray[0] : cropArray[1];
let tr = cropArray[0].corner.x > cropArray[1].corner.x ? cropArray[0] : cropArray[1];
let bl = cropArray[2].corner.x < cropArray[3].corner.x ? cropArray[2] : cropArray[3];
let br = cropArray[2].corner.x > cropArray[3].corner.x ? cropArray[2] : cropArray[3];
let widthBottom = Math.hypot(br.corner.x - bl.corner.x, br.corner.y - bl.corner.y);
let widthTop = Math.hypot(tr.corner.x - tl.corner.x, tr.corner.y - tl.corner.y);
let theWidth = (widthBottom > widthTop) ? widthBottom : widthTop;
let heightRight = Math.hypot(tr.corner.x - br.corner.x, tr.corner.y - br.corner.y);
let heightLeft = Math.hypot(tl.corner.x - bl.corner.x, tr.corner.y - bl.corner.y);
let theHeight = (heightRight > heightLeft) ? heightRight : heightLeft;
let finalDestCoords = cv.matFromArray(4, 1, cv.CV_32FC2, [0, 0, theWidth - 1, 0, theWidth - 1, theHeight - 1, 0, theHeight - 1]); //
let srcCoords = cv.matFromArray(4, 1, cv.CV_32FC2, [tl.corner.x, tl.corner.y, tr.corner.x, tr.corner.y, br.corner.x, br.corner.y, bl.corner.x, bl.corner.y]);
let dsize = new cv.Size(theWidth, theHeight);
let M = cv.getPerspectiveTransform(srcCoords, finalDestCoords)
cv.warpPerspective(src, dstcrop, M, dsize, cv.INTER_LINEAR, cv.BORDER_CONSTANT, new cv.Scalar());
cv.imshow('cropOutput', dstcrop);
let finalSize = new cv.Size(1700, 3800);
featureExtractDetect(dstcrop, finalSize)
return dstcrop;
}
function additionalCrops(dstFinal) {
let featureArr = []
// console.log(annotationJSON.sections[14].bubbles[0])
for (i = 0; i < annotationJSON.sections.length; i++){
var section = annotationJSON.sections[i]
let sectionArr = []
if (section.bubbles) {
for (j = 0; j < section.bubbles.length; j++){
let bubble = section.bubbles[j];
let bubbleArr = [];
let rect = new cv.Rect(bubble.TL_X, bubble.TL_Y, (bubble.BR_X-bubble.TL_X), (bubble.BR_Y-bubble.TL_Y));
bubbleArr.push(dstFinal.roi(rect));
if (j == section.bubbles.length - 1){
sectionArr.push(bubbleArr);
}
}
} else {
sectionArr.push(null)
}
if (section.writeins) {
for (k = 0; k < section.writeins.length; k++){
let writein = section.writeins[k];
let writeinsArr = [];
// console.log(i)
// console.log(k)
let rect = new cv.Rect(writein.TL_X, writein.TL_Y, (writein.BR_X-writein.TL_X), (writein.BR_Y-writein.TL_Y));
writeinsArr.push(dstFinal.roi(rect));
if (j == section.writeins.length - 1){
sectionArr.push(writeinsArr);
}
}
} else {
sectionArr.push(null)
}
if (section.signatures) {
for (l = 0; l < section.signatures.length; k++){
let sig = section.signatures[l]
let sigsArr = [];
let rect = new cv.Rect(sig.TL_X, sig.TL_Y, (sig.BR_X-sig.TL_X), (sig.BR_Y-sig.TL_Y));
sigsArr.push(dstFinal.roi(rect));
if (j == section.signatures.length - 1){
sectionArr.push(sigsArr);
}
}
} else {
sectionArr.push(null)
}
featureArr.push(sectionArr)
}
return featureArr;
}
function featureExtractDetect(dstFinal, finalSize) {
cv.resize(dstFinal, dstFinal, finalSize, 0, 0, cv.INTER_AREA);
let features = additionalCrops(dstFinal)
let feature = features[3][0][0] //3rd section, bubbles, first bubble
cv.imshow('cropOutput', feature);
console.log(isFilled(feature))
}
function isFilled(bubbleFeature) {
cv.cvtColor(bubbleFeature, bubbleFeature, cv.COLOR_RGBA2GRAY);
cv.threshold(bubbleFeature, bubbleFeature, 200, 255, cv.THRESH_BINARY | cv.THRESH_OTSU);
return ((1.0 - cv.countNonZero(bubbleFeature)/parseFloat(bubbleFeature.rows*bubbleFeature.cols)) > 0.60)
}
function onOpenCvReady() {
document.getElementById('status').innerHTML = 'OpenCV.js is ready.';
}
function getAnnotation() {
var annotation = '{"state":"AZ","district":5,"page":1,"sections":[{"desc":"president / vice president","max":1,"secCoords":{"TL_X":130,"TL_Y":960,"BR_X":618,"BR_Y":1660},"bubbles":[{"TL_X":560,"TL_Y":1075,"BR_X":593,"BR_Y":1100,"text":"trump pence"},{"TL_X":560,"TL_Y":1225,"BR_X":593,"BR_Y":1250,"text":"biden harris"},{"TL_X":560,"TL_Y":1375,"BR_X":593,"BR_Y":1400,"text":"jorgensen cohen"},{"TL_X":560,"TL_Y":1525,"BR_X":593,"BR_Y":1550,"text":"write-in"}],"writeins":[{"TL_X":130,"TL_Y":1550,"BR_X":618,"BR_Y":1660}],"signatures":null},{"desc":"us senate","max":1,"secCoords":{"TL_X":130,"TL_Y":1665,"BR_X":618,"BR_Y":1910},"bubbles":[{"TL_X":560,"TL_Y":1775,"BR_X":593,"BR_Y":1800,"text":"mcsally"},{"TL_X":560,"TL_Y":1925,"BR_X":593,"BR_Y":1950,"text":"kelly"},{"TL_X":560,"TL_Y":2075,"BR_X":593,"BR_Y":2100,"text":"write-in"}],"writeins":[{"TL_X":270,"TL_Y":1869,"BR_X":554,"BR_Y":1906}],"signatures":null},{"desc":"us rep","max":1,"secCoords":{"TL_X":130,"TL_Y":1910,"BR_X":618,"BR_Y":2160},"bubbles":[{"TL_X":560,"TL_Y":2025,"BR_X":593,"BR_Y":2050,"text":"biggs"},{"TL_X":560,"TL_Y":2075,"BR_X":593,"BR_Y":2100,"text":"greene"},{"TL_X":560,"TL_Y":2125,"BR_X":593,"BR_Y":2150,"text":"write-in"}],"writeins":[{"TL_X":290,"TL_Y":2115,"BR_X":545,"BR_Y":2158}],"signatures":null},{"desc":"state senate","max":1,"secCoords":{"TL_X":130,"TL_Y":2215,"BR_X":618,"BR_Y":2463},"bubbles":[{"TL_X":560,"TL_Y":2325,"BR_X":593,"BR_Y":2350,"text":"mesnard"},{"TL_X":560,"TL_Y":2375,"BR_X":593,"BR_Y":2400,"text":"kurdoglu"},{"TL_X":560,"TL_Y":2425,"BR_X":593,"BR_Y":2450,"text":"write-in"}],"writeins":[{"TL_X":290,"TL_Y":2415,"BR_X":545,"BR_Y":2460}],"signatures":null},{"desc":"state rep","max":2,"secCoords":{"TL_X":130,"TL_Y":2463,"BR_X":618,"BR_Y":2813},"bubbles":[{"TL_X":560,"TL_Y":2575,"BR_X":593,"BR_Y":2600,"text":"weninger"},{"TL_X":560,"TL_Y":2625,"BR_X":593,"BR_Y":2650,"text":"harris"},{"TL_X":560,"TL_Y":2675,"BR_X":593,"BR_Y":2700,"text":"pawlik"},{"TL_X":560,"TL_Y":2725,"BR_X":593,"BR_Y":2750,"text":"write-in 1"},{"TL_X":560,"TL_Y":2775,"BR_X":593,"BR_Y":2800,"text":"write-in 2"}],"writeins":[{"TL_X":290,"TL_Y":2715,"BR_X":545,"BR_Y":2760},{"TL_X":290,"TL_Y":2763,"BR_X":545,"BR_Y":2810}],"signatures":null},{"desc":"corporation commisioner","max":3,"secCoords":{"TL_X":130,"TL_Y":2815,"BR_X":618,"BR_Y":3363},"bubbles":[{"TL_X":560,"TL_Y":2925,"BR_X":593,"BR_Y":2950,"text":"marquez"},{"TL_X":560,"TL_Y":2975,"BR_X":593,"BR_Y":3000,"text":"o\'connor"},{"TL_X":560,"TL_Y":3025,"BR_X":593,"BR_Y":3050,"text":"sloan"},{"TL_X":560,"TL_Y":3075,"BR_X":593,"BR_Y":3100,"text":"mundell"},{"TL_X":560,"TL_Y":3125,"BR_X":593,"BR_Y":3150,"text":"stanfield"},{"TL_X":560,"TL_Y":3175,"BR_X":593,"BR_Y":3200,"text":"tovar"},{"TL_X":560,"TL_Y":3225,"BR_X":593,"BR_Y":3250,"text":"write-in 1"},{"TL_X":560,"TL_Y":3275,"BR_X":593,"BR_Y":3300,"text":"write-in 2"},{"TL_X":560,"TL_Y":3325,"BR_X":593,"BR_Y":3350,"text":"write-in 3"}],"writeins":[{"TL_X":290,"TL_Y":3215,"BR_X":545,"BR_Y":3260},{"TL_X":290,"TL_Y":3265,"BR_X":545,"BR_Y":3310},{"TL_X":290,"TL_Y":3315,"BR_X":545,"BR_Y":3360}],"signatures":null},{"desc":"board of supervisors","max":1,"secCoords":{"TL_X":614,"TL_Y":511,"BR_X":1101,"BR_Y":813},"bubbles":[{"TL_X":1046,"TL_Y":675,"BR_X":1079,"BR_Y":700,"text":"sellers"},{"TL_X":1046,"TL_Y":725,"BR_X":1079,"BR_Y":750,"text":"hodge"},{"TL_X":1046,"TL_Y":775,"BR_X":1079,"BR_Y":800,"text":"write-in"}],"writeins":[{"TL_X":753,"TL_Y":765,"BR_X":1041,"BR_Y":810}],"signatures":null},{"desc":"county assessor","max":1,"secCoords":{"TL_X":614,"TL_Y":813,"BR_X":1101,"BR_Y":1063},"bubbles":[{"TL_X":1046,"TL_Y":925,"BR_X":1079,"BR_Y":950,"text":"cook"},{"TL_X":1046,"TL_Y":975,"BR_X":1079,"BR_Y":1000,"text":"connor"},{"TL_X":1046,"TL_Y":1025,"BR_X":1079,"BR_Y":1050,"text":"write-in"}],"writeins":[{"TL_X":753,"TL_Y":1015,"BR_X":1041,"BR_Y":1060}],"signatures":null},{"desc":"county attorney","max":1,"secCoords":{"TL_X":614,"TL_Y":1066,"BR_X":1101,"BR_Y":1312},"bubbles":[{"TL_X":1046,"TL_Y":1175,"BR_X":1079,"BR_Y":1200,"text":"adel"},{"TL_X":1046,"TL_Y":1225,"BR_X":1079,"BR_Y":1250,"text":"gunnigle"},{"TL_X":1046,"TL_Y":1275,"BR_X":1079,"BR_Y":1300,"text":"write-in"}],"writeins":[{"TL_X":753,"TL_Y":1265,"BR_X":1041,"BR_Y":1310}],"signatures":null},{"desc":"county recorder","max":1,"secCoords":{"TL_X":614,"TL_Y":1313,"BR_X":1101,"BR_Y":1562},"bubbles":[{"TL_X":1046,"TL_Y":1425,"BR_X":1079,"BR_Y":1450,"text":"richer"},{"TL_X":1046,"TL_Y":1475,"BR_X":1079,"BR_Y":1500,"text":"fontes"},{"TL_X":1046,"TL_Y":1525,"BR_X":1079,"BR_Y":1550,"text":"write-in"}],"writeins":[{"TL_X":753,"TL_Y":1515,"BR_X":1041,"BR_Y":1560}],"signatures":null},{"desc":"county school superintendent","max":1,"secCoords":{"TL_X":614,"TL_Y":1563,"BR_X":1101,"BR_Y":1813},"bubbles":[{"TL_X":1046,"TL_Y":1675,"BR_X":1079,"BR_Y":1700,"text":"watson"},{"TL_X":1046,"TL_Y":1725,"BR_X":1079,"BR_Y":1750,"text":"casteen"},{"TL_X":1046,"TL_Y":1775,"BR_X":1079,"BR_Y":1800,"text":"write-in"}],"writeins":[{"TL_X":753,"TL_Y":1765,"BR_X":1041,"BR_Y":1810}],"signatures":null},{"desc":"sherrif","max":1,"secCoords":{"TL_X":614,"TL_Y":1812,"BR_X":1101,"BR_Y":2062},"bubbles":[{"TL_X":1046,"TL_Y":1925,"BR_X":1079,"BR_Y":1950,"text":"sheridan"},{"TL_X":1046,"TL_Y":1975,"BR_X":1079,"BR_Y":2000,"text":"pezone"},{"TL_X":1046,"TL_Y":2025,"BR_X":1079,"BR_Y":2050,"text":"write-in"}],"writeins":[{"TL_X":753,"TL_Y":2015,"BR_X":1041,"BR_Y":2060}],"signatures":null},{"desc":"county treasurer","max":1,"secCoords":{"TL_X":614,"TL_Y":1812,"BR_X":1101,"BR_Y":2066},"bubbles":[{"TL_X":1046,"TL_Y":2175,"BR_X":1079,"BR_Y":2200,"text":"allen"},{"TL_X":1046,"TL_Y":2225,"BR_X":1079,"BR_Y":2250,"text":"toporek"},{"TL_X":1046,"TL_Y":2275,"BR_X":1079,"BR_Y":2300,"text":"write-in"}],"writeins":[{"TL_X":753,"TL_Y":2265,"BR_X":1041,"BR_Y":2310}],"signatures":null},{"desc":"special healthcare","max":1,"secCoords":{"TL_X":614,"TL_Y":2313,"BR_X":1101,"BR_Y":2714},"bubbles":[{"TL_X":1046,"TL_Y":2575,"BR_X":1079,"BR_Y":2600,"text":"harden"},{"TL_X":1046,"TL_Y":2625,"BR_X":1079,"BR_Y":2650,"text":"farnsworth"},{"TL_X":1046,"TL_Y":2675,"BR_X":1079,"BR_Y":2700,"text":"write-in"}],"writeins":[{"TL_X":753,"TL_Y":2720,"BR_X":1041,"BR_Y":2765}],"signatures":null},{"desc":"prop 449","max":1,"secCoords":{"TL_X":614,"TL_Y":2713,"BR_X":1101,"BR_Y":3315},"bubbles":[{"TL_X":1046,"TL_Y":3225,"BR_X":1079,"BR_Y":3250,"text":"yes"},{"TL_X":1046,"TL_Y":3275,"BR_X":1079,"BR_Y":3300,"text":"no"}],"writeins":null,"signatures":null},{"desc":"county community college at-large","max":1,"secCoords":{"TL_X":1104,"TL_Y":515,"BR_X":1587,"BR_Y":812},"bubbles":[{"TL_X":1533,"TL_Y":675,"BR_X":1566,"BR_Y":700,"text":"thor"},{"TL_X":1533,"TL_Y":725,"BR_X":1566,"BR_Y":750,"text":"boggs"},{"TL_X":1533,"TL_Y":775,"BR_X":1566,"BR_Y":800,"text":"write-in"}],"writeins":[{"TL_X":1242,"TL_Y":765,"BR_X":1532,"BR_Y":810}],"signatures":null},{"desc":"county community college district 1","max":1,"secCoords":{"TL_X":1104,"TL_Y":812,"BR_X":1587,"BR_Y":1112},"bubbles":[{"TL_X":1533,"TL_Y":975,"BR_X":1566,"BR_Y":1000,"text":"smith"},{"TL_X":1533,"TL_Y":1025,"BR_X":1566,"BR_Y":1050,"text":"hendrix"},{"TL_X":1533,"TL_Y":1075,"BR_X":1566,"BR_Y":1100,"text":"write-in"}],"writeins":[{"TL_X":1242,"TL_Y":1065,"BR_X":1532,"BR_Y":1110}],"signatures":null},{"desc":"school gov. board member","max":3,"secCoords":{"TL_X":1104,"TL_Y":1164,"BR_X":1587,"BR_Y":1563},"bubbles":[{"TL_X":1533,"TL_Y":1275,"BR_X":1566,"BR_Y":1300,"text":"wirth"},{"TL_X":1533,"TL_Y":1325,"BR_X":1566,"BR_Y":1350,"text":"mozdzen"},{"TL_X":1533,"TL_Y":1375,"BR_X":1566,"BR_Y":1400,"text":"olive"},{"TL_X":1533,"TL_Y":1425,"BR_X":1566,"BR_Y":1450,"text":"write-in 1"},{"TL_X":1533,"TL_Y":1475,"BR_X":1566,"BR_Y":1500,"text":"write-in 2"},{"TL_X":1533,"TL_Y":1525,"BR_X":1566,"BR_Y":1550,"text":"write-in 3"}],"writeins":[{"TL_X":1242,"TL_Y":1415,"BR_X":1532,"BR_Y":1460},{"TL_X":1242,"TL_Y":1465,"BR_X":1532,"BR_Y":1510},{"TL_X":1242,"TL_Y":1515,"BR_X":1532,"BR_Y":1560}],"signatures":null},{"desc":"question 1","max":1,"secCoords":{"TL_X":1104,"TL_Y":1613,"BR_X":1587,"BR_Y":1915},"bubbles":[{"TL_X":1533,"TL_Y":1825,"BR_X":1566,"BR_Y":1850,"text":"for"},{"TL_X":1533,"TL_Y":1875,"BR_X":1566,"BR_Y":1900,"text":"against"}],"writeins":null,"signatures":null},{"desc":"retain brutinel","max":1,"secCoords":{"TL_X":1104,"TL_Y":2062,"BR_X":1587,"BR_Y":2162},"bubbles":[{"TL_X":1533,"TL_Y":2075,"BR_X":1566,"BR_Y":2100,"text":"yes"},{"TL_X":1533,"TL_Y":2125,"BR_X":1566,"BR_Y":2150,"text":"no"}],"writeins":null,"signatures":null},{"desc":"retain gould","max":1,"secCoords":{"TL_X":1104,"TL_Y":2162,"BR_X":1587,"BR_Y":2262},"bubbles":[{"TL_X":1533,"TL_Y":2175,"BR_X":1566,"BR_Y":2200,"text":"yes"},{"TL_X":1533,"TL_Y":2225,"BR_X":1566,"BR_Y":2250,"text":"no"}],"writeins":null,"signatures":null},{"desc":"retain lopez","max":1,"secCoords":{"TL_X":1104,"TL_Y":2262,"BR_X":1587,"BR_Y":2362},"bubbles":[{"TL_X":1533,"TL_Y":2275,"BR_X":1566,"BR_Y":2300,"text":"yes"},{"TL_X":1533,"TL_Y":2325,"BR_X":1566,"BR_Y":2350,"text":"no"}],"writeins":null,"signatures":null},{"desc":"retain howe","max":1,"secCoords":{"TL_X":1104,"TL_Y":2562,"BR_X":1587,"BR_Y":2662},"bubbles":[{"TL_X":1533,"TL_Y":2575,"BR_X":1566,"BR_Y":2600,"text":"yes"},{"TL_X":1533,"TL_Y":2625,"BR_X":1566,"BR_Y":2650,"text":"no"}],"writeins":null,"signatures":null},{"desc":"retain mcmurdie","max":1,"secCoords":{"TL_X":1104,"TL_Y":2662,"BR_X":1587,"BR_Y":2762},"bubbles":[{"TL_X":1533,"TL_Y":2675,"BR_X":1566,"BR_Y":2700,"text":"yes"},{"TL_X":1533,"TL_Y":2725,"BR_X":1566,"BR_Y":2750,"text":"no"}],"writeins":null,"signatures":null},{"desc":"retain morse","max":1,"secCoords":{"TL_X":1104,"TL_Y":2762,"BR_X":1587,"BR_Y":2862},"bubbles":[{"TL_X":1533,"TL_Y":2775,"BR_X":1566,"BR_Y":2800,"text":"yes"},{"TL_X":1533,"TL_Y":2825,"BR_X":1566,"BR_Y":2850,"text":"no"}],"writeins":null,"signatures":null},{"desc":"retain perkins","max":1,"secCoords":{"TL_X":1104,"TL_Y":2862,"BR_X":1587,"BR_Y":2962},"bubbles":[{"TL_X":1533,"TL_Y":2875,"BR_X":1566,"BR_Y":2900,"text":"yes"},{"TL_X":1533,"TL_Y":2925,"BR_X":1566,"BR_Y":2950,"text":"no"}],"writeins":null,"signatures":null},{"desc":"retain thumma","max":1,"secCoords":{"TL_X":1104,"TL_Y":2962,"BR_X":1587,"BR_Y":3062},"bubbles":[{"TL_X":1533,"TL_Y":2975,"BR_X":1566,"BR_Y":3000,"text":"yes"},{"TL_X":1533,"TL_Y":3025,"BR_X":1566,"BR_Y":3050,"text":"no"}],"writeins":null,"signatures":null},{"desc":"retain weinzweig","max":1,"secCoords":{"TL_X":1104,"TL_Y":3062,"BR_X":1587,"BR_Y":3162},"bubbles":[{"TL_X":1533,"TL_Y":3075,"BR_X":1566,"BR_Y":3100,"text":"yes"},{"TL_X":1533,"TL_Y":3125,"BR_X":1566,"BR_Y":3150,"text":"no"}],"writeins":null,"signatures":null},{"desc":"retain adleman","max":1,"secCoords":{"TL_X":1104,"TL_Y":3314,"BR_X":1587,"BR_Y":3414},"bubbles":[{"TL_X":1533,"TL_Y":3325,"BR_X":1566,"BR_Y":3350,"text":"yes"},{"TL_X":1533,"TL_Y":3375,"BR_X":1566,"BR_Y":3400,"text":"no"}],"writeins":null,"signatures":null},{"desc":"retain agne","max":1,"secCoords":{"TL_X":1104,"TL_Y":3414,"BR_X":1587,"BR_Y":3514},"bubbles":[{"TL_X":1533,"TL_Y":3425,"BR_X":1566,"BR_Y":3450,"text":"yes"},{"TL_X":1533,"TL_Y":3475,"BR_X":1566,"BR_Y":3500,"text":"no"}],"writeins":null,"signatures":null}]}'
var annotationtwo = '{"state":"AZ","district":5,"page":1,"sections":[{"desc":"Retain Beresky","max":1,"secCoords":{"TL_X":130,"TL_Y":365,"BR_X":615,"BR_Y":460},"bubbles":[{"TL_X":560,"TL_Y":375,"BR_X":593,"BR_Y":400,"text":"Yes"},{"TL_X":560,"TL_Y":425,"BR_X":593,"BR_Y":450,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Blaney","max":1,"secCoords":{"TL_X":130,"TL_Y":465,"BR_X":615,"BR_Y":560},"bubbles":[{"TL_X":560,"TL_Y":475,"BR_X":593,"BR_Y":500,"text":"Yes"},{"TL_X":560,"TL_Y":525,"BR_X":593,"BR_Y":550,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Bustamante","max":1,"secCoords":{"TL_X":130,"TL_Y":565,"BR_X":615,"BR_Y":660},"bubbles":[{"TL_X":560,"TL_Y":575,"BR_X":593,"BR_Y":600,"text":"Yes"},{"TL_X":560,"TL_Y":625,"BR_X":593,"BR_Y":650,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Coffey","max":1,"secCoords":{"TL_X":130,"TL_Y":665,"BR_X":615,"BR_Y":760},"bubbles":[{"TL_X":560,"TL_Y":675,"BR_X":593,"BR_Y":700,"text":"Yes"},{"TL_X":560,"TL_Y":725,"BR_X":593,"BR_Y":750,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Cohen (Bruce)","max":1,"secCoords":{"TL_X":130,"TL_Y":765,"BR_X":615,"BR_Y":860},"bubbles":[{"TL_X":560,"TL_Y":775,"BR_X":593,"BR_Y":800,"text":"Yes"},{"TL_X":560,"TL_Y":825,"BR_X":593,"BR_Y":850,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Cohen (Suzanne)","max":1,"secCoords":{"TL_X":130,"TL_Y":865,"BR_X":615,"BR_Y":960},"bubbles":[{"TL_X":560,"TL_Y":875,"BR_X":593,"BR_Y":900,"text":"Yes"},{"TL_X":560,"TL_Y":925,"BR_X":593,"BR_Y":950,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Contes","max":1,"secCoords":{"TL_X":130,"TL_Y":965,"BR_X":615,"BR_Y":1060},"bubbles":[{"TL_X":560,"TL_Y":975,"BR_X":593,"BR_Y":1000,"text":"Yes"},{"TL_X":560,"TL_Y":1025,"BR_X":593,"BR_Y":1046,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Coury","max":1,"secCoords":{"TL_X":130,"TL_Y":1065,"BR_X":615,"BR_Y":1160},"bubbles":[{"TL_X":560,"TL_Y":1075,"BR_X":593,"BR_Y":1100,"text":"Yes"},{"TL_X":560,"TL_Y":1125,"BR_X":593,"BR_Y":1150,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Driggs","max":1,"secCoords":{"TL_X":130,"TL_Y":1165,"BR_X":615,"BR_Y":1260},"bubbles":[{"TL_X":560,"TL_Y":1175,"BR_X":593,"BR_Y":1200,"text":"Yes"},{"TL_X":560,"TL_Y":1225,"BR_X":593,"BR_Y":1250,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Fisk","max":1,"secCoords":{"TL_X":130,"TL_Y":1265,"BR_X":615,"BR_Y":1360},"bubbles":[{"TL_X":560,"TL_Y":1275,"BR_X":593,"BR_Y":1300,"text":"Yes"},{"TL_X":560,"TL_Y":1325,"BR_X":593,"BR_Y":1350,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Gates","max":1,"secCoords":{"TL_X":130,"TL_Y":1365,"BR_X":615,"BR_Y":1460},"bubbles":[{"TL_X":560,"TL_Y":1375,"BR_X":593,"BR_Y":1400,"text":"Yes"},{"TL_X":560,"TL_Y":1425,"BR_X":593,"BR_Y":1450,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Gentry","max":1,"secCoords":{"TL_X":130,"TL_Y":1465,"BR_X":615,"BR_Y":1560},"bubbles":[{"TL_X":560,"TL_Y":1475,"BR_X":593,"BR_Y":1500,"text":"Yes"},{"TL_X":560,"TL_Y":1525,"BR_X":593,"BR_Y":1550,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Gordon","max":1,"secCoords":{"TL_X":130,"TL_Y":1565,"BR_X":615,"BR_Y":1660},"bubbles":[{"TL_X":560,"TL_Y":1575,"BR_X":593,"BR_Y":1600,"text":"Yes"},{"TL_X":560,"TL_Y":1625,"BR_X":593,"BR_Y":1650,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Hannah","max":1,"secCoords":{"TL_X":130,"TL_Y":1665,"BR_X":615,"BR_Y":1760},"bubbles":[{"TL_X":560,"TL_Y":1675,"BR_X":593,"BR_Y":1700,"text":"Yes"},{"TL_X":560,"TL_Y":1725,"BR_X":593,"BR_Y":1750,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Kemp","max":1,"secCoords":{"TL_X":130,"TL_Y":1765,"BR_X":615,"BR_Y":1860},"bubbles":[{"TL_X":560,"TL_Y":1775,"BR_X":593,"BR_Y":1800,"text":"Yes"},{"TL_X":560,"TL_Y":1825,"BR_X":593,"BR_Y":1850,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Kiley","max":1,"secCoords":{"TL_X":130,"TL_Y":1865,"BR_X":615,"BR_Y":1960},"bubbles":[{"TL_X":560,"TL_Y":1875,"BR_X":593,"BR_Y":1900,"text":"Yes"},{"TL_X":560,"TL_Y":1925,"BR_X":593,"BR_Y":1950,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Labiana","max":1,"secCoords":{"TL_X":130,"TL_Y":1965,"BR_X":615,"BR_Y":2060},"bubbles":[{"TL_X":560,"TL_Y":1975,"BR_X":593,"BR_Y":2000,"text":"Yes"},{"TL_X":560,"TL_Y":2025,"BR_X":593,"BR_Y":2050,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Lang","max":1,"secCoords":{"TL_X":130,"TL_Y":2065,"BR_X":615,"BR_Y":2160},"bubbles":[{"TL_X":560,"TL_Y":2075,"BR_X":593,"BR_Y":2100,"text":"Yes"},{"TL_X":560,"TL_Y":2125,"BR_X":593,"BR_Y":2150,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Mahoney","max":1,"secCoords":{"TL_X":130,"TL_Y":2165,"BR_X":615,"BR_Y":2260},"bubbles":[{"TL_X":560,"TL_Y":2175,"BR_X":593,"BR_Y":2200,"text":"Yes"},{"TL_X":560,"TL_Y":2225,"BR_X":593,"BR_Y":2250,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Mandell","max":1,"secCoords":{"TL_X":130,"TL_Y":2265,"BR_X":615,"BR_Y":2360},"bubbles":[{"TL_X":560,"TL_Y":2275,"BR_X":593,"BR_Y":2300,"text":"Yes"},{"TL_X":560,"TL_Y":2325,"BR_X":593,"BR_Y":2350,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Marwil","max":1,"secCoords":{"TL_X":130,"TL_Y":2365,"BR_X":615,"BR_Y":2460},"bubbles":[{"TL_X":560,"TL_Y":2375,"BR_X":593,"BR_Y":2400,"text":"Yes"},{"TL_X":560,"TL_Y":2425,"BR_X":593,"BR_Y":2450,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain McCoy","max":1,"secCoords":{"TL_X":130,"TL_Y":2465,"BR_X":615,"BR_Y":2560},"bubbles":[{"TL_X":560,"TL_Y":2475,"BR_X":593,"BR_Y":2500,"text":"Yes"},{"TL_X":560,"TL_Y":2525,"BR_X":593,"BR_Y":2550,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Mead","max":1,"secCoords":{"TL_X":130,"TL_Y":2565,"BR_X":615,"BR_Y":2660},"bubbles":[{"TL_X":560,"TL_Y":2575,"BR_X":593,"BR_Y":2600,"text":"Yes"},{"TL_X":560,"TL_Y":2625,"BR_X":593,"BR_Y":2650,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Mikitish","max":1,"secCoords":{"TL_X":130,"TL_Y":2665,"BR_X":615,"BR_Y":2760},"bubbles":[{"TL_X":560,"TL_Y":2675,"BR_X":593,"BR_Y":2700,"text":"Yes"},{"TL_X":560,"TL_Y":2725,"BR_X":593,"BR_Y":2750,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Minder","max":1,"secCoords":{"TL_X":130,"TL_Y":2765,"BR_X":615,"BR_Y":2860},"bubbles":[{"TL_X":560,"TL_Y":2775,"BR_X":593,"BR_Y":2800,"text":"Yes"},{"TL_X":560,"TL_Y":2825,"BR_X":593,"BR_Y":2850,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Mullins","max":1,"secCoords":{"TL_X":130,"TL_Y":2865,"BR_X":615,"BR_Y":2960},"bubbles":[{"TL_X":560,"TL_Y":2875,"BR_X":593,"BR_Y":2900,"text":"Yes"},{"TL_X":560,"TL_Y":2925,"BR_X":593,"BR_Y":2950,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Palmer","max":1,"secCoords":{"TL_X":130,"TL_Y":2965,"BR_X":615,"BR_Y":3060},"bubbles":[{"TL_X":560,"TL_Y":2975,"BR_X":593,"BR_Y":3000,"text":"Yes"},{"TL_X":560,"TL_Y":3025,"BR_X":593,"BR_Y":3050,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Ponce","max":1,"secCoords":{"TL_X":130,"TL_Y":3065,"BR_X":615,"BR_Y":3160},"bubbles":[{"TL_X":560,"TL_Y":3075,"BR_X":593,"BR_Y":3100,"text":"Yes"},{"TL_X":560,"TL_Y":3125,"BR_X":593,"BR_Y":3150,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Ryan","max":1,"secCoords":{"TL_X":130,"TL_Y":3165,"BR_X":615,"BR_Y":3260},"bubbles":[{"TL_X":560,"TL_Y":3175,"BR_X":593,"BR_Y":3200,"text":"Yes"},{"TL_X":560,"TL_Y":3225,"BR_X":593,"BR_Y":3250,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Sanders","max":1,"secCoords":{"TL_X":130,"TL_Y":3265,"BR_X":615,"BR_Y":3360},"bubbles":[{"TL_X":560,"TL_Y":3275,"BR_X":593,"BR_Y":3300,"text":"Yes"},{"TL_X":560,"TL_Y":3325,"BR_X":593,"BR_Y":3350,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Starr","max":1,"secCoords":{"TL_X":130,"TL_Y":3365,"BR_X":615,"BR_Y":3460},"bubbles":[{"TL_X":560,"TL_Y":3375,"BR_X":593,"BR_Y":3400,"text":"Yes"},{"TL_X":560,"TL_Y":3425,"BR_X":593,"BR_Y":3450,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Stephens","max":1,"secCoords":{"TL_X":130,"TL_Y":3465,"BR_X":615,"BR_Y":3560},"bubbles":[{"TL_X":560,"TL_Y":3475,"BR_X":593,"BR_Y":3500,"text":"Yes"},{"TL_X":560,"TL_Y":3525,"BR_X":593,"BR_Y":3550,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Thomason","max":1,"secCoords":{"TL_X":615,"TL_Y":365,"BR_X":1100,"BR_Y":460},"bubbles":[{"TL_X":1046,"TL_Y":375,"BR_X":1079,"BR_Y":400,"text":"Yes"},{"TL_X":1046,"TL_Y":425,"BR_X":1079,"BR_Y":450,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Thompson","max":1,"secCoords":{"TL_X":615,"TL_Y":465,"BR_X":1100,"BR_Y":560},"bubbles":[{"TL_X":1046,"TL_Y":475,"BR_X":1079,"BR_Y":500,"text":"Yes"},{"TL_X":1046,"TL_Y":525,"BR_X":1079,"BR_Y":550,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Udall","max":1,"secCoords":{"TL_X":615,"TL_Y":565,"BR_X":1100,"BR_Y":660},"bubbles":[{"TL_X":1046,"TL_Y":575,"BR_X":1079,"BR_Y":600,"text":"Yes"},{"TL_X":1046,"TL_Y":625,"BR_X":1079,"BR_Y":650,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Vandenberg","max":1,"secCoords":{"TL_X":615,"TL_Y":665,"BR_X":1100,"BR_Y":760},"bubbles":[{"TL_X":1046,"TL_Y":675,"BR_X":1079,"BR_Y":700,"text":"Yes"},{"TL_X":1046,"TL_Y":725,"BR_X":1079,"BR_Y":750,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Wein","max":1,"secCoords":{"TL_X":615,"TL_Y":765,"BR_X":1100,"BR_Y":860},"bubbles":[{"TL_X":1046,"TL_Y":775,"BR_X":1079,"BR_Y":800,"text":"Yes"},{"TL_X":1046,"TL_Y":825,"BR_X":1079,"BR_Y":850,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Retain Whitten","max":1,"secCoords":{"TL_X":615,"TL_Y":865,"BR_X":1100,"BR_Y":960},"bubbles":[{"TL_X":1046,"TL_Y":875,"BR_X":1079,"BR_Y":900,"text":"Yes"},{"TL_X":1046,"TL_Y":925,"BR_X":1079,"BR_Y":950,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Proposition 207","max":1,"secCoords":{"TL_X":615,"TL_Y":1015,"BR_X":1100,"BR_Y":1660},"bubbles":[{"TL_X":1046,"TL_Y":1575,"BR_X":1079,"BR_Y":1600,"text":"Yes"},{"TL_X":1046,"TL_Y":1625,"BR_X":1079,"BR_Y":1650,"text":"No"}],"writeins":null,"signatures":null},{"desc":"Proposition 208","max":1,"secCoords":{"TL_X":615,"TL_Y":1665,"BR_X":1100,"BR_Y":2265},"bubbles":[{"TL_X":1046,"TL_Y":2175,"BR_X":1079,"BR_Y":2200,"text":"Yes"},{"TL_X":1046,"TL_Y":2225,"BR_X":1079,"BR_Y":2250,"text":"No"}],"writeins":null,"signatures":null}]}'
return JSON.parse(annotation)
}
</script>
<script async src="opencv.js" onload="onOpenCvReady();" type="text/javascript"></script>
</body>
</html>