1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

js: restore deep copy behavior for Mat.clone()

Emscripten 3.1.71+ introduced ClassHandle.clone() which performs a shallow copy.
This shadowed the original OpenCV clone() method which was intended for deep copying.

This patch:
1. Hooks into onRuntimeInitialized in helpers.js
2. Overrides cv.Mat.prototype.clone to point to mat_clone (deep copy)
3. Updates JS tests to use clone() to verify the fix
This commit is contained in:
happy-capybara-man
2025-12-18 01:39:27 +08:00
parent e4d294d018
commit 8ea50a77fd
2 changed files with 18 additions and 1 deletions
+1 -1
View File
@@ -173,7 +173,7 @@ QUnit.test('test_mat_creation', function(assert) {
// clone
{
let mat = cv.Mat.ones(5, 5, cv.CV_8UC1);
let mat2 = mat.mat_clone();
let mat2 = mat.clone();
assert.equal(mat.channels, mat2.channels);
assert.equal(mat.size().height, mat2.size().height);