• Deep Copy cv::StereoBM 深度拷贝


    在使用OpenCV的三维立体重建的库时,一个重要的步骤就是生成左右视图的差异图Disparity,而控制生成disparity的参数的类是cv::StereoBM,我们有时候需要拷贝一份cv::StereoBM,然后改变其中的参数值,但是如果用默认的等号‘=’来进行拷贝,其实是浅拷贝,如果改变拷贝项的参数值,原来的参数值也会跟着改变,所以我们需要自己写一个深拷贝的函数,如下所示:

    /**
     * Deep copy cv::StereoBM bm1 to bm2
     */
    void copy_bm(const cv::StereoBM &bm1, cv::StereoBM &bm2) {
        if (!bm1.state) {
            return;
        }
        bm2.init(CV_STEREO_BM_NORMALIZED_RESPONSE, 0, 21);
        bm2.state->preFilterSize = bm1.state->preFilterSize;
        bm2.state->preFilterCap = bm1.state->preFilterCap;
        bm2.state->SADWindowSize = bm1.state->SADWindowSize;
        bm2.state->minDisparity = bm1.state->minDisparity;
        bm2.state->numberOfDisparities = bm1.state->numberOfDisparities;
        bm2.state->textureThreshold = bm1.state->textureThreshold;
        bm2.state->uniquenessRatio = bm1.state->uniquenessRatio;
        bm2.state->speckleWindowSize = bm1.state->speckleWindowSize;
        bm2.state->speckleRange = bm1.state->speckleRange;
    }
  • 相关阅读:
    Appium 自动化测试配置wda的两种方式。
    brew install jenkins
    运算符,流程控制语句,单分支,双分支,多分支
    程序交互,数据类型,格式化输出
    编程语言介绍,变量和常量
    “Hello world! ”
    斐波那锲数列 冒泡排序
    AssetBundle
    animation 老动画
    animator 新动画
  • 原文地址:https://www.cnblogs.com/grandyang/p/5610251.html
Copyright © 2020-2023  润新知