Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 27, 2026

TypeScript definitions declared SVDecomp and SVBackSubst functions that don't exist in the compiled opencv.js binary, causing runtime errors after successful compilation.

Changes

  • Removed incorrect type definitions from src/types/opencv/core_array.ts:

    • SVDecomp() function declaration
    • SVBackSubst() function declaration
  • Added test coverage in test/linearAlgebra.test.ts:

    • Verifies these functions are undefined at runtime
    • Documents available alternatives (solve, invert, eigen)
    • Confirms DECOMP constants exist (DECOMP_SVD = 1, etc.)

Impact

Users now get TypeScript compilation errors instead of runtime errors. The DECOMP_SVD constant remains available for use with alternative functions:

// Before: compiled but failed at runtime
cv.SVDecomp(src, w, u, vt);  // Runtime: "SVDecomp is not defined"

// After: TypeScript error at compile time
cv.SVDecomp(src, w, u, vt);  // TS2339: Property 'SVDecomp' does not exist

// Available alternatives:
cv.solve(A, b, x, cv.DECOMP_SVD);    // Solve with SVD decomposition
cv.invert(A, Ainv, cv.DECOMP_SVD);   // Invert with SVD decomposition
cv.eigen(src, eigenvalues, eigenvectors);  // Eigenvalue decomposition

Root Cause

These functions are not whitelisted in OpenCV's JavaScript build configuration (platforms/js/opencv_js.config.py), so they're never compiled into the WASM binary despite being valid C++ API functions.

Original prompt

This section details on the original issue you should resolve

<issue_title>SVDecomp is not defined</issue_title>
<issue_description>So try to use SVDecomp method from opencv in my project, but turns out it doesnt contain the SVDecomp function. I use it in this project min-ar-ts</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 27, 2026 06:11
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>
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>
Copilot AI changed the title [WIP] Fix SVDecomp is not defined issue in mind-ar-ts project Remove SVDecomp and SVBackSubst from TypeScript definitions Jan 27, 2026
Copilot AI requested a review from ttt43ttt January 27, 2026 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SVDecomp is not defined

2 participants