這是影像拼接 (Image Stitching)的續集,有更多客制化參數可選擇,以產生特別的拼接結果。
環境設定可直接參考:影像拼接 (Image Stitching)。
範例程式來源:C:\OpenCV2.4beta\samples\cpp\stitching_detailed.cpp
總共有以下參數可設定:
- Flags:
–preview
–try_gpu (yes|no)
- Motion Estimation Flags:
–work_megapix <float>
–features (surf|orb)
–match_conf <float>
–conf_thresh <float>
–ba (reproj|ray)
–ba_refine_mask (mask)
–wave_correct (no|horiz|vert)
–save_graph <file_name>
- Compositing Flags:
–warp (plane|cylindrical|spherical|fisheye|stereographic|compressedPlaneA2B1|
compressedPlaneA1.5B1|compressedPlanePortraitA2B1|compressedPlanePortraitA1.5B1|
paniniA2B1|paniniA1.5B1|paniniPortraitA2B1|paniniPortraitA1.5B1|mercator|transve
rseMercator)
–seam_megapix <float>
–seam (no|voronoi|gc_color|gc_colorgrad)
–compose_megapix <float>
–expos_comp (no|gain|gain_blocks)
–blend (no|feather|multiband)
–blend_strength <float>
–output <result_img>
前一程式無法處理垂直拼接,這個程式有了wave_correct這個參數可設定,我們來看第二組與第四組的拼接效果吧!default為horiz。
第二組:
設定為vert的結果:
第四組:
設定為vert的結果:
設定為no的結果:
喜歡哪個效果就選哪個用吧:P~
使用save_graph這個參數,得到這樣子的檔案內容:
graph matches_graph{
“a.jpg" — “b.jpg"[label="Nm=129, Ni=62, C=1.32762″];
“b.jpg" — “c.jpg"[label="Nm=158, Ni=103, C=1.85921″];
}
Nm is number of matches, Ni is number of inliers, C is confidence.
執行顯示的訊息變得相當完整:
- StitchTest.exe a.jpg b.jpg c.jpg
Finding features…
Features in image #1: 1250
Features in image #2: 1744
Features in image #3: 1441
Finding features, time: 3.66008 sec
Pairwise matching
1->2 matches: 101->2 matches: 83
1->2 matches: 114
1->2 & 2->1 matches: 52
.1->2 & 2->1 matches: 159
.1->2 & 2->1 matches: 141
.Pairwise matching, time: 152.073 sec
Estimating rotations…
Estimating rotations, time: 0.000403724 sec
Initial intrinsics #1:
[513.025011282021, 0, 400;
0, 513.025011282021, 267;
0, 0, 1]
Initial intrinsics #2:
[513.025011282021, 0, 400;
0, 513.025011282021, 267;
0, 0, 1]
Initial intrinsics #3:
[513.025011282021, 0, 400;
0, 513.025011282021, 267;
0, 0, 1]
Camera #1:
[726.7302324596924, 0, 400;
0, 726.7302324596924, 267;
0, 0, 1]
Camera #2:
[725.3095937708318, 0, 400;
0, 725.3095937708318, 267;
0, 0, 1]
Camera #3:
[733.7915866555516, 0, 400;
0, 733.7915866555516, 267;
0, 0, 1]
Wave correcting…
Wave correcting, time: 0.0172826 sec
Warping images (auxiliary)…
Warping images, time: 0.422173 sec
Exposure compensation…
Exposure compensation, time: 0.300704 sec
Finding seams…
Finding seams, time: 0.534436 sec
Compositing…
Compositing image #1
Multi-band blender, number of bands: 5
Compositing image #2
Compositing image #3
Compositing, time: 2.38835 sec
Finished, total time: 159.879 sec
接三張圖的總時間約為160秒。接下來看:影像拼接實驗2 (Image Stitching Experiment)。
Comments on: "[OpenCV] 影像拼接2 (Image Stitching)" (12)
想請問,要從哪裡load image,放入自己的圖片檔?
讚讚
不好意思,想請教一下
我編譯上都會有些無法辨識的問題
估計應該是相容性那邊沒設好
但我測試顯示影像的code是可以跑的,然後複製code執行就變得不能跑
是要補其他相容性嗎?
讚讚
你要看一下編譯後出現的訊息,才能知道哪裡出了問題喔~
讚讚
1>stitching_detailed.obj : error LNK2019: 無法解析的外部符號 “public: class cv::Point_ __thiscall cv::detail::CylindricalWarperGpu::warp(class cv::gpu::GpuMat const &,class cv::Mat const &,class cv::Mat const &,int,int,class cv::gpu::GpuMat &)" (?warp@CylindricalWarperGpu@detail@cv@@QAE?AV?$Point_@H@3@ABVGpuMat@gpu@3@ABVMat@3@1HHAAV563@@Z) 在函式 “public: virtual class cv::Point_ __thiscall cv::detail::CylindricalWarperGpu::warp(class cv::Mat const &,class cv::Mat const &,class cv::Mat const &,int,int,class cv::Mat &)" (?warp@CylindricalWarperGpu@detail@cv@@UAE?AV?$Point_@H@3@ABVMat@3@00HHAAV53@@Z) 中被參考
很多條這種….
讚讚
文章上頭的環境設定那一篇你有設定好嗎?
讚讚
請問我已經照您上面的所做了,包含環境設定等等,確定opencv是已經可以跑的了
但是在做影像拼接這塊時,都會出現matchers.hpp(90): error C2065: ‘Feature2D’ : 未宣告的識別項
可以請您幫幫我嗎?
感謝
讚讚
你是用哪個版本?要注意環境安裝Step 6的相依性檔案,我所使用的是2.4.0版喔!注意一下它們的檔名,可以直接到資料夾中找到該檔案,才能確定順利完成安裝。
讚讚
VC2010
剛剛提的狀況是我用2.1.2的去混用發生的
重裝純的2.4.0後會發生 opencv_core240.lib 不見的情形
讚讚
發現問題了…剛確定了一下版本
我載下來的是2.4.2
但是我並沒有去改到其他相依性那邊的名字
感謝
讚讚
恭喜^_^我猜的沒有錯!
讚讚
[…] 可見它的時間會隨著張數以類平方增長:O(x^2),簡單來說就是張數越多越慢!若要作成像X3那樣子的影像處理軟體,這種效能一定會讓使用者發瘋~好在這程式還可以調整參數,若發現沒必要的程序就可以選擇停用,以上實驗我皆使用預設參數。程式參數設定可參考:影像拼接2 (Image Stitching)。 Share this:共享EmailPrintFacebookTwitterLike this:喜歡Be the first to like this post. […]
讚讚
[…] 接續影像拼接2 (Image Stitching)的腳步,接下來當然就是一連串的實驗,有這麼好玩的程式能不玩嗎:P? […]
讚讚