本文介绍了在Visual Studio 2008上安装OpenCV 2.4.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在Visual Studio 2008(专业版)中使用OpenCV时遇到一些困难.我相信我已经完成了运行OpenCV示例的所有必要操作,但是由于运行时错误而导致崩溃.这让我发疯,希望有人能帮忙.

I'm having some difficulties trying to use OpenCV with visual studio 2008 (Professional Edition). I believe I've done everything necessary to run a OpenCV sample, but it crashes due to a run-time error. This is driving me insane, I hope someone can help.

但首先要做的事情.

  1. 已下载来自sourcefourge.net的> OpenCV 2.4.5 .

在出现提示时,我从上面的链接下载的.exe中选择了"Z:\ Games instalados \ OpenCV"作为提取到"选项.

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 \ opencv \ build \ x86 \ vc11 \ bin"(不带双引号).这是屏幕截图:.

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). Here's a screenshot: .

  • Z:\ Games instalados \ OpenCV \ opencv \ build \ include
  • Z:\ Games instalados \ OpenCV \ opencv \ build \ include \ opencv
  • Z:\ Games instalados \ OpenCV \ opencv \ build \ include \ opencv2"
  • Z:\Games instalados\OpenCV\opencv\build\include
  • Z:\Games instalados\OpenCV\opencv\build\include\opencv
  • Z:\Games instalados\OpenCV\opencv\build\include\opencv2"
  • opencv_calib3d245.lib
  • opencv_contrib245.lib
  • opencv_core245.lib
  • opencv_features2d245.lib
  • opencv_flann245.lib
  • opencv_gpu245.lib
  • opencv_highgui245.lib
  • opencv_imgproc245.lib
  • opencv_legacy245.lib
  • opencv_ml245.lib
  • opencv_nonfree245.lib
  • opencv_objdetect245.lib
  • opencv_photo245.lib
  • opencv_stitching245.lib
  • opencv_superres245.lib
  • opencv_ts245.lib
  • opencv_video245.lib
  • opencv_videostab245.lib
  • opencv_calib3d245d.lib
  • opencv_contrib245d.lib
  • opencv_core245d.lib
  • opencv_features2d245d.lib
  • opencv_flann245d.lib
  • opencv_gpu245d.lib
  • opencv_highgui245d.lib
  • opencv_imgproc245d.lib
  • opencv_legacy245d.lib
  • opencv_ml245d.lib
  • opencv_nonfree245d.lib
  • opencv_objdetect245d.lib
  • opencv_photo245d.lib
  • opencv_stitching245d.lib
  • opencv_superres245d.lib
  • opencv_ts245d.lib
  • opencv_video245d.lib
  • opencv_videostab245d.lib(请注意,尽管屏幕截图显示,我没有添加"opencv_ffmpeg245.lib").
  • opencv_calib3d245.lib
  • opencv_contrib245.lib
  • opencv_core245.lib
  • opencv_features2d245.lib
  • opencv_flann245.lib
  • opencv_gpu245.lib
  • opencv_highgui245.lib
  • opencv_imgproc245.lib
  • opencv_legacy245.lib
  • opencv_ml245.lib
  • opencv_nonfree245.lib
  • opencv_objdetect245.lib
  • opencv_photo245.lib
  • opencv_stitching245.lib
  • opencv_superres245.lib
  • opencv_ts245.lib
  • opencv_video245.lib
  • opencv_videostab245.lib
  • opencv_calib3d245d.lib
  • opencv_contrib245d.lib
  • opencv_core245d.lib
  • opencv_features2d245d.lib
  • opencv_flann245d.lib
  • opencv_gpu245d.lib
  • opencv_highgui245d.lib
  • opencv_imgproc245d.lib
  • opencv_legacy245d.lib
  • opencv_ml245d.lib
  • opencv_nonfree245d.lib
  • opencv_objdetect245d.lib
  • opencv_photo245d.lib
  • opencv_stitching245d.lib
  • opencv_superres245d.lib
  • opencv_ts245d.lib
  • opencv_video245d.lib
  • opencv_videostab245d.lib(Please note that I didn't added "opencv_ffmpeg245.lib", despite what the screenshot shows).

问题

  1. 构建项目,这里没有问题,构建成功".
  2. 调试"->开始调试".出现以下内容:错误http://s8.postimg.org/wdkubk5o3/the_error.jpg 错误的完整图片: http://s8.postimg.org/wdkubk5o3/the_error.jpg
  1. Built the project, no problems here, "Build succeeded".
  2. "Debug" -> "Start Debugging". The following appears:The error http://s8.postimg.org/wdkubk5o3/the_error.jpgFull size image for the error: http://s8.postimg.org/wdkubk5o3/the_error.jpg

我也尝试过使用hough lines示例,但是效果不佳(即使将图像与.exe imread()放在同一文件夹中也找不到图像).

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).

任何帮助将不胜感激.

如果我对某些安装步骤的理解不够清楚,请发表评论.

If I've not made some of the installation steps clear enough, please post a comment.

我已经详细介绍了要与Visual Studio 2008一起使用的最新版本的OpenCV的完整安装过程(从头开始).如果有人解决了这个问题,我们将为有相同需求(使用Visual Studio 2008的最新版OpenCV),以及可能(由于安装过程的深度)提供了一个用于安装大多数Visual Studio版本(而不是2008)的最新OpenCV的通用指南,因为该教程不会有太大变化,并且读者可以轻松地对其进行调整).

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).

推荐答案

我建议您是否要测试opencv的正确安装.只需在opencv中加载simple.jpg图像并显示它.如果这行得通,那么您可以开始调试正在崩溃的程序.您可以通过依次启用cout来对其进行调试.可能首先是在示例cout_mat.cpp中启用默认cout并注释其余部分.
这是您可以尝试测试安装的简单加载程序.

I would suggest if you want to test proper installation of opencv. Just load a simple.jpg image in opencv and display it. If this works then you can start debugging the program which is crashing. You can debug it by successively enabling the cout. May be first just enable the default cout in example cout_mat.cpp and comment rest of it.
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;
}

这篇关于在Visual Studio 2008上安装OpenCV 2.4.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 01:15