diff --git a/modules/objdetect/test/test_charucodetection.cpp b/modules/objdetect/test/test_charucodetection.cpp index 2dfbcb199f..84383d7142 100644 --- a/modules/objdetect/test/test_charucodetection.cpp +++ b/modules/objdetect/test/test_charucodetection.cpp @@ -917,9 +917,7 @@ TEST_P(CharucoBoardGenerate, issue_24806) } } -// Temporary disabled in https://github.com/opencv/opencv/pull/24338 -// 5.x version produces conrnes with different shape than 4.x (32F_C2 instead of 2x 32FC1) -TEST(Charuco, DISABLED_testSeveralBoardsWithCustomIds) +TEST(Charuco, testSeveralBoardsWithCustomIds) { Size res{500, 500}; Mat K = (Mat_(3,3) << diff --git a/modules/objdetect/test/test_chesscorners.cpp b/modules/objdetect/test/test_chesscorners.cpp index e9ff554939..1eece0dad3 100644 --- a/modules/objdetect/test/test_chesscorners.cpp +++ b/modules/objdetect/test/test_chesscorners.cpp @@ -957,5 +957,52 @@ TEST(Calib3d_CornerOrdering, issue_26830) { ASSERT_EQ(cornersMinimumSizeMatchesPatternSize, cornersMinimumSizeSmallerThanPatternSize); } +// findChessboardCorners() falls back to checkChessboard() under CALIB_CB_FAST_CHECK +// (calibinit.cpp), so a false negative here costs a detection. +// +// checkChessboard() is deliberately not required to agree with findChessboardCorners(): +// it is a permissive pre-filter, and the two legitimately differ on +// chessboard-artificial2.png, where checkChessboard() is the one that gets it right. +TEST(Calib3d_CheckChessboard, accuracy) +{ + const string folder = string(cvtest::TS::ptr()->get_data_path()) + "cameracalibration/"; + const string listname = folder + "chessboard_timing_list.dat"; + + FileStorage fs(listname, FileStorage::READ); + ASSERT_TRUE(fs.isOpened()) << "Could not read " << listname; + + FileNode boards = fs["boards"]; + ASSERT_TRUE(boards.isSeq()) << listname << " does not contain a 'boards' sequence"; + ASSERT_EQ(size_t(0), boards.size() % 4) << listname << " is malformed"; + + const int count = (int)boards.size() / 4; + ASSERT_GT(count, 0) << listname << " lists no images"; + + FileNodeIterator it = boards.begin(); + for (int i = 0; i < count; i++) + { + string imgname; + int isChessboard = 0; + Size patternSize; + read(*it++, imgname, "dummy.txt"); + read(*it++, isChessboard, 0); + read(*it++, patternSize.width, -1); + read(*it++, patternSize.height, -1); + + SCOPED_TRACE(cv::format("image %d/%d: %s", i + 1, count, imgname.c_str())); + + Mat img = imread(folder + imgname); + ASSERT_FALSE(img.empty()) << "Could not read " << folder << imgname; + ASSERT_GT(patternSize.width, 0); + ASSERT_GT(patternSize.height, 0); + + Mat gray; + cvtColor(img, gray, COLOR_BGR2GRAY); + + // EXPECT, not ASSERT: report every image rather than stopping at the first. + EXPECT_EQ(isChessboard != 0, checkChessboard(gray, patternSize)); + } +} + }} // namespace /* End of file. */ diff --git a/modules/objdetect/test/test_chesscorners_timing.cpp b/modules/objdetect/test/test_chesscorners_timing.cpp deleted file mode 100644 index c0154a2df8..0000000000 --- a/modules/objdetect/test/test_chesscorners_timing.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// -// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// Intel License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2000, Intel Corporation, all rights reserved. -// Third party copyrights are property of their respective owners. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistribution's of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistribution's in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of Intel Corporation may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors "as is" and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. -// -//M*/ - -#include "test_precomp.hpp" -#include "opencv2/imgproc.hpp" - -namespace opencv_test { namespace { - -class CV_ChessboardDetectorTimingTest : public cvtest::BaseTest -{ -public: - CV_ChessboardDetectorTimingTest(); -protected: - void run(int); -}; - - -CV_ChessboardDetectorTimingTest::CV_ChessboardDetectorTimingTest() -{ -} - -/* ///////////////////// chess_corner_test ///////////////////////// */ -void CV_ChessboardDetectorTimingTest::run( int start_from ) -{ - int code = cvtest::TS::OK; - - /* test parameters */ - std::string filepath; - std::string filename; - - std::vector v; - Mat img, gray, thresh; - - int idx, max_idx; - int progress = 0; - - filepath = cv::format("%scameracalibration/", ts->get_data_path().c_str() ); - filename = cv::format("%schessboard_timing_list.dat", filepath.c_str() ); - cv::FileStorage fs( filename, FileStorage::READ ); - cv::FileNode board_list = fs["boards"]; - cv::FileNodeIterator bl_it = board_list.begin(); - - if( !fs.isOpened() || !board_list.isSeq() || board_list.size() % 4 != 0 ) - { - ts->printf( cvtest::TS::LOG, "chessboard_timing_list.dat can not be read or is not valid" ); - code = cvtest::TS::FAIL_MISSING_TEST_DATA; - goto _exit_; - } - - max_idx = (int)(board_list.size()/4); - for( idx = 0; idx < start_from; idx++ ) - { - bl_it += 4; - } - - for( idx = start_from; idx < max_idx; idx++ ) - { - Size pattern_size; - - std::string imgname; read(*bl_it++, imgname, "dummy.txt"); - int is_chessboard = 0; - read(*bl_it++, is_chessboard, 0); - read(*bl_it++, pattern_size.width, -1); - read(*bl_it++, pattern_size.height, -1); - - ts->update_context( this, idx-1, true ); - - /* read the image */ - filename = cv::format("%s%s", filepath.c_str(), imgname.c_str() ); - - img = cv::imread( filename ); - if( img.empty() ) - { - ts->printf( cvtest::TS::LOG, "one of chessboard images can't be read: %s\n", filename.c_str() ); - code = cvtest::TS::FAIL_MISSING_TEST_DATA; - continue; - } - - ts->printf(cvtest::TS::LOG, "%s: chessboard %d:\n", imgname.c_str(), is_chessboard); - - cvtColor(img, gray, COLOR_BGR2GRAY); - - int64 _time0 = cv::getTickCount(); - bool result = cv::checkChessboard(gray, pattern_size); - int64 _time01 = cv::getTickCount(); - bool result1 = findChessboardCorners(gray, pattern_size, v, 15); - int64 _time1 = cv::getTickCount(); - - if( result != (is_chessboard != 0)) - { - ts->printf( cvtest::TS::LOG, "Error: chessboard was %sdetected in the image %s\n", - result ? "" : "not ", imgname.c_str() ); - code = cvtest::TS::FAIL_INVALID_OUTPUT; - goto _exit_; - } - if(result != result1) - { - ts->printf( cvtest::TS::LOG, "Warning: results differ cvCheckChessboard %d, cvFindChessboardCorners %d\n", - (int)result, (int)result1); - } - - int num_pixels = gray.cols*gray.rows; - float check_chessboard_time = float(_time01 - _time0)/(float)cv::getTickFrequency(); // in s - ts->printf(cvtest::TS::LOG, " cvCheckChessboard time s: %f, us per pixel: %f\n", - check_chessboard_time, check_chessboard_time*1e6/num_pixels); - - float find_chessboard_time = float(_time1 - _time01)/(float)cv::getTickFrequency(); - ts->printf(cvtest::TS::LOG, " cvFindChessboard time s: %f, us per pixel: %f\n", - find_chessboard_time, find_chessboard_time*1e6/num_pixels); - progress = update_progress( progress, idx-1, max_idx, 0 ); - } - -_exit_: - - if( code < 0 ) - ts->set_failed_test_info( code ); -} - -TEST(Calib3d_ChessboardDetector, timing) { CV_ChessboardDetectorTimingTest test; test.safe_run(); } - -}} // namespace -/* End of file. */