码迷,mamicode.com
首页 > 其他好文 > 详细

Deep Copy cv::StereoBM 深度拷贝

时间:2016-06-23 12:30:06      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:

 

在使用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;
}

 

Deep Copy cv::StereoBM 深度拷贝

标签:

原文地址:http://www.cnblogs.com/grandyang/p/5610251.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!