Adding third party libraries to an OpenCV project on Xcode - c++

I am new to the XCode environment so apologies if this sounds trivial.
I am trying to use a third party library using for OpenCV that helps me do some blob analysis, CCL etc. Hosted here
I have searched a lot but there doesn't seem to be much documentation on how to go about adding and using these new libraries. I am using XCode 4.5.2, OpenCV 2.4.2.
When I simply add all the header files to the project folder and #include them in the source code, it fails to compile. I have also tried adding the "Header Paths" but it doesn't help. What am I missing?
I have tried to follow the instructions (compiling it using the terminal but it doesn't compile too) I am not clear on how or when exactly to use CMAKE.
Any help will be appreciated. Thank you.

I would suggest you using CvBlob on google code which is different from the one on willowgarage, I have got recently confused with this so take a look at this question for alternative blob analysis libraries.
Moreover, CvBlob has also a good support community here. (Search on "[cvblobslib]" or on "[blob] [opencv]")

Try this: cvBlob: OSX installation
Once you get it compiled, you need to include the library under Link Binary with Libraries in Build Phases. (This screenshot shows the core, imgproc, and highgui libraries. Your cvBlob library would go in the same place.)

Related

SDL_AudioStreamFlush could not be located in the dynamic link library SDL2_mixer.dll

I'm just trying to follow along with the c++ graphics tutorial from MakingGamesWithBen about SDL mixer, an audio system. I got the development library from:
SDL_Mixer Development Library Download.
It's the SDL2_mixer-devel-2.0.2-VC.zip folder under development libraries for Visual C++. I've done all the same steps as what he is showing, though I've been using x64 instead of x86. When I try running the project though, it gives me the error
"SDL_AudioStreamFlush could not be located in the dynamic link library [file path] SDL2_mixer.dll". I'm not using the function SDL_AudioStreamFlush in my code at all, which is what perplexes me about this. I honestly don't have any clue how to fix this, and online documentation doesn't seem to help. Any assistance would be much appreciated, because I have tried looking on sites for other similar questions, but nothing I can use. Below should be a dropbox link to my entire solution.
https://www.dropbox.com/sh/0blrourluyjpsca/AACs4bHdZs83q_R8lSjFINIEa?dl=0
I have the same problem when using SDL_mixer and SDL_ttf.
When I change the old SDL2.dll in my folder (I put them all: header files, library files, and binary files in one directory) with the newest one (the one that is in the lib/X86/SDL2.dll) it works.

Including OpenCV source in project without installation

I'm currently trying to setup an OpenCV project using CMake.
I want to have the highest portability between machines so I thought I can achieve it by including the OpenCV source and compiling it and link it in CMake to the executable.
I'm not quite sure how to go about it because I'm a beginner to CMake and OpenCV. However, I would like to avoid installing it on the machine as much as possible as I would just want to build it and run on a machine.
So far, I've looked at the possibility of including the source of OpenCV in the CMakeFiles.txt like so:
add_subdirectory(opencv-3.1.0)
target_link_libraries(foo opencv-core)
However, it hasn't worked for me so far.
Can anyone provide me with suggestions?
Thank you.
EDIT:
The main problem I've been encountering so far is that once I use make install to move all the binaries into place, it will try to move the compiled version of OpenCV into the install location which I'm not sure how to avoid using it.

SuperLU library XCode issues

I'm a newbie when compiling and adding 3rd party C++ libraries into XCode... So here's the problem. I have .cpp files wich depend on 3 libraries. OpenCV-Eigen-SuperLU. So far think that I managed to add correctly OpenCV-Eigen, but I got trouble adding SuperLU.
I'm really confused on where should I include source files paths??. Some tutorials say that I need to create a static lib... other that I need a framework... on the other hand there are XCode project template which just include src files into a folder inside XCode project's and then reference them from build setting properties. Anyway I really need some guidance here.
So here's my setup for most of the libs. I have a folder within the XCode project with all dependencies.
Then... on project build settings I setup header search paths-- and library search paths. To point that folder
Headers for SuperLU are found correctly... but I get Linker errors.
So as you can see, I have no idea what to do... I'm Sorry but as I told on beginning I'm a newbie adding libs into XCode... plus documentation of procedures it's not good at all. So if anybody could help me with some guidance or links where I can start understanding how the linking process works would be great.
I'm a little desperate at this point, os any kind of help would be really really great.
Thanks a lot.
The problem is that both SuperLU and Objective-C define YES and NO. So you get a conflict.
In the end I was advised to create a different target to compile all SuperLU as a pure c++ project with gcc compiler. That made it possible for iOS app to use the lib as a dependency.

Using OpenSSL's CMS implementation in C++

So my project today has been to create a C++ class that consolidates a lot of our commonly used crypto tasks. Got lots of things working but ran into a bit of a snag here. For reference, I'm using XCode 3.2.5 on OS 10.6.5.
I'm attempting to utilize some of OpenSSL's CMS functions. OpenSSL's MAN Page for one of the functions I'm trying to use mentions it was included in version 0.9.8. That's the version XCode let me import without having to do anything out of the ordinary (Target -> General -> Add Linked Library). Yet with that added XCode tells me it can't find openssl/cms.h.
So thinking maybe there's some disparity between the OS X version 0.9.8 and the one on OpenSSLs page, I downloaded the source for 1.0.0c and built it. After it was built, I added libcrypto.a and libssl.a to my project as linked libraries and added "some/dirs/openssl-1.0.0c/include/**" as a header search path. Now it can find openssl/cms.h but I get a linking error on any CMS function I call.
Has anyone done this successfully? Any help would be appreciate.
Thanks!
So what I ended up doing was to create a new SDK and calling,
./Configure darwin64-x86_64-cc --prefix=/path/to/sdk/usr --openssldir=/System/Library/OpenSSL enable-cms shared
To update the version of OpenSSL included in that SDK. That's seemed to work.

How do I zip a directory of files using C++?

I'm working on a project using C++, Boost, and Qt. I understand how to compress single files and bytestreams using, for example, the qCompress() function in Qt.
How do I zip a directory of multiple files, including subdirectories? I am looking for a cross-platform (Mac, Win, Linux) solution; I'd prefer not to fire off a bunch of new processes.
Is there a standard way to combine bytestreams from multiple files into a zipped archive, or maybe there is a convenience function or method that would be available in the Boost iostream library?
Many thanks for the assistance.
Update: The QuaZip library looks really great. There is an example in the download package (in the "tests" dir) that shows very clearly how to zip up a directory of files.
Update 2: After completing this task on my Linux build environment, I discovered that QuaZip doesn't work at all with the Visual Studio compiler. It may be possible to tackle all those compiler errors, but a word of caution to anyone looking down this path.
I have found the following two libraries:
ZipIOS++. Seems to be "pure" C++. They don't list Windows explicitly as a supported platform. So i think you should try your luck yourself.
QuaZIP. Based on Qt4. Actually looks nice. They list Windows explicitly (Using mingw). Apparently, it is a C++ wrapper for [this] library.
Ah, and of course, i have ripped those sites from this Qt Mailinglist question about Zipping/Unzipping of directories :)
Just for the record...
Today, I needed to do something very similar in Visual C++. (Though wanted to maintain the possibility to compile the project on other platforms; however preferred not to adopt Qt just for this purpose.)
Ended up using the Minizip library. It is written in plain C, but devising a simple C++ wrapper around it was a breeze, and the end result works great, at least for my purposes.
I have built a wrapper around minizip adding some features that I needed and making it nicer to use it. Is does use the latest c++11 and is developed using Visual Studio 2013, so it should work out-of-the-box for you.
There's a full description here: https://github.com/sebastiandev/zipper
you can zip entire folders, streams, vectors, etc. Also a nice feature is doing everything entirely in memory.
Poco::Zip is also a choice, it has clearly documentation and some code for demo.
Poco::Zip Document
system("zip myarchive.zip *");
I tried QuaZIP 0.4.3 on Windows with VisualStudio 2010 -- there are still issues but can be resolved easily.
To build with VS:
Use CMake to configure and generate VS solution for QuaZIP.
Open soltion with VS and build -- you'll first notice that it can't find 'zlib.h'.
Open preferences for quazip project and add path to Qt's copy of Zlib to C/C++->General->Additional Include Directories: $(QTDIR)/src/3rdparty/zlib.
Rebuild again and you'll get lots of warnings and one error C2491: dllimport static issue on QuaZipFile::staticMetaObject.
This is because QuaZipFile is declared like "class QUAZIP_EXPORT QuaZipFile" and QUAZIP_EXPORT needs to resolve to Q_DECL_EXPORT for dll and to Q_DECL_IMPORT for application, based on whether QUAZIP_BUILD is defined or not. When building QuaZIP QUAZIP_BUILD should be defined but isn't -- configuration process defines in error completely useless "quazip_EXPORTS" instead.
To fix, just remove "quazip_EXPORTS" from all build configurations and add QUAZIP_BUILD instead -- QuaZIP will now build fine.