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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

VS2010下编译OpenCV2.4.6静态库

發布時間:2023/11/27 生活经验 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 VS2010下编译OpenCV2.4.6静态库 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、???從?http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.3/?下載最新的OpenCV2.4.6;

2、???將OpenCV-2.4.6.0.exe存放到D:\Soft\OpenCV2.4.6文件夾下,解壓到當前文件夾下,生成一個opencv文件夾;

3、???下載安裝CMake:http://www.cmake.org/cmake/resources/software.html;

4、???運行CMake(cmake-gui),在Where is the source code中填入剛才步驟(2)解壓縮后的文檔路徑D:/Soft/OpenCV2.4.6/opencv,在Where tobuild the binaries中填入編譯時需要存放的路徑如D:/Soft/OpenCV2.4.6/vs2010,此vs2010文件夾需自己創建;

5、???點擊Configure,在彈出的對話框中選擇Visual Studio 10,其它默認,點擊Finish;

6、???找到BUILD_SHARED_LIBS選項,去掉勾選,為了減少編譯時間,也可去掉一些其它不必要的勾選,點擊Generate;

7、???上述步驟完成后,在vs2010文件夾中,就會看到有OpenCV.sln文件;

8、???使用vs2010打開OpenCV.sln文件,分別在Debug和Release下,選擇Solution Explorer里的Solution OpenCV,點擊右鍵,運行”Rebuild Solution”,點擊CMake Targets下的INSTALL,運行”build”;會在D:/Soft/OpenCV2.4.6/vs2010/install文件夾下的lib文件夾中生成相應的靜態庫;

9、???打開vs2010,新建一個控制臺應用程序TestOpenCV,選中工程-->Properties:(1)、VC++ Directories-->Include Directories:分別在Debug和Release模式下加入, D:/Soft/OpenCV2.4.6/vs2010/install/includeD:/Soft/OpenCV2.4.6/vs2010/install/include/opencv D:/Soft/OpenCV2.4.6/vs2010/install/include/opencv2 ?(2)、C/C++-->CodeGeneration-->Runtime Library:在Debug下,將其改為Multi-threaded Debug(/MTD),在Release下,將其改為Multi-threaded(/MT)。

stdafx.h文件代碼為:

#pragma once#include "targetver.h"#include <stdio.h>
#include <tchar.h>#include "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\include\\opencv2\\core\\core.hpp"
#include "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\include\\opencv2\\highgui\\highgui.hpp"
#include "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\include\\opencv2\\imgproc\\imgproc.hpp"using namespace cv;

stdafx.cpp文件代碼為:

#include "stdafx.h"#ifdef _DEBUG
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\share\\OpenCV\\3rdparty\\lib\\zlibd.lib")
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\share\\OpenCV\\3rdparty\\lib\\libtiffd.lib")
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\share\\OpenCV\\3rdparty\\lib\\libpngd.lib")
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\share\\OpenCV\\3rdparty\\lib\\libjpegd.lib")
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\share\\OpenCV\\3rdparty\\lib\\libjasperd.lib")
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\share\\OpenCV\\3rdparty\\lib\\IlmImfd.lib")#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\lib\\opencv_core246d.lib")
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\lib\\opencv_highgui246d.lib")
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\lib\\opencv_imgproc246d.lib")#pragma comment(lib, "comctl32.lib")
#else
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\share\\OpenCV\\3rdparty\\lib\\zlib.lib")
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\share\\OpenCV\\3rdparty\\lib\\libtiff.lib")
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\share\\OpenCV\\3rdparty\\lib\\libpng.lib")
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\share\\OpenCV\\3rdparty\\lib\\libjpeg.lib")
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\share\\OpenCV\\3rdparty\\lib\\libjasper.lib")
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\share\\OpenCV\\3rdparty\\lib\\IlmImf.lib")#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\lib\\opencv_core246.lib")
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\lib\\opencv_highgui246.lib")
#pragma comment(lib, "D:\\Soft\\OpenCV2.4.6\\vs2010\\install\\lib\\opencv_imgproc246.lib")#pragma comment(lib, "comctl32.lib")
#endif

TestOpenCV.cpp文件代碼為:

#include "stdafx.h"int _tmain(int argc, _TCHAR* argv[])
{Mat image1, image2, imageResult;image1 = cv::imread("1.jpg", 2 | 4);image2 = cv::imread("2.jpg", 2 | 4);cv::subtract(image1, image2, imageResult);cv::namedWindow("show image");cv::imshow("show image", imageResult);cv::waitKey(0);cv::destroyWindow("show image");return 0;
}


總結

以上是生活随笔為你收集整理的VS2010下编译OpenCV2.4.6静态库的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

歡迎分享!

轉載請說明來源于"生活随笔",并保留原作者的名字。

本文地址:VS2010下编译OpenCV2.4.6静态库