1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge pull request #22754 from mshabunin:c-cleanup

C-API cleanup for OpenCV 5.x (imgproc, highgui)

* imgproc: C-API cleanup

* imgproc: increase cvtColor test diff threshold

* imgproc: C-API cleanup pt.2

* imgproc: C-API cleanup pt.3

* imgproc: C-API cleanup pt.4

* imgproc: C-API cleanup pt.5

* imgproc: C-API cleanup pt.5

* imgproc: C-API cleanup pt.6

* highgui: C-API cleanup

* highgui: C-API cleanup pt.2

* highgui: C-API cleanup pt.3

* highgui: C-API cleanup pt.3

* imgproc: C-API cleanup pt.7

* fixup! highgui: C-API cleanup pt.3

* fixup! imgproc: C-API cleanup pt.6

* imgproc: C-API cleanup pt.8

* imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9
This commit is contained in:
Maksim Shabunin
2022-12-14 21:57:08 +03:00
committed by GitHub
parent d49958141e
commit 8a62b03761
87 changed files with 1374 additions and 12887 deletions
-87
View File
@@ -41,90 +41,3 @@
//M*/
#include "test_precomp.hpp"
#if 0
namespace opencv_test { namespace {
class CV_WatershedTest : public cvtest::BaseTest
{
public:
CV_WatershedTest();
~CV_WatershedTest();
protected:
void run(int);
};
CV_WatershedTest::CV_WatershedTest() {}
CV_WatershedTest::~CV_WatershedTest() {}
void CV_WatershedTest::run( int /* start_from */)
{
string exp_path = string(ts->get_data_path()) + "watershed/wshed_exp.png";
Mat exp = imread(exp_path, 0);
Mat orig = imread(string(ts->get_data_path()) + "inpaint/orig.png");
FileStorage fs(string(ts->get_data_path()) + "watershed/comp.xml", FileStorage::READ);
if (orig.empty() || !fs.isOpened())
{
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA );
return;
}
CvSeq* cnts = (CvSeq*)fs["contours"].readObj();
Mat markers(orig.size(), CV_32SC1);
markers = Scalar(0);
IplImage iplmrks = cvIplImage(markers);
vector<unsigned char> colors(1);
for(int i = 0; cnts != 0; cnts = cnts->h_next, ++i )
{
cvDrawContours( &iplmrks, cnts, cvScalar(Scalar::all(i + 1)), cvScalar(Scalar::all(i + 1)), -1, CV_FILLED);
Point* p = (Point*)cvGetSeqElem(cnts, 0);
//expected image was added with 1 in order to save to png
//so now we subtract 1 to get real color
if(!exp.empty())
colors.push_back(exp.ptr(p->y)[p->x] - 1);
}
fs.release();
const int compNum = (int)(colors.size() - 1);
watershed(orig, markers);
for(int j = 0; j < markers.rows; ++j)
{
int* line = markers.ptr<int>(j);
for(int i = 0; i < markers.cols; ++i)
{
int& pixel = line[i];
if (pixel == -1) // border
continue;
if (pixel <= 0 || pixel > compNum)
continue; // bad result, doing nothing and going to get error latter;
// repaint in saved color to compare with expected;
if(!exp.empty())
pixel = colors[pixel];
}
}
Mat markers8U;
markers.convertTo(markers8U, CV_8U, 1, 1);
if( exp.empty() || orig.size() != exp.size() )
{
imwrite(exp_path, markers8U);
exp = markers8U;
}
ASSERT_EQ(0, cvtest::norm(markers8U, exp, NORM_INF));
}
TEST(Imgproc_Watershed, regression) { CV_WatershedTest test; test.safe_run(); }
}} // namespace
#endif