本文整理汇总了C++中cv::RNG::gaussian方法的典型用法代码示例。如果您正苦于以下问题:C++ RNG::gaussian方法的具体用法?C++ RNG::gaussian怎么用?C++ RNG::gaussian使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv::RNG
的用法示例。
在下文中一共展示了RNG::gaussian方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDistortionValues
void getDistortionValues(cv::RNG &rng, const Size2i &inputSize, AugParams *agp) {
// This function just gets the random distortion values without modifying the
// image itself. Useful if we need to reapply the same transformations over
// again (e.g. for all frames of a video or for a corresponding target mask)
// colornoise values
// N.B. if _contrastMax == 100, then _colorNoiseStd will be 0.0
for (int i=0; i<3; i++) {
agp->colornoise[i] = rng.gaussian(_colorNoiseStd);
}
// contrast, brightness, saturation
// N.B. all value ranges tied to _contrastMin and _contrastMax
for (int i=0; i<3; i++) {
agp->cbs[i] = rng.uniform(_contrastMin, _contrastMax) / 100.0f;
}
/**************************
* HORIZONTAL FLIP *
***************************/
agp->flip = _flip && rng(2) != 0 ? true : false;
/**************************
* ROTATION ANGLE *
***************************/
agp->angle = rng.uniform(_rotateMin, _rotateMax);
/**************************
* CROP BOX *
***************************/
float shortSide = std::min(inputSize.height, inputSize.width);
// Special case where we just grab the whole image;
if (_scaleMin == 0) {
agp->cropBox = Rect(Point2i(), inputSize);
return;
}
if (_center) {
agp->cropBox.width = shortSide * _width / (float) _scaleMin;
agp->cropBox.height = shortSide * _height / (float) _scaleMin;
agp->cropBox.x = (inputSize.width - agp->cropBox.width) / 2;
agp->cropBox.y = (inputSize.height - agp->cropBox.height) / 2;
} else {
cv::Size2f oSize = inputSize;
// This is a hack for backward compatibility.
// Valid aspect ratio range ( > 100) will override side scaling behavior
if (_aspectRatio == 0) {
float scaleFactor = rng.uniform(_scaleMin, _scaleMax);
agp->cropBox.width = shortSide * _width / scaleFactor;
agp->cropBox.height = shortSide * _height / scaleFactor;
} else {
float mAR = (float) _aspectRatio / 100.0f;
float nAR = rng.uniform(1.0f / mAR, mAR);
float oAR = oSize.width / oSize.height;
// between minscale pct% to 100% subject to aspect ratio limitation
float maxScale = nAR > oAR ? oAR / nAR : nAR / oAR;
float minScale = std::min((float) _scaleMin / 100.0f, maxScale);
float tgtArea = rng.uniform(minScale, maxScale) * oSize.area();
agp->cropBox.height = sqrt(tgtArea / nAR);
agp->cropBox.width = agp->cropBox.height * nAR;
}
agp->cropBox.x = rng.uniform(0, inputSize.width - agp->cropBox.width);
agp->cropBox.y = rng.uniform(0, inputSize.height - agp->cropBox.height);
}
return;
}