How to install and create OpenCV project on Mac OSX with XCode

Installing OpenCV on Mac OSX has always been a tough issue for me and for this reason that I start to write this post based on my experience.

In this post, I will guide you through installing from package. To start with you may download latest or stable version of opencv from here and choose OpenCV for Linux/Mac. Besides, you also need to install CMake prior to installing OpenCV package. For instruction on how to install CMake on Mac OSX, you may find here.

You can then follow these steps:

1. Extract downloaded OpenCV package

2. Start terminal, navigate to the extracted package, then use the following commands:

mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

    If you are on Mavericks, you may need to disable QUICK TIME by adding “-D WITH_QUICKTIME=OFF” as below:

mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_QUICKTIME=OFF ..

   Then, you can continue with the following commands (Still in Terminal):

make
sudo make install

When you are done with these, you can now start testing by creating a command line tool project in xcode using C++ as below:   

1) Create a new project

File> New..> Project> Command Line Tools > add in a product name and choose Type as “C++”

2) Click on the Project Name on the panel on the left. Project settings will show up on the right hand side. Choose the “Build Settings” tab. Between “BASIC” and “ALL”, choose “ALL”. Search for “HEADER_SEARCH_PATHS” then add “/usr/local/include”.

3) Now, search for “LIBRARY_SEARCH_PATHS” and as shown below, add “/usr/local/lib” to it.

4) Next, right click on the project and choose “Add Files To ProjectName”. On a new pop up dialog go to your installed OpenCV folder (i.e. release folder in the extracted opencv directory) by typing “/” followed by directory, then go to lib folder, select “libopencv_core.dylib” and “libopencv_highgui.dylib” to add (You may add other libraries as needed by your code). You are now ready to test by including header files (#include <opencv2/opencv.hpp>), write some code, and run.

 

DONE! Hope you enjoy and find this post useful!

 

 

 

 

Posted in Uncategorized | Leave a comment

How to set PATH in Mac OS

In order to set PATH in Mac OS, we can just enter command promt in the Terminal as follow:

export PATH=/usr/local/git/bin:$PATH 

Where /usr/local/git/bin is the path that we want to set.
Posted in Uncategorized | Leave a comment

How to install or upgrade setuptool on Mac OS

pip requires setuptools and it has to be installed first, before pip can run.

To install setuptools from scratch:

  1. Securely download ez_setup.py.

  2. Then run the following (which may require administrator access):

 

To upgrade a previous install of setuptools or distribute, there are two scenarios.

  1. You currently have setuptools or distribute and some version of pip:

    $ pip install --upgrade setuptools

    If you have distribute, this will upgrade to you distribute-0.7.X, which is just a wrapper, that depends on setuptools. The end result will be that you have distribute-0.7.X (which does nothing) and the latest setuptools installed.

  2. You currently have setuptools or distribute, but not pip:

    Follow the pip install procedure below, then come back and run:

    $ pip install --upgrade setuptools
Posted in Uncategorized | Leave a comment

How to install pip on Mac OS

Securely download get-pip.py

Then run the following (which may require administrator access), to install (or upgrade to) the latest version of pip:

$ python get-pip.py

Posted in Uncategorized | Leave a comment

How to install CMake on Mac OS & Linux

There are pre-compiled binaries available on the Download page for many UNIX platforms.

      There are several possible approaches for building CMake from a source tree:
    • If there is no existing CMake installation, a bootstrap script is provided: 
         ./bootstrap
          make 
          make install

      (Note: the make install step is optional, cmake will run from the build directory.) 

    • An existing CMake installation can be used to build a new version: 
         cmake . 
          make 
          make install

      (Note: the make install step is optional, cmake will run from the build directory.) 

    • On UNIX, if you are not using the GNU C++ compiler, you need to tell the bootstrap which compiler you want to use. This is done by setting the environment variables CC and CXX before running configure. For example on the SGI with the 7.3X compiler, you build like this: 
          (setenv CXX CC; setenv CC cc; ./bootstrap) 
         make 
         make install 

 

  • For more options with bootstrap, run ./bootstrap –help

Source: http://www.cmake.org/cmake/help/install.html

Posted in Uncategorized | 1 Comment

Augmented Reality in brief

Augmented Reality is a technology that view live real-world environment/objects overlaid by computer generated sensory (such as sound, text, graphics, video ..). As a result, the technology functions by enhancing one’s current perception of reality so as to give more comprehensive output to the user. Augmented Reality has been out for decades ago but it has been so popular in the last few years in many fields such as education, health, art, construction, game, military, navigation, etc.

Posted in Uncategorized | Leave a comment

FINK Installation (Mac OSX)

http://fink.thetis.ig42.org/download/srcdist.php

Posted in Uncategorized | Leave a comment

Cocos2D Installation (On MAC OSX)

Installing library is always a challenge job for me so I post here to help other as well as I myself when I need to redo it.

To install Cocos2D, you first need to download file from its official site. There are different versions available, stable and unstable, and Cocos2D 1.X is made for OpenGL ES 1.x while Cocos2D 2.X is made for OpenGL ES 2.x.

After finish downloading, extract the zip file then open terminal and go to the folder of the downloaded file and enter the following command: ./install-templates.sh -f -u

Posted in Uncategorized | Leave a comment

Is machine (computer and any electrical devices that assist human works) smarter than human?

Can you compare between machine and human being for strength and weakness of each one? 

Posted in Uncategorized | Leave a comment

Is COPY culture bad?

Should we debate on the idea of copying someone source/knowledge for using in our works?

Today while I was doing with my code, there was a guy approached me and see my code with several different colours, for variables, comment and different kind of procedures; he then asked me “Why there are many colours?”. I then explained him. He suddenly said “Oh, you are copying… You should create your own works. Don’t be like those Chinese who always copy (he may refers to all those fake products).” He was probably just kidding to me since we mock each others sometimes. And from this short conversation, I am just curious to share my ideas toward COPY culture and raise awareness to those who do not understand it clearly.

Before I start I would like to raise some questions:

– “Is copying illegal?”

– “Is it bad to copy the ideas from someone?”

Well I would say there is no exact answer to these questions. Copying is different from stealing and I would say it is not illegal to copy someone idea/knowledge once it is distributed by the owners and we follow their distribution policy and that’s why we have to study how to cite or give reference to the sources when we use them; however, we should not do if it is prohibited. In this current world, should we always keep creating something new when we already have ones that are available and enough for our requirements? I would say that is stupid to do so. But if we want to make it our own, we should not copy the whole work from others; we should find our own way to use and make it our own with proper citation or usage right. For instance, should Toyota personalise its own screw to use identically with all their cars? If so, everyone may need to create everything new from numbers, characters and so on. Now, people often create new stuff by inherited over the existing ones.

From what I said, I do not mean invention should be ignored; it is highly encouraged for something new or something which is more useful than the existing ones. This world need people to create newly not something that already exist. Many people and organisations are working very hard to discover new knowledge and we should obey their distribution policy when we use.

(This is just from my ideas; not everything is correct including my writing. Any comment, please!)

Posted in Uncategorized | Leave a comment