I don’t think image processing in Python is great, *unless* you use OpenCV, although OpenCV also makes life better in C/C++ as well. Great package. Lots of books, and online information – it is almost overwhelming. Only problem is configuring it to work with Python is nasty (maybe many things are like this?). Dependencies is what kills image processing in Python. I’m not just talking libraries you can easily include… it is also the issue with correct versions, and complex install scripts (I like pip and homebrew, but if something goes wrong for the average person, they can get horribly lost). Python’s issue of course is partially the fact that it exists in two forms: 2.7.X and 3.X. Here’s a brief article of the key differences. Better idea would have been to name Python 3.X something else – viper? adder? constrictor?
To compound things, OSX also has the built-in Python in /usr/bin/python, and a choice of others, including the homebrew version in /usr/local/bin/python. Now the version on my laptop is Python 2.7.10 (default, Oct 23 2015). Seems old right? So I updated to homebrew python… and I get 2.7.13.
Problem is you have to first choose a version of Python, then a version of OpenCV. Do I choose to continue with OpenCV 2.4.13, OR OpenCV 3.2? Even more complicated is the fact that feature detection algorithms SIFT and SURF are no longer included in OpenCV 3 by default. It requires adding an extra module. How much time do I need to spend to make sure the dependencies are all up-to-scratch? How long before a book goes out of date? (quite quickly if libraries are moved around). The other issue is that existing code imports OpenCV using “import cv2“, which is cryptic, because it seems like it’s importing OpenCV 2.X, however it actually imports whatever the core version is. To find out what you are playing with requires the use of “cv2.__version__“. Then you find out it’s ‘184.108.40.206’ and thats the reason some functions don’t work.
So I upgrade OpenCV to V3.2. And even for someone versed in the command-line, it wasn’t trivial. The install via homebrew on OSX was easy.
brew install opencv3
But after that it requires some changes to the PATH in .bash_profile, and a modification of the link in /usr/local/lib/python2.7/site-packages to point to the new cv2.so. This means doing this:
ln -s /usr/local/opt/opencv3/lib/python2.7/site-packages/cv2.so /usr/local/lib/python2.7/site-packages/cv2.so
Which means the link now looks like this:
cv2.so -> /usr/local/opt/opencv3/lib/python2.7/site-packages/cv2.so
And now… it all *seems* to work. Although some of the functions from OpenCV 2.X are different in OpenCV 3.X. Oh the drama of it all! I found a bunch of replacements for SIFT, one of which is ORB (Oriented FAST and Rotated BRIEF), and it seems to work okay. The only thing I don’t like is that the OpenCV documentation could use some more examples, and maybe a better explanation of some of the function parameters.
Look, I do like coding in Python. No issues there. But what I will say is to get any of this to work properly, and to have an understanding of how it works you have to understand and know how to use the command line. You also have to have a good handle on searching in Google, because information on how some things work is not easy to find. However if a Julia-native OpenCV were to appear (or a better interface), I would dump Python like a hotcake.