類定義與概述
Stitcher類是OpenCV(開源計算機視覺庫)中提供的高級圖像拼接器類,它封裝了從特徵查找到圖像混合的全流程算法。作為高級圖像拼接器,可以在不了解整個拼接管道細節的情況下使用該類,但為了獲得更高的拼接穩定性和最終圖像質量,建議使用者至少熟悉相關的圖像拼接理論。
該類支持通過方法在預定義配置中創建拼接器實例,這些配置對應枚舉定義的工作模式。主要的預定義模式包括(全景模式,基於單應性模型,適用於相機拍攝的照片)和(掃描模式,基於仿射模型,適用於掃瞄器或專業設備捕獲的圖像)。此外,類定義了枚舉來表示拼接操作的結果狀態碼。
發展歷程
Stitcher類早期版本主要提供方法來創建默認的拼接器實例。在後續版本中,引入了更為便捷的工廠方法,該方法支持通過預定義模式(如和)快速配置拼接器,以適應不同的相機模型(透視變換模型和仿射變換模型)。同時,其狀態碼枚舉也在發展中得到了擴充,從早期僅包含和等基礎狀態,擴展增加了如、等更具體的錯誤類型。
核心配置與模型
Stitcher類實現了兩種核心相機模型:Homography模型和Affine模型,其中Homography模型適用於創建由相機拍攝的照片全景圖,而Affine模型可用於拼接掃描件和由專用設備捕獲的對象。通過方法可以使用預配置模式,如或,這些模式設定了多個stitcher屬性以在預定義場景中操作。
關鍵可調屬性包括用於設定配準解析度,用於設定全景圖置信度閾值,以及用於控制波形校正。注意不應混合使用實現Affine模型和Homography模型的類,因為它們處理不同的變換。
高級用法與擴展
對於希望深入研究或自定義拼接管道的用戶,OpenCV提供了示例代碼(C++/Python),用於研究拼接管道的內部結構或實驗詳細配置。
如果用戶擁有CUDA設備,可以通過將參數設定為true來嘗試啟用GPU加速以卸載某些操作,而OpenCL加速則由全局OpenCV設定透明控制,與此標誌無關。
用戶可以完全自定義底層組件,例如特徵查找器()、特徵匹配器()、曝光補償器()等,並通過、、等方法進行設定。
拼接管道中目前實現了兩種相機模型:期望圖像間透視變換的模型,以及期望具有6自由度或4自由度仿射變換的模型。模型適用於創建由相機拍攝的照片全景圖,而基於仿射的模型可用於拼接由掃瞄器或專業設備捕獲的掃描件和對象。不應混合使用實現仿射模型和實現模型的類,因為它們處理不同的變換。
通過繼承Stitcher類並重寫和方法,可以實現僅在視頻第一幀進行相機標定,後續幀復用標定參數,從而有效解決視頻拼接中的抖動問題。
opencv中對於圖像拼接等提供的現有的類。
函式有:
Stitcher::createDefault
Creates a stitcher with the default parameters.
Stitcher::composePanorama
These functions try to compose the given images (or images stored internally from the other function calls) into the final pano under the assumption that the image transformations were estimated before.
Note
Use the functions only if you’re aware of the stitching pipeline, otherwise useStitcher::stitch().
C++:StatusStitcher::composePanorama(OutputArraypano)
C++:StatusStitcher::composePanorama(InputArrayimages, OutputArraypano)
Stitcher::stitch
These functions try to stitch the given images.
C++:StatusStitcher::stitch(InputArrayimages, OutputArraypano)
C++:StatusStitcher::stitch(InputArrayimages, const std::vector<std::vector<Rect>>&rois, OutputArraypano)
WarperCreator
Image warper factories base class.
class WarperCreator{public: virtual ~WarperCreator() {} virtual Ptr create(float scale) const = 0;};
PlaneWarper
Plane warper factory class.
class PlaneWarper : public WarperCreator{public: Ptr create(float scale) const { return new detail::PlaneWarper(scale); }};
See also
detail::PlaneWarper
CylindricalWarper
Cylindrical warper factory class.
class CylindricalWarper: public WarperCreator{public: Ptr create(float scale) const { return new detail::CylindricalWarper(scale); }};
See also
detail::CylindricalWarper
SphericalWarper
Spherical warper factory class.
class SphericalWarper: public WarperCreator{public: Ptr create(float scale) const { return new detail::SphericalWarper(scale); }};