1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-25 21:33:04 +04:00

Merge pull request #23736 from seanm:c++11-simplifications

Removed all pre-C++11 code, workarounds, and branches #23736

This removes a bunch of pre-C++11 workrarounds that are no longer necessary as C++11 is now required.
It is a nice clean up and simplification.

* No longer unconditionally #include <array> in cvdef.h, include explicitly where needed
* Removed deprecated CV_NODISCARD, already unused in the codebase
* Removed some pre-C++11 workarounds, and simplified some backwards compat defines
* Removed CV_CXX_STD_ARRAY
* Removed CV_CXX_MOVE_SEMANTICS and CV_CXX_MOVE
* Removed all tests of CV_CXX11, now assume it's always true. This allowed removing a lot of dead code.
* Updated some documentation consequently.
* Removed all tests of CV_CXX11, now assume it's always true
* Fixed links.

---------

Co-authored-by: Maksim Shabunin <maksim.shabunin@gmail.com>
Co-authored-by: Alexander Smorkalov <alexander.smorkalov@xperience.ai>
This commit is contained in:
Sean McBride
2024-01-19 08:53:08 -05:00
committed by GitHub
parent d066c44bce
commit e64857c561
36 changed files with 68 additions and 319 deletions
@@ -2,6 +2,8 @@
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#define PARALLEL_FOR_LAMBDA
using namespace std;
using namespace cv;
@@ -33,6 +35,8 @@ int mandelbrotFormula(const complex<float> &z0, const int maxIter=500) {
}
//! [mandelbrot-grayscale-value]
#ifndef PARALLEL_FOR_LAMBDA
//! [mandelbrot-parallel]
class ParallelMandelbrot : public ParallelLoopBody
{
@@ -71,6 +75,8 @@ private:
};
//! [mandelbrot-parallel]
#endif // !PARALLEL_FOR_LAMBDA
//! [mandelbrot-sequential]
void sequentialMandelbrot(Mat &img, const float x1, const float y1, const float scaleX, const float scaleY)
{
@@ -102,7 +108,7 @@ int main()
double t1 = (double) getTickCount();
#ifdef CV_CXX11
#ifdef PARALLEL_FOR_LAMBDA
//! [mandelbrot-parallel-call-cxx11]
parallel_for_(Range(0, mandelbrotImg.rows*mandelbrotImg.cols), [&](const Range& range){
@@ -121,14 +127,14 @@ int main()
});
//! [mandelbrot-parallel-call-cxx11]
#else
#else // PARALLEL_FOR_LAMBDA
//! [mandelbrot-parallel-call]
ParallelMandelbrot parallelMandelbrot(mandelbrotImg, x1, y1, scaleX, scaleY);
parallel_for_(Range(0, mandelbrotImg.rows*mandelbrotImg.cols), parallelMandelbrot);
//! [mandelbrot-parallel-call]
#endif
#endif // PARALLEL_FOR_LAMBDA
t1 = ((double) getTickCount() - t1) / getTickFrequency();
cout << "Parallel Mandelbrot: " << t1 << " s" << endl;
@@ -4,6 +4,8 @@
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#define PARALLEL_FOR_LAMBDA
using namespace std;
using namespace cv;
@@ -47,7 +49,8 @@ void conv_seq(Mat src, Mat &dst, Mat kernel)
}
//! [convolution-sequential]
#ifdef CV_CXX11
#ifdef PARALLEL_FOR_LAMBDA
void conv_parallel(Mat src, Mat &dst, Mat kernel)
{
int rows = src.rows, cols = src.cols;
@@ -118,7 +121,8 @@ void conv_parallel_row_split(Mat src, Mat &dst, Mat kernel)
});
//! [convolution-parallel-cxx11-row-split]
}
#else
#else // PARALLEL_FOR_LAMBDA
//! [convolution-parallel]
class parallelConvolution : public ParallelLoopBody
@@ -235,7 +239,7 @@ void conv_parallel_row_split(Mat src, Mat &dst, Mat kernel)
//! [convolution-parallel-function-row]
}
#endif
#endif // PARALLEL_FOR_LAMBDA
static void help(char *progName)
{
@@ -329,4 +333,4 @@ int main(int argc, char *argv[])
// imwrite("dst.png", dst);
return 0;
}
}
@@ -59,12 +59,12 @@ int main(int,char**)
cout << "C = " << endl << " " << C << endl << endl;
//! [comma]
// do the same with initializer_list
#ifdef CV_CXX11
//! [list]
C = (Mat_<double>({0, -1, 0, -1, 5, -1, 0, -1, 0})).reshape(3);
cout << "C = " << endl << " " << C << endl << endl;
//! [list]
#endif
//! [clone]
Mat RowClone = C.row(1).clone();
cout << "RowClone = " << endl << " " << RowClone << endl << endl;