-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
80 lines (65 loc) · 1.69 KB
/
index.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
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Camera To URL Test</title>
<script src="jquery-2.1.1.min.js"></script>
<script src="ocrad.js"></script>
<script>
function OCRImage(image){
var canvas = document.createElement('canvas')
canvas.width = image.naturalWidth;
canvas.height = image.naturalHeight;
canvas.getContext('2d').drawImage(image, 0, 0)
return OCRAD(canvas)
}
</script>
<style>
#wrap {
width:100%;
margin: 0 auto;
}
#takePictureField {
}
#yourimage {
float:left;
width:50%;
}
#OCRtext {
float:right;
width: 50%;
}
</style>
</head>
<body>
<input type="file" capture="camera" accept="image/*" id="takePictureField">
<div id="wrap">
<img id="yourimage">
<div id="OCRtext"></div>
</div>
<script>
var desiredWidth;
$(document).ready(function() {
console.log('onReady');
$("#takePictureField").on("change",gotPic);
$("#yourimage").load(getText);
desiredWidth = window.innerWidth;
if(!("url" in window) && ("webkitURL" in window)) {
window.URL = window.webkitURL;
}
});
function getText(){
var text = OCRImage($("#yourimage")[0]);
$("#OCRtext")[0].innerText = text;
}
//Credit: https://www.youtube.com/watch?v=EPYnGFEcis4&feature=youtube_gdata_player
function gotPic(event) {
if(event.target.files.length == 1 &&
event.target.files[0].type.indexOf("image/") == 0) {
$("#yourimage").attr("src",URL.createObjectURL(event.target.files[0]));
}
}
</script>
</body>
</html>