mirror of
https://github.com/opencv/opencv.git
synced 2026-11-14 21:40:06 -06:00
objdetect: default CCheckerDetector chart type to MCC24 - #30412 Fixes #30410. `CCheckerDetectorImpl::m_chartType` had no initializer and the constructor is empty, so a detector from `CCheckerDetector::create()` read an indeterminate chart type unless `setColorChartType()` was called first. It now defaults to `MCC24`, the first `ColorChart` value. With `operator new` filling memory with 0xFF, 5.x reports chart type -1 and `process()` fails on `mcc/MCC24.png`; with the fix it reports `MCC24` and finds the chart. Added `CV_mccRunCCheckerDetectorBasic.default_chart_type`, which checks the default and runs detection without setting the type. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
61 lines
1.8 KiB
C++
61 lines
1.8 KiB
C++
// This file is part of OpenCV project.
|
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
|
// of this distribution and at http://opencv.org/license.html.
|
|
|
|
#include "test_precomp.hpp"
|
|
|
|
#include <vector>
|
|
|
|
namespace opencv_test
|
|
{
|
|
namespace
|
|
{
|
|
|
|
using namespace std;
|
|
using namespace cv::mcc;
|
|
|
|
/****************************************************************************************\
|
|
* Test detection works properly on the simplest images
|
|
\****************************************************************************************/
|
|
|
|
void runCCheckerDetectorBasic(std::string image_name, ColorChart chartType)
|
|
{
|
|
Ptr<CCheckerDetector> detector = CCheckerDetector::create();
|
|
std::string path = cvtest::findDataFile("mcc/" + image_name);
|
|
cv::Mat img = imread(path);
|
|
ASSERT_FALSE(img.empty()) << "Test image can't be loaded: " << path;
|
|
|
|
detector->setColorChartType(chartType);
|
|
ASSERT_TRUE(detector->process(img));
|
|
}
|
|
TEST(CV_mccRunCCheckerDetectorBasic, accuracy_SG140)
|
|
{
|
|
runCCheckerDetectorBasic("SG140.png", SG140);
|
|
}
|
|
TEST(CV_mccRunCCheckerDetectorBasic, accuracy_MCC24)
|
|
{
|
|
runCCheckerDetectorBasic("MCC24.png", MCC24);
|
|
}
|
|
|
|
TEST(CV_mccRunCCheckerDetectorBasic, accuracy_VINYL18)
|
|
{
|
|
runCCheckerDetectorBasic("VINYL18.png", VINYL18);
|
|
}
|
|
|
|
TEST(CV_mccRunCCheckerDetectorBasic, default_chart_type)
|
|
{
|
|
Ptr<CCheckerDetector> detector = CCheckerDetector::create();
|
|
EXPECT_EQ(MCC24, detector->getColorChartType());
|
|
Ptr<CChecker> checker = CChecker::create();
|
|
EXPECT_EQ(MCC24, checker->getTarget());
|
|
EXPECT_EQ(0.f, checker->getCost());
|
|
|
|
std::string path = cvtest::findDataFile("mcc/MCC24.png");
|
|
cv::Mat img = imread(path);
|
|
ASSERT_FALSE(img.empty()) << "Test image can't be loaded: " << path;
|
|
ASSERT_TRUE(detector->process(img));
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace opencv_test
|