Matx types do not work inside Mat_ template matrices (Bug #1705)
Description
Types like Matx31f do not work correctly as Mat_<Matx31f> matrices. Not enough memory is allocated for the elements and step from one row to another is miscalculated. Problem exists at least in version 2.3.1a.
Attached test program prints out basic information and element positions in memory for couple of small test matrices. (Warning: Because of this OpenCV bug, it accesses memory outside matrix bounds) All matrices have the same size dimensions (width = 2, height = 5). Attached program gives me the following results:
For cv::Mat_<float>: (correct)
Size: 2 x 5 channels 1 element size: 4 step1: 2 total: 10
Allocated memory: 40 bytes
Pointer to element 0, 0: 20813584
Pointer to element 1, 0: 20813588
Pointer to element 0, 1: 20813592
Pointer to element 1, 1: 20813596
...
For cv::Mat_<cv::Vec3f>: (correct)
Size: 2 x 5 channels 3 element size: 12 step1: 6 total: 10
Allocated memory: 120 bytes
Pointer to element 0, 0: 20818592
Pointer to element 1, 0: 20818604
Pointer to element 0, 1: 20818616
Pointer to element 1, 1: 20818628
...
For cv::Mat_<cv::Matx31f>: (wrong)
Size: 2 x 5 channels 1 element size: 12 step1: 1 total: 10
Allocated memory: 80 bytes
Pointer to element 0, 0: 20818592
Pointer to element 1, 0: 20818604
Pointer to element 0, 1: 20818608
Pointer to element 1, 1: 20818620
...
For cv::Mat_<cv::Matx41f>: (wrong)
Size: 2 x 5 channels 1 element size: 16 step1: 1 total: 10
Allocated memory: 80 bytes
Pointer to element 0, 0: 20818720
Pointer to element 1, 0: 20818736
Pointer to element 0, 1: 20818736
Pointer to element 1, 1: 20818752
...
etc.
Associated revisions
enable Matx as Mat elements (bug #1705).
Merge pull request #1705 from ilya-lavrenov:ocl_flip
History
Updated by Alexander Shishkov almost 13 years ago
- Target version deleted ()
- Category set to documentation
Updated by Alexander Shishkov almost 13 years ago
- Priority changed from Normal to Low
Updated by Alexander Shishkov almost 13 years ago
- Target version deleted ()
Updated by Vadim Pisarevsky over 12 years ago
- Category changed from documentation to core
- Target version deleted ()
Updated by Vadim Pisarevsky over 12 years ago
thanks! the bug has been fixed in 7ee6040
- Status changed from Open to Done
- Assignee set to Vadim Pisarevsky
Updated by Andrey Kamaev about 12 years ago
- Target version set to 2.4.3