Windows上的Eclipse上的OpenCV [英] OpenCV on eclipse on windows
问题描述
我正在尝试在Windows上安装opencv,这是我的步骤:
I'm trying to install opencv on windows, here are my steps:
- 从网站上下载了opencv 2.4.3
- 运行exe,将文件夹提取到同一路径
- 打开的月食(先前已设置并配置了MinGW)
- 创建了新项目XYZ
- 添加了新文件夹"src"
- 添加了新类"main.cpp"
-
添加了以下代码:
- downloaded opencv 2.4.3 from website
- run the exe, extracted the folder in the same path
- opened eclipse (with MinGW previously set and configured)
- created new project XYZ
- added new folder "src"
- added new class "main.cpp"
added the following code:
哈希包含< cv.h>
哈希包含< highgui.h>
hash include <cv.h>
hash include <highgui.h>
using namespace cv;
int main(int argc, char** argv) {
Mat image;
image = imread(argv[1], 1);
if (argc != 2 || !image.data) {
printf("No image data \n");
return -1;
}
namedWindow("Display Image", CV_WINDOW_AUTOSIZE);
imshow("Display Image", image);
waitKey(0);
return 0;
}
添加了两条路径
added the two paths
- "E:\ Sources \ opencv \ build \ include"
- "E:\ Sources \ opencv \ build \ include \ opencv"
请告知是否缺少任何步骤
Please advice if any step is missing
推荐答案
您将需要openCV 2.4.3的最新稳定版本.
you gonna need the latest stable version of openCV 2.4.3 .
Eclipse Juno! (面向C/C ++开发人员的Eclipse IDE) 和 MinGW-适用于Windows的极简主义GNU
Eclipse Juno ! (Eclipse IDE for C/C++ Developers ) And MinGW - Minimalist GNU for Windows
我们将忽略x86/64的选择,因为我们将使用32编译器和32 openCV构建,即使系统是64编译器!
we will ignore x86/64 choice, since we gonna work with a 32 compiler / and 32 openCV build, even though the system is a 64 one !
第1步:下载并安装
Eclipse
从中下载Eclipse并解压缩归档文件. (我假设您的计算机上已经装有JRE,如果没有,请下载并安装它).
Download Eclipse from and decompress the archive . ( I assumed that you already have JRE on your computer , if not ! download and install it ) .
MinGW
下载MinGW.安装程序将引导您完成该过程! 您可能必须将bin目录添加到路径中! (默认路径:C/MinGW/bin)
Download MinGW . the installer will lead you through the process ! you might have to add the bin directory to the path ! (Default path : C/MinGW/bin )
OpenCV
从链接下载openCV exe,解压缩文件(在本教程的C:/目录中). 确保您具有下面的文件结构.
Download openCV exe from the link , extract the files (in the C:/ directory in this tutorial ) . Make sure you have the file structure below .
别忘了添加bin目录=>路径!
don't forget to add the bin directory => Path !
正如我之前提到的!即使我有64个操作系统,我也将使用x86构建,以避免编译器问题并使本教程向x86 OS用户开放!
As I mentioned earlier ! I'll use x86 build even if i have a 64 OS to avoid compiler problems and to keep this tutorial open to x86 OS users !
第2步:创建和配置
- 打开Eclipse IDE!
- 创建一个新的C ++项目:文件>新建> C ++项目
- 选择一个Hello Word项目以拥有一个预先构造的项目! 不要忘记选择MinGW工具链
- Open the Eclipse IDE !
- Create a new C++ project : File > New > C++ Project
- Choose a Hello Word Project to have a pre structured one ! Don't forget to select the MinGW toolchains
点击完成",开始工作!
Click Finish and let's get to work !
现在,您已经有了第一个Hello word项目!将Soure文件.cpp中的代码替换为下面的代码
Now that you have you first Hello word project ! replace the Code in the Soure file .cpp by the code below
///////////////CODE///////////
///////////////CODE///////////
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
Mat im = imread(argc == 2 ? argv[1] : "lenna.png", 1);
if (im.empty())
{
cout << "Cannot open image!" << endl;
return -1;
}
imshow("image", im);
waitKey(0);
return 0;
}
///////////////CODE///////////
///////////////CODE///////////
很明显,代码上存在多个错误,是的!我们必须链接库!
Obviously there are multiple errors on the code , yes ! we have to link the libraries !
现在转到属性>> C/C ++构建>>设置 在工具设置选项卡>> GCC C ++编译器>>包括和包括opencv路径中! [opencvDir \ build \ include]
Now go to Properties >> C/C++ Build >> Settings on the Tool Setting tab >> GCC C++ Compiler >> Includes and include opencv path ! [opencvDir\build\include]
现在滚动到MinGW C ++ Linker >>库,并添加库搜索路径[opencvDIR \ build \ x86 \ mingw \ lib]
Now scroll to MinGW C++ Linker >> Libraries and add the Library search path [opencvDIR\build\x86\mingw\lib]
在图书馆部分!我们根据项目需要添加任意数量的librarie! 在这里,我仅出于教程目的添加了4个库,即使只需要highgui一个库即可使我们的测试代码正常工作! 这些库的名称可以在[opencvDIR \ build \ x86 \ mingw \ lib]中找到 例子 !对于libopencv_video243.dll.a,请在链接器中添加opencv_video243!
in the Libraries part ! we add as much librarie as we need for the project ! here I added 4 libraries just for tutorial sake even if well need only the highgui one for our test code to work ! The libraries names can be found on the [opencvDIR\build\x86\mingw\lib] Example ! for libopencv_video243.dll.a wee add opencv_video243 in the linker !
单击确定"!
现在我们可以构建第一个项目! 您认为必须像源代码"lenna.png"中所暗示的那样向项目添加图片. 使用莱娜带来好运
Now we can build our first project ! You figured that you have to add a picture to the project as implied in the source code "lenna.png" Use lenna for good luck
构建并运行项目! 如果您看到漂亮的女士:)恭喜您:)
Build and Run the project ! If you see the beautiful lady :) Congrats :)
在这里查看快照! opencveclipse-on
这篇关于Windows上的Eclipse上的OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!