[英]Installation of OpenCV 2.4.5 on Visual Studio 2008
I'm having some difficulties trying to use OpenCV with visual studio 2008 (Professional Edition). 我在使用Visual Studio 2008(专业版)时尝试使用OpenCV遇到了一些困难。 I believe I've done everything necessary to run a OpenCV sample, but it crashes due to a run-time error.
我相信我已经完成了运行OpenCV示例所需的一切,但由于运行时错误导致崩溃。 This is driving me insane, I hope someone can help.
这让我疯了,我希望有人可以提供帮助。
But first things first. 但首先要做的事情。
Downloaded OpenCV 2.4.5 from sourcefourge.net. 从sourcefourge.net下载OpenCV 2.4.5 。
When prompted, I chose "Z:\\Games instalados\\OpenCV" as my "Extract to" option in the .exe downloaded from the above link. 出现提示时,我选择“Z:\\ Games instalados \\ OpenCV”作为从上面链接下载的.exe中的“Extract to”选项。
Went to "Control Panel" -> "System" -> "Advanced System Settings", then clicked on the "Environment Variables" in the "Advanced" tab. 转到“控制面板” - >“系统” - >“高级系统设置”,然后单击“高级”选项卡中的“环境变量”。 In the "System Variables" box I highlighted "Path" and clicked on "Edit...".
在“系统变量”框中,我突出显示“路径”,然后单击“编辑...”。 In the new window I added to the end of the text in "Variable Value" my installation directory with a ";"
在新窗口中,我在“变量值”的文本末尾添加了一个带有“;”的安装目录 before it, namely ";Z:\\Games instalados\\OpenCV\\opencv\\build\\x86\\vc11\\bin" (without the double quotes).
在它之前,即“; Z:\\ Games instalados \\ OpenCV \\ opencv \\ build \\ x86 \\ vc11 \\ bin”(不带双引号)。 Here's a screenshot:
这是一个截图:
.
。
I've also tried with the hough lines sample, but it didn't worked as well (even with the image in the same folder as the .exe imread() wouldn't find the image). 我也尝试过hough lines示例,但是效果不好(即使与.exe imread()相同的文件夹中的图像也找不到图像)。
Any help would be greatly appreciated. 任何帮助将不胜感激。
If I've not made some of the installation steps clear enough, please post a comment. 如果我没有明确说明某些安装步骤,请发表评论。
I've detailed a full installation procedure (from scratch) for the latest release of OpenCV to be used with Visual Studio 2008. If anyone solves this question we will have a complete, working tutorial for anyone having the same necessity (use latest OpenCV with visual studio 2008), and possibly (because of the depth in the installation procedure) a general guide for installing the latest OpenCV with most Visual Studio versions (not just the 2008, since the tutorial wouldn't change much, and the reader could easily adapt it). 我已经详细介绍了一个完整的安装程序(从头开始),用于与Visual Studio 2008一起使用的OpenCV的最新版本。如果有人解决了这个问题,我们将为具有相同必要性的任何人提供完整的工作教程(使用最新的OpenCV与visual studio 2008),并且可能(由于安装过程的深度)一般指南,用于安装最新的OpenCV与大多数Visual Studio版本(不仅仅是2008年,因为教程不会有太大变化,读者可以很容易适应它)。
I would suggest if you want to test proper installation of opencv. 我建议你是否要测试opencv的正确安装。 Just load a simple.jpg image in opencv and display it.
只需在opencv中加载simple.jpg图像并显示它。 If this works then you can start debugging the program which is crashing.
如果这样可行,那么您可以开始调试崩溃的程序。 You can debug it by successively enabling the cout.
您可以通过连续启用cout来调试它。 May be first just enable the default cout in example cout_mat.cpp and comment rest of it.
可能首先在示例cout_mat.cpp中启用默认cout并对其余部分进行注释。
Here is the simple load program you can try to test your installation. 这是您可以尝试测试安装的简单加载程序。
int main(int argc, char*argv[])
{
cvNamedWindow("My_Win", CV_WINDOW_AUTOSIZE);
IplImage *img = cvLoadImage("C:\\vid_an2\\Desert.jpg", CV_LOAD_IMAGE_UNCHANGED );
std::cout<<"Info About Image"<<std::endl;
std::cout<<"Size of Image "<<img->nSize<<std::endl;
std::cout<<"Image channels "<<img->nChannels<<std::endl;
std::cout<<"Image Width "<<img->width<<std::endl;
std::cout<<"Image Height "<<img->height<<std::endl;
std::cout<<"Image Depth "<<img->depth<<std::endl;
std::cout<<"Image WidhtStep "<<img->widthStep<<std::endl;
std::cout<<"Image Size "<<img->imageSize<<std::endl;
cvShowImage("My_Win", img);
cvWaitKey(0);
// Free the resources.
cvDestroyAllWindows();
cvReleaseImage(&img);
return 0;
}
Since you are using VS2008, change Z:\\Games instalados\\OpenCV\\opencv\\build\\x86\\vc11
to Z:\\Games instalados\\OpenCV\\opencv\\build\\x86\\vc9
. 由于您使用的是VS2008,
Z:\\Games instalados\\OpenCV\\opencv\\build\\x86\\vc11
为Z:\\Games instalados\\OpenCV\\opencv\\build\\x86\\vc9
。 The vc11 folder is for VS2012, vc9 is for VS2008. vc11文件夹用于VS2012,vc9用于VS2008。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.