openCV 2.4.3 / Xcode 4.5.2 / mac osx 10.8.2
I am trying to get openCV working with iOS. I am attempting to use the the prebuilt 2.4.3 framework from openCV.org. However I am getting the following xcode project build errors that suggest the compiler doesn't know it is dealing with c++, eg
#include <list> !'list' file not found
namespace cv !unknown type name 'namespace'
This only seems to concern the following header files:
"opencv2/nonfree/features2d.hpp"
"opencv2/nonfree/nonfree.hpp"
"opencv2/video/video.hpp"
if I don't include these three files in opencv.hpp (or anywhere else) I seem to be able to compile and use openCV ok. The trouble is, I do need the nonfree files as I am experimenting with SURF - which has been moved to nonfree recently.
This is really a twofold question (sorry ;-)
- how do I convince the compiler that these are c++ headers?
- which headers exactly do I need to use SURF?
update
I have cloned the openCV git repository and built a new framework from that. This approach had not worked previously, but today I realised that I was not using the current version of CMAKE. I had been using CMAKE 2.8.2 and this would fail to build opencv for ios. Current version CMAKE 2.8.10 builds it without any issues (that's an object lesson in obeying the docs, which do say CMAKE min. v2.8.8 is required).
Now when I add this current build of the opencv framework in an Xcode project I can include features2d and nonfree and build smoothly. The only problem remains with one header: video/background_segm.hpp
, which still yields:
#include <list> !'list' file not found
If I comment that line out I get an error on the next line:
namespace cv !unknown type name 'namespace'
It seems clear that the compiler doesn't recognise this as a C++ header, even though it is suffixed .hpp
.
In opencv2/video/video.hpp
if I remove
#include "opencv2/video/background_segm.hpp"
I can build with video.hpp
also (although I guess it would be unusable in practice).
Unfortunately I still can't get SURF to work. When I run the project it crashes with this error:
OpenCV Error: The function/feature is not implemented (OpenCV was built without SURF support)
This is triggered in legacy/features2d.cpp
:
Ptr<Feature2D> surf = Algorithm::create<Feature2D>("Feature2D.SURF");
if( surf.empty() )
CV_Error(CV_StsNotImplemented, "OpenCV was built without SURF support");
The questions remain...
- how do I convince the compiler that
background_segm.hpp
is a legit c++ header?
- how do I enable SURF support?
See Question&Answers more detail:
os