Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@u4/opencv-build
Advanced tools
A simple script to auto build recent OpenCV + contrib version via npm 2022 Edition
A simple script to auto build recent OpenCV + contrib version via npm. This script is used to auto build opencv4nodejs.
./bin/main.js
or it's alias opencv-build-npm
and accepting parametes see opencv-build-npm --help
new OpenCVBuilder({autoBuildOpencvVersion: "3.4.16", autoBuildBuildCuda: true, autoBuildWithoutContrib: false }).install()
OPENCV_BUILD_ROOT
environement variable.Each OpenCV build will take around 2Gb on your drive, so I recommand you to define the OPENCV_BUILD_ROOT
environement variable to avoid duplicate buildsand avoid node_modules auto flushs.
npm install opencv-build
npm-opencv-build usage:
--version <value> OpenCV version (OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION env variable)
--flags <value> OpenCV cMake Build flags (OPENCV4NODEJS_AUTOBUILD_FLAGS env variable)
--root <value> OpenCV-build root directory (deprecated) (INIT_CWD env variable)
--buildRoot <value> OpenCV build directory (OPENCV_BUILD_ROOT env variable)
--cuda Enable cuda in OpenCV build (OPENCV4NODEJS_BUILD_CUDA env variable)
--nocontrib Do not compile Contrib modules (OPENCV4NODEJS_AUTOBUILD_WITHOUT_CONTRIB env variable)
--nobuild Do build OpenCV (OPENCV4NODEJS_DISABLE_AUTOBUILD env variable)
--incDir <value> OpenCV include directory (OPENCV_INCLUDE_DIR env variable)
--libDir <value> OpenCV library directory (OPENCV_LIB_DIR env variable)
--binDir <value> OpenCV bin directory (OPENCV_BIN_DIR env variable)
--keepsources Keepsources OpenCV source after build
for nodejs <= 12
npm install --global windows-build-tools
It's possible to specify build environment variables by passing argument to the builder script
node lib/main.js --version 4.5.4 --buildRoot ~/openCV
with flags, do not forget the quotes "
node lib/main.js --version 4.5.4 --buildRoot ~/openCV --flags "-DOPENCV_GENERATE_PKGCONFIG=ON -DOPENCV_PC_FILE_NAME=opencv.pc"
Using the bin alias
opencv-build-npm --version 4.5.5
Or by inserting them into the package.json
where the dependency is declared an object like:
{
"opencv4nodejs": {
"autoBuildFlags": "-DOPENCV_GENERATE_PKGCONFIG=ON -DOPENCV_PC_FILE_NAME=opencv.pc",
"autoBuildOpencvVersion": "4.5.4"
}
}
By using environement varaibles.
export OPENCV4NODEJS_AUTOBUILD_FLAGS="-DOPENCV_GENERATE_PKGCONFIG=ON -DOPENCV_PC_FILE_NAME=opencv.pc"
export OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION="4.5.4"
export OPENCV_BUILD_ROOT="~/openCV"
node build/main.js
the prebuild
is a smart version selector, to avoid futher re-compilation, accepted values are:
"latestBuild"
use the last built version"latestVersion"
use the highest version number built"oldestBuild"
use the olderst built version"oldestVersion"
use the lowest version number builtthe prebuild
option intend to be use at runtime, so you do not have to keep trak of the version you want to use.
this parameter can only be provide in OpenCVBuildEnv
constructor options.
Choose the openCV version you want to build, default is 3.4.6,
This option value can be provide using:
--version
in build scriptautoBuildOpencvVersion
options field provided to OpenCVBuildEnv
constructor options.autoBuildOpencvVersion
field in the current package.json opencv4nodejs
object.OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION
environement variable.The buildRoot
is a the directory used to build openCV, Default value is the npm-opencv-build directory.
You may want to use this value to persist your files out of your node_modules
directory.
This option value can be provide using:
--buildRoot
in build scriptbuildRoot
options field provided to OpenCVBuildEnv
constructor options.OPENCV_BUILD_ROOT
environement variable.Set any value to enable, the following cMake flag will be added:
This option value can be enable using:
--cuda
in build scriptautoBuildBuildCuda
options field provided to OpenCVBuildEnv
constructor options.autoBuildBuildCuda
field in the current package.json opencv4nodejs
object.OPENCV4NODEJS_BUILD_CUDA
environement variable.Append option to CMake flags.
This option value can be enable using:
--flags
in build scriptautoBuildFlags
options field provided to OpenCVBuildEnv
constructor options.autoBuildFlags
field in the current package.json opencv4nodejs
object.OPENCV4NODEJS_AUTOBUILD_FLAGS
environement variable.Set any value to enable, this option will skip openCV Contribs.
This option value can be enable using:
--nocontrib
in build scriptautoBuildWithoutContrib
options field provided to OpenCVBuildEnv
constructor options.autoBuildWithoutContrib
field in the current package.json opencv4nodejs
object.OPENCV4NODEJS_AUTOBUILD_WITHOUT_CONTRIB
environement variable.Set any value to disable compilation from sources.
This option value can be enable using:
--nobuild
in build scriptdisableAutoBuild
options field provided to OpenCVBuildEnv
constructor options.disableAutoBuild
field in the current package.json opencv4nodejs
object.OPENCV4NODEJS_DISABLE_AUTOBUILD
environement variable.Can be set using the environment variables OPENCV4NODEJS_DISABLE_AUTOBUILD
Over write the OPENCV_INCLUDE_DIR environment variables
Over write the OPENCV_LIB_DIR environment variables
Over write the OPENCV_BIN_DIR environment variables
opencv-build-npm --flags="-DBUILD_LIST=core,imgproc,imgcodecs,videoio,highgui,video,calib3d,features2d,objdetect,dnn,ml,flann,photo,stitching,gapi" --version=3.4.15 --nocontrib
opencv-build-npm --version=4.5.4 --nocontrib
FAQs
Script to auto build recent OpenCV + contrib via npm 2024 Edition
The npm package @u4/opencv-build receives a total of 539 weekly downloads. As such, @u4/opencv-build popularity was classified as not popular.
We found that @u4/opencv-build demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.