Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
happy-capybara-man wants to merge1 commit intoopencv:4.x
base:4.x
Choose a base branch
Loading
fromhappy-capybara-man:4.x

Conversation

@happy-capybara-man
Copy link
Contributor

@happy-capybara-manhappy-capybara-man commentedDec 17, 2025
edited
Loading

Problem

In OpenCV.js,cv.Mat.clone() may resolve to EmbindClassHandle.clone() (handle/shallow clone) instead of OpenCV deep copy.

Changes

  • modules/js/src/helpers.js: overridecv.Mat.prototype.clone ->mat_clone after runtime init
  • modules/js/test/test_mat.js: update/extend tests to validate deep copy semantics ofclone()

Fixes#27572
Related: PR#26643 (js_clone_fix), PR#27985 (documentation update)

Verification

  • Built OpenCV.js with Emscripten 2.0.10
  • QUnit: bin/tests.html
  • CoreMat: test_mat_creation (0 failures)
clone_fix

Pull Request Readiness Checklist

See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

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.js2. Overrides cv.Mat.prototype.clone to point to mat_clone (deep copy)3. Updates JS tests to use clone() to verify the fix
@vrabaud
Copy link
Contributor

I think it makes sense. Users will no more about OpenCV that emscripten and will therefore expect clone to behave like in C++. LGTM

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@vrabaudvrabaudAwaiting requested review from vrabaud

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

最新版本4.12.x中,clone似乎成了浅拷贝,我不得不使用copyTo

2 participants

@happy-capybara-man@vrabaud

[8]ページ先頭

©2009-2025 Movatter.jp