设为首页 收藏本站
查看: 742|回复: 0

[经验分享] Mac os, eclipse, open cv

[复制链接]

尚未签到

发表于 2015-12-31 11:37:47 | 显示全部楼层 |阅读模式
  1. install jdk-8u60-macosx-x64
  2. install eclipse. download
  3. install cmake.  [reference from http://www.cmake.org/install/]
    3.1 download.  (what is cmake? defenition in  English or Chinese)

  3.2 open Terminal, use "/../../Desktop/cmake/bootstrap" , "make" and "make install"
  problem: "file cannot create directory: /usr/local/doc/cmake-3.3.  Maybe need administrative privileges."
  solution: "sudo make install Instead of make install" ,and require password [Reference]
  4.install opencv [Reference]
    4.1 download
    4.2 use command :(here we use commond to build a temporary folder, "build" )



# make a separate directory for building
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
  4.3 enter the temporary folder (here is "build"), and type commond:



make
sudo make install
  
  5. test on eclipse (step 1)
  5.1 Start Eclipse. Just run the executable that comes in the folder.
  5.2 Go to File -> New -> C/C++ Project
  5.3 Choose a name for your project (i.e. DisplayImage). An Empty Project should be okay for this example.  5.4 Leave everything else by default. Press Finish.
  6. test on eclipse (step 2)
  6.1 Your project (in this case DisplayImage) should appear in the Project Navigator (usually at the left side of your window).
  6.2 Now, let’s add a source file using OpenCV:
  





    • Right click on DisplayImage (in the Navigator). New -> Folder




Name your folder src and then hit Finish
Right click on your newly created src folder. Choose New source file:
Call it DisplayImage.cpp. Hit Finish
So, now you have a project with a empty .cpp file. Let’s fill it with some sample code (in other words, copy and paste the snippet below):



#include <cv.h>
#include <highgui.h>
using namespace cv;
int main( int argc, char** argv )
{
Mat image;
image = imread( argv[1], 1 );
if( argc != 2 || !image.data )
{
printf( "No image data \n" );
return -1;
}
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
imshow( "Display Image", image );
waitKey(0);
return 0;
}
  7.
We are only missing one final step: To tell OpenCV where the OpenCV headers and libraries are. For this, do the following:




  • Go to Project–>Properties


  • In C/C++ Build, click on Settings. At the right, choose the Tool Settings Tab. Here we will enter the headers and libraries info:


    • In GCC C++ Compiler, go to Includes. In Include paths(-l) you should include the path of the folder where opencv was installed. In our example, this is/usr/local/include/opencv.




      Note
        If you do not know where your opencv files are, open the Terminal and type:





      pkg-config --cflags opencv

        For instance, that command gave me this output:





      -I/usr/local/include/opencv -I/usr/local/include

    • Now go to GCC C++ Linker,there you have to fill two spaces:
        First in Library search path (-L) you have to write the path to where the opencv libraries reside, in my case the path is:





      /usr/local/lib

        Then in Libraries(-l) add the OpenCV libraries that you may need. Usually just the 3 first on the list below are enough (for simple applications) . In my case, I am putting all of them since I plan to use the whole bunch:
        opencv_core opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_features2d opencv_calib3d opencv_objdetect opencv_contrib opencv_legacy opencv_flann

        If you don’t know where your libraries are (or you are just psychotic and want to make sure the path is fine), type in Terminal:( download pkg-config)





      pkg-config --libs opencv

        My output (in case you want to check) was: .. code-block:: bash

        -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann

        Now you are done. Click OK



  • Your project should be ready to be built. For this, go to Project->Build all
      In the Console you should get something like

      If you check in your folder, there should be an executable there.


  
  http://docs.opencv.org/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-158782-1-1.html 上篇帖子: Web Service(Chapter 28 of Cocoa Programming for Mac OS X) 下篇帖子: Mac os x 10.7以后的版本,使用ftp
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表