{"library":"opencv-build","title":"OpenCV Build Script for Node.js","description":"opencv-build is an npm package designed to automate the compilation of the native OpenCV library, including its `contrib` modules, from source code. It primarily serves as a crucial build dependency for Node.js projects that integrate with OpenCV, most notably `opencv4nodejs`. This package abstracts away the complex, platform-specific steps of fetching OpenCV source, configuring the build with CMake, and compiling the binaries, which is vital for enabling computer vision capabilities in Node.js applications across different operating systems. While the specific version `0.1.9` is older, the underlying build automation approach is still actively maintained and evolved, often through similar packages like `@u4/opencv-build` for current `opencv4nodejs` versions. Its key differentiator is providing a configurable, automated native build process for a significant external dependency, streamlining development workflows by minimizing manual native compilation efforts and ensuring compatibility with the Node.js runtime. Releases are typically tied to the needs of `opencv4nodejs` and OpenCV's own release cycle, without a strict independent cadence.","language":"javascript","status":"maintenance","last_verified":"Sun Apr 19","install":{"commands":["npm install opencv-build"],"cli":null},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"{\n  \"name\": \"my-opencv-project\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Example project using opencv4nodejs with custom build flags\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"start\": \"node index.js\"\n  },\n  \"dependencies\": {\n    \"opencv4nodejs\": \"^7.0.0\",\n    \"opencv-build\": \"^0.1.9\" \n  },\n  \"opencv4nodejs\": {\n    \"autoBuildFlags\": \"-DOPENCV_GENERATE_PKGCONFIG=ON -DOPENCV_PC_FILE_NAME=opencv.pc -DBUILD_EXAMPLES=OFF\",\n    \"autoBuildOpencvVersion\": \"4.5.5\",\n    \"autoBuildWithoutContrib\": false,\n    \"autoBuildBuildCuda\": false\n  },\n  \"keywords\": [],\n  \"author\": \"\",\n  \"license\": \"MIT\"\n}\n// In index.js (demonstrates opencv4nodejs usage, not opencv-build directly)\nconst cv = require('opencv4nodejs');\n\nasync function runOpenCV() {\n  // Ensure OpenCV is built by opencv-build when opencv4nodejs is installed\n  console.log('OpenCV version:', cv.version);\n\n  const mat = new cv.Mat(100, 100, cv.CV_8UC3, [0, 0, 0]); // Black image\n  mat.drawCircle(new cv.Point(50, 50), 20, new cv.Vec(0, 255, 0), -1); // Green circle\n\n  cv.imshowWait('Image', mat);\n  cv.destroyAllWindows();\n  console.log('Image displayed and closed.');\n}\n\nrunOpenCV().catch(err => console.error(err));","lang":"javascript","description":"This quickstart demonstrates how to configure `opencv-build` via the `package.json` for an `opencv4nodejs` project, enabling custom OpenCV versions and build flags. `opencv-build` executes during `npm install` of `opencv4nodejs`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}