mirror of
https://github.com/opencv/opencv.git
synced 2026-09-12 05:11:04 -05:00
extractChannel() stopped supporting in-place operation (dst aliasing
src) after commit 416bf3253 (PR #23473), which replaced
Mat src = _src.getMat();
_dst.create(src.dims, &src.size[0], depth);
with a single up-front
_dst.createSameSize(_src, depth);
...
Mat src = _src.getMat();
When _src and _dst reference the same array, the up-front reallocation
reshapes the shared buffer to a single channel before the multi-channel
source header is fetched. mixChannels() then sees a 1-channel source and
throws for any coi >= 1.
Move createSameSize() back to after the source Mat/UMat is obtained, so
the source header keeps the original multi-channel data alive across the
destination reallocation. This preserves the 0D/1D handling introduced
by createSameSize while restoring the pre-existing in-place contract.
Adds regression test Core_Mat.extractChannel_inplace_29568.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>