mirror of
https://github.com/opencv/opencv.git
synced 2026-11-25 02:38:14 -06:00
Fix silent loss of high-channel ndarray dimensions
Detect three-dimensional NumPy arrays as multichannel inputs before applying the channel limit so OpenCV reports an explicit conversion error instead of treating the channel axis as a matrix dimension. Add regression coverage for a 129-channel remap input. Assisted-by: OpenAI Codex
This commit is contained in:
@@ -89,6 +89,19 @@ try:
|
||||
print(res1)
|
||||
|
||||
|
||||
def test_ndarray_channel_limit_is_reported(self):
|
||||
map_x, map_y = np.meshgrid(
|
||||
np.arange(8, dtype=np.float32),
|
||||
np.arange(8, dtype=np.float32),
|
||||
)
|
||||
data = np.broadcast_to(
|
||||
np.arange(129, dtype=np.uint8),
|
||||
(8, 8, 129),
|
||||
).copy()
|
||||
|
||||
with self.assertRaisesRegex(cv.error, "unable to wrap channels"):
|
||||
cv.remap(data, map_x, map_y, cv.INTER_NEAREST)
|
||||
|
||||
def test_mat_wrap_channels_zero(self):
|
||||
# Passing a 0-channel array must raise cv.error, not segfault.
|
||||
data = np.zeros((100, 100, 0), dtype=np.uint8)
|
||||
|
||||
Reference in New Issue
Block a user