2012-02-03 19:26:49 +08:00
|
|
|
set(the_description "The Core Functionality")
|
2017-03-23 21:09:47 +08:00
|
|
|
|
|
|
|
ocv_add_dispatched_file(mathfuncs_core SSE2 AVX AVX2)
|
2017-07-02 23:49:38 +08:00
|
|
|
ocv_add_dispatched_file(stat SSE4_2 AVX2)
|
2018-11-20 20:05:20 +08:00
|
|
|
ocv_add_dispatched_file(arithm SSE2 SSE4_1 AVX2 VSX3)
|
2019-03-20 13:51:32 +08:00
|
|
|
ocv_add_dispatched_file(convert SSE2 AVX2 VSX3)
|
2019-02-08 22:56:25 +08:00
|
|
|
ocv_add_dispatched_file(convert_scale SSE2 AVX2)
|
2019-02-13 23:27:55 +08:00
|
|
|
ocv_add_dispatched_file(count_non_zero SSE2 AVX2)
|
Merge pull request #22947 from chacha21:hasNonZero
Added cv::hasNonZero() #22947
`cv::hasNonZero()` is semantically equivalent to (`cv::countNonZero()>0`) but stops parsing the image when a non-zero value is found, for a performance gain
- [X] I agree to contribute to the project under Apache 2 License.
- [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [X] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This pull request might be refused, but I submit it to know if further work is needed or if I just stop working on it.
The idea is only a performance gain vs `countNonZero()>0` at the cost of more code.
Reasons why it might be refused :
- this is just more code
- the execution time is "unfair"/"unpredictable" since it depends on the position of the first non-zero value
- the user must be aware that default search is from first row/col to last row/col and has no way to customize that, even if his use case lets him know where a non zero could be found
- the PR in its current state is using, for the ocl implementation, a mere `countNonZero()>0` ; there is not much sense in trying to break early the ocl kernel call when non-zero is encountered. So the ocl implementation does not bring any improvement.
- there is no IPP function that can help (`countNonZero()` is based in `ippCountInRange`)
- the PR in its current state might be slower than a call to `countNonZero()>0` in some cases (see "challenges" below)
Reasons why it might be accepted :
- the performance gain is huge on average, if we consider that "on average" means "non zero in the middle of the image"
- the "missing" IPP implementation is replaced by an "Open-CV universal intrinsics" implementation
- the PR in its current state is almost always faster than a call to `countNonZero()>0`, is only slightly slower in the worst cases, and not even for all matrices
**Challenges**
The worst case is either an all-zero matrix, or a non-zero at the very last position. In such a case, the `hasNonZero()` implementation will parse the whole matrix like `countNonZero()` would do. But we expect the performance to be the same in this case. And `ippCountInRange` is hard to beat !
There is also the case of very small matrices (<=32x32...) in 8b, where the SIMD can be hard to feed.
For all cases but the worse, my custom `hasNonZero()` performs better than `ippCountInRange()`
For the worst case, my custom `hasNonZero()` performs better than `ippCountInRange()` *except for large matrices of type CV_32S or CV_64F* (but surprisingly, not CV_32F).
The difference is small, but it exists (and I don't understand why).
For very small CV_8U matrices `ippCountInRange()` seems unbeatable.
Here is the code that I use to check timings
```
//test cv::hasNonZero() vs (cv::countNonZero()>0) for different matrices sizes, types, strides...
{
cv::setRNGSeed(1234);
const std::vector<cv::Size> sizes = {{32, 32}, {64, 64}, {128, 128}, {320, 240}, {512, 512}, {640, 480}, {1024, 768}, {2048, 2048}, {1031, 1000}};
const std::vector<int> types = {CV_8U, CV_16U, CV_32S, CV_32F, CV_64F};
const size_t iterations = 1000;
for(const cv::Size& size : sizes)
{
for(const int type : types)
{
for(int c = 0 ; c<2 ; ++c)
{
const bool continuous = !c;
for(int i = 0 ; i<4 ; ++i)
{
cv::Mat m = continuous ? cv::Mat::zeros(size, type) : cv::Mat(cv::Mat::zeros(cv::Size(2*size.width, size.height), type), cv::Rect(cv::Point(0, 0), size));
const bool nz = (i <= 2);
const unsigned int nzOffsetRange = 10;
const unsigned int nzOffset = cv::randu<unsigned int>()%nzOffsetRange;
const cv::Point pos =
(i == 0) ? cv::Point(nzOffset, 0) :
(i == 1) ? cv::Point(size.width/2-nzOffsetRange/2+nzOffset, size.height/2) :
(i == 2) ? cv::Point(size.width-1-nzOffset, size.height-1) :
cv::Point(0, 0);
std::cout << "============================================================" << std::endl;
std::cout << "size:" << size << " type:" << type << " continuous = " << (continuous ? "true" : "false") << " iterations:" << iterations << " nz=" << (nz ? "true" : "false");
std::cout << " pos=" << ((i == 0) ? "begin" : (i == 1) ? "middle" : (i == 2) ? "end" : "none");
std::cout << std::endl;
cv::Mat mask = cv::Mat::zeros(size, CV_8UC1);
mask.at<unsigned char>(pos) = 0xFF;
m.setTo(cv::Scalar::all(0));
m.setTo(cv::Scalar::all(nz ? 1 : 0), mask);
std::vector<bool> results;
std::vector<double> timings;
{
bool res = false;
auto ref = cv::getTickCount();
for(size_t k = 0 ; k<iterations ; ++k)
res = cv::hasNonZero(m);
auto now = cv::getTickCount();
const bool error = (res != nz);
if (error)
printf("!!ERROR!!\r\n");
results.push_back(res);
timings.push_back(1000.*(now-ref)/cv::getTickFrequency());
}
{
bool res = false;
auto ref = cv::getTickCount();
for(size_t k = 0 ; k<iterations ; ++k)
res = (cv::countNonZero(m)>0);
auto now = cv::getTickCount();
const bool error = (res != nz);
if (error)
printf("!!ERROR!!\r\n");
results.push_back(res);
timings.push_back(1000.*(now-ref)/cv::getTickFrequency());
}
const size_t bestTimingIndex = (std::min_element(timings.begin(), timings.end())-timings.begin());
if ((bestTimingIndex != 0) || (std::find_if_not(results.begin(), results.end(), [&](bool r) {return (r == nz);}) != results.end()))
{
std::cout << "cv::hasNonZero\t\t=>" << results[0] << ((results[0] != nz) ? " ERROR" : "") << " perf:" << timings[0] << "ms => " << (iterations/timings[0]*1000) << " im/s" << ((bestTimingIndex == 0) ? " * " : "") << std::endl;
std::cout << "cv::countNonZero\t=>" << results[1] << ((results[1] != nz) ? " ERROR" : "") << " perf:" << timings[1] << "ms => " << (iterations/timings[1]*1000) << " im/s" << ((bestTimingIndex == 1) ? " * " : "") << std::endl;
}
}
}
}
}
}
```
Here is a report of this benchmark (it only reports timings when `cv::countNonZero()` is faster)
My CPU is an Intel Core I7 4790 @ 3.60Ghz
```
============================================================
size:[32 x 32] type:0 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[32 x 32] type:0 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[32 x 32] type:0 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[32 x 32] type:0 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[32 x 32] type:0 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[32 x 32] type:0 continuous = false iterations:1000 nz=true pos=middle
cv::hasNonZero =>1 perf:0.353764ms => 2.82674e+06 im/s
cv::countNonZero =>1 perf:0.282044ms => 3.54555e+06 im/s *
============================================================
size:[32 x 32] type:0 continuous = false iterations:1000 nz=true pos=end
cv::hasNonZero =>1 perf:0.610478ms => 1.63806e+06 im/s
cv::countNonZero =>1 perf:0.283182ms => 3.5313e+06 im/s *
============================================================
size:[32 x 32] type:0 continuous = false iterations:1000 nz=false pos=none
cv::hasNonZero =>0 perf:0.630115ms => 1.58701e+06 im/s
cv::countNonZero =>0 perf:0.282044ms => 3.54555e+06 im/s *
============================================================
size:[32 x 32] type:2 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[32 x 32] type:2 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[32 x 32] type:2 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[32 x 32] type:2 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[32 x 32] type:2 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[32 x 32] type:2 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[32 x 32] type:2 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[32 x 32] type:2 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[32 x 32] type:4 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[32 x 32] type:4 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[32 x 32] type:4 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[32 x 32] type:4 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[32 x 32] type:4 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[32 x 32] type:4 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[32 x 32] type:4 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[32 x 32] type:4 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[32 x 32] type:5 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[32 x 32] type:5 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[32 x 32] type:5 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[32 x 32] type:5 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[32 x 32] type:5 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[32 x 32] type:5 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[32 x 32] type:5 continuous = false iterations:1000 nz=true pos=end
cv::hasNonZero =>1 perf:0.607347ms => 1.64651e+06 im/s
cv::countNonZero =>1 perf:0.467037ms => 2.14116e+06 im/s *
============================================================
size:[32 x 32] type:5 continuous = false iterations:1000 nz=false pos=none
cv::hasNonZero =>0 perf:0.618162ms => 1.6177e+06 im/s
cv::countNonZero =>0 perf:0.468175ms => 2.13595e+06 im/s *
============================================================
size:[32 x 32] type:6 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[32 x 32] type:6 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[32 x 32] type:6 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[32 x 32] type:6 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[32 x 32] type:6 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[32 x 32] type:6 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[32 x 32] type:6 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[32 x 32] type:6 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[64 x 64] type:0 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[64 x 64] type:0 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[64 x 64] type:0 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[64 x 64] type:0 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[64 x 64] type:0 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[64 x 64] type:0 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[64 x 64] type:0 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[64 x 64] type:0 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[64 x 64] type:2 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[64 x 64] type:2 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[64 x 64] type:2 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[64 x 64] type:2 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[64 x 64] type:2 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[64 x 64] type:2 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[64 x 64] type:2 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[64 x 64] type:2 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[64 x 64] type:4 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[64 x 64] type:4 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[64 x 64] type:4 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[64 x 64] type:4 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[64 x 64] type:4 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[64 x 64] type:4 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[64 x 64] type:4 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[64 x 64] type:4 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[64 x 64] type:5 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[64 x 64] type:5 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[64 x 64] type:5 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[64 x 64] type:5 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[64 x 64] type:5 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[64 x 64] type:5 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[64 x 64] type:5 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[64 x 64] type:5 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[64 x 64] type:6 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[64 x 64] type:6 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[64 x 64] type:6 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[64 x 64] type:6 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[64 x 64] type:6 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[64 x 64] type:6 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[64 x 64] type:6 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[64 x 64] type:6 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[128 x 128] type:0 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[128 x 128] type:0 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[128 x 128] type:0 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[128 x 128] type:0 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[128 x 128] type:0 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[128 x 128] type:0 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[128 x 128] type:0 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[128 x 128] type:0 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[128 x 128] type:2 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[128 x 128] type:2 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[128 x 128] type:2 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[128 x 128] type:2 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[128 x 128] type:2 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[128 x 128] type:2 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[128 x 128] type:2 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[128 x 128] type:2 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[128 x 128] type:4 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[128 x 128] type:4 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[128 x 128] type:4 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[128 x 128] type:4 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[128 x 128] type:4 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[128 x 128] type:4 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[128 x 128] type:4 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[128 x 128] type:4 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[128 x 128] type:5 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[128 x 128] type:5 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[128 x 128] type:5 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[128 x 128] type:5 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[128 x 128] type:5 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[128 x 128] type:5 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[128 x 128] type:5 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[128 x 128] type:5 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[128 x 128] type:6 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[128 x 128] type:6 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[128 x 128] type:6 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[128 x 128] type:6 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[128 x 128] type:6 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[128 x 128] type:6 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[128 x 128] type:6 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[128 x 128] type:6 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[320 x 240] type:0 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[320 x 240] type:0 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[320 x 240] type:0 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[320 x 240] type:0 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[320 x 240] type:0 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[320 x 240] type:0 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[320 x 240] type:0 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[320 x 240] type:0 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[320 x 240] type:2 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[320 x 240] type:2 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[320 x 240] type:2 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[320 x 240] type:2 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[320 x 240] type:2 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[320 x 240] type:2 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[320 x 240] type:2 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[320 x 240] type:2 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[320 x 240] type:4 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[320 x 240] type:4 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[320 x 240] type:4 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[320 x 240] type:4 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[320 x 240] type:4 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[320 x 240] type:4 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[320 x 240] type:4 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[320 x 240] type:4 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[320 x 240] type:5 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[320 x 240] type:5 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[320 x 240] type:5 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[320 x 240] type:5 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[320 x 240] type:5 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[320 x 240] type:5 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[320 x 240] type:5 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[320 x 240] type:5 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[320 x 240] type:6 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[320 x 240] type:6 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[320 x 240] type:6 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[320 x 240] type:6 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[320 x 240] type:6 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[320 x 240] type:6 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[320 x 240] type:6 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[320 x 240] type:6 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[512 x 512] type:0 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[512 x 512] type:0 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[512 x 512] type:0 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[512 x 512] type:0 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[512 x 512] type:0 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[512 x 512] type:0 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[512 x 512] type:0 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[512 x 512] type:0 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[512 x 512] type:2 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[512 x 512] type:2 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[512 x 512] type:2 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[512 x 512] type:2 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[512 x 512] type:2 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[512 x 512] type:2 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[512 x 512] type:2 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[512 x 512] type:2 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[512 x 512] type:4 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[512 x 512] type:4 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[512 x 512] type:4 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[512 x 512] type:4 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[512 x 512] type:4 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[512 x 512] type:4 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[512 x 512] type:4 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[512 x 512] type:4 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[512 x 512] type:5 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[512 x 512] type:5 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[512 x 512] type:5 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[512 x 512] type:5 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[512 x 512] type:5 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[512 x 512] type:5 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[512 x 512] type:5 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[512 x 512] type:5 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[512 x 512] type:6 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[512 x 512] type:6 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[512 x 512] type:6 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[512 x 512] type:6 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[512 x 512] type:6 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[512 x 512] type:6 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[512 x 512] type:6 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[512 x 512] type:6 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[640 x 480] type:0 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[640 x 480] type:0 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[640 x 480] type:0 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[640 x 480] type:0 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[640 x 480] type:0 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[640 x 480] type:0 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[640 x 480] type:0 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[640 x 480] type:0 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[640 x 480] type:2 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[640 x 480] type:2 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[640 x 480] type:2 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[640 x 480] type:2 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[640 x 480] type:2 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[640 x 480] type:2 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[640 x 480] type:2 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[640 x 480] type:2 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[640 x 480] type:4 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[640 x 480] type:4 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[640 x 480] type:4 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[640 x 480] type:4 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[640 x 480] type:4 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[640 x 480] type:4 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[640 x 480] type:4 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[640 x 480] type:4 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[640 x 480] type:5 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[640 x 480] type:5 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[640 x 480] type:5 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[640 x 480] type:5 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[640 x 480] type:5 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[640 x 480] type:5 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[640 x 480] type:5 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[640 x 480] type:5 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[640 x 480] type:6 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[640 x 480] type:6 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[640 x 480] type:6 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[640 x 480] type:6 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[640 x 480] type:6 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[640 x 480] type:6 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[640 x 480] type:6 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[640 x 480] type:6 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[1024 x 768] type:0 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[1024 x 768] type:0 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[1024 x 768] type:0 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[1024 x 768] type:0 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[1024 x 768] type:0 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[1024 x 768] type:0 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[1024 x 768] type:0 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[1024 x 768] type:0 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[1024 x 768] type:2 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[1024 x 768] type:2 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[1024 x 768] type:2 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[1024 x 768] type:2 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[1024 x 768] type:2 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[1024 x 768] type:2 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[1024 x 768] type:2 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[1024 x 768] type:2 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[1024 x 768] type:4 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[1024 x 768] type:4 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[1024 x 768] type:4 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[1024 x 768] type:4 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[1024 x 768] type:4 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[1024 x 768] type:4 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[1024 x 768] type:4 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[1024 x 768] type:4 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[1024 x 768] type:5 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[1024 x 768] type:5 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[1024 x 768] type:5 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[1024 x 768] type:5 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[1024 x 768] type:5 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[1024 x 768] type:5 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[1024 x 768] type:5 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[1024 x 768] type:5 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[1024 x 768] type:6 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[1024 x 768] type:6 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[1024 x 768] type:6 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[1024 x 768] type:6 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[1024 x 768] type:6 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[1024 x 768] type:6 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[1024 x 768] type:6 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[1024 x 768] type:6 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[2048 x 2048] type:0 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[2048 x 2048] type:0 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[2048 x 2048] type:0 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[2048 x 2048] type:0 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[2048 x 2048] type:0 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[2048 x 2048] type:0 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[2048 x 2048] type:0 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[2048 x 2048] type:0 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[2048 x 2048] type:2 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[2048 x 2048] type:2 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[2048 x 2048] type:2 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[2048 x 2048] type:2 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[2048 x 2048] type:2 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[2048 x 2048] type:2 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[2048 x 2048] type:2 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[2048 x 2048] type:2 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[2048 x 2048] type:4 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[2048 x 2048] type:4 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[2048 x 2048] type:4 continuous = true iterations:1000 nz=true pos=end
cv::hasNonZero =>1 perf:895.381ms => 1116.84 im/s
cv::countNonZero =>1 perf:882.569ms => 1133.06 im/s *
============================================================
size:[2048 x 2048] type:4 continuous = true iterations:1000 nz=false pos=none
cv::hasNonZero =>0 perf:899.53ms => 1111.69 im/s
cv::countNonZero =>0 perf:870.894ms => 1148.24 im/s *
============================================================
size:[2048 x 2048] type:4 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[2048 x 2048] type:4 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[2048 x 2048] type:4 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[2048 x 2048] type:4 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[2048 x 2048] type:5 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[2048 x 2048] type:5 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[2048 x 2048] type:5 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[2048 x 2048] type:5 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[2048 x 2048] type:5 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[2048 x 2048] type:5 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[2048 x 2048] type:5 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[2048 x 2048] type:5 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[2048 x 2048] type:6 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[2048 x 2048] type:6 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[2048 x 2048] type:6 continuous = true iterations:1000 nz=true pos=end
cv::hasNonZero =>1 perf:2018.92ms => 495.313 im/s
cv::countNonZero =>1 perf:1966.37ms => 508.552 im/s *
============================================================
size:[2048 x 2048] type:6 continuous = true iterations:1000 nz=false pos=none
cv::hasNonZero =>0 perf:2005.87ms => 498.537 im/s
cv::countNonZero =>0 perf:1992.78ms => 501.812 im/s *
============================================================
size:[2048 x 2048] type:6 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[2048 x 2048] type:6 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[2048 x 2048] type:6 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[2048 x 2048] type:6 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[1031 x 1000] type:0 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[1031 x 1000] type:0 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[1031 x 1000] type:0 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[1031 x 1000] type:0 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[1031 x 1000] type:0 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[1031 x 1000] type:0 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[1031 x 1000] type:0 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[1031 x 1000] type:0 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[1031 x 1000] type:2 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[1031 x 1000] type:2 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[1031 x 1000] type:2 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[1031 x 1000] type:2 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[1031 x 1000] type:2 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[1031 x 1000] type:2 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[1031 x 1000] type:2 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[1031 x 1000] type:2 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[1031 x 1000] type:4 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[1031 x 1000] type:4 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[1031 x 1000] type:4 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[1031 x 1000] type:4 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[1031 x 1000] type:4 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[1031 x 1000] type:4 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[1031 x 1000] type:4 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[1031 x 1000] type:4 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[1031 x 1000] type:5 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[1031 x 1000] type:5 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[1031 x 1000] type:5 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[1031 x 1000] type:5 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[1031 x 1000] type:5 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[1031 x 1000] type:5 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[1031 x 1000] type:5 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[1031 x 1000] type:5 continuous = false iterations:1000 nz=false pos=none
============================================================
size:[1031 x 1000] type:6 continuous = true iterations:1000 nz=true pos=begin
============================================================
size:[1031 x 1000] type:6 continuous = true iterations:1000 nz=true pos=middle
============================================================
size:[1031 x 1000] type:6 continuous = true iterations:1000 nz=true pos=end
============================================================
size:[1031 x 1000] type:6 continuous = true iterations:1000 nz=false pos=none
============================================================
size:[1031 x 1000] type:6 continuous = false iterations:1000 nz=true pos=begin
============================================================
size:[1031 x 1000] type:6 continuous = false iterations:1000 nz=true pos=middle
============================================================
size:[1031 x 1000] type:6 continuous = false iterations:1000 nz=true pos=end
============================================================
size:[1031 x 1000] type:6 continuous = false iterations:1000 nz=false pos=none
done
```
2023-06-09 18:37:20 +08:00
|
|
|
ocv_add_dispatched_file(has_non_zero SSE2 AVX2)
|
2022-07-20 18:25:39 +08:00
|
|
|
ocv_add_dispatched_file(matmul SSE2 SSE4_1 AVX2 AVX512_SKX NEON_DOTPROD)
|
2019-02-19 21:58:32 +08:00
|
|
|
ocv_add_dispatched_file(mean SSE2 AVX2)
|
2019-02-22 19:17:18 +08:00
|
|
|
ocv_add_dispatched_file(merge SSE2 AVX2)
|
2019-02-22 17:35:32 +08:00
|
|
|
ocv_add_dispatched_file(split SSE2 AVX2)
|
2019-02-11 21:21:49 +08:00
|
|
|
ocv_add_dispatched_file(sum SSE2 AVX2)
|
2017-03-23 21:09:47 +08:00
|
|
|
|
2018-07-30 23:53:05 +08:00
|
|
|
# dispatching for accuracy tests
|
2019-06-03 23:05:35 +08:00
|
|
|
ocv_add_dispatched_file_force_all(test_intrin128 TEST SSE2 SSE3 SSSE3 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX)
|
|
|
|
ocv_add_dispatched_file_force_all(test_intrin256 TEST AVX2 AVX512_SKX)
|
|
|
|
ocv_add_dispatched_file_force_all(test_intrin512 TEST AVX512_SKX)
|
2018-07-30 23:53:05 +08:00
|
|
|
|
2021-02-04 06:04:35 +08:00
|
|
|
|
2021-03-19 06:58:05 +08:00
|
|
|
set(PARALLEL_ENABLE_PLUGINS_DEFAULT ON)
|
|
|
|
if(EMSCRIPTEN OR IOS OR WINRT)
|
|
|
|
set(PARALLEL_ENABLE_PLUGINS_DEFAULT OFF)
|
|
|
|
endif()
|
2021-02-04 06:04:35 +08:00
|
|
|
# parallel backends configuration
|
2021-03-19 06:58:05 +08:00
|
|
|
set(PARALLEL_ENABLE_PLUGINS "${PARALLEL_ENABLE_PLUGINS_DEFAULT}" CACHE BOOL "Allow building parallel plugin support")
|
2021-02-04 06:04:35 +08:00
|
|
|
# TODO building plugins with OpenCV is not supported yet
|
|
|
|
#set(PARALLEL_PLUGIN_LIST "" CACHE STRING "List of parallel backends to be compiled as plugins (tbb, openmp or special value 'all')")
|
|
|
|
#string(REPLACE "," ";" PARALLEL_PLUGIN_LIST "${PARALLEL_PLUGIN_LIST}") # support comma-separated list (,) too
|
2021-12-22 00:34:48 +08:00
|
|
|
#string(TOLOWER "${PARALLEL_PLUGIN_LIST}" PARALLEL_PLUGIN_LIST)
|
2021-02-04 06:04:35 +08:00
|
|
|
|
|
|
|
|
2015-06-05 21:24:38 +08:00
|
|
|
ocv_add_module(core
|
2015-02-19 21:17:19 +08:00
|
|
|
OPTIONAL opencv_cudev
|
2020-06-09 02:32:53 +08:00
|
|
|
WRAP java objc python js)
|
2012-02-03 19:54:16 +08:00
|
|
|
|
2015-02-21 00:47:45 +08:00
|
|
|
set(extra_libs "")
|
|
|
|
|
2019-07-18 18:22:02 +08:00
|
|
|
if(WINRT AND WINDOWS_STORE AND CMAKE_SYSTEM_VERSION MATCHES "8.0")
|
2015-02-21 00:47:45 +08:00
|
|
|
list(APPEND extra_libs ole32.lib)
|
2013-07-19 17:43:05 +08:00
|
|
|
endif()
|
|
|
|
|
2018-04-06 19:21:15 +08:00
|
|
|
if(HAVE_TBB)
|
|
|
|
list(APPEND extra_libs tbb)
|
|
|
|
endif()
|
|
|
|
|
2015-12-09 10:45:10 +08:00
|
|
|
if(DEFINED WINRT AND NOT DEFINED ENABLE_WINRT_MODE_NATIVE)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
|
|
|
|
endif()
|
|
|
|
|
2012-02-03 19:26:49 +08:00
|
|
|
if(HAVE_CUDA)
|
2019-04-01 03:54:13 +08:00
|
|
|
if(NOT HAVE_opencv_cudev)
|
2019-03-28 21:51:11 +08:00
|
|
|
message(FATAL_ERROR "CUDA: OpenCV requires enabled 'cudev' module from 'opencv_contrib' repository: https://github.com/opencv/opencv_contrib")
|
|
|
|
endif()
|
2014-02-24 18:35:34 +08:00
|
|
|
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wenum-compare -Wunused-function -Wshadow)
|
2012-02-03 19:26:49 +08:00
|
|
|
endif()
|
|
|
|
|
2019-11-01 20:07:49 +08:00
|
|
|
if(CV_TRACE AND HAVE_ITT)
|
2017-05-25 23:59:01 +08:00
|
|
|
add_definitions(-DOPENCV_WITH_ITT=1)
|
|
|
|
endif()
|
|
|
|
|
2023-08-24 03:53:11 +08:00
|
|
|
# https://github.com/opencv/opencv/issues/24145
|
|
|
|
if(HAVE_IPP)
|
|
|
|
OCV_OPTION(OPENCV_IPP_ENABLE_ALL "Enable all OPENCV_IPP_ options at once" OFF)
|
|
|
|
OCV_OPTION(OPENCV_IPP_MEAN "Enable IPP optimizations for mean (+200Kb in binary size)" OPENCV_IPP_ENABLE_ALL)
|
|
|
|
OCV_OPTION(OPENCV_IPP_MINMAX "Enable IPP optimizations for minMaxLoc/minMaxIdx (+200Kb in binary size)" OPENCV_IPP_ENABLE_ALL)
|
|
|
|
OCV_OPTION(OPENCV_IPP_SUM "Enable IPP optimizations for sum (+100Kb in binary size)" OPENCV_IPP_ENABLE_ALL)
|
|
|
|
|
|
|
|
if(OPENCV_IPP_MEAN)
|
|
|
|
ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/mean.dispatch.cpp "OPENCV_IPP_MEAN=1")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(OPENCV_IPP_MINMAX)
|
|
|
|
ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/minmax.cpp "OPENCV_IPP_MINMAX=1")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(OPENCV_IPP_SUM)
|
|
|
|
ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/sum.dispatch.cpp "OPENCV_IPP_SUM=1")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-08-16 22:16:02 +08:00
|
|
|
file(GLOB lib_cuda_hdrs
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/*.hpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/*.h")
|
|
|
|
file(GLOB lib_cuda_hdrs_detail
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/detail/*.hpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/detail/*.h")
|
|
|
|
file(GLOB_RECURSE module_opencl_hdrs
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/opencl/*")
|
2013-04-05 00:54:35 +08:00
|
|
|
|
2016-08-26 18:33:47 +08:00
|
|
|
source_group("Include\\Cuda Headers" FILES ${lib_cuda_hdrs})
|
|
|
|
source_group("Include\\Cuda Headers\\Detail" FILES ${lib_cuda_hdrs_detail})
|
|
|
|
|
2021-01-21 19:03:17 +08:00
|
|
|
file(GLOB_RECURSE core_parallel_hdrs
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/parallel/*.hpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/parallel/*.h")
|
|
|
|
ocv_source_group("Include" DIRBASE "${CMAKE_CURRENT_LIST_DIR}/include" FILES ${core_parallel_hdrs})
|
|
|
|
|
2016-08-26 18:33:47 +08:00
|
|
|
source_group("Src" FILES "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version_string.inc")
|
2013-04-05 00:54:35 +08:00
|
|
|
|
2014-08-01 22:11:20 +08:00
|
|
|
ocv_glob_module_sources(SOURCES "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version_string.inc"
|
2021-01-21 19:03:17 +08:00
|
|
|
HEADERS ${core_parallel_hdrs} ${module_opencl_hdrs} ${lib_cuda_hdrs} ${lib_cuda_hdrs_detail})
|
2013-03-31 18:54:23 +08:00
|
|
|
|
2017-06-13 00:10:13 +08:00
|
|
|
ocv_module_include_directories(${the_module} ${ZLIB_INCLUDE_DIRS} ${OPENCL_INCLUDE_DIRS})
|
|
|
|
if(ANDROID AND HAVE_CPUFEATURES)
|
2017-08-21 11:31:21 +08:00
|
|
|
ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/system.cpp "HAVE_CPUFEATURES=1")
|
2017-06-13 00:10:13 +08:00
|
|
|
ocv_module_include_directories(${CPUFEATURES_INCLUDE_DIRS})
|
|
|
|
endif()
|
2017-05-25 23:59:01 +08:00
|
|
|
if(ITT_INCLUDE_DIRS)
|
|
|
|
ocv_module_include_directories(${ITT_INCLUDE_DIRS})
|
|
|
|
endif()
|
2017-07-27 23:01:34 +08:00
|
|
|
if(HAVE_POSIX_MEMALIGN)
|
2017-08-21 11:31:21 +08:00
|
|
|
ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/alloc.cpp "HAVE_POSIX_MEMALIGN=1")
|
2017-07-27 23:01:34 +08:00
|
|
|
endif()
|
|
|
|
if(HAVE_MALLOC_H)
|
2017-08-21 11:31:21 +08:00
|
|
|
ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/alloc.cpp "HAVE_MALLOC_H=1")
|
2017-07-27 23:01:34 +08:00
|
|
|
endif()
|
|
|
|
if(HAVE_MEMALIGN)
|
2017-08-21 11:31:21 +08:00
|
|
|
ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/alloc.cpp "HAVE_MEMALIGN=1")
|
2017-07-27 23:01:34 +08:00
|
|
|
endif()
|
2020-12-23 21:59:28 +08:00
|
|
|
if(HAVE_WIN32_ALIGNED_MALLOC)
|
|
|
|
ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/alloc.cpp "HAVE_WIN32_ALIGNED_MALLOC=1")
|
|
|
|
endif()
|
2020-09-11 18:29:31 +08:00
|
|
|
if(HAVE_VA_INTEL_OLD_HEADER)
|
|
|
|
ocv_append_source_file_compile_definitions("${CMAKE_CURRENT_LIST_DIR}/src/va_intel.cpp" "HAVE_VA_INTEL_OLD_HEADER")
|
|
|
|
endif()
|
2021-02-18 21:36:07 +08:00
|
|
|
if(OPENCV_LIBVA_LINK)
|
|
|
|
ocv_append_source_file_compile_definitions("${CMAKE_CURRENT_LIST_DIR}/src/va_intel.cpp" "OPENCV_LIBVA_LINK=1")
|
|
|
|
endif()
|
2017-07-27 23:01:34 +08:00
|
|
|
|
2020-01-21 18:51:03 +08:00
|
|
|
option(OPENCV_ENABLE_ALLOCATOR_STATS "Enable Allocator metrics" ON)
|
|
|
|
|
|
|
|
if(NOT OPENCV_ENABLE_ALLOCATOR_STATS)
|
|
|
|
add_definitions(-DOPENCV_DISABLE_ALLOCATOR_STATS=1)
|
2020-12-06 04:41:25 +08:00
|
|
|
elseif(HAVE_CXX11 OR DEFINED OPENCV_ALLOCATOR_STATS_COUNTER_TYPE)
|
2020-01-21 18:51:03 +08:00
|
|
|
if(NOT DEFINED OPENCV_ALLOCATOR_STATS_COUNTER_TYPE)
|
|
|
|
if(HAVE_ATOMIC_LONG_LONG AND OPENCV_ENABLE_ATOMIC_LONG_LONG)
|
2020-12-06 04:41:25 +08:00
|
|
|
if(MINGW)
|
|
|
|
# command-line generation issue due to space in value, int/int64_t should be used instead
|
|
|
|
# https://github.com/opencv/opencv/issues/16990
|
|
|
|
message(STATUS "Consider adding OPENCV_ALLOCATOR_STATS_COUNTER_TYPE=int/int64_t according to your build configuration")
|
|
|
|
else()
|
|
|
|
set(OPENCV_ALLOCATOR_STATS_COUNTER_TYPE "long long")
|
|
|
|
endif()
|
2020-01-21 18:51:03 +08:00
|
|
|
else()
|
|
|
|
set(OPENCV_ALLOCATOR_STATS_COUNTER_TYPE "int")
|
|
|
|
endif()
|
|
|
|
endif()
|
2020-12-06 04:41:25 +08:00
|
|
|
if(DEFINED OPENCV_ALLOCATOR_STATS_COUNTER_TYPE)
|
|
|
|
message(STATUS "Allocator metrics storage type: '${OPENCV_ALLOCATOR_STATS_COUNTER_TYPE}'")
|
|
|
|
add_definitions("-DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE=${OPENCV_ALLOCATOR_STATS_COUNTER_TYPE}")
|
|
|
|
endif()
|
2020-01-21 18:51:03 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2021-02-04 06:04:35 +08:00
|
|
|
if(PARALLEL_ENABLE_PLUGINS)
|
|
|
|
ocv_append_source_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/parallel/parallel.cpp "PARALLEL_ENABLE_PLUGINS=1")
|
|
|
|
if(OPENCV_DEBUG_POSTFIX)
|
|
|
|
ocv_append_source_file_compile_definitions("${CMAKE_CURRENT_LIST_DIR}/src/parallel/parallel.cpp" "DEBUG_POSTFIX=${OPENCV_DEBUG_POSTFIX}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2015-02-21 00:47:45 +08:00
|
|
|
ocv_create_module(${extra_libs})
|
2012-02-03 19:26:49 +08:00
|
|
|
|
2019-12-13 22:52:40 +08:00
|
|
|
ocv_target_link_libraries(${the_module} PRIVATE
|
2017-05-25 23:59:01 +08:00
|
|
|
"${ZLIB_LIBRARIES}" "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}"
|
2021-12-07 13:47:54 +08:00
|
|
|
"${OPENGL_LIBRARIES}"
|
2022-06-15 06:16:51 +08:00
|
|
|
"${GLX_LIBRARIES}"
|
2018-03-28 21:34:37 +08:00
|
|
|
"${LAPACK_LIBRARIES}" "${CPUFEATURES_LIBRARIES}" "${HALIDE_LIBRARIES}"
|
2017-05-25 23:59:01 +08:00
|
|
|
"${ITT_LIBRARIES}"
|
2017-08-17 05:23:06 +08:00
|
|
|
"${OPENCV_HAL_LINKER_LIBS}"
|
2017-05-25 23:59:01 +08:00
|
|
|
)
|
2017-02-15 22:12:28 +08:00
|
|
|
|
2021-02-23 08:22:06 +08:00
|
|
|
if(OPENCV_CORE_EXCLUDE_C_API)
|
|
|
|
ocv_target_compile_definitions(${the_module} PRIVATE "OPENCV_EXCLUDE_C_API=1")
|
|
|
|
endif()
|
|
|
|
|
2021-07-09 04:21:21 +08:00
|
|
|
if(OPENCV_DISABLE_THREAD_SUPPORT)
|
|
|
|
ocv_target_compile_definitions(${the_module} PUBLIC "OPENCV_DISABLE_THREAD_SUPPORT=1")
|
|
|
|
endif()
|
|
|
|
|
2021-07-21 23:46:05 +08:00
|
|
|
if(OPENCV_SEMIHOSTING)
|
|
|
|
ocv_target_compile_definitions(${the_module} PRIVATE "-DOPENCV_SEMIHOSTING")
|
|
|
|
endif(OPENCV_SEMIHOSTING)
|
|
|
|
|
2018-08-31 21:23:26 +08:00
|
|
|
if(HAVE_HPX)
|
|
|
|
ocv_target_link_libraries(${the_module} LINK_PRIVATE "${HPX_LIBRARIES}")
|
|
|
|
endif()
|
|
|
|
|
2023-01-16 17:44:13 +08:00
|
|
|
if(HAVE_OPENMP AND DEFINED OpenMP_CXX_LIBRARIES AND OpenMP_CXX_LIBRARIES)
|
|
|
|
ocv_target_link_libraries(${the_module} LINK_PRIVATE "${OpenMP_CXX_LIBRARIES}")
|
|
|
|
endif()
|
|
|
|
|
2012-02-03 19:26:49 +08:00
|
|
|
ocv_add_accuracy_tests()
|
|
|
|
ocv_add_perf_tests()
|
2018-02-27 02:10:21 +08:00
|
|
|
|
|
|
|
ocv_install_3rdparty_licenses(SoftFloat "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/SoftFloat/COPYING.txt")
|
2017-03-12 12:49:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
# generate data (samples data) config file
|
2023-02-03 18:02:45 +08:00
|
|
|
set(OPENCV_DATA_CONFIG_FILE "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv_data_config.hpp")
|
2017-03-12 12:49:07 +08:00
|
|
|
set(OPENCV_DATA_CONFIG_STR "")
|
|
|
|
|
|
|
|
if(CMAKE_INSTALL_PREFIX)
|
|
|
|
set(OPENCV_DATA_CONFIG_STR "${OPENCV_DATA_CONFIG_STR}
|
|
|
|
#define OPENCV_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\"
|
|
|
|
")
|
|
|
|
endif()
|
|
|
|
if(OPENCV_OTHER_INSTALL_PATH)
|
|
|
|
set(OPENCV_DATA_CONFIG_STR "${OPENCV_DATA_CONFIG_STR}
|
|
|
|
#define OPENCV_DATA_INSTALL_PATH \"${OPENCV_OTHER_INSTALL_PATH}\"
|
|
|
|
")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(OPENCV_DATA_CONFIG_STR "${OPENCV_DATA_CONFIG_STR}
|
|
|
|
#define OPENCV_BUILD_DIR \"${CMAKE_BINARY_DIR}\"
|
|
|
|
")
|
|
|
|
|
|
|
|
file(RELATIVE_PATH SOURCE_DIR_RELATIVE ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
|
|
|
|
set(OPENCV_DATA_CONFIG_STR "${OPENCV_DATA_CONFIG_STR}
|
|
|
|
#define OPENCV_DATA_BUILD_DIR_SEARCH_PATHS \\
|
|
|
|
\"${SOURCE_DIR_RELATIVE}/\"
|
|
|
|
")
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
file(RELATIVE_PATH INSTALL_DATA_DIR_RELATIVE "${CMAKE_INSTALL_PREFIX}/${OPENCV_BIN_INSTALL_PATH}" "${CMAKE_INSTALL_PREFIX}/${OPENCV_OTHER_INSTALL_PATH}")
|
|
|
|
else()
|
|
|
|
file(RELATIVE_PATH INSTALL_DATA_DIR_RELATIVE "${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}" "${CMAKE_INSTALL_PREFIX}/${OPENCV_OTHER_INSTALL_PATH}")
|
|
|
|
endif()
|
|
|
|
list(APPEND OPENCV_INSTALL_DATA_DIR_RELATIVE "${INSTALL_DATA_DIR_RELATIVE}")
|
|
|
|
string(REPLACE ";" "\",\\\n \"" OPENCV_INSTALL_DATA_DIR_RELATIVE_STR "\"${OPENCV_INSTALL_DATA_DIR_RELATIVE}\"")
|
|
|
|
set(OPENCV_DATA_CONFIG_STR "${OPENCV_DATA_CONFIG_STR}
|
|
|
|
#define OPENCV_INSTALL_DATA_DIR_RELATIVE ${OPENCV_INSTALL_DATA_DIR_RELATIVE_STR}
|
|
|
|
")
|
|
|
|
|
|
|
|
if(EXISTS "${OPENCV_DATA_CONFIG_FILE}")
|
|
|
|
file(READ "${OPENCV_DATA_CONFIG_FILE}" __content)
|
|
|
|
endif()
|
|
|
|
if(NOT OPENCV_DATA_CONFIG_STR STREQUAL "${__content}")
|
|
|
|
file(WRITE "${OPENCV_DATA_CONFIG_FILE}" "${OPENCV_DATA_CONFIG_STR}")
|
|
|
|
endif()
|