把前面搞得拼接程序的匹配关系,传送给对Opencv 的stitching 再拼接,两者相匹合来拼接看看效果如何
流程:
1。运程前面的分圈匹配,记下匹配关系,并保存到文件
2。在Opencv 的stitching中读出匹配关系,其它的不匹配
3。把费时的光束平差法改成"ray";//射线发散误差方法
再把费时的曝光补偿改成ExposureCompensator::GAIN;//增益法
接着把也费时的寻找接缝线改成"voronoi"; //逐点法
保存匹配关系(83图)
void WriteMatcherFile(float i,float j)//写匹配对到文件 { FILE* IMGdata; fopen_s(&IMGdata, "matcher_1_2.txt", "a"); std::string s=num2str(i)+" "+ num2str(j); int count = fwrite(s.c_str(), sizeof(char), s.length(), IMGdata); count = fwrite("\n", sizeof(char), 1, IMGdata); fclose(IMGdata); }matcher_1_2.txt中的内容是这样的:
0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 54 54 55 55 56 56 57 57 58 58 59 59 60 60 61 61 62 62 63 63 64 64 65 65 66 66 67 67 68 68 69 69 70 70 71 71 72 72 73 73 74 74 75 75 76 76 77 77 78 78 79 79 80 80 81 81 82 0 27 0 28 0 29 0 28 27 29 3 30 2 30 4 31 5 32 6 33 7 34 8 35 9 36 11 37 10 37 11 38 12 39 13 40 14 41 17 43 20 45 22 46 24 47 24 48 26 49 27 50 28 51 28 52 28 53 28 54 28 55 4 56 5 57 6 58 7 59 8 60 9 61 10 62 11 63 10 63 12 64 13 65 14 66 15 67 15 68 16 69 17 70 18 71 19 72 21 74 22 75 23 76 24 77 25 78 26 79 27 80 28 81 28 82载入匹配列表
//载入匹配列表 vector<string> matcher_id; LoadImageNamesFromFile("matcher_1_2.txt",matcher_id); //分解id for (int i = 0; i < matcher_id.size (); ++i) { Point2i a=分解id(matcher_id[i]);//分解id cout<<a.x<<","<<a.y<<endl; if(a.x+1<a.y)//不是相连 { //匹配 vector<ImageFeatures> f2; vector<MatchesInfo> m2; f2.push_back (features[a.x]); f2.push_back (features[a.y]); f2_matcher(f2,m2); //按列表匹配,并加入 //正向 int k=a.x*num_images+a.y; pairwise_matches[k]= m2[1]; pairwise_matches[k].src_img_idx =a.x; pairwise_matches[k].dst_img_idx =a.y; //反向 k=a.y*num_images+a.x; pairwise_matches[k]= m2[2]; pairwise_matches[k].src_img_idx =a.y; pairwise_matches[k].dst_img_idx =a.x; } }如果把现在中的最费时光束平差去掉,效果:
虽然速度很快,但不理想。如果加回的话,效果:
用时590.425秒,差不多10分钟,加上前面的4分钟,差不多15分钟(83图)
其中载入图像,特征检测,匹配重复了一遍,如果合两为一,还要少一点点(当然最费时的还是光束平差法)
这样差不多可以使用了。
结束。