When using OpenCV's three-dimensional reconstructed library, an important step is to generate the left and right view of the difference graph disparity, and control the generation disparity parameters of the class is CV::STEREOBM, we sometimes need to copy a CV::STEREOBM, Then change the value of the parameter, but if the default equals ' = ' to copy, is actually a shallow copy, if you change the parameter value of the copied item, the original parameter value will also change, so we need to write a deep copy of the function, as follows:
/** * Deep copy cv::stereobm bm1 to bm2*/voidCOPY_BM (ConstCV::STEREOBM &bm1, CV::STEREOBM &bm2) { if(!bm1.state) {return; } bm2.init (Cv_stereo_bm_normalized_response,0, +); 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 Depth copy