Skip to content

The findContours function is significantly slower in version 4.11 compared to version 4.7. #26775

@solidR22

Description

@solidR22

Describe the feature and motivation

Thank you for your work, but I tested and found that the speed of this function in version 4.11 is slower than in version 4.7.
Here are the test images and test results.

#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
	Mat img = imread("111.bmp", cv::IMREAD_GRAYSCALE);

	cv::Mat mask;
	inRange(img, 110, 120, mask);

	std::vector<std::vector<cv::Point>> v_cont;
	for (int i = 0; i < 10; i++)
	{
		v_cont.clear();
		auto start = chrono::system_clock::now();
		cv::findContours(mask, v_cont, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE);
		auto end = chrono::system_clock::now();
		auto duration = chrono::duration_cast<chrono::microseconds>(end - start) / 1000.;
		cout << "4.11 findContours cost" << double(duration.count()) << "ms" << endl;
	}
}

1234

image
image

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions