久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Windows 7 上的 OpenCV 2.4 和 MinGW 入門

Getting started with OpenCV 2.4 and MinGW on Windows 7(Windows 7 上的 OpenCV 2.4 和 MinGW 入門)
本文介紹了Windows 7 上的 OpenCV 2.4 和 MinGW 入門的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如何安裝 OpenCV 2.4 并使用 MinGW 編譯我的代碼?

解決方案

1.安裝 OpenCV 2.4.3

首先,從 sourceforge.net 獲取 并雙擊開始安裝.只需按照向導并選擇要安裝的目錄,例如C:MinGW.

選擇要安裝的C Compiler"和C++ Compiler".

安裝程序會從網(wǎng)上下載一些包,所以你需要等待一段時間.安裝完成后,使用前面描述的步驟將 C:MinGWin 添加到您的系統(tǒng)路徑.

要測試您的 MinGW 安裝是否成功,請打開命令行框并鍵入:gcc.如果一切正常,它將顯示此消息:

gcc:致命錯誤:沒有輸入文件編譯終止

這樣就完成了 MinGW 的安裝,現(xiàn)在是編寫Hello, World!"的時候了.程序.

<小時>

3.編寫示例代碼

打開您的文本編輯器并輸入以下代碼并將文件保存到 loadimg.cpp.

#include "opencv2/highgui/highgui.hpp"#include 使用命名空間 cv;使用命名空間標準;int main(int argc, char** argv){Mat im = imread(argc == 2 ? argv[1] : "lena.jpg", 1);如果 (im.empty()){cout<<無法打開圖像!"<<結束;返回-1;}imshow("圖像", im);等待鍵(0);返回0;}

lena.jpg 或任何您喜歡的圖像與上述文件放在同一目錄中.打開命令行框并通過鍵入以下內容編譯上面的代碼:

g++ -I"C:opencvuildinclude" -L"C:opencvuildx86mingwlib" loadimg.cpp -lopencv_core243 -lopencv_highgui243 -o loadimg

如果編譯成功,它將創(chuàng)建一個名為 loadimg.exe 的可執(zhí)行文件.

類型:

loadimg

執(zhí)行程序.結果:

<小時>

4.從這里去哪里?

既然您的 OpenCV 環(huán)境已準備就緒,接下來要做什么?

  1. 轉到示例目錄 →C:opencvsamplescpp.
  2. 閱讀并編譯一些代碼.
  3. 編寫您自己的代碼.

How do I install OpenCV 2.4 and compile my code with MinGW?

解決方案

1. Installing OpenCV 2.4.3

First, get OpenCV 2.4.3 from sourceforge.net. Its a self-file-extracting so just double click the file to start installation. Install it in a directory, say C:.

Wait until all files get extracted. It will create a new directory C:opencv which contains OpenCV header files, libraries, code samples, etc.

Now you need to add C:opencvuildx86mingwin directory to your system PATH. This directory contains OpenCV DLLs which is required for running your code.

Open Control PanelSystemAdvanced system settingsAdvanced TabEnvironment variables...

You will see a window like shown below:

On the System Variables section,
select Path (1), click Edit... (2), add C:opencvuildx86mingwin (3) then click Ok.

This will completes the OpenCV 2.4.3 installation on your computer.


2. Installing MinGW compiler suite

I highly recommend you to use gcc (GNU Compiler Collection) for compiling your code. gcc is the compiler suite widely available in Linux systems and MinGW is the native port for Windows.

Download the MinGW installer from Sourceforge.net and double click to start installation. Just follow the wizard and select the directory to be installed, say C:MinGW.

Select "C Compiler" and "C++ Compiler" to be installed.

The installer will download some packages from the internet so you have to wait for a while. After the installation finished, add C:MinGWin to your system path using the steps described before.

To test if your MinGW installation is success, open a command-line box and type: gcc. If everything is ok, it will display this message:

gcc: fatal error: no input files
compilation terminated

This completes the MinGW installation, now is the time to write your "Hello, World!" program.


3. Write a sample code

Open your text editor and type the code below and save the file to loadimg.cpp.

#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] : "lena.jpg", 1);
  if (im.empty())
  {
    cout << "Cannot open image!" << endl;
    return -1;
  }

  imshow("image", im);
  waitKey(0);

  return 0;
}

Put lena.jpg or any image you like in the same directory with the file above. Open a command-line box and compile the code above by typing:

g++ -I"C:opencvuildinclude" -L"C:opencvuildx86mingwlib" loadimg.cpp -lopencv_core243 -lopencv_highgui243 -o loadimg

If it compiles successfully, it will create an executable named loadimg.exe.

Type:

loadimg

To execute the program. Result:


4. Where to go from here?

Now that your OpenCV environment is ready, what's next?

  1. Go to the samples dir → C:opencvsamplescpp.
  2. Read and compile some code.
  3. Write your own code.

這篇關于Windows 7 上的 OpenCV 2.4 和 MinGW 入門的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

boost_1_60_0 .zip installation in windows(Windows 中的 boost_1_60_0 .zip 安裝)
How do I get console output in C++ with a Windows program?(如何使用 Windows 程序在 C++ 中獲得控制臺輸出?)
How do I calculate the week number given a date?(如何計算給定日期的周數(shù)?)
OpenCV with Network Cameras(帶有網(wǎng)絡攝像機的 OpenCV)
Export all symbols when creating a DLL(創(chuàng)建 DLL 時導出所有符號)
The program can#39;t start because libgcc_s_dw2-1.dll is missing(程序無法啟動,因為缺少 libgcc_s_dw2-1.dll)
主站蜘蛛池模板: 特级丰满少妇一级aaaa爱毛片 | 午夜视频免费看 | 伊人精品在线 | 综合色婷婷一区二区亚洲欧美国产 | 午夜你懂的 | 欧美色图一区二区 | 天美传媒在线观看 | 亚洲欧美视频在线 | 中文字幕在线免费看 | 亚洲精品欧美 | 男人添女人囗交图 | 亚洲高清视频在线观看 | 日韩亚洲在线 | 精品久久久久久久久久久 | 日韩欧美视频在线 | 91成人精品一区在线播放 | 中文字幕久久久 | 欧美xx孕妇 | 国产成人精品视频 | 深夜免费福利 | 久久国产热 | 日韩中文字幕在线观看 | 黄色三级视频网站 | 日本不卡视频 | 一区二区黄色 | 欧美日韩久久久 | 窝窝午夜精品一区二区 | 黄色小视频免费观看 | 18精品爽国产白嫩精品 | 欧美 日韩 国产 成人 在线 | 久久爱综合 | 国产精品高潮呻吟av | 亚洲自拍网站 | 成人羞羞国产免费游戏 | 在线观看的av网站 | 午夜在线影院 | 大尺度性做爰的小说金陵春 | 国产91免费 | 天天操天天操 | 国产精品一区久久 | 波多野结衣乳巨码无在线观看 |