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

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2024-01-23 17:06:52 +03:00
148 changed files with 3263 additions and 1564 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;