Skip to content

Commit

Permalink
Consolidate the asm.js and wasm versions
Browse files Browse the repository at this point in the history
  • Loading branch information
huningxin committed Aug 13, 2017
1 parent be4666e commit bca40d6
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 832 deletions.
File renamed without changes.
3 changes: 0 additions & 3 deletions samples/face-detection-wasm/README.txt

This file was deleted.

190 changes: 0 additions & 190 deletions samples/face-detection-wasm/js/index.js

This file was deleted.

16 changes: 0 additions & 16 deletions samples/face-detection-wasm/license.txt

This file was deleted.

25 changes: 0 additions & 25 deletions samples/face-detection/css/style.css

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>OpenCV.js Face Detection (WebAssembly)</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="../css/style.css">
</head>

<body>
Expand All @@ -26,6 +26,11 @@
<script src="../libs/adapter-latest.js"></script>
<script src="../libs/stats.min.js"></script>
<script src="../libs/dat.gui.min.js"></script>
<script src="../libs/utils.js"></script>
<script>
var featuresReady = checkFeatures(document.getElementById("info"), {webrtc: true, wasm: true});
</script>
<script src="js/index.js"></script>
<script>
var Module = {
wasmBinaryFile: '../../build/wasm/opencv_js.wasm',
Expand All @@ -38,6 +43,5 @@
};
</script>
<script async src="../../build/wasm/opencv.js"></script>
<script src="js/index.js"></script>
</body>
</html>
8 changes: 6 additions & 2 deletions samples/face-detection/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>OpenCV.js Face Detection</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<div id="info" class="text-center">
Expand All @@ -25,6 +25,11 @@
<script src="../libs/adapter-latest.js"></script>
<script src="../libs/stats.min.js"></script>
<script src="../libs/dat.gui.min.js"></script>
<script src="../libs/utils.js"></script>
<script>
var featuresReady = checkFeatures(document.getElementById("info"), {webrtc: true});
</script>
<script src="js/index.js"></script>
<script>
var Module = {
preRun: [function() {
Expand All @@ -36,6 +41,5 @@
};
</script>
<script async src="../../build/asm.js/opencv.js"></script>
<script src="js/index.js"></script>
</body>
</html>
6 changes: 5 additions & 1 deletion samples/face-detection/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ function initUI() {

function opencvIsReady() {
console.log('OpenCV.js is ready');
if (!featuresReady) {
console.log('Requred features are not ready.');
return;
}
info.innerHTML = '';
initUI();
startCamera();
}
}
8 changes: 4 additions & 4 deletions samples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
<div class="textblock">
<ul>
<li>
<p class="startli"><a class="el" href="video-processing">Video processing (asm.js)</a></p>
<p class="startli"><a class="el" href="video-processing/index.html">Video processing (asm.js)</a></p>
<p class="startli"></p>
</li>
<li>
<p class="startli"><a class="el" href="video-processing-wasm">Video processing (wasm)</a></p>
<p class="startli"><a class="el" href="video-processing/index-wasm.html">Video processing (wasm)</a></p>
<p class="startli"></p>
</li>
<li>
<p class="startli"><a class="el" href="face-detection">Face detection (asm.js)</a></p>
<p class="startli"><a class="el" href="face-detection/index.html">Face detection (asm.js)</a></p>
<p class="startli"></p>
</li>
<li>
<p class="startli"><a class="el" href="face-detection-wasm">Face detection (wasm)</a></p>
<p class="startli"><a class="el" href="face-detection/index-wasm.html">Face detection (wasm)</a></p>
<p class="startli"></p>
</li>
</ul>
Expand Down
30 changes: 30 additions & 0 deletions samples/libs/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function checkFeatures(info, features) {
var wasmSupported = true, webrtcSupported = true;
if (features.webrtc) {
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
webrtcSupported = false;
}
}
if (features.wasm && !window.WebAssembly) {
wasmSupported = false;
}

if (!webrtcSupported || !wasmSupported) {
var text = "Your web browser doesn't support ";
var len = text.length;
if (!webrtcSupported) {
text += "WebRTC";
}
if (!wasmSupported) {
if (text.length > len) {
text += " and ";
}
text += "WebAssembly"
}
text += ".";
info.innerHTML = text;
return false;
}

return true;
}
3 changes: 0 additions & 3 deletions samples/video-processing-wasm/README.txt

This file was deleted.

25 changes: 0 additions & 25 deletions samples/video-processing-wasm/css/style.css

This file was deleted.

Loading

0 comments on commit bca40d6

Please sign in to comment.