Repository: opencv
Issue: SeamlessClone cannot run in parallel on Ubuntu 18.04
Labels: optimization,feature,category: photo

##### System information (version)

- OpenCV => 4.2.0
- Operating System / Platform => ubuntu 18.04
- Compiler => cc
- CPU => Intel(R) Core(TM) i7-9700F CPU @ 3.00GHz

##### Detailed description

I have a project that needs to call `SeamlessClone` for seamless image fusion. I enabled parallel library support when I compiled the OpenCV library, but this function still takes a lot of time to execute (about 20s). I looked at the computer resource usage via `htop` command and found that it only occupied one core.

![](https://raw.githubusercontent.com/Feyily/imgbed/master/20210122163340.png)

The command I used when generating the Makefile of the opencv library
```
cmake CMAKE_BUILD_TYPE=Release -DWITH_IPP=OFF -DWITH_TBB=OFF -DWITH_OPENMP=ON  -DWITH_PTHREADS_PF=OFF ..
```

![](https://raw.githubusercontent.com/Feyily/imgbed/master/20210122162926.png)

, and cmake profile also shows that openmp is enabled.

In addition, I tried to test the `SeamlessClone` function on a Windows system with parallel support enabled and found that the execution was fast (less than 1 second) and the function was multithreaded. I also tested it on a Centos system, and as on ubuntu, there was no parallel effect.

##### Windows System information

- OpenCV => 4.2.0
- Operating System / Platform => Windows 10 20H2
- Compiler => Visual Studio 2019
- CPU => Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz

I ran a series of tests to make sure that opencv was parallelized, but it didn't work on `SeamlessClone`!

I wonder, is this a bug or is `SeamlessClone` not supporting parallel execution on the Linux platform?

##### Code I used

``` c++
RemoveLight::RemoveLight(Mat inImage)
{
	Mat SplicingImage;
	hconcat(inImage, inImage, SplicingImage);
	vconcat(SplicingImage, SplicingImage, SplicingImage);

	Mat mask = 255 * Mat::ones(inImage.rows, inImage.cols, inImage.depth());
	Point centerPt = Point(SplicingImage.cols / 2, SplicingImage.rows / 2);

	seamlessClone(inImage, SplicingImage, mask, centerPt, SplicingImage, NORMAL_CLONE);
	// NORMAL_CLONE MIXED_CLONE MONOCHROME_TRANSFER

	int cols = inImage.cols;
	int rows = inImage.rows;
	Rect rect = Rect(cols * (3. / 4), rows * (3. / 4), cols / 2, rows / 2);

	resize(SplicingImage(rect), resImage, Size(510, 510));
}
```

Related issue: #19350 

##### Issue submission checklist

 - [x] I report the issue, it's not a question
   <!--
   OpenCV team works with forum.opencv.org, Stack Overflow and other communities
   to discuss problems. Tickets with question without real issue statement will be
   closed.
   -->
 - [x] I checked the problem with documentation, FAQ, open issues,
       forum.opencv.org, Stack Overflow, etc and have not found solution
   <!--
   Places to check:
   * OpenCV documentation: https://docs.opencv.org
   * FAQ page: https://github.com/opencv/opencv/wiki/FAQ
   * OpenCV forum: https://forum.opencv.org
   * OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
   * Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
   -->
 - [x] I updated to latest OpenCV version and the issue is still there
   <!--
   master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.
   OpenCV team supports only latest release for each branch.
   The ticket is closed, if the problem is not reproduced with modern version.
   -->
 - [x] There is reproducer code and related data files: videos, images, onnx, etc
   <!--
   The best reproducer -- test case for OpenCV that we can add to the library.
   Recommendations for media files and binary files:
   * Try to reproduce the issue with images and videos in opencv_extra repository
     to reduce attachment size
   * Use PNG for images, if you report some CV related bug, but not image reader
     issue
   * Attach the image as archive to the ticket, if you report some reader issue.
     Image hosting services compress images and it breaks the repro code.
   * Provide ONNX file for some public model or ONNX file with with random weights,
     if you report ONNX parsing or handling issue. Architecture details diagram
     from netron tool can be very useful too. See https://lutzroeder.github.io/netron/
   -->