mac安装clion、opencv及简单测试

1. 安装clion

  在clion官网下载的安装包。本来在知乎上有妹子说这个软件学生免费,结果找了半天也没找到那个链接。在网上找了几个注册码也没成功,所以。。我的暴脾气。。就直接上淘宝买了一个,几块钱,剩下了时间成本,挺好的。哈哈哈~吧这个注册码贴出来,大家分享吧。clion的版本是mac版本的2017.2。注册码如下:

BSJK89HP2N-eyJsaWNlbnNlSWQiOiJCU0pLODlIUDJOIiwibGljZW5zZWVOYW1lIjoi5b285bK4IOi9r+S7tjEiLCJhc3NpZ25lZU5hbWUiOiIiLCJhc3NpZ25lZUVtYWlsIjoiIiwibGljZW5zZVJlc3RyaWN0aW9uIjoiRm9yIGVkdWNhdGlvbmFsIHVzZSBvbmx5IiwiY2hlY2tDb25jdXJyZW50VXNlIjpmYWxzZSwicHJvZHVjdHMiOlt7ImNvZGUiOiJBQyIsInBhaWRVcFRvIjoiMjAxOC0wNy0yMCJ9LHsiY29kZSI6IkRNIiwicGFpZFVwVG8iOiIyMDE4LTA3LTIwIn0seyJjb2RlIjoiSUkiLCJwYWlkVXBUbyI6IjIwMTgtMDctMjAifSx7ImNvZGUiOiJSUzAiLCJwYWlkVXBUbyI6IjIwMTgtMDctMjAifSx7ImNvZGUiOiJXUyIsInBhaWRVcFRvIjoiMjAxOC0wNy0yMCJ9LHsiY29kZSI6IkRQTiIsInBhaWRVcFRvIjoiMjAxOC0wNy0yMCJ9LHsiY29kZSI6IlJDIiwicGFpZFVwVG8iOiIyMDE4LTA3LTIwIn0seyJjb2RlIjoiUFMiLCJwYWlkVXBUbyI6IjIwMTgtMDctMjAifSx7ImNvZGUiOiJEQyIsInBhaWRVcFRvIjoiMjAxOC0wNy0yMCJ9LHsiY29kZSI6IkRCIiwicGFpZFVwVG8iOiIyMDE4LTA3LTIwIn0seyJjb2RlIjoiUk0iLCJwYWlkVXBUbyI6IjIwMTgtMDctMjAifSx7ImNvZGUiOiJQQyIsInBhaWRVcFRvIjoiMjAxOC0wNy0yMCJ9LHsiY29kZ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WMAkGA1UdEwQCMAAwHQYDVR0OBBYEFGEpG9oZGcfLMGNBkY7SgHiMGgTcMEgGA1UdIwRBMD+AFKOetkhnQhI2Qb1t4Lm0oFKLl/GzoRykGjAYMRYwFAYDVQQDDA1KZXRQcm9maWxlIENBggkA0myxg7KDeeEwEwYDVR0lBAwwCgYIKwYBBQUHAwEwCwYDVR0PBAQDAgWgMA0GCSqGSIb3DQEBCwUAA4ICAQC9WZuYgQedSuOc5TOUSrRigMw4/+wuC5EtZBfvdl4HT/8vzMW/oUlIP4YCvA0XKyBaCJ2iX+ZCDKoPfiYXiaSiH+HxAPV6J79vvouxKrWg2XV6ShFtPLP+0gPdGq3x9R3+kJbmAm8w+FOdlWqAfJrLvpzMGNeDU14YGXiZ9bVzmIQbwrBA+c/F4tlK/DV07dsNExihqFoibnqDiVNTGombaU2dDup2gwKdL81ua8EIcGNExHe82kjF4zwfadHk3bQVvbfdAwxcDy4xBjs3L4raPLU3yenSzr/OEur1+jfOxnQSmEcMXKXgrAQ9U55gwjcOFKrgOxEdek/Sk1VfOjvS+nuM4eyEruFMfaZHzoQiuw4IqgGc45ohFH0UUyjYcuFxxDSU9lMCv8qdHKm+wnPRb0l9l5vXsCBDuhAGYD6ss+Ga+aDY6f/qXZuUCEUOH3QUNbbCUlviSz6+GiRnt1kA9N2Qachl+2yBfaqUqr8h7Z2gsx5LcIf5kYNsqJ0GavXTVyWh7PYiKX4bs354ZQLUwwa/cG++2+wNWP+HtBhVxMRNTdVhSm38AknZlD+PTAsWGu9GyLmhti2EnVwGybSD2Dxmhxk3IPCkhKAK+pl0eWYGZWG3tJ9mZ7SowcXLWDFAk0lRJnKGFMTggrWjV8GYpw5bq23VmIqqDLgkNzuoog==

好长好长啊~哈哈哈~希望能够帮助到广大网友。

2. 安装opencv

  在bash中使用如下命令安装opencv。

brew install homebrew/science/opencv

同时,opencv和opencv2是可以同时存在的,可以使用如下命令安装opencv3。

brew install homebrew/science/opencv3

  在使用brew命令安装时,遇到了“-bash: brew: command not found“。原因是没有安装Homebrew。使用如下命令进行解决:

 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3. clion+opencv简单测试

  修改clion项目中的CMakeLists.txt,添加三行信息,修改后的样子如下所示:

cmake_minimum_required(VERSION 3.7)
project(untitled) #将untitled改为自己的工程名
find_package(OpenCV)
#或者find_package(OpenCV3)
include_directories( ${OpenCV_INCLUDE_DIRS} )
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(untitled ${SOURCE_FILES})
target_link_libraries( untitled ${OpenCV_LIBS} )

运行测试用例:

#include 
#include 

using namespace std;
using namespace cv;
int main() {
    Mat srcImage = imread("show.png");
    imshow("[img]", srcImage);
    waitKey(0);
    return 0;
}

你可能感兴趣的:(mac安装clion、opencv及简单测试)