当前位置: 首页>>代码示例>>C++>>正文


C++ cv::Point2i方法代码示例

本文整理汇总了C++中cv::Point2i方法的典型用法代码示例。如果您正苦于以下问题:C++ cv::Point2i方法的具体用法?C++ cv::Point2i怎么用?C++ cv::Point2i使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cv的用法示例。


在下文中一共展示了cv::Point2i方法的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;
    }
开发者ID:SmartPlanetInternational,项目名称:neon,代码行数:71,代码来源:image.hpp


注:本文中的cv::Point2i方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。