test_scansegment.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #include "test_precomp.hpp"
  5. namespace opencv_test { namespace {
  6. static void runScanSegment(int slices)
  7. {
  8. Mat img = imread(cvtest::findDataFile("cv/shared/lena.png"), IMREAD_COLOR);
  9. Mat labImg;
  10. cvtColor(img, labImg, COLOR_BGR2Lab);
  11. Ptr<ScanSegment> ss = createScanSegment(labImg.cols, labImg.rows, 500, slices, true);
  12. ss->iterate(labImg);
  13. int numSuperpixels = ss->getNumberOfSuperpixels();
  14. EXPECT_GT(numSuperpixels, 100);
  15. EXPECT_LE(numSuperpixels, 500);
  16. Mat res;
  17. ss->getLabelContourMask(res, false);
  18. EXPECT_GE(cvtest::norm(res, NORM_L1), 1000000);
  19. if (cvtest::debugLevel >= 10)
  20. {
  21. imshow("ScanSegment", res);
  22. waitKey();
  23. }
  24. }
  25. TEST(ximgproc_ScanSegment, smoke) { runScanSegment(1); }
  26. TEST(ximgproc_ScanSegment, smoke4) { runScanSegment(4); }
  27. TEST(ximgproc_ScanSegment, smoke8) { runScanSegment(8); }
  28. }} // namespace