OpenCV Configuration and Optimization Notes


Background

The default package for OpenCV on Fedora 20 (f20) is

opencv-2.4.7-6

The performance of such algorithms as Classifier::detectMultiScale and opencv_traincascade can be optimized via the installation of additional packages, and then enabling them when rebuilding OpenCV with various build flags.

Looking through the opencv.spec SRPM file, various enable flags are provided for configuration tweaking and tuning purposes when rebuilding with rpmbuild.

The most relevant for optimization:

--with eigen3
--with sse3

The most relevant for extending capabilities:

--with ffmpeg
--with openni

The default package can be rebuilt with these optimizations using syntax like:

rpmbuild -ba opencv.spec --with ffmpeg --with openni --with eigen3 --with sse3

However, even when using these flags on f20, the output provided by cmake at configuration time as per doesn’t enthuse. So, rebuild upstream sources without RPM to master the package configuration, and then bring this knowledge back into the RPM package. Old school, yo.

Looking at the upstream source repository, and then rebasing the f20 sources to the latest release of OpenCV (2.4.9) starts off the SRPM hacking. To get a cmake build going, build the opencv sources as specified in the link, to get dependency tracking working.

The file CMakeLists.txt has the build-time configure options.

A list of the most interesting:

WITH_CUDA
WITH_CUFFT
WITH_BLAS

WITH_FFMPEG
WITH_OPENNI

WITH_EIGEN
WITH_IPP
WITH_TBB / BUILD_TBB
WITH_OPENMP
WITH_OPENCL

enable_dynamic_cuda
enable_fast_math
enable_sse3

Setup, Install Prerequisites.

A couple of these are easy to enable, with dependencies already pre-packaged.

For development, you’ll need the following dependencies:

yum install -y gtk2-devel libtheora-devel libvorbis-devel libraw1394-devel libdc1394-devel jasper-devel libpng-devel libjpeg-devel libtiff-devel libv4l-devel libGL-devel gtkglext-devel OpenEXR-devel zlib-devel python2-devel swig python-sphinx gstreamer-devel gstreamer-plugins-base-devel opencl-headers gstreamer-plugins-bad-free-devel gstreamer-python-devel gstreamer-devel gstreamer-plugins-bad-free-devel-docs gstreamer-plugins-base-devel-docs gstreamer-plugins-ugly-devel-docs libpng12-devel mesa-libGLES-devel

To execute binaries that have been compiled with this optimized version of opencv, one will need to install the OpenCL runtime.

For OPENNI

yum install -y openni openni-devel openni-doc

For FFMPEG

yum install -y ffmpeg ffmpeg-devel

For TBB

yum install -y tbb tbb-devel tbb-doc

For EIGEN

yum install -y eigen3-devel eigen3-doc

For IPP

To enable WITH_IPP, more elaborate configuration is required. First, install Intel Performance Primitives (aka IPP). From the User’s Guide: Note that opencv_traincascade application can use TBB for multi-threading. To use it in multicore mode OpenCV must be built with TBB.

After IPP is installed, the system must be configured to use it easily. To fixup PATHs, pick one of two options.

One: add the following to LD_LIBRARY_PATH and LD_RUN_PATH:

/opt/intel/ipp/lib/intel64:/opt/intel/lib/intel64/

Two: edit /etc/ldso.conf.d and add

tbb.conf
/opt/intel/lib/intel64

ipp.conf
/opt/intel/ipp/lib/intel64

Furthermore, for OpenCV configuration to find the installed IPP at SRPM build time, the environment variable IPPROOT must be set, as follows:

setenv IPPROOT /opt/intel/ipp

Build SRPM

Build the modified opencv package with the following custom SPEC file. No configuration options are necessary: WITH_IPP, WITH_TBB, WITH_EIGEN are all enabled.

Then, force install it over the default libs as follows:

rpm -Uvh --nodeps opencv-2.4.9-3 etc etc.

Recompile the opencv app in question, and volia. Optimized. Speedups may vary, seeing ~ 2.3x speedups in processing times.

iAM/iCAN CJ Redux

sky.(selectionS+).32

iAM/iCAN is a multimedia documentary shot in Austin, Texas in 1994. It featured tagged/searchable video embedded into a raster graphic interface. Five subjects discussed gender, race, nascent-on-line culture, technology, hopes and dreams for the future. Given the technical constraints of the time, this meant 4:3 aspect video compressed to a rather severe 160 x 160 pixels, so that streaming off of a state-of-the-art 2x cd-rom player was feasible. Video was shot by Shane Herman, and edited with Premiere. An interface was coded in Director. We called it New Media but didn’t really even understand the Old Medias.

background(james)

Years later, the video is small and grainy and the interface elements seem rather small, but still pretty. The audio is still quite powerful. The interface doesn’t work anymore but the individual graphic elements can be clicked on and the original files are still valid. Still holding interest: the audio, the actual interviews.

Here are all the interviews with CJ Manetta-Romano, who has fearlessly given permission to share his commentary from 1994.


Politics, Working Together, Unity


Interactive Entertainment, Technology as Adult Toys


Internet Culture


Was Intimidated by Technology


Future Interactive Education


Gender Generation Gap


Gender Stereotypes and Rave Flyers


Anarchy, Raves as Free Space


Future Raves, After Raves

iAM/iCAN Steve Redux

sky.(selectionS+).32

iAM/iCAN is a multimedia documentary shot in Austin, Texas in 1994. It featured tagged/searchable video embedded into a raster graphic interface. Five subjects discussed gender, race, nascent-on-line culture, technology, hopes and dreams for the future. Given the technical constraints of the time, this meant 4:3 aspect video compressed to a rather severe 160 x 160 pixels, so that streaming off of a state-of-the-art 2x cd-rom player was feasible. Video was shot by Shane Herman, and edited with Premiere. An interface was coded in Director. We called it New Media but didn’t really even understand the Old Medias.

background(james)

Years later, the video is small and grainy and the interface elements seem rather small, but still pretty. The audio is still quite powerful. The interface doesn’t work anymore but the individual graphic elements can be clicked on and the original files are still valid. Still holding interest: the audio, the actual interviews.

Here are all the interviews with Steve Wechsler, who has fearlessly given permission to share his commentary from 1994.


Components of Activism


Empathy Leads to Unity


Future Vision


Entertainment Is Passive


Commodity Culture


Anonymity of Cyberspace Manifests in Rave


Lossy Communication


Internet Culture, Email Lists, Online Education

iAM/iCAN Brandon Redux

sky.(selectionS+).32

iAM/iCAN is a multimedia documentary shot in Austin, Texas in 1994. It featured tagged/searchable video embedded into a raster graphic interface. Five subjects discussed gender, race, nascent-on-line culture, technology, hopes and dreams for the future. Given the technical constraints of the time, this meant 4:3 aspect video compressed to a rather severe 160 x 160 pixels, so that streaming off of a state-of-the-art 2x cd-rom player was feasible. Video was shot by Shane Herman, and edited with Premiere. An interface was coded in Director. We called it New Media but didn’t really even understand the Old Medias.

background(brandon)

Years later, the video is small and grainy and the interface elements seem rather small, but still pretty. The audio is still quite powerful. The interface doesn’t work anymore but the individual graphic elements can be clicked on and the original files are still valid. Still holding interest: the audio, the actual interviews.

Here are all the interviews with Brandon Rogeness, who has fearlessly given permission to share his commentary from 1994.


Government and Politics


Generation Mine


Multicultural Background, Black and Latin Histories


Minority and Majority Rights


Conflict Resolution


Aggression and Violence


Hacking, Chaos


Limitations of CD-ROM medium


My Computer Interface


Computer Use and Abuse


Kids and Cats

iAM/iCAN James Redux

sky.(selectionS+).32

iAM/iCAN is a multimedia documentary shot in Austin, Texas in 1994. It featured tagged/searchable video embedded into a raster graphic interface. Five subjects discussed gender, race, nascent-on-line culture, technology, hopes and dreams for the future. Given the technical constraints of the time, this meant 4:3 aspect video compressed to a rather severe 160 x 160 pixels, so that streaming off of a state-of-the-art 2x cd-rom player was feasible. Video was shot by Shane Herman, and edited with Premiere. An interface was coded in Director. We called it New Media but didn’t really even understand the Old Medias.

background(james)

Years later, the video is small and grainy and the interface elements seem rather small, but still pretty. The audio is still quite powerful. The interface doesn’t work anymore but the individual graphic elements can be clicked on and the original files are still valid. Still holding interest: the audio, the actual interviews.

Here are all the interviews with James Edward Neal, who has fearlessly given permission to share his commentary from 1994.


Conflict Resolution


Minorities in the System


Political Activity


Hopes for Internet


Prejudice Online


Multicultural Background


Multicultural Education


Extended Families


My Own Computer


Kids


Thanks

Oh So That’s How You Do It

b.d.artist

 

I’m consistently a failure at any kind of practical art practice.

As just one example, I didn’t quite get that one is supposed to have an artist web site these days. Partly that is due to my own confusion about being an artist and not owning that identity. That part is on me. Partly that is pure ignorance about art-world expectations and best practices. This part is now happily solved.

After taking a bunch of art-professionalization classes at Creative Capital, I’ve decided to adopt a new approach to my art on the web. Namely, an artist web site that follows the best practices established in the Web Site, Blog, and Email Essentials webinar.

aka benjamin.dekosnik.com

If I applied for an art grant in the dark ages before Sue Schaffner showed me the light, and you are a grant reader directed to links on this website, do yourself a favor. Read the artist website first.

 

Follow

Get every new post delivered to your Inbox.