Skip to content

Commit 6e20771

Browse files
authored
Merge pull request #130 from UrielCh/C++17
- use C++17 flag - fix support for openCV 4.7.0, 4.8.0, 4.9.0
2 parents f38f701 + c3a7319 commit 6e20771

File tree

85 files changed

+674
-806
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+674
-806
lines changed

.eslintrc

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
{
2+
"parser": "@typescript-eslint/parser",
3+
// "parserOptions": {
4+
// "ecmaVersion": 2018,
5+
// "sourceType": "module",
6+
// "ecmaFeatures": {
7+
// "jsx": true
8+
// },
9+
// "project": "./tsconfig.json"
10+
// },
211
"ignorePatterns": [ "**/*.js" ],
312
"root": true,
4-
"parser": "@typescript-eslint/parser",
513
"plugins": [
614
"@typescript-eslint"
715
],
@@ -18,9 +26,17 @@
1826
"no-nested-ternary": 0,
1927
"no-async-promise-executor": 0,
2028
"radix": 0
29+
// unit tests only
30+
// "max-len" : 0,
31+
// "no-new" : 0,
32+
// "no-unused-expressions": 0,
33+
// "prefer-spread": 0,
34+
// "@typescript-eslint/ban-ts-comment": 0,
35+
// "@typescript-eslint/no-explicit-any": 0
2136
},
2237
"env": {
2338
"es6": true,
2439
"node": true
40+
// "mocha": true
2541
}
2642
}

.github/workflows/prebuild.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ jobs:
4444
strategy:
4545
matrix:
4646
opencv_version:
47-
# - 4.7.0 not available yet
47+
- 4.9.0
48+
- 4.8.0
49+
- 4.7.0
4850
- 4.6.0
49-
- 4.5.5 # 2019-12-23 ubuntu 22.04
50-
- 4.5.1 # raspberry Pi version
51+
# - 4.5.5 # 2019-12-23 ubuntu 22.04
52+
###- 4.5.1 # raspberry Pi version
5153
# - 4.2.0 # 2019-12-23 ubuntu 20.04
5254
# - 3.4.16
5355
node_version:

bin/install.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/usr/bin/env node
22
const compileLib = require("../install/compileLib.js");
3-
compileLib.compileLib(process.argv);
3+
const {argv} = process;
4+
compileLib.compileLib(argv);

binding.gyp

+5-5
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,15 @@
120120
"cc/highgui/highgui.cc",
121121
"cc/highgui/highguiConstants.cc",
122122
],
123-
124123
"cflags" : [
125-
"-std=c++14"
124+
"-std=c++17"
126125
],
127126
"cflags!" : [
127+
"-std=c++17",
128128
"-fno-exceptions"
129129
],
130130
"cflags_cc!": [
131+
"-std=c++17",
131132
"-fno-rtti",
132133
"-fno-exceptions"
133134
],
@@ -136,7 +137,7 @@
136137
],
137138
"xcode_settings": {
138139
"OTHER_CFLAGS": [
139-
"-std=c++14",
140+
"-std=c++17",
140141
"-stdlib=libc++"
141142
],
142143
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
@@ -175,7 +176,6 @@
175176
"cflags": ["--coverage"],
176177
"ldflags": ["--coverage"]
177178
},
178-
}
179-
179+
}
180180
}]
181181
}

install/compileLib.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ or use OPENCV4NODEJS_* env variable.`);
333333
`CV_VERSION_REVISION=${cvVersion[2]}`,
334334
...OPENCV4NODEJS_DEFINES
335335
],
336-
"cStandard": "c11",
337-
"cppStandard": "c++11",
336+
"cStandard": "c17",
337+
"cppStandard": "c++17",
338338
// "compilerArgs": [ "-std=c++11" ]
339339
};
340340
if (process.platform === 'win32') {
@@ -361,6 +361,10 @@ or use OPENCV4NODEJS_* env variable.`);
361361
console.log('');
362362
}
363363
else {
364+
// for (const key in process.env) {
365+
// if (key.startsWith('OPENCV'))
366+
// console.log(`export ${key}=${process.env[key]}`);
367+
// }
364368
const child = child_process.exec(nodegypCmd, { maxBuffer: Infinity, cwd }, function (error /*, stdout, stderr*/) {
365369
// fs.unlinkSync(realGyp);
366370
const bin = buildOptions.extra.electron ? 'electron-rebuild' : 'node-gyp';

install/compileLib.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@ or use OPENCV4NODEJS_* env variable.`)
360360
`CV_VERSION_MINOR=${cvVersion[1]}`,
361361
`CV_VERSION_REVISION=${cvVersion[2]}`,
362362
...OPENCV4NODEJS_DEFINES],
363-
"cStandard": "c11",
364-
"cppStandard": "c++11",
363+
"cStandard": "c17",
364+
"cppStandard": "c++17",
365365
// "compilerArgs": [ "-std=c++11" ]
366366
}
367367
if (process.platform === 'win32') {
@@ -386,6 +386,10 @@ or use OPENCV4NODEJS_* env variable.`)
386386
console.log(nodegypCmd);
387387
console.log('');
388388
} else {
389+
// for (const key in process.env) {
390+
// if (key.startsWith('OPENCV'))
391+
// console.log(`export ${key}=${process.env[key]}`);
392+
// }
389393
const child = child_process.exec(nodegypCmd, { maxBuffer: Infinity, cwd }, function (error/*, stdout, stderr*/) {
390394
// fs.unlinkSync(realGyp);
391395
const bin = buildOptions.extra.electron ? 'electron-rebuild' : 'node-gyp';

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
"build": "tsc --pretty --project .",
4040
"prepack": "npm run build",
4141
"install": "node bin/install.js auto",
42-
"install_Mac": "CXXFLAGS=\"-std=c++14 -Wno-c++11-narrowing -Wno-c++17-extensions -Wno-c++17-attribute-extensions\" node ./bin/install.js --version 4.5.3 build",
42+
"install_Mac": "CXXFLAGS=\"-std=c++17 -Wno-c++11-narrowing -Wno-c++17-extensions -Wno-c++17-attribute-extensions\" node ./bin/install.js --version 4.5.3 build",
4343
"install_default": "node bin/install.js rebuild",
4444
"install_ubuntu": "echo call: sudo apt install libopencv-dev; build-opencv --incDir /usr/include/opencv4/ --libDir /lib/x86_64-linux-gnu/ --binDir=/usr/bin/ --nobuild rebuild",
45-
"install_macm1": "node bin/install.js --version 4.5.4 --flag=\"-DCMAKE_SYSTEM_PROCESSOR=arm64 -DCMAKE_OSX_ARCHITECTURES=arm64 -DWITH_FFMPEG=ON\" rebuild",
45+
"install_macm1": "node bin/install.js --version 4.6.0 --flag=\"-DCMAKE_SYSTEM_PROCESSOR=arm64 -DCMAKE_OSX_ARCHITECTURES=arm64 -DWITH_FFMPEG=ON\" rebuild",
4646
"install_cuda": "cross-env OPENCV4NODEJS_DISABLE_AUTOBUILD= node bin/install.js --version 4.6.0 --flags=\"-DWITH_CUDA=ON -DWITH_CUDNN=ON -DOPENCV_DNN_CUDA=ON -DCUDA_FAST_MATH=ON -DWITH_FFMPEG=ON\" rebuild",
4747
"install_4_6_0_cuda_30XX": "cross-env OPENCV4NODEJS_DISABLE_AUTOBUILD= node bin/install.js --keepsource --version 4.6.0 --cuda --cudaArch=8.6 rebuild",
4848
"test": "cd test && pnpm install && pnpm run test",
@@ -55,9 +55,9 @@
5555
"build-debug": "npm run build && BINDINGS_DEBUG=true node bin/install.js rebuild"
5656
},
5757
"dependencies": {
58-
"@u4/opencv-build": "0.7.8",
58+
"@u4/opencv-build": "^0.8.3",
5959
"@u4/tiny-glob": "^0.3.2",
60-
"nan": "^2.18.0",
60+
"nan": "^2.19.0",
6161
"node-gyp": "^10.0.1",
6262
"npmlog": "^7.0.1",
6363
"picocolors": "^1.0.0"

pnpm-lock.yaml

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/.eslintrc

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
{
2-
"extends": ["eslint:recommended", "airbnb"],
2+
"parser": "@typescript-eslint/parser",
3+
"parserOptions": {
4+
"ecmaVersion": 2018,
5+
"sourceType": "module",
6+
"ecmaFeatures": {
7+
"jsx": true
8+
},
9+
"project": "./tsconfig.json"
10+
},
11+
"plugins": [
12+
"@typescript-eslint"
13+
],
14+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended"],
315
"rules": {
416
"linebreak-style": 0,
517
"comma-dangle": ["error", "always-multiline"],
@@ -12,13 +24,13 @@
1224
"no-underscore-dangle": 0,
1325
"no-nested-ternary": 0,
1426
"radix": 0,
15-
1627
// unit tests only
1728
"max-len" : 0,
1829
"no-new" : 0,
1930
"no-unused-expressions": 0,
20-
"prefer-spread": 0
21-
31+
"prefer-spread": 0,
32+
"@typescript-eslint/ban-ts-comment": 0,
33+
"@typescript-eslint/no-explicit-any": 0
2234
},
2335
"env": {
2436
"es6": true,

test/externalMemTracking/defaultDisabled.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { expect } from 'chai';
22
import cv from '@u4/opencv4nodejs';
3-
import { TestContext } from '../tests/model';
3+
import { getTestContext } from '../tests/model';
44

5-
const ctxt = new TestContext(cv);
5+
const ctxt = getTestContext();
66

77
describe('External Memory Tracking', () => {
88
it('should be enabled (opencv 3.1.0+)/ disabled(opencv 3.0.0) by default', () => {

test/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
"name": "opencv4nodejs_test",
33
"version": "1.1.0",
44
"scripts": {
5-
"test": "mocha -r ts-node/register --timeout 30000 ./tests/index.test.ts",
5+
"test": "mocha -r ts-node/register --timeout 30000 ./tests/**/*.test.ts",
66
"test2": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'tests/**/*.test.ts'",
77
"test3": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'tests/**/simple.test.ts'",
8+
"testIO": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'tests/io/**/*.ts'",
9+
"testIOIO": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'tests/io/io.test.ts'",
10+
"testCore": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'tests/core/core.test.ts'",
811
"test-appveyor": "set APPVEYOR_BUILD=true && mocha -r ts-node/register --timeout 30000 ./tests/index.test.ts",
912
"test-docker": "DOCKER_BUILD=true mocha -r ts-node/register --timeout 60000 ./tests/index.test.ts",
1013
"test-externalMemTrackingOther": "mocha -r ts-node/register --timeout 30000 ./externalMemTracking/other/index.test.ts",

test/pnpm-lock.yaml

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/tests/calib3d/MatCalib3dTests.ts test/tests/calib3d/MatCalib3d.test.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ import { expect } from 'chai';
22
import {
33
CalibrationMatrixValues, CorrectMatchesRet, DecomposeEssentialMatRet, DecomposeHomographyMatRet, DecomposeProjectionMatrixRet, Mat, OptimalNewCameraMatrix, RqDecomp3x3Ret, StereoRectify, Vec3,
44
} from '@u4/opencv4nodejs';
5-
import { TestContext } from '../model';
5+
import { getTestContext } from '../model';
66
import { assertMetaData } from '../../utils/matTestUtils';
77
import { expectToBeVec2, expectToBeVec3, expectToBeVec4 } from '../../utils/testUtils';
88
import { generateAPITests } from '../../utils/generateAPITests';
9+
import toTest from '../toTest';
910

10-
export default (args: TestContext) => {
11+
if (toTest.calib3d) {
1112
const {
1213
cv,
1314
cvVersionLowerThan,
1415
cvVersionGreaterEqual,
15-
} = args;
16+
} = getTestContext();
1617

1718
const imagePoints = [
1819
new cv.Point2(0, 0),
@@ -133,7 +134,7 @@ export default (args: TestContext) => {
133134

134135
describe('drawChessboardCorners', () => {
135136
const expectOutput = () => {
136-
// expect not to throw
137+
// expect not to throw
137138
};
138139

139140
const patternSize = new cv.Size(2, 2);
@@ -161,7 +162,7 @@ export default (args: TestContext) => {
161162
describe('find4QuadCornerSubpix', () => {
162163
const img = new cv.Mat(200, 200, cv.CV_8U, 0);
163164
const expectOutput = () => {
164-
// expect not to throw
165+
// expect not to throw
165166
};
166167

167168
const regionSize = new cv.Size(2, 2);
@@ -381,7 +382,7 @@ export default (args: TestContext) => {
381382

382383
describe('filterSpeckles', () => {
383384
const expectOutput = () => {
384-
// expect not to throw
385+
// expect not to throw
385386
};
386387
const newVal = 1.0;
387388
const maxSpeckleSize = 10;
@@ -402,7 +403,7 @@ export default (args: TestContext) => {
402403

403404
describe('validateDisparity', () => {
404405
const expectOutput = () => {
405-
// expect not to throw
406+
// expect not to throw
406407
};
407408
const cost = new cv.Mat(10, 10, cv.CV_16S, 0);
408409
const minDisparity = 1;
@@ -539,4 +540,4 @@ export default (args: TestContext) => {
539540
});
540541
});
541542
}
542-
};
543+
}

test/tests/calib3d/calib3dTests.ts test/tests/calib3d/calib3d.test.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import {
55
import { generateAPITests } from '../../utils/generateAPITests';
66
import { assertMetaData } from '../../utils/matTestUtils';
77
import { assertPropsWithValue, expectToBeVec3 } from '../../utils/testUtils';
8-
import { TestContext } from '../model';
8+
import { getTestContext } from '../model';
9+
import toTest from '../toTest';
910

10-
const CV_CALIB_USE_INTRINSIC_GUESS = 1;
11+
if (toTest.calib3d) {
12+
const CV_CALIB_USE_INTRINSIC_GUESS = 1;
1113

12-
export default (args: TestContext) => {
13-
const { cv, cvVersionGreaterEqual } = args;
14+
const { cv, cvVersionGreaterEqual } = getTestContext();
1415

1516
const objectPoints = [
1617
new cv.Point3(0, 0, 0),
@@ -256,7 +257,7 @@ export default (args: TestContext) => {
256257
distCoefficients,
257258
];
258259
// openCV3 only
259-
const getOptionalParamsMap = (): Array<[string, any]> => ([
260+
const getOptionalParamsMap = (): Array<[string, unknown]> => ([
260261
['flags', CV_CALIB_USE_INTRINSIC_GUESS as number],
261262
['termCriteria', new cv.TermCriteria()],
262263
]);
@@ -538,7 +539,7 @@ export default (args: TestContext) => {
538539
imagePoints,
539540
imagePoints,
540541
]);
541-
const getOptionalParamsMap = (): Array<[string, any]> => ([
542+
const getOptionalParamsMap = (): Array<[string, number]> => ([
542543
['method', cv.LMEDS],
543544
['ransacReprojThreshold', 1.0],
544545
['maxIters', 1000],
@@ -599,4 +600,4 @@ export default (args: TestContext) => {
599600
});
600601
});
601602
}
602-
};
603+
}

test/tests/calib3d/index.ts

-8
This file was deleted.

0 commit comments

Comments
 (0)