CARVIEW |
Select Language
HTTP/2 200
date: Sun, 27 Jul 2025 11:12:20 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/opencv/opencv.git
etag: W/"81fff83471668c7e6de3f2a7e2deec6f"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=xY0YoCuOSEOzmst9aYpQSks03kUc84Z2Hu%2FBlJu1tgnzrdJJNgIdL1rqvgfYfCu4fAaVOciQh6nfl5uHduIzJbaNQU0cvwdguocgBvS4rdStv6wyr%2F%2F5qSyxzQGJNBe1%2FB04285btL4AEl8lBZC9ZIs5fBh%2FInWEUuVdYunb%2Bub7cGdOTaFw4uvhAKX4gsKoPGbqVV3tPb6QtKwZgk1B0K87l4GhB7Yme84xkgy557kskPtsmii%2FoVioTgLK6j38m2NOXjR0EXvqapXfYJNtXg%3D%3D--9SD3wOjhuM76ci1t--j3eUmEDOM4GaMCXt09yaAQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1357691129.1753614740; Path=/; Domain=github.com; Expires=Mon, 27 Jul 2026 11:12:20 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Mon, 27 Jul 2026 11:12:20 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: C32A:32A0BD:421F77:58F02E:68860994
Merge pull request #27408 from KAVYANSHTYAGI:Umat-vector-contructor · opencv/opencv@7ca36d9 · GitHub
Copy file name to clipboardExpand all lines: modules/core/include/opencv2/core/mat.hpp
Copy file name to clipboardExpand all lines: modules/core/include/opencv2/core/mat.inl.hpp
Copy file name to clipboardExpand all lines: modules/core/test/test_umat.cpp
Skip to content
Navigation Menu
{{ message }}
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
Commit 7ca36d9
authored
Merge pull request #27408 from KAVYANSHTYAGI:Umat-vector-contructor
Deprecate copyData Parameter in UMat Construction from std::vector and Always Copy Data #27408
Overview
This PR simplifies and modernizes the construction of cv::UMat from std::vector by removing the legacy copyData parameter, always copying the data, and ensuring clearer, safer semantics. This brings UMat in line with current best practices and paves the way for the upcoming OpenCV 5.x series.
What Changed?
1. Header Documentation Update
Removed confusing or obsolete documentation about copyData and clarified the behavior:
Old: builds matrix from std::vector with or without copying the data
New: builds matrix from std::vector. The data is always copied. The copyData parameter is deprecated and will be removed in OpenCV 5.0.
2. Implementation Update
In UMat::UMat(const std::vector<_Tp>& vec, bool copyData), the copyData parameter:
Is now ignored and marked as deprecated.
Marked with CV_UNUSED(copyData) for backward compatibility and to avoid warnings.
The constructor always copies the data from the input vector, regardless of the value of copyData.
All branching logic around copyData has been removed. Any code for "not copying" was not implemented and is now dropped.
This guarantees data safety and predictable behavior.
3. Test Added
A new test construct_from_vector in test_umat_from_vector.cpp:
Verifies that UMat copies the vector data, not referencing it.
Modifies the source vector after construction to confirm that the UMat is unaffected (proving copy, not reference).
Checks matrix shape, type, and content to ensure correctness.
Why This Change?
1. Safety and Predictability
Always copying avoids dangling references and hard-to-debug lifetime issues with stack/heap-allocated vectors.
Removes an undocumented, unimplemented branch (copyData=false).
2. Backward Compatibility
The constructor signature remains for now, but the copyData parameter is marked as deprecated and ignored.
Codebases that pass the parameter will still compile and run as before (but always copy).
3. API Clarity and Maintenance
Documentation now matches the real implementation.
No misleading expectations about zero-copy.
Code is cleaner, future-proof, and easier to maintain.
4. Preparation for OpenCV 5.0
The copyData parameter is deprecated and will be removed in OpenCV 5.x.
Prepares users and downstream libraries for the planned change.
How This Helps OpenCV Users and Developers
Guarantees data safety and makes behavior explicit.
Removes legacy/ambiguous code.
Provides a clear path to OpenCV 5.x.
Minimizes future migration pain.
Ensures all users see the same, reliable behavior (copy semantics).
Refer:#274091 parent ebfee90 commit 7ca36d9Copy full SHA for 7ca36d9
File tree
Expand file treeCollapse file tree
3 files changed
+30
-11
lines changedFilter options
- modules/core
- include/opencv2/core
- test
Expand file treeCollapse file tree
3 files changed
+30
-11
lines changedmodules/core/include/opencv2/core/mat.hpp
Copy file name to clipboardExpand all lines: modules/core/include/opencv2/core/mat.hpp+2-2Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2482 | 2482 |
| |
2483 | 2483 |
| |
2484 | 2484 |
| |
2485 |
| - | |
2486 |
| - | |
| 2485 | + | |
| 2486 | + | |
2487 | 2487 |
| |
2488 | 2488 |
| |
2489 | 2489 |
| |
|
modules/core/include/opencv2/core/mat.inl.hpp
Copy file name to clipboardExpand all lines: modules/core/include/opencv2/core/mat.inl.hpp+4-9Lines changed: 4 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3254 | 3254 |
| |
3255 | 3255 |
| |
3256 | 3256 |
| |
3257 |
| - | |
3258 |
| - | |
| 3257 | + | |
| 3258 | + | |
3259 | 3259 |
| |
| 3260 | + | |
3260 | 3261 |
| |
3261 | 3262 |
| |
3262 |
| - | |
3263 |
| - | |
3264 |
| - | |
3265 |
| - | |
3266 |
| - | |
3267 |
| - | |
3268 |
| - | |
| 3263 | + | |
3269 | 3264 |
| |
3270 | 3265 |
| |
3271 | 3266 |
| |
|
modules/core/test/test_umat.cpp
Copy file name to clipboardExpand all lines: modules/core/test/test_umat.cpp+24Lines changed: 24 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
919 | 919 |
| |
920 | 920 |
| |
921 | 921 |
| |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
922 | 944 |
| |
923 | 945 |
| |
924 | 946 |
| |
| |||
1452 | 1474 |
| |
1453 | 1475 |
| |
1454 | 1476 |
| |
| 1477 | + | |
| 1478 | + | |
1455 | 1479 |
|
You can’t perform that action at this time.
0 commit comments