OPENCV 2.4.9 stitching.cpp编译失败

LoveYouSelf 2014-08-26 03:05:48
OPCV 2.4.9配置均按照网上要求且能实现网上给出的效果,对于OPCV 2.4.9 sample下的一些工程也都能正常编译通过,求大神告知如何解决。


#include <iostream>
#include <fstream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/stitching/stitcher.hpp"

using namespace std;
using namespace cv;

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

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

int main(int argc, char* argv[])
{
int retval = parseCmdArgs(argc, argv);
if (retval) return -1;

Mat pano;
Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
//Stitcher::Status status;
//status = stitcher.stitch(imgs,pano);
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;
}


void printUsage()
{
cout <<
"Rotation model images stitcher.\n\n"
"stitching img1 img2 [...imgN]\n\n"
"Flags:\n"
" --try_use_gpu (yes|no)\n"
" Try to use GPU. The default value is 'no'. All default values\n"
" are for CPU mode.\n"
" --output <result_img>\n"
" The default is 'result.jpg'.\n";
}


int parseCmdArgs(int argc, char** argv)
{
if (argc == 1)
{
printUsage();
return -1;
}
for (int i = 1; i < argc; ++i)
{
if (string(argv[i]) == "--help" || string(argv[i]) == "/?")
{
printUsage();
return -1;
}
else if (string(argv[i]) == "--try_use_gpu")
{
if (string(argv[i + 1]) == "no")
try_use_gpu = false;
else if (string(argv[i + 1]) == "yes")
try_use_gpu = true;
else
{
cout << "Bad --try_use_gpu flag value\n";
return -1;
}
i++;
}
else if (string(argv[i]) == "--output")
{
result_name = argv[i + 1];
i++;
}
else
{
Mat img = imread(argv[i]);
if (img.empty())
{
cout << "Can't read image '" << argv[i] << "'\n";
return -1;
}
imgs.push_back(img);
}
}
return 0;
}


错误如下:
1>------ 已启动生成: 项目: Test2, 配置: Debug Win32 ------
1>生成启动时间为 2014/8/26 14:56:25。
1>InitializeBuildStatus:
1> 正在对“Debug\Test2.unsuccessfulbuild”执行 Touch 任务。
1>ClCompile:
1> stitching.cpp
1>stitching.obj : error LNK2019: 无法解析的外部符号 "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),该符号在函数 _main 中被引用
1>stitching.obj : error LNK2019: 无法解析的外部符号 "public: static class cv::Stitcher __cdecl cv::Stitcher::createDefault(bool)" (?createDefault@Stitcher@cv@@SA?AV12@_N@Z),该符号在函数 _main 中被引用
1>F:\fyj\All Code\C++\OpenCV\Test2\Debug\Test2.exe : fatal error LNK1120: 2 个无法解析的外部命令
...全文
562 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
tf000537 2016-05-02
  • 打赏
  • 举报
回复
要加对应的lib 详见http://www.ithao123.cn/content-6717260.html

5,530

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 模式及实现
社区管理员
  • 模式及实现社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧