我正在構建一個Android應用程序來創建全景圖。用戶捕捉一組圖像,那些圖像 被髮送到我的原生針跡功能,該功能基於https://github.com/opencv/opencv/blob/master/samples/cpp/stitching_detailed.cpp。 由於圖像是按順序排列的,因此我想只將每個圖像與矢量中的下一個圖像進行匹配。OpenCV 3.1爲了拍攝而拼接圖像
我發現英特爾的一篇文章,在做這一點與下面的代碼:
vector<MatchesInfo> pairwise_matches;
BestOf2NearestMatcher matcher(try_gpu, match_conf);
Mat matchMask(features.size(),features.size(),CV_8U,Scalar(0));
for (int i = 0; i < num_images -1; ++i)
{
matchMask.at<char>(i,i+1) =1;
}
matcher(features, pairwise_matches,matchMask);
matcher.collectGarbage();
問題是,這不會編譯。我猜是因爲即時通訊使用OpenCV 3.1。 後來我發現的地方,該代碼會做同樣的:
int range_width = 2;
BestOf2NearestRangeMatcher matcher(range_width, try_cuda, match_conf);
matcher(features, pairwise_matches);
matcher.collectGarbage();
而對於我的大部分樣品能正常工作。但有時候,特別是當我拼接一大組圖像(大約15)時,一些對象出現在彼此的頂部和它們不應該的位置。 我也注意到,最終結果的「開始」(左側)並不是向量中的第一個圖像,這是奇怪的 。
我使用「orb」作爲features_type和「ray」作爲ba_cost_func。似乎我不能在OpenCV 3.1上使用SURF。 我的初始參數,其餘是這樣的:
bool try_cuda = false;
double compose_megapix = -1; //keeps resolution for final panorama
float match_conf = 0.3f; //0.3 default for orb
string ba_refine_mask = "xxxxx";
bool do_wave_correct = true;
WaveCorrectKind wave_correct = detail::WAVE_CORRECT_HORIZ;
int blend_type = Blender::MULTI_BAND;
float blend_strength = 5;
double work_megapix = 0.6;
double seam_megapix = 0.08;
float conf_thresh = 0.5f;
int expos_comp_type = ExposureCompensator::GAIN_BLOCKS;
string seam_find_type = "dp_colorgrad";
string warp_type = "spherical";
所以任何人都可以開導我,爲什麼這不是工作,我應該如何符合我的特點是什麼?任何幫助或方向將不勝感激!
TL; DR:我想按拍攝順序拼接圖像,但上面的代碼不適合我,我該怎麼做?