Add onRuntimeInitialized for opencv.js
authorDmitry Kurtaev <dmitry.kurtaev+github@gmail.com>
Mon, 11 Mar 2019 08:44:16 +0000 (11:44 +0300)
committerDmitry Kurtaev <dmitry.kurtaev+github@gmail.com>
Mon, 11 Mar 2019 08:44:16 +0000 (11:44 +0300)
doc/js_tutorials/js_assets/utils.js

index 8e56396..4d5deb0 100644 (file)
@@ -8,8 +8,19 @@ function Utils(errorOutputId) { // eslint-disable-line no-unused-vars
         script.setAttribute('async', '');
         script.setAttribute('type', 'text/javascript');
         script.addEventListener('load', () => {
-            console.log(cv.getBuildInformation());
-            onloadCallback();
+            if (cv.getBuildInformation)
+            {
+                console.log(cv.getBuildInformation());
+                onloadCallback();
+            }
+            else
+            {
+                // WASM
+                cv['onRuntimeInitialized']=()=>{
+                    console.log(cv.getBuildInformation());
+                    onloadCallback();
+                }
+            }
         });
         script.addEventListener('error', () => {
             self.printError('Failed to load ' + OPENCV_URL);