-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
55 lines (45 loc) · 1.38 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Image Processing</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h2>Image Processing with opencv.js</h2>
<h3 id='status'>Loading...</h3>
<div>
<canvas id="original"></canvas>
<label for="file">Choose image</label>
<input type="file" id="fileInput" name="file" />
</div>
<div id="steps">
</div>
<script async src="opencv.js" onload="onOpenCvReady();" type="text/javascript"></script>
<script src="processing.js" type="text/javascript"></script>
<script type="text/javascript">
const img = new Image()
const originalImage = document.getElementById('original')
const originalContext = originalImage.getContext('2d')
const inputElement = document.getElementById('fileInput')
const stepsDiv = document.getElementById('steps')
const steps = new Steps(stepsDiv)
steps.addStep(new BlurStep(img))
steps.addStep(new MaskStep())
steps.addStep(new CannyStep())
steps.addStep(new HoughPStep())
img.onload = () => {
let src = cv.imread(img)
cv.imshow('original', src)
src.delete()
steps.run()
}
inputElement.addEventListener('change', (e) =>{
img.src = URL.createObjectURL(e.target.files[0])
}, false)
function onOpenCvReady() {
document.getElementById('status').innerHTML = 'Ready!'
}
</script>
</body>
</html>