日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發(fā)布時(shí)間:2025/7/25 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 关于Opencv2.4.x中stitcher类的简单应用 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

?

1.opencv2.4以上版本有stitcher類,可以簡單方便的實(shí)現(xiàn)圖像的拼接,目前只是簡單的測(cè)試一下stitcher類的拼接功能,也是糾結(jié)了好長時(shí)間,最終發(fā)現(xiàn)是要在鏈接庫中加上opencv_stitching249.lib(對(duì)于Release),opencv_stitching249d.lib(對(duì)于Debug)才行,不然會(huì)出現(xiàn)VS2013編譯不成功,錯(cuò)誤提示是:(注:紅色數(shù)字249是當(dāng)前opencv的版本號(hào),根據(jù)你的opencv版本號(hào),更改這個(gè)數(shù)值)

?

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 2010Projectsstitching20Debugstitching20.exe : fatal error LNK1120: 2 unresolved externals

?

? ? ? ? 下面是測(cè)試程序:

編譯環(huán)境:

? ? ? ?操作系統(tǒng):XP

? ? ? ?opencv版本:2.4.9

? ? ? ?編譯器版本:VS2013

程序代碼?

#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[])
{
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;
}

除了上面的錯(cuò)誤之外,還會(huì)出現(xiàn)像下面的錯(cuò)誤,很多個(gè)
stitching\detail\warpers_inl.hpp(186): error C2059: 語法錯(cuò)誤:“::”
錯(cuò)誤代碼示例:
  • size.Width?=?std::max(size.Width,?elementSize.Width); ?
  • ?2.錯(cuò)誤原因

    ?? 函數(shù)模板max與Visual C++中的全局的宏max沖突。?

    3.解決辦法

    ? ? 1.第一種辦法:設(shè)置項(xiàng)目屬性,在預(yù)定義處理器中添加定義NOMINMAX來禁止使用Visual C++的min/max宏定義。

    ???????????????????????項(xiàng)目屬性?? ——> C/C++ ——> 預(yù)處理器 ——> 預(yù)處理器定義 (此處添加預(yù)定義編譯開關(guān)?? NOMINMAX)

    但是visual C++中定義能自動(dòng)匹配double和int,如果進(jìn)行了上述設(shè)置,代碼中手動(dòng)將int型的數(shù)據(jù)乘以1.0來達(dá)到double的目的。

    ? ? 2.第二種辦法:?加上括號(hào),與Vsual C++的min/max宏定義區(qū)分開? ? ? ? ? ? ? ? ??

    size.Width?=?std::max(size.Width,?elementSize.Width); ? 修改為如下內(nèi)容:

    ? ? size.Width?=?(std::max)(size.Width,?elementSize.Width); ?



    ?

    轉(zhuǎn)載于:https://www.cnblogs.com/fengting/p/4978364.html

    總結(jié)

    以上是生活随笔為你收集整理的关于Opencv2.4.x中stitcher类的简单应用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。