-
Notifications
You must be signed in to change notification settings - Fork 91
/
edge_detector.html
103 lines (89 loc) · 2.59 KB
/
edge_detector.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Computer Vision Guide</title>
<!-- IMPORT OPENCV -->
<script
async
src="https://docs.opencv.org/master/opencv.js"
onload="onOpenCvReady();"
type="text/javascript"
></script>
<!-- IMPORT BOOTSTRAP FOR UI -->
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb"
crossorigin="anonymous"
/>
</head>
<body>
<div class="container">
<center>
<a href="https://github.com/mesutpiskin/computer-vision-guide"
>https://github.com/mesutpiskin/computer-vision-guide</a
>
<p>Canny Edge Detector</p>
</center>
<br />
<div class="row">
<div class="col-sm">
<div class="card">
<div class="card-header">
Input Image
</div>
<div class="card-block text-center">
<img id="imageOriginal" class="card-img-top" />
</div>
<div class="card-footer text-muted">
<input type="file" id="imageInput" name="file" />
</div>
</div>
</div>
</div>
<br />
<div class="row">
<div class="col-sm">
<div class="card">
<div class="card-header">
After Image Processing
</div>
<div class="card-block">
<canvas id="imageCanvas"></canvas>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
document.body.classList.add("loading");
let imgElement = document.getElementById("imageOriginal");
let inputElement = document.getElementById("imageInput");
inputElement.addEventListener(
"change",
e => {
imgElement.src = URL.createObjectURL(e.target.files[0]);
},
false
);
// ---IMAGE PROCESSING---
imgElement.onload = function() {
let frame = cv.imread(imgElement);
let dst = new cv.Mat();
// RGB to GRAY color space
cv.cvtColor(frame, frame, cv.COLOR_RGB2GRAY, 0);
// canny edge detector
cv.Canny(frame, dst, 50, 100, 3, false);
cv.imshow("imageCanvas", dst);
frame.delete();
dst.delete();
};
// ---IMAGE PROCESSING---
// Opencv loaded
function onOpenCvReady() {
document.body.classList.remove("loading");
}
</script>
</body>
</html>