首页 文章

OpenCV通过NuGet包与Visual Studio 2015,如何配置?

提问于
浏览
2

我正在尝试使用Visual Studio 2015中的NuGet包使用OpenCV,我似乎无法完成所有配置 . 我不确定我是否在某个地方犯了错误,或者我正在尝试的不支持 .

一点点背景,我一段时间地做了这个教程:

https://www.youtube.com/watch?v=7SM5OD2pZKY https://github.com/MicrocontrollersAndMore/OpenCV_3_Windows_10_Installation_Tutorial

如果可能的话,我想更新它以使用NuGets . 我每天都在工作中使用NuGets,所以我对这个概念很熟悉,但我以前只使用NuGets和.Net(Visual Basic或C#)应用程序 .

我正在尝试使用平面jane C OpenCV,而不是在.NET或UWP应用程序中 .

为了记录,在一个单独的.Net测试项目中,我尝试了EmguCV NuGet包:

enter image description here

使用Visual Studio 2015,一切都按预期工作(对于那些不熟悉的人,Emgu CV可能是OpenCV最老/最知名/最稳定的.Net包装器)

以下是我尝试使用NuGets使常规C OpenCV在Visual Studio 2015中工作的步骤:

启动Visual Studio 2015,创建一个空项目:

enter image description here

打开NuGet包管理器:

enter image description here

我选择OpenCV.Win.ImgProc,因为它似乎是唯一可用的OpenCV 3.x NuGet,这也是按预期自动导入Core:

enter image description here

enter image description here

然后我添加了一个.cpp文件并复制/粘贴在已知良好的OpenCV代码中,OpenCV库无法识别:

enter image description here

我尝试了Build - > Clean,Build - > Build,同样关心 . 我也尝试将“解决方案配置”和“解决方案平台”设置为Debug / Release / x86 / x64,同样令人担忧 .

我在这里错过了一步吗? NuGets只能在.Net或UWP等托管环境中工作,还是可以使用常规C?我确实注意到关于UWP的描述中的提及:

enter image description here

但是我没有使用VideoIO,所以我不确定这是否重要 .

有人有这个成功吗?我总是可以回到直接引用Project - >(项目名称)属性中的库的“旧学校”方式,如上面链接的教程所示,但我想尽可能使用NuGets .

-----------编辑---------------

我不得不在此处对Leo-MSFT做出回应以允许足够的角色和截图 . 感谢Leo-MSFT的建议,但有两个问题 . 首先,该软件包是OpenCV 2.4.10,现在已经过时了:

enter image description here

2,如果我使用该包,则红色下划线消失了,但是当我尝试构建和运行时,我收到以下链接器错误:

1> ------ Build build:项目:Test2,配置:调试x64 ------ 1> test.cpp 1> test.obj:错误LNK2019:未解析的外部符号"void __cdecl cv::fastFree(void *)"(?fastFree @ cv @@在函数引用YAXPEAX @ Z)"public: __cdecl cv::Mat::~Mat(void)"(?? 1Mat @ @@ CV @ QEAA XZ)1> test.obj:错误LNK2019:解析外部符号"public: __cdecl cv::_InputArray::_InputArray(class cv::Mat const &)"(?? 0_InputArray @ @@ CV @ QEAA @ AEBVMat 1个@@ Z)在函数main 1> test.obj中引用:错误LNK2019:未解析的外部符号"public: __cdecl cv::_OutputArray::_OutputArray(class cv::Mat &)"(?? 0_OutputArray @ cv @@ QEAA @ AEAVMat @ 1 @@ Z)在函数main 1> test.obj中引用:错误LNK2019:未解析的外部符号"public: void __cdecl cv::Mat::deallocate(void)"(解除分配@垫@ @@ CV QEAAXXZ?)在函数引用"public: void __cdecl cv::Mat::release(void)" 1> test.obj(释放@垫@ @@ CV QEAAXXZ?):错误LNK2019:解析的外部符号"public: void __cdecl cv::Mat::copySize(class cv::Mat const &)"(copySize @垫@ @@ CV QEAAXAEBV12 @@ Z)在函数引用"public: class cv::Mat & __cdecl cv::Mat::operator=(class cv::Mat const &)"(?? 4MAT @ @@ CV @ QEAAAEAV01 @@ AEBV01 Z)1> test.obj:错误LNK2019:解析的外部符号"int __cdecl cv::_interlockedExchangeAdd(int *,int)"(_interlockedExchangeAdd @ @@ CV @ YAHPEAHH Z)中函数引用"public: class cv::Mat & __cdecl cv::Mat::operator=(class cv::Mat const &)"(?? 4Mat @ cv @@ QEAAAEAV01 @ AEBV01 @@ Z) 1> test.obj:错误LNK2019:未解析的外部符号"void __cdecl cv::namedWindow(class std::basic_string,class std::allocator > const &,int)"(?namedWindow @ cv @@ YAXAEBV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ H @ Z)在函数main 1> test.obj中引用:错误LNK2019:未解析的外部符号"int __cdecl cv::waitKey(int)"(?waitKey @ cv @@ YAHH @ Z)在函数main 1> test.obj中引用:错误LNK2019:未解析的外部符号"void __cdecl cv::imshow(class std::basic_string,class std::allocator > const &,class cv::_InputArray const &)"(?imshow @cv @@ YAXAEBV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ AEBV_InputArray @ 1 @@ Z)在函数main 1> test.obj中引用:error LNK2019:未解析的外部符号"class cv::Mat __cdecl cv::imread(class std::basic_string,class std::allocator > const &,int)"(?imread @ cv @@ YA?AVMat @ 1 @ AEBV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ H @ Z )在函数main 1> test.obj中引用:错误LNK2019:未解析的外部符号“void _cdecl cv :: GaussianBlur(class cv :: _ InputArray const&,class cv :: OutputArray const&,class cv :: Size,double,double ,int)" (?GaussianBlur@cv@@YAXAEBV_InputArray@1@AEBV_OutputArray@1@V?$Size@H@1@NNH@Z) referenced in function main 1>test.obj : error LNK2019: unresolved external symbol " void __cdecl cv :: Canny(class cv :: _ InputArray const&,class cv :: _ OutputArray const&,double,double,int,bool)" (?Canny@cv@@YAXAEBV_InputArray@1@AEBV_OutputArray@1@NNH_N@Z) referenced in function main 1>test.obj : error LNK2019: unresolved external symbol " void __c东方电气CV :: cvtColor(CV类:: _ InputArray常量和,类品种:: _ OutputArray常量和,INT,INT)”(?cvtColor @ CV @@ YAXAEBV_InputArray @ 1 @ AEBV_OutputArray @ 1 @ HH @ Z)在功能上主要参考1> C:\ Users \ cdahms \ Documents \ Test2 \ x64 \ Debug \ Test2.exe:致命错误LNK1120:13个未解析的外部因素==========构建:0成功,1个失败,0个到达-date,0跳过==========

在尝试了各种选项后,我已经确定了这个包:

enter image description here

这似乎有用,虽然它不是很有信心鼓舞人心,它显然被贴上了“不是官方的标签”包“并且它稍微过时了(从OpenCV 3.1.0到3.2.0没有太多变化) . 我想我会使用它直到发布一个正确的更新包 .

1 回答

  • 2

    对于测试OpenCV代码,OpenCV库包是 OpenCV3.1 而不是OpenCV.Win.ImgProc .

    下面是我的测试结果,因此您只需为该OpenCV代码安装 OpenCV3.1 NuGet包而不是OpenCV.Win.ImgProc .

    enter image description here

    请注意:OpenCV3.1不是官方软件包 .

相关问题