2

我有这个代码:

#include <opencv2\stitching\stitcher.hpp>

int Stitching()
{
Stitcher m_stitcher = m_stitcher.createDefault(false);

vector<Mat> images; 
Mat img1 = imread("0.jpg"); //read image 0
Mat img2 = imread("1.jpg"); //read image 1
Mat Result;

//add images to the array
images.push_back(img1);
images.push_back(img2);

m_stitcher.stitch(images, Result);
imwrite("panorama.jpg",Result);
return 0;
}

构建后我收到此错误:

错误 4 错误 C2248: 'cv::Stitcher::Stitcher' : 无法访问在类 'cv::Stitcher' C:\Users\Desktop\Projects\SamplePanorama - PanoramaStitch\SamplePanorama \StitchEngine.cpp 602 中声明的私有成员

我应该添加什么才能使stitch() 正常工作?

4

1 回答 1

0

您的类Stitcher似乎没有公共构造函数。如果这是您拥有的类,则需要给它一个公共构造函数,以便能够构造Stitcher. 然而,这似乎是一个第三方库,一个快速的谷歌搜索告诉你这个方法的存在Stitcher

static Stitcher createDefault(bool try_use_gpu = false);

为了创建您的实例,Stitcher您可能必须执行以下操作:

Stitcher m_stitcher = Stitcher::CreateDefault();

编辑:为了修复链接器错误,您可能需要将正确的 lib 文件添加到链接器的输入列表中。此链接应该可以帮助您进行设置, http: //opencv.willowgarage.com/wiki/InstallGuide

于 2012-12-19T20:45:28.170 回答