pranjal9091
2868492769
core: forbid trace and setIdentity for non-2D matrices ( #30785 )
...
* core: support 1D Mat in trace and setIdentity for non-float types
In OpenCV 5.x, 1D Mat support was introduced and cv::trace and
cv::setIdentity were updated with CV_Assert(m.dims <= 2). However,
both functions previously relied on m.diag() as the general fallback
path for non-float types (e.g. integer and multi-channel types).
Since Mat::diag strictly asserts dims == 2, calling cv::trace or
cv::setIdentity on a 1D non-float Mat resulted in an assertion failure
in Mat::diag.
Fix this by using m.col(0) when m.dims <= 1 (mirroring the behavior of
1xN 2D matrices), and gracefully handling empty matrices. Also add unit
tests covering 1D Mat across integral, floating point, and multi-channel
types for both cv::trace and cv::setIdentity.
* core: handle 0-D Mat in trace and setIdentity for non-float types
Properly handle 0-D matrices (scalars) in cv::trace using cv::sum(m)
and in cv::setIdentity using m = s without invoking m.col(0).
Also add unit tests for 0-D Mat covering integral, floating-point,
and multi-channel types.
* core: forbid trace and setIdentity for non-2D matrices
2026-11-26 18:00:46 +05:30
..
2026-11-25 14:23:05 +05:30
2026-11-05 14:07:17 +05:30
2026-11-25 14:23:05 +05:30
2026-05-20 17:57:51 +03:00
2025-09-19 03:25:40 +00:00
2026-07-09 12:17:24 +03:00
2023-01-09 11:08:02 +00:00
2024-11-14 08:33:22 +03:00
2026-11-19 21:58:34 +00:00
2026-10-31 18:09:59 +08:00
2026-03-02 01:47:14 -08:00
2026-10-31 22:22:25 +08:00
2026-10-31 18:09:59 +08:00
2026-11-20 13:24:29 +05:30
2024-01-19 16:53:08 +03:00
2026-09-23 10:44:20 +03:00
2025-01-10 15:02:18 +03:00
2026-07-18 01:26:36 +03:00
2022-07-24 11:58:17 +03:00
2018-09-07 20:33:52 +09:00
2026-10-19 09:39:08 +03:00
2026-07-15 15:45:01 +03:00
2026-09-09 20:12:34 +08:00
2018-07-04 19:11:29 +03:00
2025-09-15 15:03:34 +03:00
2026-09-06 10:20:41 +03:00
2026-07-15 15:45:01 +03:00
2026-10-23 23:18:58 +05:30
2026-11-17 00:16:46 +08:00
2026-11-19 19:10:37 +05:30
2026-11-20 14:37:51 +08:00
2026-10-26 21:23:59 +03:00
2026-05-20 17:29:34 +05:30
2026-05-20 17:29:34 +05:30
2019-03-05 14:47:04 +03:00
2025-08-11 12:15:24 +03:00
2023-05-22 11:02:04 +03:00
2026-07-28 20:28:24 +05:30
2022-03-03 07:21:53 +09:00
2019-03-24 18:34:09 +03:00
2026-09-16 13:59:50 +03:00
2026-11-17 14:41:43 +03:00
2026-11-17 14:41:43 +03:00
2026-11-17 14:41:43 +03:00
2018-04-24 16:03:40 +03:00
2026-09-22 01:01:01 +09:00
2026-10-23 18:10:21 +05:30
2021-02-16 11:10:45 +00:00
2026-11-17 20:22:07 +05:30
2024-02-11 10:42:41 +03:00
2026-10-26 21:23:59 +03:00
2021-09-10 12:10:41 +00:00
2026-10-02 13:18:18 +03:00
2026-11-17 20:22:07 +05:30
2023-09-21 18:24:38 +03:00
2026-09-29 17:06:55 +03:00
2025-03-30 16:17:07 +03:00
2023-06-20 09:56:57 +03:00
2026-11-22 02:28:24 +05:30
2026-06-18 17:29:18 +03:00
2026-06-18 17:29:18 +03:00
2026-07-18 01:26:36 +03:00
2026-10-21 15:07:53 +03:00
2026-07-18 01:26:36 +03:00
2026-11-08 11:47:11 +03:00
2026-11-25 16:18:41 +05:30
2026-07-18 01:26:36 +03:00
2026-11-25 15:56:47 +05:30
2026-11-25 15:56:47 +05:30
2018-09-14 06:45:31 +09:00
2026-07-09 12:17:24 +03:00
2025-09-15 15:03:34 +03:00
2026-11-26 18:00:46 +05:30
2025-09-15 15:03:34 +03:00
2026-11-20 17:54:15 +05:30
2026-10-16 14:08:56 +03:00
2026-11-13 16:16:51 +05:30
2026-11-23 15:01:58 +03:00
2026-09-23 10:44:20 +03:00
2026-10-14 21:20:21 +08:00
2023-08-11 08:33:33 +03:00
2026-10-29 18:03:13 +05:30
2026-10-29 08:35:30 +03:00
2026-11-13 15:36:54 +05:30
2026-11-13 15:36:54 +05:30
2026-11-07 20:13:55 +09:00
2026-10-14 11:26:22 +03:00
2026-10-29 16:37:25 +08:00
2026-11-25 14:58:32 +08:00
2024-02-12 14:20:35 +03:00
2026-11-20 12:54:06 +05:30
2026-10-12 16:33:54 +03:00
2026-10-15 14:41:15 +08:00
2026-02-18 04:35:41 +08:00
2018-01-26 04:09:11 +00:00
2026-11-11 10:24:16 +05:30
2024-11-14 08:33:22 +03:00
2026-09-23 14:28:55 +02:00
2025-03-07 08:35:44 +03:00
2026-11-05 14:17:21 +03:00
2026-11-03 16:24:39 +03:00
2026-10-02 18:55:19 +05:30
2026-11-03 16:24:39 +03:00
2026-11-03 16:24:39 +03:00
2026-11-05 14:17:21 +03:00
2026-09-14 07:48:54 +05:30
2026-10-21 14:41:44 +03:00
2026-09-23 10:44:20 +03:00
2026-11-07 20:13:55 +09:00
2026-09-18 14:56:16 +03:00
2026-09-18 14:56:16 +03:00
2026-10-06 12:44:51 +03:00
2026-09-23 14:28:55 +02:00
2026-10-14 21:20:21 +08:00
2023-10-06 13:33:21 +03:00
2026-10-15 10:37:45 +02:00
2026-07-10 18:31:01 +03:00
2018-02-12 14:14:08 +03:00
2026-07-01 15:48:47 +03:00
2018-08-27 14:42:18 +03:00
2026-11-09 09:41:13 +05:30
2026-11-09 09:41:13 +05:30
2026-10-19 09:39:08 +03:00
2024-03-26 15:17:18 +03:00
2026-05-21 15:53:15 +03:00
2026-11-20 02:03:16 +08:00
2026-11-20 17:54:15 +05:30
2018-01-16 17:33:06 +03:00
2022-02-22 19:55:26 +00:00
2024-10-30 18:37:22 +03:00