testBigMat.cpp
1 | #include <iostream> |
---|---|
2 | #include <opencv2/core/core.hpp> |
3 | |
4 | //From http://docs.opencv.org/modules/core/doc/basic_structures.html#mat-iscontinuous
|
5 | // alternative implementation of Mat::isContinuous()
|
6 | bool myCheckMatContinuity(const cv::Mat& m) |
7 | { |
8 | //return (m.flags & Mat::CONTINUOUS_FLAG) != 0;
|
9 | return m.rows == 1 || m.step == m.cols*m.elemSize(); |
10 | } |
11 | |
12 | int
|
13 | main() |
14 | { |
15 | const int rows=3780; |
16 | const int cols=6142; |
17 | const int numChan = 100; |
18 | |
19 | cv::Mat m = cv::Mat::zeros(rows, cols, CV_32FC(numChan)); |
20 | //cv::Mat m(rows, cols, CV_32FC(numChan));
|
21 | |
22 | |
23 | |
24 | bool c1 = m.isContinuous();
|
25 | bool c2 = myCheckMatContinuity(m);
|
26 | if (c1 != c2) {
|
27 | std::cerr<<"m.isContinuous()="<<c1<<" != myCheckMatContinuity(m)="<<c2<<" !!!"<<std::endl; |
28 | } |
29 | else {
|
30 | std::cerr<<"Ok.\n";
|
31 | } |
32 | |
33 | return 0; |
34 | } |
35 | |
36 | |
37 | //On Windows 7, with Visual C++ 2010 Express, linked with precompiled OpenCV (ia32),
|
38 | // I get the following error message:
|
39 | //"OpenCV Error: One of arguments' values is out of range (The total matrix size does not fit to "size_t" type) in unknown function,
|
40 | //file C:\slave\WinInstallerMegaPack\src\opencv\modules\core\src\matrix.cpp, line 125"
|
41 | |
42 | // On linux (Fedora 14 x86_64), with g++ 4.5.1, linked with OpenCV compiled in 64-bit,
|
43 | // I get no error but the created matrix is marked as not continuous
|