Ask Your Question
1

Does Linux tutorial method work on Mac OSX?

asked 2013-04-08 06:51:12 -0600

johnsankey gravatar image

updated 2013-04-08 08:23:24 -0600

There's no tutorial for a Mac OSX install. I have Python27+numpy+scipy installed in /Library/Frameworks/...

Will the method described at http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation work on OSX to install opencv for me?

In particular, will sudo make install put opencv in /Library with the Python27... that Apple links to?

edit retag flag offensive close merge delete

Comments

Trial and error I would say :D

StevenPuttemans ( 2013-04-08 07:55:10 -0600 )edit

Steven, I've been trialing and erroring non-stop for over 2 weeks, and failing every step of the way. MacPorts has given up on me (the problem seems to be a QGIS+GRASS+python native install that makes it impossible for Apple to recognize anything in /opt/local/..., and I need it). I'm going to have to drop out of a course I really need if I can't get opencv to work with the /Library python. I'm a photographer, not a Unix guy, and I obviously don't know enough to poke around blindly in Unix.

If I can manage to get this to work, I'll write it up as carefully as I can and submit it as a tutorial - from the list of posts at the right of this screen, it's obviously needed, and I'm happy to help. But, I need some help ...(more)

johnsankey ( 2013-04-08 08:36:26 -0600 )edit

Okay, looking at the download page, it states that linux/mac osx use the same download link. I guess this indicates you need to follow the installation steps that are done on linux to get OpenCV and python to work.

StevenPuttemans ( 2013-04-08 08:52:42 -0600 )edit

I've installed cmake with cmake-2.8.10.2-Darwin64-universal.dmg

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=~/Applications/opencv-2.4.4

CMake Error: The source directory "/Users/john/Applications/opencv-2.4.4/CMAKE_INSTALL_PREFIX=/Users/john/Applications/opencv-2.4.4" does not exist.

It does exist - I was in it.

FaceTracker/REAME.txt Building the OpenCV.framework: In the main directory of the opencv distribution, you will find a shell script called 'make_frameworks.sh' that does all of the typical unixy './configure && make' stuff required to build a universal binary framework. Invoke this script from Terminal.app, wait some minutes and you are done.

There is no such script in the package OpenCV-2.4.4a.tar.bz2

...?

johnsankey ( 2013-04-08 10:17:25 -0600 )edit

I have no experience in Python and building OpenCV myself, so guess my help stops here. Go through guides online, there are tons of guides explaining the installation of openCV in mac OSX.

StevenPuttemans ( 2013-04-08 12:16:47 -0600 )edit

I found heaps of guides that were for old versions, but one mentioned a cmake -G "Unix Makefiles" command that uses a CMakeLists.txt that is in the tarball. Tried it:

cmake -G "Unix Makefiles"

make

sudo make install

all kinds of directories and stuff were put in the opencv-2.4.4 directory but nothing put into Library/Frameworks/Python.framework/Versions/2.7/lib/Python2.7/site-packages where numpy & scipy are, so python can't find it.

So, what has to be moved to the python site-packages directory from the build directory so python can find it?

johnsankey ( 2013-04-08 15:35:04 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-04-08 16:02:58 -0600

Guanta gravatar image

First of all: I don't use Mac but Linux (and partially Windows), so maybe it is different. But here is how it works under Linux and since MacOs and Linux are similar in many points (since MacOs is an early FreeBSD clone) it may also work for you (no guarantee here!). Ah and before you start now following my points: Have you checked if python is properly installed at all? Try to run ipython (the interactive python shall). If that is not the case install python first properly! Okay now my linux-opencv-install-howto ;) :

  1. Extract opencv-package in a folder - lets call it 'opencv'
  2. make a build folder in the extracted folder, let's call it 'build'
  3. go into that folder ( cd build)
  4. start ccmake by ccmake ../ , now you get a curse-interface, select the option to build Python (I think it's called build_opencv_python - or similar - I am currently not under linix...). If you have set your options (you can also select several others like optimization stuff and so on): hit c for configure, hit c probably again, until it disappears (if you get any errors you have to resolve them now), hit g for generate and quit.
  5. run make -j3 (that calls the make-files with 3 threads to build opencv a little bit faster ;)
  6. run sudo make install (this installs opencv to the cmake-install-prefix-path, typically /usr/local (maybe this is different under MacOS)

If you have installed Python properly beforehand everything should work fine now. If it doesn't work then try to set your PYTHONPATH (this is an environment variable) to the location where cv2.so is located. Look it up online how to set environment variables under MacOS (under linux it works by putting it in the .bashrc file like this: export PYTHONPATH=$PYTHONPATH:/your/path/to/python/stuff). Good luck!

edit flag offensive delete link more

Comments

Thanks for the try, Guanta. Yes, my /Library python is installed properly, and works fine with code that uses it, numpy and scipy. The method above, using the native install of cmake, installs opencv into the build directory and cv2.so into build/lib

Python couldn't find opencv, so I exported PYTHONPATH to include the build path; python still couldn't find opencv. I've been told that *.so files are only used in Windows builds, not in unix-like builds such as Mac OSX, but that's just quoting others. OSX (I have 10.6.8) needs a "framework build" and cmake doesn't seem to produce one. I note that PYTHONPATH is null in my system; I suspect that framework builds don't use it.

johnsankey ( 2013-04-08 20:44:40 -0600 )edit

Sounds weired to me, but I am not a MacOS guy, so all what you say is probably true. Ok, so your problem is that you are searching for possibilities to add the python-libraries which are generated by cmake (or not? is it a cmake-problem? Check that!) to your python-installation. I guess this is a common problem?! I really hope you'll find a solution!! Please poste your solution here if you find one!

Guanta ( 2013-04-09 03:14:38 -0600 )edit
Login/Signup to Answer

Stats

Asked: 2013-04-08 06:51:12 -0600

Seen: 289 times

Last updated: Apr 08 '13