mirror of
https://github.com/opencv/opencv.git
synced 2025-08-05 14:06:35 +08:00
Merge pull request #26587 from anandkaranubc:fix-nu-svc-parameter-check
Fix #25812: Add error handling for invalid nu parameter in SVM NU_SVC #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 #25812](https://github.com/opencv/opencv/issues/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
This commit is contained in:
parent
0dfc5d416f
commit
d85c13bcbb
@ -41,10 +41,12 @@
|
|||||||
//M*/
|
//M*/
|
||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
#include <opencv2/core/utils/logger.hpp>
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
/****************************************************************************************\
|
||||||
COPYRIGHT NOTICE
|
COPYRIGHT NOTICE
|
||||||
----------------
|
----------------
|
||||||
@ -1458,9 +1460,10 @@ public:
|
|||||||
for( j = i+1; j< class_count; j++ )
|
for( j = i+1; j< class_count; j++ )
|
||||||
{
|
{
|
||||||
int cj = class_ranges[j+1] - class_ranges[j];
|
int cj = class_ranges[j+1] - class_ranges[j];
|
||||||
if( nu*(ci + cj)*0.5 > std::min( ci, cj ) )
|
if( nu*(ci + cj)*0.5 > std::min( ci, cj ) ) {
|
||||||
// TODO: add some diagnostic
|
CV_LOG_ERROR(NULL, "Training cases incompatible with nu parameter—try a lower value.");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user