Using C + + OpenCV library under Mac OS x

Source: Internet
Author: User

1. If CMake is not installed, install using the command Brew install CMake.

If Pkg-config is not installed, use the command brew install Pkg-config installation. If the Pkg-config program cannot be found after installation, copy it to the/usr/local/bin directory.

2. Installing OPENCV

Brew Install OpenCV

3. Test procedures

#include <iostream>#include<opencv2/opencv.hpp>#include<vector>#include<string>using namespacestd;using namespaceCV;intMain () {Cv::mat img_encode; Img_encode= Imread ("./obito.jpeg", Cv_load_image_color); Vector<uchar>Data_encode; Imencode (". JPEG", Img_encode, Data_encode); stringStr_encode (Data_encode.begin (), Data_encode.end ()); //cout << str_encode << Endl;Cv::mat Img_decode; Vector<uchar>data (Str_encode.begin (), Str_encode.end ()); Img_decode=imdecode (data, cv_load_image_color); Imshow ("pic", Img_decode); Cvwaitkey (10000); //cout << "Hello" << Endl;}

The compile command is: g++ cpp_opencv.cpp-o cpp_opencv ' pkg-config--cflags--libs Opencv '

Or simply list the link library: g++ cpp_opencv.cpp -l/usr/local/lib/-lopencv_highgui.3.4.2-lopencv_core.3.4.2-lopencv_imgcodecs

Using C + + OpenCV library under Mac OS x

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.