cinder / Cinder-OpenCV

OpenCV CinderBlock
101 stars 95 forks source link

Upgrade OpenCV binaries #6

Open pizthewiz opened 10 years ago

pizthewiz commented 10 years ago

In an effort to update OpenCV binaries, I thought we could document the recipe used to build OpenCV per platform and offload later updates to others via pull requests (the actual Cinder shim seems pretty thin and unlikely to require much modification version-to-version).

OS X

After installing CMake via Homebrew, I built for OS X via:

% cd opencv-2.4.8
% mkdir build && cd build
% cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/tmp/purgatorio -DCMAKE_OSX_DEPLOYMENT_TARGET= -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" -DBUILD_SHARED_LIBS=OFF -DWITH_CUDA=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF
% make -j8
% make install

The includes, OS X binaries and samples are updated in my fork's opencv-2.4.8 branch. In a quick run of each sample, they all seem to run as expected.

iOS

It isn't entirely clear which settings need to be tweaked to compile targeting the iOS SDKs for arm7, arm7s, arm64 and i386 (for the simulator). Any ideas?

MSW

Not being particularly Windows-savvy, could someone contribute a build recipe and binaries for x64 and x86?

gaborpapp commented 10 years ago

Thanks for this initiative. I also rebuilt OpenCV on OSX for the Cinder dev branch, and I had to add other options to make it work. Especially the -stdlib=libc++ switch is important:

cmake -DBUILD_SHARED_LIBS=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_ocl=OFF -DBUILD_opencv_superres=OFF -D"CMAKE_OSX_ARCHITECTURES=i386;x86_64" -DENABLE_FAST_MATH=ON -DCMAKE_CXX_FLAGS="-fvisibility-inlines-hidden -stdlib=libc++" -DWITH_1394=OFF -DWITH_CARBON=OFF -DWITH_FFMPEG=OFF -DWITH_IMAGEIO=OFF -DWITH_IPP=OFF -DWITH_OPENNI=OFF -DWITH_QT=OFF -DWITH_QUICKTIME=OFF -DWITH_V4L=OFF -DWITH_PVAPI=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo ..

pizthewiz commented 10 years ago

Hey Gabor, thanks for the suggestions, I'll be sure to rebuild my fork's binaries with at least libc++.

Could I ask why you disabled the OpenCL and Super Res modules? Did you disable native and third-party video/image handling (1394, carbon, ffmpeg, imageio, ipp, openni, qt, quicktime, v4l) for consistency with Cinder's specific needs?

gaborpapp commented 10 years ago

I think they didn't build and/or they were not part of the original Cinder OpenCV libs, so I disabled them, to make it build faster.

pizthewiz commented 10 years ago

Great, I ended up with the following to use libc++ as suggested but also built the OpenCL and Super Res modules, as they might be useful moving forward:

$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/tmp/purgatorio -DCMAKE_OSX_DEPLOYMENT_TARGET= -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" -DENABLE_FAST_MATH=ON -DCMAKE_CXX_FLAGS="-fvisibility-inlines-hidden -stdlib=libc++" -DBUILD_SHARED_LIBS=OFF -DWITH_CUDA=OFF -DWITH_FFMPEG=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF ..
heisters commented 10 years ago

on Windows, I've found you need need to disable BUILD_SHARED_LIBS and BUILD_WITH_STATIC_CRT, then manually set the Runtime Library in Visual Studio to MT for release and MTd for debug. The Runtime Library needs to be set for all projects within the solution.

I wonder if there's any way to set the Runtime Library through CMake? I couldn't find one.

pizthewiz commented 10 years ago