From 32cca928508bfb0b068dee241204261461482823 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 06:04:27 +0000 Subject: [PATCH 1/3] Initial plan From b9cc32e687be14cebf0ecbf1d5f106d84a8401a2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 06:11:47 +0000 Subject: [PATCH 2/3] Remove SVDecomp and SVBackSubst from TypeScript definitions These functions are not available in the compiled opencv.js binary and were causing runtime errors. Added test to verify the fix and document available alternatives. Co-authored-by: ttt43ttt <132509+ttt43ttt@users.noreply.github.com> --- src/types/opencv/core_array.ts | 22 ------------ test/linearAlgebra.test.ts | 66 ++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 22 deletions(-) create mode 100644 test/linearAlgebra.test.ts diff --git a/src/types/opencv/core_array.ts b/src/types/opencv/core_array.ts index 24f264a..f0b64b7 100644 --- a/src/types/opencv/core_array.ts +++ b/src/types/opencv/core_array.ts @@ -2654,28 +2654,6 @@ export declare function subtract( */ export declare function sum(src: InputArray): Scalar; -/** - * wrap [SVD::backSubst] - */ -export declare function SVBackSubst( - w: InputArray, - u: InputArray, - vt: InputArray, - rhs: InputArray, - dst: OutputArray, -): void; - -/** - * wrap [SVD::compute] - */ -export declare function SVDecomp( - src: InputArray, - w: OutputArray, - u: OutputArray, - vt: OutputArray, - flags?: int, -): void; - /** * The function [cv::theRNG] returns the default random number generator. For each thread, there is a * separate random number generator, so you can use the function safely in multi-thread environments. diff --git a/test/linearAlgebra.test.ts b/test/linearAlgebra.test.ts new file mode 100644 index 0000000..1c4a4b0 --- /dev/null +++ b/test/linearAlgebra.test.ts @@ -0,0 +1,66 @@ +import { setupOpenCv } from "./cv"; + +beforeAll(setupOpenCv); + +describe("Linear Algebra Functions", () => { + it("should have solve, invert, and eigen functions", () => { + // These functions are available in opencv.js + expect(typeof cv.solve).toBe("function"); + expect(typeof cv.invert).toBe("function"); + expect(typeof cv.eigen).toBe("function"); + }); + + it("should have DECOMP constants", () => { + // DECOMP constants are available + expect(cv.DECOMP_LU).toBe(0); + expect(cv.DECOMP_SVD).toBe(1); + expect(cv.DECOMP_EIG).toBe(2); + expect(cv.DECOMP_CHOLESKY).toBe(3); + expect(cv.DECOMP_QR).toBe(4); + expect(cv.DECOMP_NORMAL).toBe(16); + }); + + it("should NOT have SVDecomp and SVBackSubst functions", () => { + // SVDecomp and SVBackSubst are not compiled into opencv.js + // These functions were incorrectly included in TypeScript definitions before + // Using bracket notation to avoid TypeScript compilation errors + expect((cv as any)["SVDecomp"]).toBeUndefined(); + expect((cv as any)["SVBackSubst"]).toBeUndefined(); + }); + + it("should demonstrate solve function works", () => { + // Create a simple 2x2 linear system and verify solve can be called + const A = cv.matFromArray(2, 2, cv.CV_64F, [2, 1, 1, 3]); + const b = cv.matFromArray(2, 1, cv.CV_64F, [5, 6]); + const x = new cv.Mat(); + + const result = cv.solve(A, b, x, cv.DECOMP_LU); + + // Just verify the function executes without error + expect(typeof result).toBe("boolean"); + expect(x.rows).toBe(2); + expect(x.cols).toBe(1); + + // Clean up + A.delete(); + b.delete(); + x.delete(); + }); + + it("should demonstrate invert function works", () => { + // Create a 2x2 matrix and invert it + const A = cv.matFromArray(2, 2, cv.CV_64F, [4, 7, 2, 6]); + const Ainv = new cv.Mat(); + + const det = cv.invert(A, Ainv, cv.DECOMP_LU); + + // Just verify the function executes without error + expect(typeof det).toBe("number"); + expect(Ainv.rows).toBe(2); + expect(Ainv.cols).toBe(2); + + // Clean up + A.delete(); + Ainv.delete(); + }); +}); From d86a238060fc69afc1eeef2543b1d959efe1193a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 06:13:59 +0000 Subject: [PATCH 3/3] Address code review feedback with better test comments Added clarifying comments to test cases explaining the matrix values are arbitrary and just for functional testing. Co-authored-by: ttt43ttt <132509+ttt43ttt@users.noreply.github.com> --- package-lock.json | 13 +++++++------ test/linearAlgebra.test.ts | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2507829..49506c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3321,10 +3321,11 @@ "license": "MIT" }, "node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz", + "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==", "dev": true, + "license": "MIT", "dependencies": { "argparse": "^1.0.7", "esprima": "^4.0.0" @@ -7112,9 +7113,9 @@ "dev": true }, "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz", + "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==", "dev": true, "requires": { "argparse": "^1.0.7", diff --git a/test/linearAlgebra.test.ts b/test/linearAlgebra.test.ts index 1c4a4b0..8c2769b 100644 --- a/test/linearAlgebra.test.ts +++ b/test/linearAlgebra.test.ts @@ -30,6 +30,7 @@ describe("Linear Algebra Functions", () => { it("should demonstrate solve function works", () => { // Create a simple 2x2 linear system and verify solve can be called + // Using arbitrary matrix values just to test the function executes const A = cv.matFromArray(2, 2, cv.CV_64F, [2, 1, 1, 3]); const b = cv.matFromArray(2, 1, cv.CV_64F, [5, 6]); const x = new cv.Mat(); @@ -48,7 +49,8 @@ describe("Linear Algebra Functions", () => { }); it("should demonstrate invert function works", () => { - // Create a 2x2 matrix and invert it + // Create a simple invertible 2x2 matrix to test the function + // Using arbitrary matrix values just to test the function executes const A = cv.matFromArray(2, 2, cv.CV_64F, [4, 7, 2, 6]); const Ainv = new cv.Mat();