Add TypeScript declaration and tests for mat_clone() method #86
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
cv::Mat::clone()
method was not creating proper deep copies of the underlying data, causing cloned matrices to share the same data buffer. This resulted in modifications to one matrix affecting the other, which is incorrect behavior.Problem
The issue occurred because the existing
clone()
method was using emscripten's generic object cloning mechanism, which only copied the object header and metadata, not the underlying data buffer.Solution
OpenCV v4.11.0 includes a native
mat_clone()
method that creates proper deep copies of Mat objects with independent data buffers. This PR adds TypeScript declarations and comprehensive tests for this method.Usage
Changes Made
mat_clone()
method insrc/types/opencv/Mat.ts
test/Mat.test.ts
mat_clone()
function works correctly for proper deep copyingThe original
clone()
method remains unchanged to avoid breaking existing code. Users can migrate tomat_clone()
for proper deep copying behavior.Fixes #85.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.