7
votes

I want to do a project involving Computer Vision. Mostly object detection/identification. After some research, I keep coming back to OpenCV. But all of the tutorials are from 2008 (I guess it was big for a bit then). It doesn't compile in Python on the mac apparently. I'm using the C++ framework right out of Xcode, but none of the tutorials work as they're outdated and the documentation sucks from what I can parse.

Is there a better solution for what I'm doing, and does anyone have any suggestions as to learning how to to use OpenCV?

Thanks

3
Try the OpenCV book from O'Reilly ?Paul R
Released: September 2008 -- sorry, every tutorial from '08 doesn't work. I believe the framework has changed a lot since then. And from a review on that page: "Book was good at the time, but no longer applies as opencv has moved on. They should update their book."switz
Have a look at the examples in the OpenCV source code.James
I don't recommend the Python interface. I've had multiple problems trying to do very simple stuff with it. I've also don't recommend the C++ interface for Windows for the same reasons. This is what I think of OpenCV until v2.3.1 (I haven't tried the latest though). The C/C++ interface for Linux and Mac works awesomely. On Mac, I use the cmd-line to compile my applications. g++ source.cpp -o source `pkg-config --cflags --libs opencv` karlphillip
if you can stomach it then use the C API. Used that on Windows and Linux. Other than a few unwieldy function names, it works. And you can follow that O Rielly book without worry.AruniRC

3 Answers

7
votes

I have had similar problems getting started with OpenCV and from my experience this is actually the biggest hurdle to learning it. Here is what worked for me:

  1. This book: "OpenCV 2 Computer Vision Application Programming Cookbook." It's the most up-to-date book and has examples on how to solve different Computer Vision problems (You can see the table of contents on Amazon with "Look Inside!"). It really helped ease me into OpenCV and get comfortable with how the library works.

  2. Like have others have said, the samples are very helpful. For things that the book skips or covers only briefly you can usually find more detailed examples when looking through the samples. You can also find different ways of solving the same problem between the book and the samples. For example, for finding keypoints/features, the book shows an example using FAST features:

    vector<KeyPoint> keypoints;
    FastFeatureDetector fast(40);
    fast.detect(image, keypoints);

    But in the samples you will find a much more flexible way (if you want to have the option of choosing which keypoint detection algorithm to use):

    vector<KeyPoint> keypoints;
    Ptr<FeatureDetector> featureDetector = FeatureDetector::create("FAST");
    featureDetector->detect(image, keypoints);

From my experience things eventually start to click and for more specific questions you start finding up-to-date information on blogs or right here on StackOverflow.

2
votes

Let me add a couple of things. First, I can assure you that the Python bindings to OpenCV work on a Mac. I use them every day.

Many people like OpenCV for many reasons:

  1. The license is good, friendly to integration into commercial products, etc.
  2. It is quite good from a technical stand point. It gives you a reference implementation of state of the art algorithms.
  3. It tends to be quite fast compared to the alternatives (Matlab I'm looking at you).

Like everything in life, it is not perfect:

  1. It is a good example of a software library that is a moving target. I have a 300 line python program that uses OpenCV and every few months when a new version of OpenCV is released I have to change it to adapt to the new function names/calling conventions, etc. The library does advance, a lot, however it is a pain to have to change the same program 3 times per year.
  2. It has a learning curve, like computer vision itself, it is quite technical and not easy to learn.

There are alternatives (with other pros and cons) MATLAB with the Image Processing Toolbox is one such example.

0
votes

The simplest answer that comes to mind, is to read the example code with a bit of understanding, and to try out if Your ideas work. The api does change, and most of the tutorials are writen for the first versions of OpenCV, and it looks that nobody bothered to rewrite them. Nevertheless the core ideas behind it are not changing. So if You find a tutorial answering Your questions, but written in old API just look in the documentation for modern replacements of used functions. It’s not easy and quick, but looks like it works. If You use the newest (actually 2.3) version, I suggest using both the 2.1 documntation and 2.3 docs + tutorials . You should also look into the samples, which should have been installed alongside the library. There are lots of hints about how to use certain structures and tricks that weren't mentioned in documentation. Finally, don't be afraid to look inside the code of the library itself (if You compiled it on Your own). Unfortunately, thats the only source I know to check for example what code corresponds to which type of Mat object.