一、首先
安装完成Opencv2017链接为:https://opencv.org/releases/,选择版本3.4.11的windows。在安装Opencv2017之前,需要安装Visual Studio 2017,软件及安装步骤链接为:https://mp.weixin.qq.com/s/MHbkGslWpX80xe6VoIDs8w 。
二、其次
掌握C++语言,从网上可以系统的学习。C++是在C基础上发展过来的,基本的语句跟C的差别不大,比如说if语句、for语句、while语句等;但是,C++又和C有所不同,C++是面向对象的程序语言。
以下是用Opencv运行的C++程序:
#include <iostream> using namespace std; int a = 5,b=8,i=1,d; const float PI = 3.1415926;//符号常量在声明时一定要赋值 long double c = a + PI; #define N = 8 int main() { std:cout << "Hello everyone,welcome to C++!\n"; int year; bool isLeapyear;//取值范围只有true和false,字节长度为1.(布尔或逻辑型) cout << "Enter the year:";//输出字符串 cin >> year;//输入多少年 isLeapyear=((year % 4 == 0 && year % 100 == 0) || (year % 400 == 0)); if (isLeapyear) cout << year << " is a leap year." << endl; else cout << year << "isn't a leap year." << endl; cout << ++i << endl;//把i自加之后输出 cout << "a+b=" << a+b <<endl; cout << "请输入d="; cin >> d;//键入d是多少 cout << "a+d=" << a + d << endl; return 0; }
输出的结果首先要从键盘上输入有多少年,其次要输入一个数字;用这个数字与5相加,运行结果如下: