Middlebury提供的源码,虽然花了不到一个小时就运行起来啦。但说实话,它那循环读取脚本命令来执行算法真是让我费了不少头脑,花了近三天时间,我才弄明白了它的运行机制。你说,我就想提取一下算法,你给我整这么多圈子干啥。于是,在我明白了它的运行机制以后,就将无关的代码通通咔嚓了。剩下了最重要的两个类。

以下是我的操作过程。

1.1

新建解决方案SolutionXYZ、工程ExecutionXYZ及TestData目录。

为工程配置OpenCV库、pnglib库及jpeglib库

对VS2013还需要在C/C++->Preprocessor->Preprocessor Definitions中添加指令_CRT_SECURE_NO_WARNINGS

添加本人的CCC目录到工程内,没有则不用添加。

1.2

将<MiddEval3-SDK-1.6.zip>中的MiddEval3\code路径下的imageLib目录解压到工程内

将imageLib中Error.h文件中的snprintf改为_snprintf方可

1.3

将<StereoMatch_1_0.exe>中的StereoMatch目录解压到工程内。

删除StereoMatch目录下的StereoMatch.dsp、StereoMatch.dsw、License.txt、Makefile、README-StereoMatch.txt。

删除StereoMatch目录下的Convert.cpp、Convert.h、Convolve.h、Convolve.cpp、Copyright.h、Error.h、Image.cpp、Image.h、ImageIO.cpp、ImageIO.h、RefCntMem.cpp、RefCntMem.h、main.cpp、StereoIO.h、StereoIO.cpp、Verbose.h、ParameterIO.cpp、ParameterIO.h

1.4

将<Stereo-patch.zip>内的StcEvaluate.cpp解压到StereoMatch目录内覆盖原有文件

将<LASW.zip>内除Makefile文件外的所有文件解压到StereoMatch目录内覆盖原有文件

将<bp-extensions.tgz>内的StcOptBPSync.cpp, StcOptBP.cpp, node.h, node.cpp, bpregions.h, bpregions.cpp解压到StereoMatch目录内覆盖原有文件

将StereoMatch目录内的所有文件都打开并保存一遍。

在StereoMatcher.h中添加

void OptBP();

void OptBPSync();

在StereoParameters.h的eSymmetric =6,后添加

eBPSync      = 7,

eBPAccel     = 8,

在StcOptimize.cpp的opt_fn == eSimulAnnl的添加

||opt_fn == eBPAccel||opt_fn == eBPSync

在StcOptimize.cpp的OptSymmetric();break;的添加

case eBPAccel:

OptBP();  // run the optimization

break;

case eBPSync:

OptBPSync();  // run the optimization

break;

1.5

将所有StereoMatch目录中的所有文件中的"Image.h"改为"./../imageLib/Image.h"

将所有StereoMatch目录中的所有文件中的"Error.h"改为"./../imageLib/Error.h"

将所有StereoMatch目录中的所有文件中的"Convert.h"改为"./../imageLib/Convert.h"

将所有StereoMatch目录中的所有文件中的"ImageIO.h"改为"./../imageLib/ImageIO.h"

将所有StereoMatch目录中的所有文件中的"Convolve.h"改为"./../imageLib/Convolve.h"

将所有StereoMatch目录中的所有文件中的所有#include "ParameterIO.h"及#include "Verbose.h"都删除

将所有类的protected成员改为public成员

暂且注释掉parser_flg.c中的所有代码

由vs2010和2013仍不支持const常量作为数组维数,所以BP算法还没法使用。为编译成功,将bpregions.cpp和node.cpp全部注释,将StcOptBP.cpp和StcOptBPSync.cpp中的相应函数的函数体注释。

1.6

在StereoParameters.h中添加如下代码:

enum EVerbosityLevel

{

eVerboseQuiet           = 0,   // no output except for errors

eVerboseWarning         = 1,   // include warning messages

eVerboseSummary         = 2,   // print brief summary of algorithm and result

eVerboseProgress        = 3,   // report progress through steps of algorithm

eVerboseFileIO          = 4,   // report reading and writing of files

eVerboseTiming          = 5,   // print timing information

eVerbosePredictionError = 6,   // print prediction error for all frames

eVerboseScriptFile      = 10,  // echo commands from script file

eVerboseInnerLoops      = 15,  // show inner iterations

eVerboseDumpFiles       = 25,  // dump intermediate results as image files

eVerboseAllMessages     = 99   // include all information

};

enum EStereoMatchStatus

{                  // Match status computed by symmetric matcher (values in m_status)

eUnknownMatch = 0,

eCertainMatch = 1,

eAmbiguousMatch = 2,

eOccludedMatch = 3,

};

struct CStereoFrame

{                  // An input image and its associated meta-data (depth map, ground truth, ...):

CByteImage input_image;             // input image (gray or color)

CByteImage depth_image;             // depth image (input/output)

CByteImage truth_image;             // ground truth depth image

CByteImage resampled_image;         // resampled image (for reprojection error)

float predict_err;                  // prediction error (visible pixels)

float predict_visible;              // fraction of pixels visible

};

将StereoMatcher.h中的enum EstereoMatchStatus{…}和struct CstereoFrame{…}删除

将StereoParameters.h中代码void PIOInitialize(CParameterIO& prw)删除或注释

将StereoParameters.cpp中代码void PIOInitialize(CParameterIO& prw){…}删除或注释

将StereoParameters.cpp代码都加到StereoParameters.h中并删除StereoParameters.cpp

1.7

可选操作。

将所有Stc**.cpp中的”./../imageLib/***.h”,并补加这些头文件到”StereoMatcher.h”文件中

将StereoMatcher.cpp中代码全部转移到StereoMatcher.h中后将其删除

对文件编号:

1.1StcPreProcess.cpp

1.2StcRawCosts.cpp

1.3StcAggregate.cpp

1.4StcOptimize.cpp

1.5StcRefine.cpp

1.6StcEvaluate.cpp

2.1StcDiffusion.cpp

2.2LASW.cpp

2.2LASW.h

3.1StcOptDP.cpp

3.2StcOptSO.cpp

3.3StcSimulAnn.cpp

3.4StcGraphCut.cpp

编译出错时再对头文件名进行更改。

1.8

在TestData目录内新建目录:map, sawtooth, venus。然后将< imagedirs.zip>中对应目录内的imx.pgm, imy.pgm, dispx.pgm, dispy.pgm文件复制过来,并都统一命名为:im0.pgm, im1.pgm, disp0.pgm, disp1.pgm

1.9

接下就是实现<Scripts.zip>、<LASWscripts.zip>及<bp-extensions.zip>中的exp7_bps.txt和exp8_bpa.txt的功能。

添加scripts.h和main.cpp

#include "CCC/COMCV.h"
#include "StereoMatch/StereoMatcher.h"
#include <fstream>
#include <iomanip>

//输出参数
void writeParams(CStereoMatcher &s, string &path)
{
    ofstream out(path);
    out << "preproc_addnoise_stddev " << s.preproc_addnoise_stddev;//0.000000

    out << endl << "disp_step " << s.disp_step;//1.000000

    out << endl << "disp_scale " << s.disp_scale;//8.000000

    out << endl << "diff_lambda " << s.diff_lambda;//0.150000
    out << endl << "diff_beta " << s.diff_beta;//0.500000
    out << endl << "diff_scale_cost " << s.diff_scale_cost;//0.010000
    out << endl << "diff_mu " << s.diff_mu;//0.500000
    out << endl << "diff_sigmaP " << s.diff_sigmaP;//0.400000
    out << endl << "diff_epsP " << s.diff_epsP;//0.010000

    out << endl << "aggr_gamma_proximity " << s.aggr_gamma_proximity;// 5.500000
    out << endl << "aggr_gamma_similarity " << s.aggr_gamma_similarity;// 5.000000

    out << endl << "opt_smoothness " << s.opt_smoothness;//1.000000
    out << endl << "opt_grad_thresh " << s.opt_grad_thresh;//5.000000
    out << endl << "opt_grad_penalty " << s.opt_grad_penalty;//1.000000

    out << endl << "opt_sa_start_T " << s.opt_sa_start_T;//10.000000
    out << endl << "opt_sa_end_T " << s.opt_sa_end_T;//0.010000

    out << endl << "opt_min_margin " << s.opt_min_margin;//0.700000

    out << endl << "eval_bad_thresh " << s.eval_bad_thresh;//1.000000
    out << endl << "eval_error_scale " << s.eval_error_scale;//0.000000

    out << endl << "eval_disp_gap " << s.eval_disp_gap;//2.000000

    out << endl << "eval_textureless_thresh " << s.eval_textureless_thresh;//4.000000

    )<< s.eval_empty_color;//0x00ffc0ff
    out << endl << "eval_partial_shuffle " << s.eval_partial_shuffle;//0.000000

    out << endl << "rms_error_all" << s.rms_error_all;
    out << endl << "rms_error_nonocc " << s.rms_error_nonocc;//1.898849
    out << endl << "rms_error_occ " << s.rms_error_occ;//17.536930
    out << endl << "rms_error_textured " << s.rms_error_textured;//1.895457
    out << endl << "rms_error_textureless " << s.rms_error_textureless;//2.254724
    out << endl << "rms_error_discont " << s.rms_error_discont;//6.221545
    out << endl << "bad_pixels_all " << s.bad_pixels_all;//0.074057
    out << endl << "bad_pixels_nonocc " << s.bad_pixels_nonocc;//0.017140
    out << endl << "bad_pixels_occ " << s.bad_pixels_occ;//0.971484
    out << endl << "bad_pixels_textured " << s.bad_pixels_textured;//0.016978
    out << endl << "bad_pixels_textureless " << s.bad_pixels_textureless;//0.035714
    out << endl << "bad_pixels_discont " << s.bad_pixels_discont;//0.114071
    out << endl << "fraction_matched " << s.fraction_matched;//0.100000
    out << endl << "predict_err_near " << s.predict_err_near;//-;//1.000000
    out << endl << "predict_err_middle " << s.predict_err_middle;//-;//1.000000
    out << endl << "predict_err_match " << s.predict_err_match;//-;//1.000000
    out << endl << "predict_err_far " << s.predict_err_far;//-;//1.000000
    out << endl << "final_energy " << s.final_energy;//611911.437500
    out << endl << "total_time " << s.total_time;//1.681000

    out.close();
}

//相同参数
void comParam(CStereoMatcher &s)
{
    s.verbose = eVerboseSummary;
    s.evaluate_only = s.evaluate_only;
    s.frame_ref = ;
    s.frame_match = ;
    s.eval_predict_type = ePredictNone;
    s.eval_error_scale = ;
    s.disp_min = ;
    s.disp_scale = ;
    s.eval_disp_gap = ;
    s.eval_ignore_border = ;
}

//与目录相关的参数
void dirParam(CStereoMatcher &s, string &dir)
{
    string im0path, im1path, trupath;
    cout << endl << dir.substr(dir.find_last_of();
    ) == "map")
    {
        s.disp_max = ;
        im0path = dir + "/im0.pgm";
        im1path = dir + "/im1.pgm";
        trupath = dir + "/disp0.pgm";
    }
    ) == "sawtooth")
    {
        s.disp_max = ;
        im0path = dir + "/im0.ppm";
        im1path = dir + "/im1.ppm";
        trupath = dir + "/disp0.pgm";
    }
    ) == "venus")
    {
        s.disp_max = ;
        im0path = dir + "/im0.ppm";
        im1path = dir + "/im1.ppm";
        trupath = dir + "/disp0.pgm";
    }
    CStereoFrame fr0, fr1;
    ReadImage(fr0.input_image, im0path.c_str());
    ReadImage(fr1.input_image, im1path.c_str());
    ReadImage(fr0.truth_image, trupath.c_str());
    s.m_frame.push_back(fr0);
    s.m_frame.push_back(fr1);
}

//测试方案一
void costSSD9(CStereoMatcher &s, string &dir)
{
    //0.此函数内的公共设置
    s.aggr_window_size = ;
    s.aggr_minfilter = ;
    ] = { , , , , , ,  };

    //1.测试一
    s.match_fn = eAD;
    s.match_interval = ;
    ] = { dir + "/SAD09.pgm", dir + "/SAD09t50.pgm", dir + "/SAD09t20.pgm", dir + "/SAD09t10.pgm", dir + "/SAD09t05.pgm", dir + "/SAD09t02.pgm", dir + "/SAD09t01.pgm" };
    ; i < ; i++)
    {
        s.match_max = match_max[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out1[i].c_str());
        writeParams(s,out1[i].substr(, out1[i].find_last_of(".")) + ".txt");
        ;
    }
    //2.测试二
    s.match_fn = eSD;
    s.match_interval = ;
    ] = { dir + "/SSD09.pgm", dir + "/SSD09t50.pgm", dir + "/SSD09t20.pgm", dir + "/SSD09t10.pgm", dir + "/SSD09t05.pgm", dir + "/SSD09t02.pgm", dir + "/SSD09t01.pgm" };
    ; i < ; i++)
    {
        s.match_max = match_max[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out2[i].c_str());
        writeParams(s, out2[i].substr(, out2[i].find_last_of(".")) + ".txt");
    }
    //3.测试三
    s.match_fn = eAD;
    s.match_interval = ;
    ] = { dir + "/SAD09b.pgm", dir + "/SAD09bt50.pgm", dir + "/SAD09bt20.pgm", dir + "/SAD09bt10.pgm", dir + "/SAD09bt05.pgm", dir + "/SAD09bt02.pgm", dir + "/SAD09bt01.pgm" };
    ; i < ; i++)
    {
        s.match_max = match_max[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out3[i].c_str());
        writeParams(s, out3[i].substr(, out3[i].find_last_of(".")) + ".txt");
    }
    //4.测试四
    s.match_fn = eSD;
    s.match_interval = ;
    ] = { dir + "/SSD09b.pgm", dir + "/SSD09bt50.pgm", dir + "/SSD09bt20.pgm", dir + "/SSD09bt10.pgm", dir + "/SSD09bt05.pgm", dir + "/SSD09bt02.pgm", dir + "/SSD09bt01.pgm" };
    ; i < ; i++)
    {
        s.match_max = match_max[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out4[i].c_str());
        writeParams(s, out4[i].substr(, out4[i].find_last_of(".")) + ".txt");
    }
}

//测试方案二
void costSSDMF9(CStereoMatcher &s, string &dir)
{
    //0.此函数内的公共设置
    s.aggr_window_size = ;
    s.aggr_minfilter = ;
    ] = { , , , , , ,  };

    //1.测试一
    s.match_fn = eAD;
    s.match_interval = ;
    ] = { dir + "/SADmf09.pgm", dir + "/SADmf09t50.pgm", dir + "/SADmf09t20.pgm", dir + "/SADmf09t10.pgm", dir + "/SADmf09t05.pgm", dir + "/SADmf09t02.pgm", dir + "/SADmf09t01.pgm" };
    ; i < ; i++)
    {
        s.match_max = match_max[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out1[i].c_str());
        writeParams(s, out1[i].substr(, out1[i].find_last_of(".")) + ".txt");
        ;
    }
    //2.测试二
    s.match_fn = eSD;
    s.match_interval = ;
    ] = { dir + "/SSDmf09.pgm", dir + "/SSDmf09t50.pgm", dir + "/SSDmf09t20.pgm", dir + "/SSDmf09t10.pgm", dir + "/SSDmf09t05.pgm", dir + "/SSDmf09t02.pgm", dir + "/SSDmf09t01.pgm" };
    ; i < ; i++)
    {
        s.match_max = match_max[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out2[i].c_str());
        writeParams(s, out2[i].substr(, out2[i].find_last_of(".")) + ".txt");
    }
    //3.测试三
    s.match_fn = eAD;
    s.match_interval = ;
    ] = { dir + "/SADmf09b.pgm", dir + "/SADmf09bt50.pgm", dir + "/SADmf09bt20.pgm", dir + "/SADmf09bt10.pgm", dir + "/SADmf09bt05.pgm", dir + "/SADmf09bt02.pgm", dir + "/SADmf09bt01.pgm" };
    ; i < ; i++)
    {
        s.match_max = match_max[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out3[i].c_str());
        writeParams(s, out3[i].substr(, out3[i].find_last_of(".")) + ".txt");
    }
    //4.测试四
    s.match_fn = eSD;
    s.match_interval = ;
    ] = { dir + "/SSDmf09b.pgm", dir + "/SSDmf09bt50.pgm", dir + "/SSDmf09bt20.pgm", dir + "/SSDmf09bt10.pgm", dir + "/SSDmf09bt05.pgm", dir + "/SSDmf09bt02.pgm", dir + "/SSDmf09bt01.pgm" };
    ; i < ; i++)
    {
        s.match_max = match_max[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out4[i].c_str());
        writeParams(s, out4[i].substr(, out4[i].find_last_of(".")) + ".txt");
    }
}

//测试方案三
void costGlobal(CStereoMatcher &s, string &dir)
{
    //0.此函数内的公共设置
    ] = { , , , , ,  };

    //1.DP测试
    s.aggr_iter = ;
    s.opt_fn = eDynamicProg;
    s.opt_occlusion_cost = ;
    s.opt_smoothness = ;
    //1.1
    s.match_fn = eAD;
    s.match_interval = ;
    ] = { dir + "/DPm1o20s0020.pgm", dir + "/DPm1o20s0020t50.pgm", dir + "/DPm1o20s0020t20.pgm", dir + "/DPm1o20s0020t10.pgm", dir + "/DPm1o20s0020t05.pgm", dir + "/DPm1o20s0020t02.pgm" };
    ; i < ; i++)
    {
        s.match_max = match_max[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out11[i].c_str());
        writeParams(s, out11[i].substr(, out11[i].find_last_of(".")) + ".txt");
        ;
    }
    //1.2
    s.match_fn = eAD;
    s.match_interval = ;
    ] = { dir + "/DPm1o20s0020b.pgm", dir + "/DPm1o20s0020bt50.pgm", dir + "/DPm1o20s0020bt20.pgm", dir + "/DPm1o20s0020bt10.pgm", dir + "/DPm1o20s0020bt05.pgm", dir + "/DPm1o20s0020bt02.pgm" };
    ; i < ; i++)
    {
        s.match_max = match_max[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out12[i].c_str());
        writeParams(s, out12[i].substr(, out12[i].find_last_of(".")) + ".txt");
    }

    //2.SO测试
    s.aggr_iter = ;
    s.opt_fn = eScanlineOpt;
    s.opt_smoothness = ;
    //2.1
    s.match_fn = eAD;
    s.match_interval = ;
    ] = { dir + "/SOm1s0020.pgm", dir + "/SOm1s0020t50.pgm", dir + "/SOm1s0020t20.pgm", dir + "/SOm1s0020t10.pgm", dir + "/SOm1s0020t05.pgm", dir + "/SOm1s0020t02.pgm" };
    ; i < ; i++)
    {
        s.match_max = match_max[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out21[i].c_str());
        writeParams(s, out21[i].substr(, out21[i].find_last_of(".")) + ".txt");
    }
    //2.2
    s.match_fn = eAD;
    s.match_interval = ;
    ] = { dir + "/SOm1s0020b.pgm", dir + "/SOm1s0020bt50.pgm", dir + "/SOm1s0020bt20.pgm", dir + "/SOm1s0020bt10.pgm", dir + "/SOm1s0020bt05.pgm", dir + "/SOm1s0020bt02.pgm" };
    ; i < ; i++)
    {
        s.match_max = match_max[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out22[i].c_str());
        writeParams(s, out22[i].substr(, out22[i].find_last_of(".")) + ".txt");
    }

    //3.GC测试
    s.aggr_iter = ;
    s.opt_fn = eGraphCut;
    s.opt_smoothness = ;
    //3.1
    s.match_fn = eAD;
    s.match_interval = ;
    ] = { dir + "/GCm1s0020.pgm", dir + "/GCm1s0020t50.pgm", dir + "/GCm1s0020t20.pgm", dir + "/GCm1s0020t10.pgm", dir + "/GCm1s0020t05.pgm" };
    ; i < ; i++)
    {
        s.match_max = match_max[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out31[i].c_str());
        writeParams(s, out31[i].substr(, out31[i].find_last_of(".")) + ".txt");
    }
    //3.2
    s.match_fn = eAD;
    s.match_interval = ;
    ] = { dir + "/GCm1s0020b.pgm", dir + "/GCm1s0020bt50.pgm", dir + "/GCm1s0020bt20.pgm", dir + "/GCm1s0020bt10.pgm", dir + "/GCm1s0020bt05.pgm" };
    ; i < ; i++)
    {
        s.match_max = match_max[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out32[i].c_str());
        writeParams(s, out32[i].substr(, out32[i].find_last_of(".")) + ".txt");
    }
}

//测试方案四
void aggr(CStereoMatcher &s, string &dir)
{
    //0.此函数内的公共设置
    s.match_fn = eAD;
    s.opt_fn = eWTA;

    //1.测试一
    s.aggr_fn = eBox;
    s.aggr_iter = ;
    s.aggr_minfilter = ;
    ] = { dir + "/SAD03.pgm", dir + "/SAD05.pgm", dir + "/SAD07.pgm", dir + "/SAD09.pgm", dir + "/SAD11.pgm", dir + "/SAD13.pgm", dir + "/SAD15.pgm", dir + "/SAD17.pgm", dir + "/SAD19.pgm", dir + "/SAD21.pgm", dir + "/SAD23.pgm", dir + "/SAD25.pgm", dir + "/SAD27.pgm", dir + "/SAD29.pgm" };
    ; i < ; i++)
    {
        s.aggr_window_size =  * i + ;
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out1[i].c_str());
        writeParams(s, out1[i].substr(, out1[i].find_last_of(".")) + ".txt");
        ;
    }

    //2.测试二
    s.aggr_fn = eBox;
    s.aggr_iter = ;
    ] = { dir + "/SADmf03.pgm", dir + "/SADmf05.pgm", dir + "/SADmf07.pgm", dir + "/SADmf09.pgm", dir + "/SADmf11.pgm", dir + "/SADmf13.pgm", dir + "/SADmf15.pgm", dir + "/SADmf17.pgm", dir + "/SADmf19.pgm", dir + "/SADmf21.pgm", dir + "/SADmf23.pgm", dir + "/SADmf25.pgm", dir + "/SADmf27.pgm", dir + "/SADmf29.pgm" };
    ; i < ; i++)
    {
        s.aggr_window_size =  * i + ;
        s.aggr_minfilter =  * i + ;
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out2[i].c_str());
        writeParams(s, out2[i].substr(, out2[i].find_last_of(".")) + ".txt");
        ;
    }

    //3.测试三
    s.aggr_fn = eBinomial;
    s.aggr_minfilter = ;
    ] = { dir + "/SADbf02.pgm", dir + "/SADbf04.pgm", dir + "/SADbf06.pgm", dir + "/SADbf08.pgm", dir + "/SADbf10.pgm", dir + "/SADbf12.pgm", dir + "/SADbf14.pgm", dir + "/SADbf16.pgm", dir + "/SADbf18.pgm", dir + "/SADbf20.pgm", dir + "/SADbf22.pgm", dir + "/SADbf24.pgm", dir + "/SADbf26.pgm", dir + "/SADbf28.pgm" };
    ; i < ; i++)
    {
        s.aggr_iter =  * i + ;
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out3[i].c_str());
        writeParams(s, out3[i].substr(, out3[i].find_last_of(".")) + ".txt");
    }

    //4.测试四
    s.aggr_fn = eDiffusion;
    s.aggr_minfilter = ;
    s.diff_lambda = 0.15;
    ] = { dir + "/SADdiff010.pgm", dir + "/SADdiff020.pgm", dir + "/SADdiff030.pgm", dir + "/SADdiff040.pgm", dir + "/SADdiff050.pgm", dir + "/SADdiff060.pgm", dir + "/SADdiff070.pgm", dir + "/SADdiff080.pgm", dir + "/SADdiff090.pgm", dir + "/SADdiff100.pgm", dir + "/SADdiff110.pgm", dir + "/SADdiff120.pgm", dir + "/SADdiff130.pgm", dir + "/SADdiff140.pgm", dir + "/SADdiff150.pgm" };
    ; i < ; i++)
    {
        s.aggr_iter =  * i + ;
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out4[i].c_str());
        writeParams(s, out4[i].substr(, out4[i].find_last_of(".")) + ".txt");
    }

    //5.测试五
    s.aggr_fn = eMembrane;
    s.aggr_minfilter = ;
    s.diff_lambda = 0.15;
    s.aggr_iter = ;
    ] = { dir + "/SADmemb09.pgm", dir + "/SADmemb08.pgm", dir + "/SADmemb07.pgm", dir + "/SADmemb06.pgm", dir + "/SADmemb05.pgm", dir + "/SADmemb04.pgm", dir + "/SADmemb03.pgm", dir + "/SADmemb02.pgm", dir + "/SADmemb01.pgm", dir + "/SADmemb00.pgm" };
    ; i < ; i++)
    {
        s.diff_beta = 0.9 - 0.1 * (float)i;
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out5[i].c_str());
        writeParams(s, out5[i].substr(, out5[i].find_last_of(".")) + ".txt");
    }
}

//测试方案五
void lambda(CStereoMatcher &s, string dir)
{
    //0.此函数内的公共设置
    ] = { , , , , , , ,  };

    //1.DP测试
    s.match_fn = eAD;
    s.aggr_iter = ;
    s.opt_fn = eDynamicProg;
    //1.1
    s.opt_occlusion_cost = ;
    ] = { dir + "/DPm1o20s0005.pgm", dir + "/DPm1o20s0010.pgm", dir + "/DPm1o20s0020.pgm", dir + "/DPm1o20s0050.pgm", dir + "/DPm1o20s0100.pgm", dir + "/DPm1o20s0200.pgm", dir + "/DPm1o20s0500.pgm", dir + "/DPm1o20s1000.pgm" };
    ; i < ; i++)
    {
        s.opt_smoothness = opt_smoothness[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out11[i].c_str());
        writeParams(s, out11[i].substr(, out11[i].find_last_of(".")) + ".txt");
        ;
    }
    //1.2
    s.opt_occlusion_cost = ;
    ] = { dir + "/DPm1o50s0005.pgm", dir + "/DPm1o50s0010.pgm", dir + "/DPm1o50s0020.pgm", dir + "/DPm1o50s0050.pgm", dir + "/DPm1o50s0100.pgm", dir + "/DPm1o50s0200.pgm", dir + "/DPm1o50s0500.pgm", dir + "/DPm1o50s1000.pgm" };
    ; i < ; i++)
    {
        s.opt_smoothness = opt_smoothness[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out12[i].c_str());
        writeParams(s, out12[i].substr(, out12[i].find_last_of(".")) + ".txt");
    }
    //1.3
    s.opt_occlusion_cost = ;
    ] = { dir + "/DPm1o80s0005.pgm", dir + "/DPm1o80s0010.pgm", dir + "/DPm1o80s0020.pgm", dir + "/DPm1o80s0050.pgm", dir + "/DPm1o80s0100.pgm", dir + "/DPm1o80s0200.pgm", dir + "/DPm1o80s0500.pgm", dir + "/DPm1o80s1000.pgm" };
    ; i < ; i++)
    {
        s.opt_smoothness = opt_smoothness[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out13[i].c_str());
        writeParams(s, out13[i].substr(, out13[i].find_last_of(".")) + ".txt");
    }

    //2.SO测试
    s.match_fn = eAD;
    s.aggr_iter = ;
    s.opt_fn = eScanlineOpt;
    ] = { dir + "/SOm1s0005.pgm", dir + "/SOm1s0010.pgm", dir + "/SOm1s0020.pgm", dir + "/SOm1s0050.pgm", dir + "/SOm1s0100.pgm", dir + "/SOm1s0200.pgm", dir + "/SOm1s0500.pgm", dir + "/SOm1s1000.pgm" };
    ; i < ; i++)
    {
        s.opt_smoothness = opt_smoothness[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out2[i].c_str());
        writeParams(s, out2[i].substr(, out2[i].find_last_of(".")) + ".txt");
    }

    //3.GC测试
    s.match_fn = eAD;
    s.aggr_iter = ;
    s.opt_fn = eGraphCut;
    ] = { dir + "/GCm1s0005.pgm", dir + "/GCm1s0010.pgm", dir + "/GCm1s0020.pgm", dir + "/GCm1s0050.pgm", dir + "/GCm1s0100.pgm", dir + "/GCm1s0200.pgm", dir + "/GCm1s0500.pgm", dir + "/GCm1s1000.pgm" };
    ; i < ; i++)
    {
        s.opt_smoothness = opt_smoothness[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out3[i].c_str());
        writeParams(s, out3[i].substr(, out3[i].find_last_of(".")) + ".txt");
    }

    //4.SA测试
    s.match_fn = eAD;
    s.aggr_iter = ;
    s.opt_fn = eSimulAnnl;
    s.opt_sa_start_T = ;
    s.opt_max_iter = ;
    ] = { dir + "/SAm1s0005.pgm", dir + "/SAm1s0010.pgm", dir + "/SAm1s0020.pgm", dir + "/SAm1s0050.pgm", dir + "/SAm1s0100.pgm", dir + "/SAm1s0200.pgm", dir + "/SAm1s0500.pgm", dir + "/SAm1s1000.pgm" };
    ; i < ; i++)
    {
        s.opt_smoothness = opt_smoothness[i];
        s.ComputeCorrespondence(); s.Evaluate();
        WriteImage(s.m_frame[].depth_image, out4[i].c_str());
        writeParams(s, out4[i].substr(, out4[i].find_last_of(".")) + ".txt");
    }
}

//测试LASW
void lasw(CStereoMatcher &s, string dir)
{
    s.match_max = ;
    s.match_fn = eAD;
    s.opt_fn = eWTA;
    s.aggr_fn = eASWeight;
    s.aggr_iter = ;
    s.aggr_window_size = ;
    s.aggr_gamma_proximity = 17.5;
    s.aggr_gamma_similarity = 5.0;
    s.aggr_color_space = eCIELab;

    string out = dir + "/AD_asw_35.pgm";
    s.ComputeCorrespondence();
    s.Evaluate();
    WriteImage(s.m_frame[].depth_image, out.c_str());
    writeParams(s, , out.find_last_of(".")) + ".txt");
    ;
}

//执行
void execute()
{
    vector<string> dirs = cv_GetListFolders("./../TestData", "*", true);
    ; i < dirs.size(); i++)
    {
        CStereoMatcher s;
        comParam(s);
        dirParam(s, dirs[i]);
        //costSSD9(s, dirs[i]);
        //costSSDMF9(s, dirs[i]);
        //costGlobal(s, dirs[i]);
        //aggr(s, dirs[i]);
        //lambda(s, dirs[i]);
        lasw(s, dirs[i]);
    }
}

立体匹配:关于Middlebury提供的源码的简化使用的更多相关文章

  1. 立体匹配:关于Middlebury提供的源码的简化后的结构

  2. 微信/易信公共平台开发(四):公众号调试器 (仿真微信平台,提供PHP源码)

    开发微信/易信公共平台时,调试往往很麻烦,一般只能在手机上边试边改, 或在服务器写日志.当你的服务器脚本有Bug时,手机上没有显示,追查是不容易的.我在开发过程中,编写了一个调试器, 能仿真微信/易信 ...

  3. easyui源码翻译1.32+API翻译全篇导航 (提供下载源码)

    前言 EasyUI每个组件都会有 属性.方法.事件 属性 所有的属性都定义在jQuery.fn.{plugin}.defaults里面.例如,对话框属性定义在jQuery.fn.dialog.defa ...

  4. Sencha Touch+PhoneGap打造超级奶爸之喂养记(一) 源码免费提供

    起源 非常高兴我的宝宝健康平安的出生了.对于初次做奶爸的我,喜悦过后,面临着各中担心,担心宝宝各项指标是否正常.最初几天都是在医院待着,从出生那一天开始,护士妹妹隔一段时间就会来问宝宝的喂奶,大小便, ...

  5. Sencha Touch+PhoneGap打造超级奶爸之喂养记(一) 源码免费提供(转)

    起源 非常高兴我的宝宝健康平安的出生了.对于初次做奶爸的我,喜悦过后,面临着各中担心,担心宝宝各项指标是否正常.最初几天都是在医院待着,从出生那一天开始,护士妹妹隔一段时间就会来问宝宝的喂奶,大小便, ...

  6. mono-3.4.0 源码安装时出现的问题 [do-install] Error 2 [install-pcl-targets] Error 1 解决方法

    Mono 3.4修复了很多bug,继续加强稳定性和性能(其实Mono 3.2.8 已经很稳定,性能也很好了),但是从http://download.mono-project.com/sources/m ...

  7. Winform下CefSharp的引用、配置、实例与报错排除(源码)

    Winform下CefSharp的引用.配置.实例与报错排除 本文详细介绍了CefSharp在vs2013..net4.0环境下,创建Winfrom项目.引用CefSharp的方法,演示了winfro ...

  8. require() 源码解读

    2009年,Node.js 项目诞生,所有模块一律为 CommonJS 格式. 时至今日,Node.js 的模块仓库 npmjs.com ,已经存放了15万个模块,其中绝大部分都是 CommonJS ...

  9. Apache Spark源码剖析

    Apache Spark源码剖析(全面系统介绍Spark源码,提供分析源码的实用技巧和合理的阅读顺序,充分了解Spark的设计思想和运行机理) 许鹏 著   ISBN 978-7-121-25420- ...

随机推荐

  1. wikioi 1474 十进制转m进制

    /*===================================== 1474 十进制转m进制 题目描述 Description 将十进制数n转换成m进制数 m<=16 n<=1 ...

  2. JQuery Pagenation 知识点整理——phototype 应用(20150517)(转)

    JS中的phototype是JS中比较难理解的一个部分 本文基于下面几个知识点: 1 原型法设计模式 在.Net中可以使用clone()来实现原型法 原型法的主要思想是,现在有1个类A,我想要创建一个 ...

  3. python简单粗暴多进程之concurrent.futures

    python在前面写过多线程的库threading: python3多线程趣味详解 但是今天发现一个封装得更加简单暴力的多进程库concurrent.futures: # !/usr/bin/pyth ...

  4. android数据存储之File

    android中使用File进行存储主要使用到OpenFileOutput和OpenFileInput两个方法,下面直接用一个例子来说明一下. (1)布局文件main.xml文件 <?xml v ...

  5. github 添加 C# IGNORE

    在创建仓库时选择 VisualStudio 即可.

  6. windows下 更新 android studio SDK 到最新版本 解决方案

    一.设置代理信息 打开android studio>>File>>Settings>>Appearance&Behavion>>System S ...

  7. 剑指offer系列43---判断平衡二叉树

    [题目]判断一颗二叉树是不是平衡二叉树. * 平衡二叉树定义:任意子节点深度相差不超过1.[思路]由上题,利用递归得到二叉树每个结点的深度同时比较. package com.exe9.offer; i ...

  8. python之pexpect模块

    最近在看<Python自动化运维技术与最佳实战>这本书,学到了一个运维中用到的模块:pexpect 下面是其定义: Pexpect 是一个用来启动子程序并对其进行自动控制的 Python ...

  9. How to install Wordpress 4.0 on CentOS 7.0

    This document describes how to install and configure Wordpress 4.0 on CentOS 7.0. WordPress started ...

  10. Makefile选项CFLAGS,LDFLAGS,LIBS

    CFLAGS 表示用于 C 编译器的选项, CXXFLAGS 表示用于 C++ 编译器的选项.这两个变量实际上涵盖了编译和汇编两个步骤. CFLAGS: 指定头文件(.h文件)的路径,如:CFLAGS ...