关于Opencv2.4.x中stitcher类的简单应用


       opencv2.4以上版本有stitcher类,可以简单方便的实现图像的拼接,目前只是简单的测试一下stitcher类的拼接功能,也是纠结了好长时间,最终发现是要在链接库中加上opencv_stitching244.lib(对于Release),opencv_stitching244d.lib(对于Debug)才行,不然会出现VS2010编译不成功,错误提示是:

1>main.obj : error LNK2019: unresolved external symbol "public: enum cv::Stitcher::Status __thiscall cv::Stitcher::stitch(class cv::_InputArray const &,class cv::_OutputArray const &)" (?stitch@Stitcher@cv@@QAE?AW4Status@12@ABV_InputArray@2@ABV_OutputArray@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: static class cv::Stitcher __cdecl cv::Stitcher::createDefault(bool)" (?createDefault@Stitcher@cv@@SA?AV12@_N@Z) referenced in function _main
1>D:\visual studio 2010\Projects\stitching20\Debug\stitching20.exe : fatal error LNK1120: 2 unresolved externals

        下面是测试程序:

编译环境:

       操作系统:XP

       opencv版本:2.4.4

       编译器版本:VS2010

程序代码 

#include 
#include 
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/stitching/stitcher.hpp"

using namespace std;
using namespace cv;

bool try_use_gpu = false;
vector imgs;
string result_name = "result.jpg";

//void printUsage();
//int parseCmdArgs(int argc, char** argv);

int main(int argc, char* argv[])
{
	Mat img=imread("1.jpg");
	imgs.push_back(img);
	img=imread("2.jpg");
	imgs.push_back(img);
	img=imread("3.jpg");
	imgs.push_back(img);

	Mat pano;
	Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
	Stitcher::Status status = stitcher.stitch(imgs, pano);
	if (status != Stitcher::OK)
	{
		cout << "Can't stitch images, error code = " << int(status) << endl;
		return -1;
	}

	imwrite(result_name, pano);
	return 0;
}
贴上图片:

关于Opencv2.4.x中stitcher类的简单应用_第1张图片  

关于Opencv2.4.x中stitcher类的简单应用_第2张图片  

关于Opencv2.4.x中stitcher类的简单应用_第3张图片


你可能感兴趣的:(Opencv2.0)