Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cc/core/coreUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
Nan::SetPrototypeMethod(ctor, "bitwiseXor", BitwiseXor); \
Nan::SetPrototypeMethod(ctor, "abs", Abs); \
Nan::SetPrototypeMethod(ctor, "transpose", Transpose); \
Nan::SetPrototypeMethod(ctor, "inv", Inv); \
Nan::SetPrototypeMethod(ctor, "determinant", Determinant);\
Nan::SetPrototypeMethod(ctor, "matMul", MatMul);

Expand Down Expand Up @@ -157,6 +158,9 @@
static NAN_METHOD(Transpose) { \
FF_SELF_OPERATOR(cv::transpose); \
} \
static NAN_METHOD(Inv) { \
FF_SELF_OPERATOR(cv::invert); \
} \
static NAN_METHOD(MatMul) { \
FF_OPERATOR(*, FF_APPLY_OPERATOR, Mat, "MatMul"); \
}
Expand Down
1 change: 1 addition & 0 deletions lib/typings/Mat.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export class Mat {
inRangeAsync(lower: Vec3, upper: Vec3): Promise<Mat>;
integral(sdepth?: number, sqdepth?: number): { sum: Mat, sqsum: Mat, tilted: Mat };
integralAsync(sdepth?: number, sqdepth?: number): Promise<{ sum: Mat, sqsum: Mat, tilted: Mat }>;
inv(): Mat;
laplacian(ddepth: number, ksize?: number, scale?: number, delta?: number, borderType?: number): Mat;
laplacianAsync(ddepth: number, ksize?: number, scale?: number, delta?: number, borderType?: number): Promise<Mat>;
matMul(B: Mat): Mat;
Expand Down
19 changes: 19 additions & 0 deletions test/tests/core/Mat/operatorTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = function ({ cv, utils }) {
const {
assertError,
assertDataDeepEquals,
assertDataAlmostDeepEquals,
assertMetaData
} = utils;

Expand Down Expand Up @@ -353,7 +354,25 @@ module.exports = function ({ cv, utils }) {
assertDataDeepEquals(res.getDataAsArray(), expectedResult);
});
});

describe('inv', () => {
it('apply inverse to matrix', () => {
const mat0 = new cv.Mat([
[4, 7],
[2, 6]
], cv.CV_32F);
const expectedResult = [
[0.6, -0.7],
[-0.2, 0.4]
];

const res = mat0.inv();
assertMetaData(res)(2, 2, cv.CV_32F);

assertDataAlmostDeepEquals(res.getDataAsArray(), expectedResult);
});
});

describe('matMul', () => {
operatorRequiresArg('matMul');

Expand Down