Thursday, April 14, 2011

IPP works with OpenCV 2.0 : a solution

The libraries name of IPP has been changed since IPP 7.0, so the New Opencv can not be compiled with IPP.
The solution is to change the CMakeLists.txt in the OpenCV2.0's source file.
The following is what I did, where the IPP_PATH is defined as /opt/intel/ipp/lib/ia32 in the CMAKE:

############################### IPP ################################
set(IPP_FOUND)
set(OPENCV_LOADER_PATH)

if(UNIX)
if(APPLE)
set(OPENCV_LOADER_PATH DYLD_LIBRARY_PATH)
else()
set(OPENCV_LOADER_PATH LD_LIBRARY_PATH)
endif()
endif()

foreach(v "7.0" "6.1" "6.0" "5.3" "5.2" "5.1")
if(NOT IPP_FOUND)
if(WIN32)
find_path(IPP_PATH "ippi-${v}.dll"
PATHS ${CMAKE_PROGRAM_PATH} ${CMAKE_SYSTEM_PROGRAM_PATH}
DOC "The path to IPP dynamic libraries")
if(NOT IPP_PATH)
find_path(IPP_PATH "ippiem64t-${v}.dll"
PATHS ${CMAKE_PROGRAM_PATH} ${CMAKE_SYSTEM_PROGRAM_PATH}
DOC "The path to IPP dynamic libraries")
endif()
endif()
if(UNIX)
find_path(IPP_PATH "libippi${CMAKE_SHARED_LIBRARY_SUFFIX}.${v}"
PATHS ${CMAKE_LIBRARY_PATH} ${CMAKE_SYSTEM_LIBRARY_PATH} ENV ${OPENCV_LOADER_PATH}
DOC "The path to IPP dynamic libraries")
if(NOT IPP_PATH)
find_path(IPP_PATH "libippiem64t${CMAKE_SHARED_LIBRARY_SUFFIX}.${v}"
PATHS ${CMAKE_LIBRARY_PATH} ${CMAKE_SYSTEM_LIBRARY_PATH} ENV ${OPENCV_LOADER_PATH}
DOC "The path to IPP dynamic libraries")
endif()
endif()
if(IPP_PATH)
file(GLOB IPP_HDRS "${IPP_PATH}/../../../ipp/include")
if(IPP_HDRS)
set(IPP_FOUND TRUE)
endif()
endif()
endif()
endforeach()

message(STATUS "IPP detected: ${IPP_FOUND}")

if(WIN32 AND NOT MSVC)
set(IPP_FOUND)
endif()

set(USE_IPP ${IPP_FOUND} CACHE BOOL "Use IPP when available")

message(STATUS "IPP_FOUND: ${IPP_FOUND}")
message(STATUS "USE_IPP: ${USE_IPP}")
message(STATUS "USE_PATH: ${IPP_PATH}")


if(IPP_FOUND AND USE_IPP)
add_definitions(-DHAVE_IPP)
include_directories("${IPP_PATH}/../../../ipp/include")
link_directories("${IPP_PATH}/../../../ipp/lib/ia32")

file(GLOB em64t_files "${IPP_PATH}/../lib/*em64t*")
set(IPP_ARCH)
if(em64t_files)
set(IPP_ARCH "em64t")
endif()

set(A ${CMAKE_STATIC_LIBRARY_PREFIX})
set(B ${IPP_ARCH}${CMAKE_STATIC_LIBRARY_SUFFIX})
if(WIN32)
set(L l)
else()
set(L)
endif()
set(IPP_LIBS
${A}ippvm_l${B}
${A}ippcc_l${B}
${A}ippcv_l${B}
${A}ippi_l${B}
${A}ipps_l${B}
${A}ippcore_l${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()

No comments: