Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

opencv-build

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opencv-build - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

2

package.json
{
"name": "opencv-build",
"version": "0.1.0",
"version": "0.1.1",
"description": "A simple script to auto build recent OpenCV + contrib version via npm",

@@ -5,0 +5,0 @@ "main": "./build/index.js",

@@ -13,2 +13,6 @@ import * as fs from 'fs';

export function buildWithCuda() : boolean {
return !!process.env.OPENCV4NODEJS_BUILD_CUDA || false;
}
export function isWithoutContrib() {

@@ -15,0 +19,0 @@ return !!process.env.OPENCV4NODEJS_AUTOBUILD_WITHOUT_CONTRIB

@@ -6,6 +6,6 @@ import * as fs from 'fs';

import { dirs } from './dirs';
import { autoBuildFlags, numberOfCoresAvailable, opencvVersion, parseAutoBuildFlags, isWithoutContrib } from './env';
import { autoBuildFlags, numberOfCoresAvailable, opencvVersion, parseAutoBuildFlags, isWithoutContrib, buildWithCuda } from './env';
import { findMsBuild } from './findMsBuild';
import { AutoBuildFile } from './types';
import { exec, isWin, spawn } from './utils';
import { exec, isWin, spawn, isCudaAvailable } from './utils';

@@ -48,2 +48,11 @@ const log = require('npmlog')

function getCudaCmakeFlags() {
return [
'-DWITH_CUDA=ON',
'-DBUILD_opencv_cudacodec=OFF', // video codec (NVCUVID) is deprecated in cuda 10, so don't add it
'-DCUDA_FAST_MATH=ON', // optional
'-DWITH_CUBLAS=ON', // optional
];
}
function getSharedCmakeFlags() {

@@ -56,2 +65,8 @@ const conditionalFlags = isWithoutContrib()

]
if (buildWithCuda() && isCudaAvailable()) {
log.info('install', 'Adding CUDA flags...');
conditionalFlags.concat(getCudaCmakeFlags());
}
return defaultCmakeFlags

@@ -101,7 +116,10 @@ .concat(conditionalFlags)

export async function setupOpencv() {
const msbuild = await getMsbuildIfWin()
// Get cmake flags here to check for CUDA early on instead of the start of the building process
const cMakeFlags = isWin() ? getWinCmakeFlags(msbuild.version) : getSharedCmakeFlags();
const tag = opencvVersion()
log.info('install', 'installing opencv version %s into directory: %s', tag, dirs.opencvRoot)
const msbuild = await getMsbuildIfWin()
await exec(getMkDirCmd('opencv'), { cwd: dirs.rootDir })

@@ -120,3 +138,3 @@ await exec(getRmDirCmd('build'), { cwd: dirs.opencvRoot })

await spawn('cmake', getCmakeArgs(isWin() ? getWinCmakeFlags(msbuild.version) : getSharedCmakeFlags()), { cwd: dirs.opencvBuild })
await spawn('cmake', getCmakeArgs(cMakeFlags), { cwd: dirs.opencvBuild })
await getRunBuildCmd(isWin() ? msbuild.path : undefined)()

@@ -123,0 +141,0 @@

import * as child_process from 'child_process';
import * as fs from 'fs';
import * as path from 'path';

@@ -80,1 +82,29 @@ const log = require('npmlog')

}
export async function isCudaAvailable() {
log.info('install', 'Check if CUDA is available & what version...');
if (isWin()) {
try {
await requireCmd('nvcc --version', 'CUDA availability check');
return true;
} catch (err) {
log.info('install', 'Seems like CUDA is not installed.');
return false;
}
}
// Because NVCC is not installed by default & requires an extra install step,
// this is work around that always works
const cudaVersionFilePath = path.resolve('/usr/local/cuda/version.txt');
if (fs.existsSync(cudaVersionFilePath)) {
const content = fs.readFileSync(cudaVersionFilePath, 'utf8');
log.info('install', content);
return true;
} else {
log.info('install', 'CUDA version file could not be found.');
return false;
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc