pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

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

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

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

這樣就完成了 MinGW 的安裝,現在是編寫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

如果編譯成功,它將創建一個名為 loadimg.exe 的可執行文件.

類型:

loadimg

執行程序.結果:

<小時>

4.從這里去哪里?

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

  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模板網!

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

相關文檔推薦

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?(如何計算給定日期的周數?)
OpenCV with Network Cameras(帶有網絡攝像機的 OpenCV)
Export all symbols when creating a DLL(創建 DLL 時導出所有符號)
The program can#39;t start because libgcc_s_dw2-1.dll is missing(程序無法啟動,因為缺少 libgcc_s_dw2-1.dll)
主站蜘蛛池模板: 【北京写字楼出租_写字楼租赁_办公室出租网/出售】-远行地产官网 | 自动化生产线-自动化装配线-直流电机自动化生产线-东莞市慧百自动化有限公司 | 医疗仪器模块 健康一体机 多参数监护仪 智慧医疗仪器方案定制 血氧监护 心电监护 -朗锐慧康 | 临沂招聘网_人才市场_招聘信息_求职招聘找工作请认准【马头商标】 | 大立教育官网-一级建造师培训-二级建造师培训-造价工程师-安全工程师-监理工程师考试培训 | 无线联网门锁|校园联网门锁|学校智能门锁|公租房智能门锁|保障房管理系统-KEENZY中科易安 | 垃圾处理设备_餐厨垃圾处理设备_厨余垃圾处理设备_果蔬垃圾处理设备-深圳市三盛环保科技有限公司 | 能量回馈_制动单元_电梯节能_能耗制动_深圳市合兴加能科技有限公司 | 数字展示在线_数字展示行业门户网站| 翅片管换热器「型号全」_厂家-淄博鑫科环保 | 吉祥新世纪铝塑板_生产铝塑板厂家_铝塑板生产厂家_临沂市兴达铝塑装饰材料有限公司 | 聚氨酯催化剂K15,延迟催化剂SA-1,叔胺延迟催化剂,DBU,二甲基哌嗪,催化剂TMR-2,-聚氨酯催化剂生产厂家 | 济南侦探调查-济南调查取证-山东私家侦探-山东白豹调查咨询公司 密集架|电动密集架|移动密集架|黑龙江档案密集架-大量现货厂家销售 | 沈飞防静电地板__机房地板-深圳市沈飞防静电设备有限公司 | 广东高华家具-公寓床|学生宿舍双层铁床厂家【质保十年】 | 纯化水设备-纯水设备-超纯水设备-[大鹏水处理]纯水设备一站式服务商-东莞市大鹏水处理科技有限公司 | 涂层测厚仪_漆膜仪_光学透过率仪_十大创新厂家-果欧电子科技公司 | 学叉车培训|叉车证报名|叉车查询|叉车证怎么考-工程机械培训网 | 英思科GTD-3000EX(美国英思科气体检测仪MX4MX6)百科-北京嘉华众信科技有限公司 | 洛阳永磁工业大吊扇研发生产-工厂通风降温解决方案提供商-中实洛阳环境科技有限公司 | 衬四氟_衬氟储罐_四氟储罐-无锡市氟瑞特防腐科技有限公司 | 深圳活动策划公司|庆典策划|专业公关活动策划|深圳艺典文化传媒 重庆中专|职高|技校招生-重庆中专招生网 | 船老大板材_浙江船老大全屋定制_船老大官网 | 杭州实验室尾气处理_实验台_实验室家具_杭州秋叶实验设备有限公司 | 聚丙烯酰胺_阴离子_阳离子「用量少」巩义亿腾厂家直销,售后无忧 聚合甘油__盐城市飞龙油脂有限公司 | 破碎机锤头_耐磨锤头_合金锤头-鼎成机械一站式耐磨铸件定制服务 微型驱动系统解决方案-深圳市兆威机电股份有限公司 | 超声波分散机-均质机-萃取仪-超声波涂料分散设备-杭州精浩 | 车牌识别道闸_停车场收费系统_人脸识别考勤机_速通门闸机_充电桩厂家_中全清茂官网 | 镀锌角钢_槽钢_扁钢_圆钢_方矩管厂家_镀锌花纹板-海邦钢铁(天津)有限公司 | 企典软件一站式企业管理平台,可私有、本地化部署!在线CRM客户关系管理系统|移动办公OA管理系统|HR人事管理系统|人力 | 招商帮-一站式网络营销服务|互联网整合营销|网络推广代运营|信息流推广|招商帮企业招商好帮手|搜索营销推广|短视视频营销推广 | X光检测仪_食品金属异物检测机_X射线检测设备_微现检测 | 3dmax渲染-效果图渲染-影视动画渲染-北京快渲科技有限公司 | 游动电流仪-流通式浊度分析仪-杰普仪器(上海)有限公司 | 合肥废气治理设备_安徽除尘设备_工业废气处理设备厂家-盈凯环保 合肥防火门窗/隔断_合肥防火卷帘门厂家_安徽耐火窗_良万消防设备有限公司 | uv固化机-丝印uv机-工业烤箱-五金蚀刻机-分拣输送机 - 保定市丰辉机械设备制造有限公司 | 铸钢件厂家-铸钢齿轮-减速机厂家-淄博凯振机械有限公司 | 云南标线|昆明划线|道路标线|交通标线-就选云南云路施工公司-云南云路科技有限公司 | 法兰连接型电磁流量计-蒸汽孔板节流装置流量计-北京凯安达仪器仪表有限公司 | 成都亚克力制品,PVC板,双色板雕刻加工,亚克力门牌,亚克力标牌,水晶字雕刻制作-零贰捌广告 | 直流电能表-充电桩电能表-导轨式电能表-智能电能表-浙江科为电气有限公司 |