@ -409,7 +409,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
( ( ( _param2 . rows = = 1 | | _param2 . cols = = 1 ) & &
( ( ( _param2 . rows = = 1 | | _param2 . cols = = 1 ) & &
( _param2 . rows + _param2 . cols - 1 = = cn | | _param2 . rows + _param2 . cols - 1 = = 1 | |
( _param2 . rows + _param2 . cols - 1 = = cn | | _param2 . rows + _param2 . cols - 1 = = 1 | |
( _param1 . size ( ) = = Size ( 1 , 4 ) & & _param1 . type ( ) = = CV_64F & & cn < = 4 ) ) ) | |
( _param1 . size ( ) = = Size ( 1 , 4 ) & & _param1 . type ( ) = = CV_64F & & cn < = 4 ) ) ) | |
( _param2 . rows = = cn & & _param2 . cols = = cn & & disttype = = NORMAL ) ) ) ;
( _param2 . rows = = cn & & _param2 . cols = = cn & & disttype = = RNG : : NORMAL ) ) ) ;
Vec2i * ip = 0 ;
Vec2i * ip = 0 ;
Vec2d * dp = 0 ;
Vec2d * dp = 0 ;
@ -421,7 +421,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
int n1 = ( int ) _param1 . total ( ) ;
int n1 = ( int ) _param1 . total ( ) ;
int n2 = ( int ) _param2 . total ( ) ;
int n2 = ( int ) _param2 . total ( ) ;
if ( disttype = = UNIFORM )
if ( disttype = = RNG : : UNIFORM )
{
{
_parambuf . allocate ( cn * 8 + n1 + n2 ) ;
_parambuf . allocate ( cn * 8 + n1 + n2 ) ;
double * parambuf = _parambuf . data ( ) ;
double * parambuf = _parambuf . data ( ) ;
@ -535,7 +535,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
}
}
CV_Assert ( func ! = 0 ) ;
CV_Assert ( func ! = 0 ) ;
}
}
else if ( disttype = = CV_RAND_ NORMAL )
else if ( disttype = = RNG : : NORMAL )
{
{
_parambuf . allocate ( MAX ( n1 , cn ) + MAX ( n2 , cn ) ) ;
_parambuf . allocate ( MAX ( n1 , cn ) + MAX ( n2 , cn ) ) ;
double * parambuf = _parambuf . data ( ) ;
double * parambuf = _parambuf . data ( ) ;
@ -586,7 +586,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
float * nbuf = 0 ;
float * nbuf = 0 ;
float * tmpbuf = 0 ;
float * tmpbuf = 0 ;
if ( disttype = = UNIFORM )
if ( disttype = = RNG : : UNIFORM )
{
{
buf . allocate ( blockSize * cn * 4 ) ;
buf . allocate ( blockSize * cn * 4 ) ;
param = ( uchar * ) ( double * ) buf . data ( ) ;
param = ( uchar * ) ( double * ) buf . data ( ) ;
@ -637,7 +637,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
{
{
int len = std : : min ( total - j , blockSize ) ;
int len = std : : min ( total - j , blockSize ) ;
if ( disttype = = CV_RAND_UNI )
if ( disttype = = RNG : : UNIFORM )
func ( ptr , len * cn , & state , param , tmpbuf , smallFlag ) ;
func ( ptr , len * cn , & state , param , tmpbuf , smallFlag ) ;
else
else
{
{
@ -753,12 +753,31 @@ void cv::randShuffle( InputOutputArray _dst, double iterFactor, RNG* _rng )
# ifndef OPENCV_EXCLUDE_C_API
# ifndef OPENCV_EXCLUDE_C_API
// Related with https://github.com/opencv/opencv/issues/26258
// To suppress cast-user-defined warning for casting CvRNG to cv::RNG& with GCC14.
// ( CvRNG is uint64, and cv::RNG has only status member which is uint64. )
# if defined(__GNUC__) && __GNUC__ >= 14
# define CV_IGNORE_CAST_USER_DEFINED_WARNING
# endif
CV_IMPL void
CV_IMPL void
cvRandArr ( CvRNG * _rng , CvArr * arr , int disttype , CvScalar param1 , CvScalar param2 )
cvRandArr ( CvRNG * _rng , CvArr * arr , int disttype , CvScalar param1 , CvScalar param2 )
{
{
cv : : Mat mat = cv : : cvarrToMat ( arr ) ;
cv : : Mat mat = cv : : cvarrToMat ( arr ) ;
# ifdef CV_IGNORE_CAST_USER_DEFINED_WARNING
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wcast-user-defined"
# endif
// !!! this will only work for current 64-bit MWC RNG !!!
// !!! this will only work for current 64-bit MWC RNG !!!
cv : : RNG & rng = _rng ? ( cv : : RNG & ) * _rng : cv : : theRNG ( ) ;
cv : : RNG & rng = _rng ? ( cv : : RNG & ) * _rng : cv : : theRNG ( ) ;
# ifdef CV_IGNORE_CAST_USER_DEFINED_WARNING
# pragma GCC diagnostic pop
# endif
rng . fill ( mat , disttype = = CV_RAND_NORMAL ?
rng . fill ( mat , disttype = = CV_RAND_NORMAL ?
cv : : RNG : : NORMAL : cv : : RNG : : UNIFORM , cv : : Scalar ( param1 ) , cv : : Scalar ( param2 ) ) ;
cv : : RNG : : NORMAL : cv : : RNG : : UNIFORM , cv : : Scalar ( param1 ) , cv : : Scalar ( param2 ) ) ;
}
}
@ -766,10 +785,25 @@ cvRandArr( CvRNG* _rng, CvArr* arr, int disttype, CvScalar param1, CvScalar para
CV_IMPL void cvRandShuffle ( CvArr * arr , CvRNG * _rng , double iter_factor )
CV_IMPL void cvRandShuffle ( CvArr * arr , CvRNG * _rng , double iter_factor )
{
{
cv : : Mat dst = cv : : cvarrToMat ( arr ) ;
cv : : Mat dst = cv : : cvarrToMat ( arr ) ;
# ifdef CV_IGNORE_CAST_USER_DEFINED_WARNING
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wcast-user-defined"
# endif
cv : : RNG & rng = _rng ? ( cv : : RNG & ) * _rng : cv : : theRNG ( ) ;
cv : : RNG & rng = _rng ? ( cv : : RNG & ) * _rng : cv : : theRNG ( ) ;
# ifdef CV_IGNORE_CAST_USER_DEFINED_WARNING
# pragma GCC diagnostic pop
# endif
cv : : randShuffle ( dst , iter_factor , & rng ) ;
cv : : randShuffle ( dst , iter_factor , & rng ) ;
}
}
# ifdef CV_IGNORE_CAST_USER_DEFINED_WARNING
# undef CV_IGNORE_CAST_USER_DEFINED_WARNING
# endif
# endif // OPENCV_EXCLUDE_C_API
# endif // OPENCV_EXCLUDE_C_API