Can anybody generate opencv.js? - javascript

I can't generate OpenCV.js using this instructions: https://docs.opencv.org/master/d4/da1/tutorial_js_setup.html
I have this error:
CMake Error: CMake was unable to find a build program corresponding to
"Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need
to select a different build tool.
When I'm trying to execute:
python ./platforms/js/build_js.py build_js
Alright, guys! You can download opencv.js from sources (press F12) of this Page: https://docs.opencv.org/master/js_face_detection_camera.html

You can find a nightly build at https://docs.opencv.org/master/opencv.js and some useful stuff at https://docs.opencv.org/master/utils.js .
<script async src="https://docs.opencv.org/master/opencv.js" type="text/javascript"></script>

I'm still not able to build it from source.
But this version of opencv.js worked for me on MacOS https://docs.opencv.org/3.4/opencv.js

I'll just list out the parts where installation was slightly different from what was outlined in https://docs.opencv.org/master/d4/da1/tutorial_js_setup.html.
For installing Binaryen, make sure you cd into the emsdk directory and then run these:
./emsdk install binaryen-master-64bit
./emsdk activate binaryen-master-64bit
From the official docs,
python ./platforms/js/build_js.py build_js
doesn't work because you need to add an additional flag --emscripten_dir to specify where the correct path. Note that you want the folder below the emsdk root directory, typically /fastcomp/emscripten/ (for the older “fastcomp” compiler; for the newer upstream LLVM wasm backend it will be /upstream/emscripten/).
I personally used the /upstream/emscripten one
So run this:
python /Users/fangran/opencv/platforms/js/build_js.py build_wasm --build_wasm --emscripten_dir /Users/fangran/emsdk/upstream/emscripten
And it should work and return:
=====
===== Build finished
=====
OpenCV.js location: /Users/fangran/opencv/build_wasm/bin/opencv.js
For more details: refer to this link

Looks like Emscripten doesn't setup the enviroment variable correctly to the SDK
For anyone trying to get this to build you need to specify the correct path to the Emscripten
which is the path where Emscripten is installed found in emsdk/upstream/emscripten
python ./platforms/js/build_js.py build_js --emscripten_dir=/home/username/Desktop/emsdk/upstream/emscripten
This should then work

Related

How to configure create-react-kotlin-app in order to get kotlinx.serialization working

I've been trying to get the kotlinx.serialization library working with Kotlin/JS using the create-react-kotlin-app
However, I am not so familiar with the huge nodeJS and webpack mess.
I did the following:
1) Downloaded the kotlinx.serialization library from maven repository a located it aside the nodeJS dependencies, because there is so far no any npm module for this.
2) Modified the node_modules/#jetbrains/kotlin-webpack-plugin/plugin.js in order to compile my library, in particular I added this row to the prepareLibraries function:
opts.libraries.push(opts.packagesContents[0]["_where"]+"/lib/kotlinx-serialization-runtime-js/build/classes/main/kotlinx-serialization-runtime-js.js")
3) Modified the last line in node_modules/kotlin-compiler/bin/kotlinc in order to enable the the serialization compiler plugin:
${JAVACMD:=java}" $JAVA_OPTS "${java_args[#]}" -cp "${kotlin_app[#]}" "${kotlin_args[#]}" -Xplugin=$KOTLIN_HOME/lib/kotlinx-serialization-compiler-plugin.jar
The thing is that when I run the dev server using npm start, it compiles and runs as expected, but when I run npm run build, I got the following error:
Creating an optimized production build...
Failed to compile.
warning: flag is not supported by this version of the compiler: -
Xplugin=/home/Project/archetype-frontend-kotlin/node_modules/kotlin-compiler/lib/kotlinx-serialization-compiler-plugin.jar
npm ERR! code ELIFECYCLE
And of course when I remove the -Xplugin argument, the application is throwing exceptions like this:
Can't locate argument-less serializer for class Pu…h as lists, please provide serializer explicitly.
(There is an issue on GH related to this https://github.com/Kotlin/kotlinx.serialization/issues/278)
Thanks for any help
Okay, I think I managed to make it work.
Here are the steps as I remember them:
as suggested in https://youtrack.jetbrains.com/issue/CRKA-84, did npm eject and added plugin: require.resolve('kotlin-compiler/lib/kotlinx-serialization-compiler-plugin.jar'), to webpack-kotlin-*.js files (after new KotlinWebpackPlugin).
downloaded the compiled runtime from maven (https://dl.bintray.com/kotlin/kotlinx/org/jetbrains/kotlinx/kotlinx-serialization-runtime-js/0.9.0/) and unpacked it to node-modules/kotlinx-serialization-runtime-js
hacked kotlin-compiler.js by adding the library path (there must be a better way!):
options.libraries.join(isWindows ? ';' : ':') + ":<absolute_path_to_project>/node_modules/kotlinx-serialization-runtime-js/kotlinx-serialization-runtime-js.meta.js"
copied kotlinx-serialization-runtime-js.js and kotlinx-serialization-runtime-js.js.map to node-modules/.cache/kotlin-webpack.
After this yarn start appears to be able to compile some test code that uses kotlinx-serialization, however, Idea fails to find where kotlinx.serialization module comes from.
I hope this answer inspires someone who is willing to reverse-engieer this build system to make a better fix.

Visual Studio Code not performing error checking in Javascript

I've tried following these instructions:
https://code.visualstudio.com/Docs/runtimes/nodejs
I am not getting the green/red swiggly lines at all. Is there something I'm missing?
You can also see the same thing in this video:
https://youtu.be/sE8_bTEBlFg?t=1m37s
As far as I know, they're running the default editor. I've tried installing typings and typescript using npm. I've Followed that tutorial to get Javascript intellisense for node.js, but I fail to get either error/warning checking or any type information for node.js modules.
Is there a location the type files should be installed to in order to make them global to every JS project you create in VS Code?
OK, so I managed get get some code suggestions working after reading up online. Without using the whole Typings tools, I acquired node.d.ts (found it on my computer inside C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions) and placed that in my project's directory structure inside the ".vscode" folder. At the top of my .js file I added the following line:
/// <reference path=".vscode/node.d.ts" />
The code seems to be recognized now.
I read up on this tip here: How to Import Intellisense files into vsCode (Visual Studio Code)
If you are using ESLint and you have an .eslint.js file in the project root you also need the eslint dependency installed in the project. Otherwise, if there is a .eslint.js file but the ESLint dependency is not installed Visual Studio Code will report nothing in the editor.
Maybe you didn't use the -g flag to install them globally? Alternately, perhaps it's a missing jsconfig.json file?

Installing gifify on Windows

So gifify is a pretty awesome script that converts videos to gifs via command line: https://github.com/vvo/gifify
I'm keen to get this working on my Windows 10 machine. I'm pretty new to windows and relatively new to coding, but I was able to get a few things working, but ran into a problem.
Here is what I did:
Installed node.js + npm
Installed FFmpeg using npm
Installed ImageMagick using npm (i think i did this wrong, might have only installed the wrapper).
Downloaded giflossy. It needed to be built (?)
Installed Visual Studio 2015, tried to build it using nmake and got this error:
NMAKE : fatal error U1073: don't know how to make 'win32cfg.h'
The command I used was:
PS C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin> .\nmake -f "C:\Users\Robert's Workstation\.npm-global\node_modules\giflossy-lossy-1.82.1\src\Makefile.w32"
Would really appreciate some help with this :D
I think I f***ing did it!
I spent two hours wildly downloading binaries, googling like crazy and adding a quantum tonne of environment variables to the PATH, but I did it. Here's how:
ffmpeg: http://ffmpeg.zeranoe.com/builds/. Download the binaries, place them in your Programs folder (or anywhere), copy the path and add it to your PATH environment variable
Gifsickle with lossy. I tried to compile the source from GitHub, but both makefiles threw an error (I did not investigate that any further). Instead, I searched for an already compiled binary on the web (risky) and found: https://encode.ru/threads/2481-How-to-compile-giflossy. You need 7zip to extract the binaries, but once you've done this, place them in your Programs Folder, add the path to the binaries to your PATH environment variable and you're set.
ImageMagick with convert: https://www.imagemagick.org/script/download.php#windows
Make sure to check the following options:
This should add the ImageMagick binaries to the PATH env vars for you.
Battle any '[x] is not recognised as blah' errors with locating the binary and adding its path to the PATH env variable.
If there's only the source available and you have to compile it by yourself, search for compiled binaries online.

Yeoman angular-feature generator cdnify task not found

I've been looking for some automatic way to generate an angular app. I tried to use the angular generator on YEOMAN, but I didn't like the app structure provided.
I found out this other generator angular-feature(https://github.com/codigo-pl/generator-angular-feature) which seems to solve my problem. But so far I could not make it works. Every time when I try to generate the app(on feature structure) returns me an error:
command: grunt build (even if I try grunt server returns me the same)
C:\Users\xxxxxx\WorkFolders\temp\testGenerator>grunt build Loading
"cdnify.js" tasks...ERROR
Error: Unable to parse C:\Users\xxxxxx\WorkFolders\temp\testGenerator .bowerrc:
Unexpected token v Warning: Task "cdnify" not found. Use --force to
continue.
Aborted due to warnings.
UPDATE:
Inside the file .bowerrc:
{
"directory": "app\vendor/bower_components"
}
My folder after running generator:
testGenerator
--app
----src
------common
--node_modules
There's no bower_components folder in any place in my APP folder.
Has anyone already used this YEOMAN generator and had the same problem?
Is there another YEOMAN generator structured by feature like this one?
Try this command in your project to fix the issue.
npm install --save-dev grunt-google-cdn
I am really not sure why this isn't documented officially anywhere nor why the default Yeoman project generation script builds with errors. I had to execute searches to find out about this command.
Also, make sure you are using a stable version of Node/npm. One of my problems was that I was using the latest version of npm, which is 0.11.12. However, according to Node.js's website, that version is unstable. Instead, I had to use version 0.10.26, their latest stable version.
Links:
https://github.com/yeoman/generator-angular/issues/12
https://groups.google.com/forum/#!topic/yeoman-dev/3LFTPpqRInU
the problem was sorted out and it was facing me all the time.
Problem
{
"directory": "app\vendor/bower_components"
}
Solution
{
"directory": "app/vendor/bower_components"
}
The generator is generating backslash instead slash. But the strange thing it seems be happening only on windows. Ubuntu and Mavericks I don't have this problem.

Chrome V8 errors

I'm trying to build the Chrome V8 javascript engine so I can embed it into my c++ project. I'm following the tutorial here. I downloaded everything that was needed and managed to get the project solution created but when I compile it only 5 of the 12 solutions get compiled correctly. Can someone shed some light on my problem? There doesn't seem to be much info on the web about it.
Some tricks I learned are this:
use the correct gyp command that will generate correct sln files. maybe target architecture argument was wrong or some other parameter you supply to gyp.
I do not know how to properly "clean" the source tree, so if I wanted new options to gyp I just delete the whole source tree and unpack from original archive. (or use svn).
Make sure you use python and cygwin supplied with v8 sources.
I used pc emulator (qemu) to install Windows XP + Visual studio and v8 sources+tools.
I tried various versions of Visual Studio only VS Express 2010 worked.
On linux everything is simpler. And you do not even need to build it, just use "aptitude install v8-dev"

Categories