This document will get you started with all npm
modules residing in this repository. You will be able to build all Node.js
module/add-on on top of your Linux
PC or IoT
board, and then make your customization to the C++ add-on(s).
Make sure you've done all the necessary steps described in Setup Environment, to get your hardware and software environment ready.
There is 4 Node.js
C++ add-ons in this repository. Node.js
C++ add-on is supposed to be built by node-gyp
, which should be ready installed in Setup Environment.
Choose the add-on that you want to work on, by typing: cd src/<add-on directory>
, e.g. taking Person Library
as an example:
cd src/person-tracking
And then key in
npm install
node-gyp rebuild
to build the add-on. You might see several lines of message. The build is successful if it ends with the following lines.
make: Leaving directory '<your local dir>/src/person-tracking/build'
gyp info ok
After building it, it's time to test it in your Node.js
program. Unlike the standard npm install <module-name>
way of using a module/add-on, you need to explicitly specify the directory in your Node.js
program, e.g.
// Node.js program
const personLibrary = require('</path/to/your/code>/src/person-tracking');
To debug the C++ add-on, the add-on should be built with debug symbols:
node-gyp rebuild --debug
After a successful debug build, you can use gdb
or other debugger to debug the C++ source code, e.g.
gdb --args node <your-program>.js
mocha
is the framework for unit testing, simply key in the following command to run the unit test.
mocha
Then the test will be started and test report will be printed in terminal.
To specify a test suite to run, key in the following command:
mocha test/<file-name>.js
The API of each C++ add-on is defined by WebIDL
language and then language bindings will be generated using WIDL-NAN
.
To change API definition, go to src/idl
directory and choose a file to modify, and then implement the change in C++ source code. Run node-gyp build
in your terminal to see if it builds.
Checkout WIDL-NAN
Wiki for the design and usage of the WIDL-NAN
language binding tool.
After making your change, you might wat to contribute the change into our repo. Pleaes refer to Contribution Guide for more information.
- You might want to read the Best Known Methods (BKM) document to addressing known issues.
- Current API definition is described in specification.
-
rs::error
withwhat(): uvcvideo kernel module is not loaded
The uvcvideo module needed to be loaded into the kernal.
sudo modprobe uvcvideo
-
Error message says missing
boostXXX
file during building process Need to install used libboost library as the following line.sudo apt-get install libboost-thread-dev