Skip to content

Commit d85c13b

Browse files
Merge pull request opencv#26587 from anandkaranubc:fix-nu-svc-parameter-check
Fix opencv#25812: Add error handling for invalid nu parameter in SVM NU_SVC opencv#26587 ### 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 [Issue opencv#25812](opencv#25812) - [ ] 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
1 parent 0dfc5d4 commit d85c13b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

modules/ml/src/svm.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@
4141
//M*/
4242

4343
#include "precomp.hpp"
44+
#include <opencv2/core/utils/logger.hpp>
4445

4546
#include <stdarg.h>
4647
#include <ctype.h>
4748

49+
4850
/****************************************************************************************\
4951
COPYRIGHT NOTICE
5052
----------------
@@ -1458,9 +1460,10 @@ class SVMImpl CV_FINAL : public SVM
14581460
for( j = i+1; j< class_count; j++ )
14591461
{
14601462
int cj = class_ranges[j+1] - class_ranges[j];
1461-
if( nu*(ci + cj)*0.5 > std::min( ci, cj ) )
1462-
// TODO: add some diagnostic
1463+
if( nu*(ci + cj)*0.5 > std::min( ci, cj ) ) {
1464+
CV_LOG_ERROR(NULL, "Training cases incompatible with nu parameter—try a lower value.");
14631465
return false;
1466+
}
14641467
}
14651468
}
14661469
}

0 commit comments

Comments
 (0)