OpenCV / EmguCV大图像拼接

我是图像拼接技术和算法的新手。 我需要的是缝合几张图像(从2到20)。 图像大小约为4-5 MB,分辨率为4000×3000。

由于我有.NET背景,我尝试了与安装包一起使用的EmguCV拼接示例应用程序。 但是我一直得到OutOfMemoryexception或者没有分配xxxxx字节。 之后我尝试编写使用OpenCV的原生C ++控制台应用程序并获得相同的结果。 问题是拼接实现内部还是我需要为Stitcher类设置一些特殊设置?

尝试了不同版本的Emgu – 2.9,2.4.2和2.4,OpenCV – 2.4.7

将图像大小调整为800×600无济于事。 当它很小时,库返回0作为结果。

我在两台不同的Windows 8 x64机器上测试了它,内存为8 GB,Windows 7 x64为16 GB。 在这两种情况下,应用程序都会尝试使用所有可用内存,然后崩溃。

有谁知道这个库可以处理的最大图像大小是多少? 我应该使用什么设置来减少内存使用量? 有没有人能够缝合大图像?

将不胜感激任何帮助或建议。

谢谢!

EmguCV C#代码(它实际上是来自EmguCV Image Stitching示例应用程序的代码)

private void selectImagesButton_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.CheckFileExists = true; dlg.Multiselect = true; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { sourceImageDataGridView.Rows.Clear(); Image[] sourceImages = new Image[dlg.FileNames.Length]; for (int i = 0; i < sourceImages.Length; i++) { sourceImages[i] = new Image(dlg.FileNames[i]); using (Image thumbnail = sourceImages[i].Resize(200, 200, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC, true)) { DataGridViewRow row = sourceImageDataGridView.Rows[sourceImageDataGridView.Rows.Add()]; row.Cells["FileNameColumn"].Value = dlg.FileNames[i]; row.Cells["ThumbnailColumn"].Value = thumbnail.ToBitmap(); row.Height = 200; } } try { using (Stitcher stitcher = new Stitcher(true)) { Image result = stitcher.Stitch(sourceImages); resultImageBox.Image = result; } } finally { foreach (Image img in sourceImages) { img.Dispose(); } } } } 

OpenCV C ++代码:

 #include  #include  #include "opencv2/core/core.hpp" #include "opencv2/features2d/features2d.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/calib3d/calib3d.hpp" #include  using namespace cv; using namespace std; int main() { Stitcher stitcher = Stitcher::createDefault(); vector images; Mat img1 = imread("1.jpg"); Mat img2 = imread("2.jpg"); if(!img1.data && !img2.data) { cout<<"Error!\n"; return -1; } Mat Result; //add images to the array images.push_back(img1); images.push_back(img2); cout<<"Stitching started...\n"; Stitcher::Status status = stitcher.stitch(images, Result); if (status != Stitcher::OK) { cout << "Can't stitch images, error code = " << status << endl; } imwrite("result.jpg",Result); return 0; } 

更新:

在拼接器中禁用wave corerection后,我能够处理更大的文件并且它不会填满所有空闲RAM。

我也想知道处理多个图像的最佳方法是什么。 将它们拼接在一起或将所有图像放到数组中并承担处理OpenCV库的所有责任?

是否有在OpenCV库中实现的拼接算法的描述? 我刚刚发现这个图http://docs.opencv.org/modules/stitching/doc/introduction.html我想知道并理解场景背后的所有细节,因为我将处理不同分辨率和大小的不同图像。 因此,在性能和质量之间取得平衡非常重要。

谢谢!