Merge remote-tracking branch 'origin/2.4' into merge-2.4

Conflicts:
	doc/tutorials/definitions/noContent.rst
	doc/tutorials/gpu/gpu-basics-similarity/gpu-basics-similarity.rst
	doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.rst
	doc/tutorials/introduction/how_to_write_a_tutorial/how_to_write_a_tutorial.rst
	modules/core/include/opencv2/core/core.hpp
	modules/core/include/opencv2/core/internal.hpp
	modules/core/include/opencv2/core/version.hpp
	modules/gpu/CMakeLists.txt
	modules/highgui/perf/perf_output.cpp
	modules/highgui/test/test_video_io.cpp
	modules/ocl/include/opencv2/ocl/ocl.hpp
	modules/ocl/perf/main.cpp
	modules/ocl/src/hog.cpp
	modules/ocl/src/initialization.cpp
	modules/ocl/src/moments.cpp
	modules/ocl/src/opencl/moments.cl
	modules/ocl/test/main.cpp
	modules/ocl/test/test_moments.cpp
	modules/python/test/test.py
	modules/ts/include/opencv2/ts/ts_perf.hpp
	modules/ts/src/precomp.hpp
	modules/ts/src/ts_perf.cpp
pull/1081/head
Roman Donchenko 12 years ago
commit 4cf9990d4e
  1. 70
      3rdparty/tbb/CMakeLists.txt
  2. 1747
      android/android.toolchain.cmake
  3. 1
      android/readme.txt
  4. 40
      cmake/OpenCVDetectCUDA.cmake
  5. 3
      cmake/OpenCVFindLibsGUI.cmake
  6. 6
      cmake/templates/cvconfig.h.cmake
  7. 2
      doc/_themes/blue/layout.html
  8. 226
      doc/conf.py
  9. 2
      doc/tutorials/definitions/noContent.rst
  10. 235
      doc/tutorials/gpu/gpu-basics-similarity/gpu-basics-similarity.rst
  11. 16
      doc/tutorials/introduction/android_binary_package/O4A_SDK.rst
  12. 18
      doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.rst
  13. 441
      doc/tutorials/introduction/how_to_write_a_tutorial/how_to_write_a_tutorial.rst
  14. 2
      doc/tutorials/introduction/ios_install/ios_install.rst
  15. 2
      doc/tutorials/introduction/windows_install/windows_install.rst
  16. 2
      doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.rst
  17. 2
      doc/tutorials/ml/introduction_to_svm/introduction_to_svm.rst
  18. 1
      ios/configure-device_xcode.sh
  19. 1
      ios/configure-simulator_xcode.sh
  20. 15
      ios/readme.txt
  21. 2
      modules/contrib/src/inputoutput.cpp
  22. 31
      modules/core/doc/basic_structures.rst
  23. 8
      modules/core/doc/clustering.rst
  24. 8
      modules/core/doc/drawing_functions.rst
  25. 2
      modules/core/doc/operations_on_arrays.rst
  26. 9
      modules/core/doc/utility_and_system_functions_and_macros.rst
  27. 11
      modules/core/doc/xml_yaml_persistence.rst
  28. 2
      modules/core/include/opencv2/core/mat.hpp
  29. 28
      modules/core/include/opencv2/core/private.hpp
  30. 31
      modules/core/src/parallel.cpp
  31. 9
      modules/gpu/perf/perf_main.cpp
  32. 2
      modules/highgui/CMakeLists.txt
  33. 4
      modules/highgui/include/opencv2/highgui/highgui_c.h
  34. 49
      modules/highgui/include/opencv2/highgui/ios.h
  35. 10
      modules/highgui/perf/perf_input.cpp
  36. 14
      modules/highgui/perf/perf_output.cpp
  37. 2
      modules/highgui/perf/perf_precomp.hpp
  38. 40
      modules/highgui/src/cap.cpp
  39. 5
      modules/highgui/src/cap_dc1394_v2.cpp
  40. 8
      modules/highgui/src/cap_ffmpeg.cpp
  41. 4
      modules/highgui/src/cap_libv4l.cpp
  42. 1243
      modules/highgui/src/cap_msmf.cpp
  43. 4
      modules/highgui/src/cap_v4l.cpp
  44. 4
      modules/highgui/src/cap_vfw.cpp
  45. 117
      modules/highgui/src/ios_conversions.mm
  46. 3
      modules/highgui/src/precomp.hpp
  47. 1
      modules/highgui/src/window_QT.cpp
  48. 6
      modules/highgui/test/test_precomp.hpp
  49. 54
      modules/highgui/test/test_video_io.cpp
  50. 2
      modules/imgproc/perf/perf_cvt_color.cpp
  51. 3
      modules/imgproc/perf/perf_resize.cpp
  52. 3
      modules/imgproc/perf/perf_threshold.cpp
  53. 2
      modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java
  54. 1
      modules/java/generator/src/java/android+JavaCameraView.java
  55. 5
      modules/java/generator/src/java/android+OpenCVLoader.java
  56. 4
      modules/java/generator/src/java/highgui+VideoCapture.java
  57. 9
      modules/nonfree/perf/perf_main.cpp
  58. 56
      modules/ocl/include/opencv2/ocl.hpp
  59. 67
      modules/ocl/perf/main.cpp
  60. 4
      modules/ocl/perf/perf_imgproc.cpp
  61. 152
      modules/ocl/perf/perf_opticalflow.cpp
  62. 4
      modules/ocl/perf/precomp.cpp
  63. 2
      modules/ocl/src/haar.cpp
  64. 16
      modules/ocl/src/hog.cpp
  65. 15
      modules/ocl/src/imgproc.cpp
  66. 79
      modules/ocl/src/initialization.cpp
  67. 2
      modules/ocl/src/mcwutil.cpp
  68. 21
      modules/ocl/src/moments.cpp
  69. 290
      modules/ocl/src/opencl/moments.cl
  70. 20
      modules/ocl/src/opencl/objdetect_hog.cl
  71. 450
      modules/ocl/src/opencl/optical_flow_farneback.cl
  72. 41
      modules/ocl/src/opencl/stereobm.cl
  73. 540
      modules/ocl/src/optical_flow_farneback.cpp
  74. 2
      modules/ocl/test/main.cpp
  75. 2
      modules/ocl/test/test_imgproc.cpp
  76. 8
      modules/ocl/test/test_moments.cpp
  77. 6
      modules/ocl/test/test_objdetect.cpp
  78. 72
      modules/ocl/test/test_optflow.cpp
  79. 9
      modules/superres/perf/perf_main.cpp
  80. 3
      modules/ts/include/opencv2/ts/ts_gtest.h
  81. 33
      modules/ts/include/opencv2/ts/ts_perf.hpp
  82. 48
      modules/ts/misc/testlog_parser.py
  83. 167
      modules/ts/misc/xls-report.py
  84. 2
      modules/ts/src/precomp.hpp
  85. 11
      modules/ts/src/ts_func.cpp
  86. 33
      modules/ts/src/ts_gtest.cpp
  87. 123
      modules/ts/src/ts_perf.cpp
  88. 2
      platforms/android/service/doc/BaseLoaderCallback.rst
  89. 4
      platforms/android/service/doc/JavaHelper.rst
  90. 4
      platforms/android/service/engine/AndroidManifest.xml
  91. 2
      platforms/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp
  92. 12
      platforms/android/service/readme.txt
  93. 2
      platforms/ios/Info.plist.in
  94. 9
      platforms/ios/build_framework.py
  95. 0
      platforms/ios/cmake/Modules/Platform/iOS.cmake
  96. 8
      platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake
  97. 8
      platforms/ios/cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake
  98. 7
      platforms/ios/readme.txt
  99. 4
      platforms/readme.txt
  100. 2
      platforms/scripts/ABI_compat_generator.py
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,12 +1,30 @@
#Cross compile TBB from source #Cross compile TBB from source
project(tbb) project(tbb)
# 4.1 update 2 - works fine if (WIN32 AND NOT ARM)
set(tbb_ver "tbb41_20130116oss") message(FATAL_ERROR "BUILD_TBB option supports Windows on ARM only!\nUse regular official TBB build instead of the BUILD_TBB option!")
set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130116oss_src.tgz") endif()
set(tbb_md5 "3809790e1001a1b32d59c9fee590ee85")
# 4.1 update 4 - works fine
set(tbb_ver "tbb41_20130613oss")
set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130613oss_src.tgz")
set(tbb_md5 "108c8c1e481b0aaea61878289eb28b6a")
set(tbb_version_file "version_string.ver") set(tbb_version_file "version_string.ver")
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused-parameter)
# 4.1 update 3 dev - works fine
#set(tbb_ver "tbb41_20130401oss")
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130401oss_src.tgz")
#set(tbb_md5 "f2f591a0d2ca8f801e221ce7d9ea84bb")
#set(tbb_version_file "version_string.ver")
#ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
# 4.1 update 2 - works fine
#set(tbb_ver "tbb41_20130116oss")
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130116oss_src.tgz")
#set(tbb_md5 "3809790e1001a1b32d59c9fee590ee85")
#set(tbb_version_file "version_string.ver")
#ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
# 4.1 update 1 - works fine # 4.1 update 1 - works fine
#set(tbb_ver "tbb41_20121003oss") #set(tbb_ver "tbb41_20121003oss")
@ -107,7 +125,7 @@ if(NOT EXISTS "${tbb_src_dir}")
RESULT_VARIABLE tbb_untar_RESULT) RESULT_VARIABLE tbb_untar_RESULT)
if(NOT tbb_untar_RESULT EQUAL 0 OR NOT EXISTS "${tbb_src_dir}") if(NOT tbb_untar_RESULT EQUAL 0 OR NOT EXISTS "${tbb_src_dir}")
message(FATAL_ERROR "Failed to unpack TBB sources") message(FATAL_ERROR "Failed to unpack TBB sources from ${tbb_tarball} to ${tbb_src_dir} with error ${tbb_untar_RESULT}")
endif() endif()
endif() endif()
@ -123,13 +141,22 @@ file(GLOB lib_hdrs "${tbb_src_dir}/src/tbb/*.h")
list(APPEND lib_srcs "${tbb_src_dir}/src/rml/client/rml_tbb.cpp") list(APPEND lib_srcs "${tbb_src_dir}/src/rml/client/rml_tbb.cpp")
if (WIN32) if (WIN32)
add_definitions(-D__TBB_DYNAMIC_LOAD_ENABLED=0 add_definitions(/D__TBB_DYNAMIC_LOAD_ENABLED=0
-D__TBB_BUILD=1 /D__TBB_BUILD=1
-D_UNICODE /DTBB_NO_LEGACY=1
-DUNICODE /D_UNICODE
-DWINAPI_FAMILY=WINAPI_FAMILY_APP /DUNICODE
-DDO_ITT_NOTIFY=0 /DWINAPI_FAMILY=WINAPI_FAMILY_APP
/DDO_ITT_NOTIFY=0
/DUSE_WINTHREAD
) # defines were copied from windows.cl.inc ) # defines were copied from windows.cl.inc
if (ARM)
add_definitions(/D_WIN32_WINNT=0x0602
/D__TBB_WIN32_USE_CL_BUILTINS
)
endif()
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} /APPCONTAINER") set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} /APPCONTAINER")
else() else()
add_definitions(-D__TBB_DYNAMIC_LOAD_ENABLED=0 #required add_definitions(-D__TBB_DYNAMIC_LOAD_ENABLED=0 #required
@ -173,7 +200,23 @@ endif()
set(TBB_SOURCE_FILES ${TBB_SOURCE_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/${tbb_version_file}") set(TBB_SOURCE_FILES ${TBB_SOURCE_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/${tbb_version_file}")
add_library(tbb ${TBB_SOURCE_FILES}) add_library(tbb ${TBB_SOURCE_FILES})
target_link_libraries(tbb c m dl)
if (WIN32)
if (ARM)
set(platform_macro /D_M_ARM=1)
endif()
add_custom_command(TARGET tbb
PRE_BUILD
COMMAND ${CMAKE_C_COMPILER} /nologo /TC /EP ${tbb_src_dir}\\src\\tbb\\win32-tbb-export.def /DTBB_NO_LEGACY=1 /D_CRT_SECURE_NO_DEPRECATE /D__TBB_BUILD=1 ${platform_macro} /I${tbb_src_dir}\\src /I${tbb_src_dir}\\include > "${tbb_src_dir}\\src\\tbb\\tbb.def"
WORKING_DIRECTORY ${tbb_src_dir}\\src\\tbb
COMMENT "Generating tbb.def file" VERBATIM
)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEF:${tbb_src_dir}/src/tbb/tbb.def /DLL /MAP /fixed:no /INCREMENTAL:NO")
else()
target_link_libraries(tbb c m dl)
endif()
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations)
string(REPLACE "-Werror=non-virtual-dtor" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE "-Werror=non-virtual-dtor" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
@ -182,6 +225,7 @@ set_target_properties(tbb
PROPERTIES OUTPUT_NAME tbb PROPERTIES OUTPUT_NAME tbb
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH} ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
) )
if(ENABLE_SOLUTION_FOLDERS) if(ENABLE_SOLUTION_FOLDERS)

File diff suppressed because it is too large Load Diff

@ -1 +0,0 @@
All Android specific sources are moved to platforms/android.

@ -29,10 +29,42 @@ if(CUDA_FOUND)
if(${CUDA_VERSION} VERSION_LESS "5.5") if(${CUDA_VERSION} VERSION_LESS "5.5")
find_cuda_helper_libs(npp) find_cuda_helper_libs(npp)
else() else()
find_cuda_helper_libs(nppc) # hack for CUDA 5.5
find_cuda_helper_libs(nppi) if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
find_cuda_helper_libs(npps) unset(CUDA_TOOLKIT_INCLUDE CACHE)
set(CUDA_npp_LIBRARY ${CUDA_nppc_LIBRARY} ${CUDA_nppi_LIBRARY} ${CUDA_npps_LIBRARY}) unset(CUDA_CUDART_LIBRARY CACHE)
unset(CUDA_cublas_LIBRARY CACHE)
unset(CUDA_cufft_LIBRARY CACHE)
unset(CUDA_npp_LIBRARY CACHE)
if(SOFTFP)
set(cuda_arm_path "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-gnueabi")
else()
set(cuda_arm_path "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-gnueabihf")
endif()
set(CUDA_TOOLKIT_INCLUDE "${cuda_arm_path}/include" CACHE PATH "include path")
set(CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE})
set(cuda_arm_library_path "${cuda_arm_path}/lib")
set(CUDA_CUDART_LIBRARY "${cuda_arm_library_path}/libcudart.so" CACHE FILEPATH "cudart library")
set(CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY})
set(CUDA_cublas_LIBRARY "${cuda_arm_library_path}/libcublas.so" CACHE FILEPATH "cublas library")
set(CUDA_cufft_LIBRARY "${cuda_arm_library_path}/libcufft.so" CACHE FILEPATH "cufft library")
set(CUDA_nppc_LIBRARY "${cuda_arm_library_path}/libnppc.so" CACHE FILEPATH "nppc library")
set(CUDA_nppi_LIBRARY "${cuda_arm_library_path}/libnppi.so" CACHE FILEPATH "nppi library")
set(CUDA_npps_LIBRARY "${cuda_arm_library_path}/libnpps.so" CACHE FILEPATH "npps library")
set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}" CACHE STRING "npp library")
else()
unset(CUDA_npp_LIBRARY CACHE)
find_cuda_helper_libs(nppc)
find_cuda_helper_libs(nppi)
find_cuda_helper_libs(npps)
set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}" CACHE STRING "npp library")
endif()
endif() endif()
if(WITH_NVCUVID) if(WITH_NVCUVID)

@ -24,7 +24,6 @@ if(WITH_QT)
if(Qt5Core_FOUND AND Qt5Gui_FOUND AND Qt5Widgets_FOUND AND Qt5Test_FOUND AND Qt5Concurrent_FOUND) if(Qt5Core_FOUND AND Qt5Gui_FOUND AND Qt5Widgets_FOUND AND Qt5Test_FOUND AND Qt5Concurrent_FOUND)
set(HAVE_QT5 ON) set(HAVE_QT5 ON)
set(HAVE_QT ON) set(HAVE_QT ON)
add_definitions(-DHAVE_QT)
find_package(Qt5OpenGL) find_package(Qt5OpenGL)
if(Qt5OpenGL_FOUND) if(Qt5OpenGL_FOUND)
set(QT_QTOPENGL_FOUND ON) set(QT_QTOPENGL_FOUND ON)
@ -36,7 +35,6 @@ if(WITH_QT)
find_package(Qt4 REQUIRED QtCore QtGui QtTest) find_package(Qt4 REQUIRED QtCore QtGui QtTest)
if(QT4_FOUND) if(QT4_FOUND)
set(HAVE_QT TRUE) set(HAVE_QT TRUE)
add_definitions(-DHAVE_QT) # We need to define the macro this way, using cvconfig.h does not work
endif() endif()
endif() endif()
endif() endif()
@ -61,7 +59,6 @@ if(WITH_OPENGL)
list(APPEND OPENCV_LINKER_LIBS ${OPENGL_LIBRARIES}) list(APPEND OPENCV_LINKER_LIBS ${OPENGL_LIBRARIES})
if(QT_QTOPENGL_FOUND) if(QT_QTOPENGL_FOUND)
set(HAVE_QT_OPENGL TRUE) set(HAVE_QT_OPENGL TRUE)
add_definitions(-DHAVE_QT_OPENGL)
else() else()
ocv_include_directories(${OPENGL_INCLUDE_DIR}) ocv_include_directories(${OPENGL_INCLUDE_DIR})
endif() endif()

@ -225,3 +225,9 @@
/* Clp support */ /* Clp support */
#cmakedefine HAVE_CLP #cmakedefine HAVE_CLP
/* Qt support */
#cmakedefine HAVE_QT
/* Qt OpenGL support */
#cmakedefine HAVE_QT_OPENGL

@ -183,7 +183,7 @@
{% if theme_lang == 'c' %} {% if theme_lang == 'c' %}
{% endif %} {% endif %}
{% if theme_lang == 'cpp' %} {% if theme_lang == 'cpp' %}
<li>Try the <a href="http://docs.opencv.org/trunk/opencv_cheatsheet.pdf">Cheatsheet</a>.</li> <li>Try the <a href="http://docs.opencv.org/opencv_cheatsheet.pdf">Cheatsheet</a>.</li>
{% endif %} {% endif %}
{% if theme_lang == 'py' %} {% if theme_lang == 'py' %}
<li>Try the <a href="cookbook.html">Cookbook</a>.</li> <li>Try the <a href="cookbook.html">Cookbook</a>.</li>

@ -284,120 +284,122 @@ latex_domain_indices = True
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [
('index', 'opencv', u'The OpenCV Reference Manual', ('index', 'opencv', u'The OpenCV Reference Manual',
[u'opencv-dev@itseez.com'], 1) [u'admin@opencv.org'], 1)
] ]
# ---- External links for tutorials ----------------- # ---- External links for tutorials -----------------
extlinks = { extlinks = {
'basicstructures' : ('http://opencv.itseez.com/modules/core/doc/basic_structures.html#%s', None), 'basicstructures' : ('http://docs.opencv.org/modules/core/doc/basic_structures.html#%s', None),
'oldbasicstructures' : ('http://opencv.itseez.com/modules/core/doc/old_basic_structures.html#%s', None), 'oldbasicstructures' : ('http://docs.opencv.org/modules/core/doc/old_basic_structures.html#%s', None),
'readwriteimagevideo' : ('http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html#%s', None), 'readwriteimagevideo' : ('http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#%s', None),
'operationsonarrays' : ('http://opencv.itseez.com/modules/core/doc/operations_on_arrays.html#%s', None), 'operationsonarrays' : ('http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#%s', None),
'utilitysystemfunctions':('http://opencv.itseez.com/modules/core/doc/utility_and_system_functions_and_macros.html#%s', None), 'utilitysystemfunctions':('http://docs.opencv.org/modules/core/doc/utility_and_system_functions_and_macros.html#%s', None),
'imgprocfilter':('http://opencv.itseez.com/modules/imgproc/doc/filtering.html#%s', None), 'imgprocfilter':('http://docs.opencv.org/modules/imgproc/doc/filtering.html#%s', None),
'svms':('http://opencv.itseez.com/modules/ml/doc/support_vector_machines.html#%s', None), 'svms':('http://docs.opencv.org/modules/ml/doc/support_vector_machines.html#%s', None),
'drawingfunc':('http://opencv.itseez.com/modules/core/doc/drawing_functions.html#%s', None), 'drawingfunc':('http://docs.opencv.org/modules/core/doc/drawing_functions.html#%s', None),
'xmlymlpers':('http://opencv.itseez.com/modules/core/doc/xml_yaml_persistence.html#%s', None), 'xmlymlpers':('http://docs.opencv.org/modules/core/doc/xml_yaml_persistence.html#%s', None),
'hgvideo' : ('http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html#%s', None), 'hgvideo' : ('http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#%s', None),
'gpuinit' : ('http://opencv.itseez.com/modules/gpu/doc/initalization_and_information.html#%s', None), 'gpuinit' : ('http://docs.opencv.org/modules/gpu/doc/initalization_and_information.html#%s', None),
'gpudatastructure' : ('http://opencv.itseez.com/modules/gpu/doc/data_structures.html#%s', None), 'gpudatastructure' : ('http://docs.opencv.org/modules/gpu/doc/data_structures.html#%s', None),
'gpuopmatrices' : ('http://opencv.itseez.com/modules/gpu/doc/operations_on_matrices.html#%s', None), 'gpuopmatrices' : ('http://docs.opencv.org/modules/gpu/doc/operations_on_matrices.html#%s', None),
'gpuperelement' : ('http://opencv.itseez.com/modules/gpu/doc/per_element_operations.html#%s', None), 'gpuperelement' : ('http://docs.opencv.org/modules/gpu/doc/per_element_operations.html#%s', None),
'gpuimgproc' : ('http://opencv.itseez.com/modules/gpu/doc/image_processing.html#%s', None), 'gpuimgproc' : ('http://docs.opencv.org/modules/gpu/doc/image_processing.html#%s', None),
'gpumatrixreduct' : ('http://opencv.itseez.com/modules/gpu/doc/matrix_reductions.html#%s', None), 'gpumatrixreduct' : ('http://docs.opencv.org/modules/gpu/doc/matrix_reductions.html#%s', None),
'filtering':('http://opencv.itseez.com/modules/imgproc/doc/filtering.html#%s', None), 'filtering':('http://docs.opencv.org/modules/imgproc/doc/filtering.html#%s', None),
'flann' : ('http://opencv.itseez.com/modules/flann/doc/flann_fast_approximate_nearest_neighbor_search.html#%s', None ), 'flann' : ('http://docs.opencv.org/modules/flann/doc/flann_fast_approximate_nearest_neighbor_search.html#%s', None ),
'calib3d' : ('http://opencv.itseez.com/trunk/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#%s', None ), 'calib3d' : ('http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#%s', None ),
'feature2d' : ('http://opencv.itseez.com/trunk/modules/imgproc/doc/feature_detection.html#%s', None ), 'feature2d' : ('http://docs.opencv.org/modules/imgproc/doc/feature_detection.html#%s', None ),
'imgproc_geometric' : ('http://opencv.itseez.com/trunk/modules/imgproc/doc/geometric_transformations.html#%s', None ), 'imgproc_geometric' : ('http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html#%s', None ),
'opencv_group' : ('http://tech.groups.yahoo.com/group/OpenCV/%s', None), # 'opencv_group' : ('http://answers.opencv.org/%s', None),
'opencv_qa' : ('http://answers.opencv.org/%s', None),
'cvt_color': ('http://opencv.itseez.com/modules/imgproc/doc/miscellaneous_transformations.html?highlight=cvtcolor#cvtcolor%s', None), 'how_to_contribute' : ('http://code.opencv.org/projects/opencv/wiki/How_to_contribute/%s', None),
'imread': ('http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=imread#imread%s', None),
'imwrite': ('http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=imwrite#imwrite%s', None), 'cvt_color': ('http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html?highlight=cvtcolor#cvtcolor%s', None),
'imshow': ('http://opencv.itseez.com/modules/highgui/doc/user_interface.html?highlight=imshow#imshow%s', None), 'imread': ('http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=imread#imread%s', None),
'named_window': ('http://opencv.itseez.com/modules/highgui/doc/user_interface.html?highlight=namedwindow#namedwindow%s', None), 'imwrite': ('http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=imwrite#imwrite%s', None),
'wait_key': ('http://opencv.itseez.com/modules/highgui/doc/user_interface.html?highlight=waitkey#waitkey%s', None), 'imshow': ('http://docs.opencv.org/modules/highgui/doc/user_interface.html?highlight=imshow#imshow%s', None),
'add_weighted': ('http://opencv.itseez.com/modules/core/doc/operations_on_arrays.html?highlight=addweighted#addweighted%s', None), 'named_window': ('http://docs.opencv.org/modules/highgui/doc/user_interface.html?highlight=namedwindow#namedwindow%s', None),
'saturate_cast': ('http://opencv.itseez.com/modules/core/doc/utility_and_system_functions_and_macros.html?highlight=saturate_cast#saturate-cast%s', None), 'wait_key': ('http://docs.opencv.org/modules/highgui/doc/user_interface.html?highlight=waitkey#waitkey%s', None),
'mat_zeros': ('http://opencv.itseez.com/modules/core/doc/basic_structures.html?highlight=zeros#mat-zeros%s', None), 'add_weighted': ('http://docs.opencv.org/modules/core/doc/operations_on_arrays.html?highlight=addweighted#addweighted%s', None),
'convert_to': ('http://opencv.itseez.com/modules/core/doc/basic_structures.html#mat-convertto%s', None), 'saturate_cast': ('http://docs.opencv.org/modules/core/doc/utility_and_system_functions_and_macros.html?highlight=saturate_cast#saturate-cast%s', None),
'create_trackbar': ('http://opencv.itseez.com/modules/highgui/doc/user_interface.html?highlight=createtrackbar#createtrackbar%s', None), 'mat_zeros': ('http://docs.opencv.org/modules/core/doc/basic_structures.html?highlight=zeros#mat-zeros%s', None),
'point': ('http://opencv.itseez.com/modules/core/doc/basic_structures.html#point%s', None), 'convert_to': ('http://docs.opencv.org/modules/core/doc/basic_structures.html#mat-convertto%s', None),
'scalar': ('http://opencv.itseez.com/modules/core/doc/basic_structures.html#scalar%s', None), 'create_trackbar': ('http://docs.opencv.org/modules/highgui/doc/user_interface.html?highlight=createtrackbar#createtrackbar%s', None),
'line': ('http://opencv.itseez.com/modules/core/doc/drawing_functions.html#line%s', None), 'point': ('http://docs.opencv.org/modules/core/doc/basic_structures.html#point%s', None),
'ellipse': ('http://opencv.itseez.com/modules/core/doc/drawing_functions.html#ellipse%s', None), 'scalar': ('http://docs.opencv.org/modules/core/doc/basic_structures.html#scalar%s', None),
'rectangle': ('http://opencv.itseez.com/modules/core/doc/drawing_functions.html#rectangle%s', None), 'line': ('http://docs.opencv.org/modules/core/doc/drawing_functions.html#line%s', None),
'circle': ('http://opencv.itseez.com/modules/core/doc/drawing_functions.html#circle%s', None), 'ellipse': ('http://docs.opencv.org/modules/core/doc/drawing_functions.html#ellipse%s', None),
'fill_poly': ('http://opencv.itseez.com/modules/core/doc/drawing_functions.html#fillpoly%s', None), 'rectangle': ('http://docs.opencv.org/modules/core/doc/drawing_functions.html#rectangle%s', None),
'rng': ('http://opencv.itseez.com/modules/core/doc/operations_on_arrays.html?highlight=rng#rng%s', None), 'circle': ('http://docs.opencv.org/modules/core/doc/drawing_functions.html#circle%s', None),
'put_text': ('http://opencv.itseez.com/modules/core/doc/drawing_functions.html#puttext%s', None), 'fill_poly': ('http://docs.opencv.org/modules/core/doc/drawing_functions.html#fillpoly%s', None),
'gaussian_blur': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=gaussianblur#gaussianblur%s', None), 'rng': ('http://docs.opencv.org/modules/core/doc/operations_on_arrays.html?highlight=rng#rng%s', None),
'blur': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=blur#blur%s', None), 'put_text': ('http://docs.opencv.org/modules/core/doc/drawing_functions.html#puttext%s', None),
'median_blur': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=medianblur#medianblur%s', None), 'gaussian_blur': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=gaussianblur#gaussianblur%s', None),
'bilateral_filter': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=bilateralfilter#bilateralfilter%s', None), 'blur': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=blur#blur%s', None),
'erode': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=erode#erode%s', None), 'median_blur': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=medianblur#medianblur%s', None),
'dilate': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=dilate#dilate%s', None), 'bilateral_filter': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=bilateralfilter#bilateralfilter%s', None),
'get_structuring_element': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=getstructuringelement#getstructuringelement%s', None), 'erode': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=erode#erode%s', None),
'flood_fill': ( 'http://opencv.itseez.com/modules/imgproc/doc/miscellaneous_transformations.html?highlight=floodfill#floodfill%s', None), 'dilate': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=dilate#dilate%s', None),
'morphology_ex': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=morphologyex#morphologyex%s', None), 'get_structuring_element': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=getstructuringelement#getstructuringelement%s', None),
'pyr_down': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=pyrdown#pyrdown%s', None), 'flood_fill': ( 'http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html?highlight=floodfill#floodfill%s', None),
'pyr_up': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=pyrup#pyrup%s', None), 'morphology_ex': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=morphologyex#morphologyex%s', None),
'resize': ('http://opencv.itseez.com/modules/imgproc/doc/geometric_transformations.html?highlight=resize#resize%s', None), 'pyr_down': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=pyrdown#pyrdown%s', None),
'threshold': ('http://opencv.itseez.com/modules/imgproc/doc/miscellaneous_transformations.html?highlight=threshold#threshold%s', None), 'pyr_up': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=pyrup#pyrup%s', None),
'filter2d': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=filter2d#filter2d%s', None), 'resize': ('http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html?highlight=resize#resize%s', None),
'copy_make_border': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=copymakeborder#copymakeborder%s', None), 'threshold': ('http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html?highlight=threshold#threshold%s', None),
'sobel': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=sobel#sobel%s', None), 'filter2d': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=filter2d#filter2d%s', None),
'scharr': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=scharr#scharr%s', None), 'copy_make_border': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=copymakeborder#copymakeborder%s', None),
'laplacian': ('http://opencv.itseez.com/modules/imgproc/doc/filtering.html?highlight=laplacian#laplacian%s', None), 'sobel': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=sobel#sobel%s', None),
'canny': ('http://opencv.itseez.com/modules/imgproc/doc/feature_detection.html?highlight=canny#canny%s', None), 'scharr': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=scharr#scharr%s', None),
'copy_to': ('http://opencv.itseez.com/modules/core/doc/basic_structures.html?highlight=copyto#mat-copyto%s', None), 'laplacian': ('http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=laplacian#laplacian%s', None),
'hough_lines' : ('http://opencv.itseez.com/modules/imgproc/doc/feature_detection.html?highlight=houghlines#houghlines%s', None), 'canny': ('http://docs.opencv.org/modules/imgproc/doc/feature_detection.html?highlight=canny#canny%s', None),
'hough_lines_p' : ('http://opencv.itseez.com/modules/imgproc/doc/feature_detection.html?highlight=houghlinesp#houghlinesp%s', None), 'copy_to': ('http://docs.opencv.org/modules/core/doc/basic_structures.html?highlight=copyto#mat-copyto%s', None),
'hough_circles' : ('http://opencv.itseez.com/modules/imgproc/doc/feature_detection.html?highlight=houghcircles#houghcircles%s', None), 'hough_lines' : ('http://docs.opencv.org/modules/imgproc/doc/feature_detection.html?highlight=houghlines#houghlines%s', None),
'remap' : ('http://opencv.itseez.com/modules/imgproc/doc/geometric_transformations.html?highlight=remap#remap%s', None), 'hough_lines_p' : ('http://docs.opencv.org/modules/imgproc/doc/feature_detection.html?highlight=houghlinesp#houghlinesp%s', None),
'warp_affine' : ('http://opencv.itseez.com/modules/imgproc/doc/geometric_transformations.html?highlight=warpaffine#warpaffine%s' , None), 'hough_circles' : ('http://docs.opencv.org/modules/imgproc/doc/feature_detection.html?highlight=houghcircles#houghcircles%s', None),
'get_rotation_matrix_2d' : ('http://opencv.itseez.com/modules/imgproc/doc/geometric_transformations.html?highlight=getrotationmatrix2d#getrotationmatrix2d%s', None), 'remap' : ('http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html?highlight=remap#remap%s', None),
'get_affine_transform' : ('http://opencv.itseez.com/modules/imgproc/doc/geometric_transformations.html?highlight=getaffinetransform#getaffinetransform%s', None), 'warp_affine' : ('http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html?highlight=warpaffine#warpaffine%s' , None),
'equalize_hist' : ('http://opencv.itseez.com/modules/imgproc/doc/histograms.html?highlight=equalizehist#equalizehist%s', None), 'get_rotation_matrix_2d' : ('http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html?highlight=getrotationmatrix2d#getrotationmatrix2d%s', None),
'split' : ('http://opencv.itseez.com/modules/core/doc/operations_on_arrays.html?highlight=split#split%s', None), 'get_affine_transform' : ('http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html?highlight=getaffinetransform#getaffinetransform%s', None),
'calc_hist' : ('http://opencv.itseez.com/modules/imgproc/doc/histograms.html?highlight=calchist#calchist%s', None), 'equalize_hist' : ('http://docs.opencv.org/modules/imgproc/doc/histograms.html?highlight=equalizehist#equalizehist%s', None),
'normalize' : ('http://opencv.itseez.com/modules/core/doc/operations_on_arrays.html?highlight=normalize#normalize%s', None), 'split' : ('http://docs.opencv.org/modules/core/doc/operations_on_arrays.html?highlight=split#split%s', None),
'match_template' : ('http://opencv.itseez.com/modules/imgproc/doc/object_detection.html?highlight=matchtemplate#matchtemplate%s', None), 'calc_hist' : ('http://docs.opencv.org/modules/imgproc/doc/histograms.html?highlight=calchist#calchist%s', None),
'min_max_loc' : ('http://opencv.itseez.com/modules/core/doc/operations_on_arrays.html?highlight=minmaxloc#minmaxloc%s', None), 'normalize' : ('http://docs.opencv.org/modules/core/doc/operations_on_arrays.html?highlight=normalize#normalize%s', None),
'mix_channels' : ( 'http://opencv.itseez.com/modules/core/doc/operations_on_arrays.html?highlight=mixchannels#mixchannels%s', None), 'match_template' : ('http://docs.opencv.org/modules/imgproc/doc/object_detection.html?highlight=matchtemplate#matchtemplate%s', None),
'calc_back_project' : ('http://opencv.itseez.com/modules/imgproc/doc/histograms.html?highlight=calcbackproject#calcbackproject%s', None), 'min_max_loc' : ('http://docs.opencv.org/modules/core/doc/operations_on_arrays.html?highlight=minmaxloc#minmaxloc%s', None),
'compare_hist' : ('http://opencv.itseez.com/modules/imgproc/doc/histograms.html?highlight=comparehist#comparehist%s', None), 'mix_channels' : ( 'http://docs.opencv.org/modules/core/doc/operations_on_arrays.html?highlight=mixchannels#mixchannels%s', None),
'corner_harris' : ('http://opencv.itseez.com/modules/imgproc/doc/feature_detection.html?highlight=cornerharris#cornerharris%s', None), 'calc_back_project' : ('http://docs.opencv.org/modules/imgproc/doc/histograms.html?highlight=calcbackproject#calcbackproject%s', None),
'good_features_to_track' : ('http://opencv.itseez.com/modules/imgproc/doc/feature_detection.html?highlight=goodfeaturestotrack#goodfeaturestotrack%s', None), 'compare_hist' : ('http://docs.opencv.org/modules/imgproc/doc/histograms.html?highlight=comparehist#comparehist%s', None),
'corner_min_eigenval' : ('http://opencv.itseez.com/modules/imgproc/doc/feature_detection.html?highlight=cornermineigenval#cornermineigenval%s', None), 'corner_harris' : ('http://docs.opencv.org/modules/imgproc/doc/feature_detection.html?highlight=cornerharris#cornerharris%s', None),
'corner_eigenvals_and_vecs' : ('http://opencv.itseez.com/modules/imgproc/doc/feature_detection.html?highlight=cornereigenvalsandvecs#cornereigenvalsandvecs%s', None), 'good_features_to_track' : ('http://docs.opencv.org/modules/imgproc/doc/feature_detection.html?highlight=goodfeaturestotrack#goodfeaturestotrack%s', None),
'corner_sub_pix' : ('http://opencv.itseez.com/modules/imgproc/doc/feature_detection.html?highlight=cornersubpix#cornersubpix%s', None), 'corner_min_eigenval' : ('http://docs.opencv.org/modules/imgproc/doc/feature_detection.html?highlight=cornermineigenval#cornermineigenval%s', None),
'find_contours' : ('http://opencv.itseez.com/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=findcontours#findcontours%s', None), 'corner_eigenvals_and_vecs' : ('http://docs.opencv.org/modules/imgproc/doc/feature_detection.html?highlight=cornereigenvalsandvecs#cornereigenvalsandvecs%s', None),
'convex_hull' : ('http://opencv.itseez.com/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=convexhull#convexhull%s', None), 'corner_sub_pix' : ('http://docs.opencv.org/modules/imgproc/doc/feature_detection.html?highlight=cornersubpix#cornersubpix%s', None),
'draw_contours' : ('http://opencv.itseez.com/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=drawcontours#drawcontours%s', None), 'find_contours' : ('http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=findcontours#findcontours%s', None),
'bounding_rect' : ('http://opencv.itseez.com/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=boundingrect#boundingrect%s', None), 'convex_hull' : ('http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=convexhull#convexhull%s', None),
'min_enclosing_circle' : ('http://opencv.itseez.com/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=minenclosingcircle#minenclosingcircle%s', None), 'draw_contours' : ('http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=drawcontours#drawcontours%s', None),
'min_area_rect' : ('http://opencv.itseez.com/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=minarearect#minarearect%s', None), 'bounding_rect' : ('http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=boundingrect#boundingrect%s', None),
'fit_ellipse' : ('http://opencv.itseez.com/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=fitellipse#fitellipse%s', None), 'min_enclosing_circle' : ('http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=minenclosingcircle#minenclosingcircle%s', None),
'moments' : ('http://opencv.itseez.com/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=moments#moments%s', None), 'min_area_rect' : ('http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=minarearect#minarearect%s', None),
'contour_area' : ('http://opencv.itseez.com/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=contourarea#contourarea%s', None), 'fit_ellipse' : ('http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=fitellipse#fitellipse%s', None),
'arc_length' : ('http://opencv.itseez.com/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=arclength#arclength%s', None), 'moments' : ('http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=moments#moments%s', None),
'point_polygon_test' : ('http://opencv.itseez.com/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=pointpolygontest#pointpolygontest%s', None), 'contour_area' : ('http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=contourarea#contourarea%s', None),
'feature_detector' : ( 'http://opencv.itseez.com/modules/features2d/doc/common_interfaces_of_feature_detectors.html?highlight=featuredetector#FeatureDetector%s', None), 'arc_length' : ('http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=arclength#arclength%s', None),
'feature_detector_detect' : ('http://opencv.itseez.com/modules/features2d/doc/common_interfaces_of_feature_detectors.html?highlight=detect#featuredetector-detect%s', None ), 'point_polygon_test' : ('http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=pointpolygontest#pointpolygontest%s', None),
'surf_feature_detector' : ('http://opencv.itseez.com/modules/features2d/doc/common_interfaces_of_feature_detectors.html?highlight=surffeaturedetector#surffeaturedetector%s', None ), 'feature_detector' : ( 'http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_feature_detectors.html?highlight=featuredetector#FeatureDetector%s', None),
'draw_keypoints' : ('http://opencv.itseez.com/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html?highlight=drawkeypoints#drawkeypoints%s', None ), 'feature_detector_detect' : ('http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_feature_detectors.html?highlight=detect#featuredetector-detect%s', None ),
'descriptor_extractor': ( 'http://opencv.itseez.com/modules/features2d/doc/common_interfaces_of_descriptor_extractors.html?highlight=descriptorextractor#descriptorextractor%s', None ), 'surf_feature_detector' : ('http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_feature_detectors.html?highlight=surffeaturedetector#surffeaturedetector%s', None ),
'descriptor_extractor_compute' : ( 'http://opencv.itseez.com/modules/features2d/doc/common_interfaces_of_descriptor_extractors.html?highlight=compute#descriptorextractor-compute%s', None ), 'draw_keypoints' : ('http://docs.opencv.org/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html?highlight=drawkeypoints#drawkeypoints%s', None ),
'surf_descriptor_extractor' : ( 'http://opencv.itseez.com/modules/features2d/doc/common_interfaces_of_descriptor_extractors.html?highlight=surfdescriptorextractor#surfdescriptorextractor%s', None ), 'descriptor_extractor': ( 'http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_descriptor_extractors.html?highlight=descriptorextractor#descriptorextractor%s', None ),
'draw_matches' : ( 'http://opencv.itseez.com/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html?highlight=drawmatches#drawmatches%s', None ), 'descriptor_extractor_compute' : ( 'http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_descriptor_extractors.html?highlight=compute#descriptorextractor-compute%s', None ),
'find_homography' : ('http://opencv.itseez.com/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html?highlight=findhomography#findhomography%s', None), 'surf_descriptor_extractor' : ( 'http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_descriptor_extractors.html?highlight=surfdescriptorextractor#surfdescriptorextractor%s', None ),
'perspective_transform' : ('http://opencv.itseez.com/modules/core/doc/operations_on_arrays.html?highlight=perspectivetransform#perspectivetransform%s', None ), 'draw_matches' : ( 'http://docs.opencv.org/modules/features2d/doc/drawing_function_of_keypoints_and_matches.html?highlight=drawmatches#drawmatches%s', None ),
'flann_based_matcher' : ('http://opencv.itseez.com/modules/features2d/doc/common_interfaces_of_descriptor_matchers.html?highlight=flannbasedmatcher#flannbasedmatcher%s', None), 'find_homography' : ('http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html?highlight=findhomography#findhomography%s', None),
'brute_force_matcher' : ('http://opencv.itseez.com/modules/features2d/doc/common_interfaces_of_descriptor_matchers.html?highlight=bruteforcematcher#bruteforcematcher%s', None ), 'perspective_transform' : ('http://docs.opencv.org/modules/core/doc/operations_on_arrays.html?highlight=perspectivetransform#perspectivetransform%s', None ),
'cascade_classifier' : ('http://opencv.itseez.com/modules/objdetect/doc/cascade_classification.html?highlight=cascadeclassifier#cascadeclassifier%s', None ), 'flann_based_matcher' : ('http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_descriptor_matchers.html?highlight=flannbasedmatcher#flannbasedmatcher%s', None),
'cascade_classifier_load' : ('http://opencv.itseez.com/modules/objdetect/doc/cascade_classification.html?highlight=load#cascadeclassifier-load%s', None ), 'brute_force_matcher' : ('http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_descriptor_matchers.html?highlight=bruteforcematcher#bruteforcematcher%s', None ),
'cascade_classifier_detect_multiscale' : ('http://opencv.itseez.com/modules/objdetect/doc/cascade_classification.html?highlight=detectmultiscale#cascadeclassifier-detectmultiscale%s', None ) 'cascade_classifier' : ('http://docs.opencv.org/modules/objdetect/doc/cascade_classification.html?highlight=cascadeclassifier#cascadeclassifier%s', None ),
'cascade_classifier_load' : ('http://docs.opencv.org/modules/objdetect/doc/cascade_classification.html?highlight=load#cascadeclassifier-load%s', None ),
'cascade_classifier_detect_multiscale' : ('http://docs.opencv.org/modules/objdetect/doc/cascade_classification.html?highlight=detectmultiscale#cascadeclassifier-detectmultiscale%s', None )
} }

@ -1,3 +1,3 @@
.. note:: .. note::
Unfortunetly we have no tutorials into this section. Nevertheless, our tutorial writting team is working on it. If you have a tutorial suggestion or you have writen yourself a tutorial (or coded a sample code) that you would like to see here please contact us via our :opencv_group:`user group <>`. Unfortunetly we have no tutorials into this section. And you can help us with that, since OpenCV is a community effort. If you have a tutorial suggestion or you have written a tutorial yourself (or coded a sample code) that you would like to see here, please contact follow these instructions: :ref:`howToWriteTutorial` and :how_to_contribute:`How to contribute <>`.

File diff suppressed because one or more lines are too long

@ -48,10 +48,10 @@ The structure of package contents looks as follows:
:: ::
OpenCV-2.4.5-android-sdk OpenCV-2.4.6-android-sdk
|_ apk |_ apk
| |_ OpenCV_2.4.5_binary_pack_armv7a.apk | |_ OpenCV_2.4.6_binary_pack_armv7a.apk
| |_ OpenCV_2.4.5_Manager_2.7_XXX.apk | |_ OpenCV_2.4.6_Manager_2.8_XXX.apk
| |
|_ doc |_ doc
|_ samples |_ samples
@ -98,7 +98,7 @@ The structure of package contents looks as follows:
* :file:`doc` folder contains various OpenCV documentation in PDF format. * :file:`doc` folder contains various OpenCV documentation in PDF format.
It's also available online at http://docs.opencv.org. It's also available online at http://docs.opencv.org.
.. note:: The most recent docs (nightly build) are at http://docs.opencv.org/trunk/. .. note:: The most recent docs (nightly build) are at http://docs.opencv.org/2.4.
Generally, it's more up-to-date, but can refer to not-yet-released functionality. Generally, it's more up-to-date, but can refer to not-yet-released functionality.
.. TODO: I'm not sure that this is the best place to talk about OpenCV Manager .. TODO: I'm not sure that this is the best place to talk about OpenCV Manager
@ -157,10 +157,10 @@ Get the OpenCV4Android SDK
.. code-block:: bash .. code-block:: bash
unzip ~/Downloads/OpenCV-2.4.5-android-sdk.zip unzip ~/Downloads/OpenCV-2.4.6-android-sdk.zip
.. |opencv_android_bin_pack| replace:: :file:`OpenCV-2.4.5-android-sdk.zip` .. |opencv_android_bin_pack| replace:: :file:`OpenCV-2.4.6-android-sdk.zip`
.. _opencv_android_bin_pack_url: http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.5/OpenCV-2.4.5-android-sdk.zip/download .. _opencv_android_bin_pack_url: http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.6/OpenCV-2.4.6-android-sdk.zip/download
.. |opencv_android_bin_pack_url| replace:: |opencv_android_bin_pack| .. |opencv_android_bin_pack_url| replace:: |opencv_android_bin_pack|
.. |seven_zip| replace:: 7-Zip .. |seven_zip| replace:: 7-Zip
.. _seven_zip: http://www.7-zip.org/ .. _seven_zip: http://www.7-zip.org/
@ -295,7 +295,7 @@ Well, running samples from Eclipse is very simple:
.. code-block:: sh .. code-block:: sh
:linenos: :linenos:
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.5_Manager_2.7_armv7a-neon.apk <Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.6_Manager_2.8_armv7a-neon.apk
.. note:: ``armeabi``, ``armv7a-neon``, ``arm7a-neon-android8``, ``mips`` and ``x86`` stand for .. note:: ``armeabi``, ``armv7a-neon``, ``arm7a-neon-android8``, ``mips`` and ``x86`` stand for
platform targets: platform targets:

@ -55,14 +55,14 @@ Manager to access OpenCV libraries externally installed in the target system.
:guilabel:`File -> Import -> Existing project in your workspace`. :guilabel:`File -> Import -> Existing project in your workspace`.
Press :guilabel:`Browse` button and locate OpenCV4Android SDK Press :guilabel:`Browse` button and locate OpenCV4Android SDK
(:file:`OpenCV-2.4.5-android-sdk/sdk`). (:file:`OpenCV-2.4.6-android-sdk/sdk`).
.. image:: images/eclipse_opencv_dependency0.png .. image:: images/eclipse_opencv_dependency0.png
:alt: Add dependency from OpenCV library :alt: Add dependency from OpenCV library
:align: center :align: center
#. In application project add a reference to the OpenCV Java SDK in #. In application project add a reference to the OpenCV Java SDK in
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.5``. :guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.6``.
.. image:: images/eclipse_opencv_dependency1.png .. image:: images/eclipse_opencv_dependency1.png
:alt: Add dependency from OpenCV library :alt: Add dependency from OpenCV library
@ -101,7 +101,7 @@ See the "15-puzzle" OpenCV sample for details.
public void onResume() public void onResume()
{ {
super.onResume(); super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_5, this, mLoaderCallback); OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback);
} }
... ...
@ -128,27 +128,27 @@ described above.
#. Add the OpenCV library project to your workspace the same way as for the async initialization #. Add the OpenCV library project to your workspace the same way as for the async initialization
above. Use menu :guilabel:`File -> Import -> Existing project in your workspace`, above. Use menu :guilabel:`File -> Import -> Existing project in your workspace`,
press :guilabel:`Browse` button and select OpenCV SDK path press :guilabel:`Browse` button and select OpenCV SDK path
(:file:`OpenCV-2.4.5-android-sdk/sdk`). (:file:`OpenCV-2.4.6-android-sdk/sdk`).
.. image:: images/eclipse_opencv_dependency0.png .. image:: images/eclipse_opencv_dependency0.png
:alt: Add dependency from OpenCV library :alt: Add dependency from OpenCV library
:align: center :align: center
#. In the application project add a reference to the OpenCV4Android SDK in #. In the application project add a reference to the OpenCV4Android SDK in
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.5``; :guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.6``;
.. image:: images/eclipse_opencv_dependency1.png .. image:: images/eclipse_opencv_dependency1.png
:alt: Add dependency from OpenCV library :alt: Add dependency from OpenCV library
:align: center :align: center
#. If your application project **doesn't have a JNI part**, just copy the corresponding OpenCV #. If your application project **doesn't have a JNI part**, just copy the corresponding OpenCV
native libs from :file:`<OpenCV-2.4.5-android-sdk>/sdk/native/libs/<target_arch>` to your native libs from :file:`<OpenCV-2.4.6-android-sdk>/sdk/native/libs/<target_arch>` to your
project directory to folder :file:`libs/<target_arch>`. project directory to folder :file:`libs/<target_arch>`.
In case of the application project **with a JNI part**, instead of manual libraries copying you In case of the application project **with a JNI part**, instead of manual libraries copying you
need to modify your ``Android.mk`` file: need to modify your ``Android.mk`` file:
add the following two code lines after the ``"include $(CLEAR_VARS)"`` and before add the following two code lines after the ``"include $(CLEAR_VARS)"`` and before
``"include path_to_OpenCV-2.4.5-android-sdk/sdk/native/jni/OpenCV.mk"`` ``"include path_to_OpenCV-2.4.6-android-sdk/sdk/native/jni/OpenCV.mk"``
.. code-block:: make .. code-block:: make
:linenos: :linenos:
@ -221,7 +221,7 @@ taken:
.. code-block:: make .. code-block:: make
include C:\Work\OpenCV4Android\OpenCV-2.4.5-android-sdk\sdk\native\jni\OpenCV.mk include C:\Work\OpenCV4Android\OpenCV-2.4.6-android-sdk\sdk\native\jni\OpenCV.mk
Should be inserted into the :file:`jni/Android.mk` file **after** this line: Should be inserted into the :file:`jni/Android.mk` file **after** this line:
@ -379,7 +379,7 @@ result.
public void onResume() public void onResume()
{ {
super.onResume(); super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback); OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback);
} }
#. Defines that your activity implements ``CvViewFrameListener2`` interface and fix activity related #. Defines that your activity implements ``CvViewFrameListener2`` interface and fix activity related

File diff suppressed because one or more lines are too long

@ -37,7 +37,7 @@ Building OpenCV from Source, using CMake and Command Line
.. code-block:: bash .. code-block:: bash
cd ~/<my_working_directory> cd ~/<my_working_directory>
python opencv/ios/build_framework.py ios python opencv/platforms/ios/build_framework.py ios
If everything's fine, a few minutes later you will get ~/<my_working_directory>/ios/opencv2.framework. You can add this framework to your Xcode projects. If everything's fine, a few minutes later you will get ~/<my_working_directory>/ios/opencv2.framework. You can add this framework to your Xcode projects.

@ -292,7 +292,7 @@ Building the library
This will create an *Install* directory inside the *Build* one collecting all the built binaries into a single place. Use this only after you built both the *Release* and *Debug* versions. This will create an *Install* directory inside the *Build* one collecting all the built binaries into a single place. Use this only after you built both the *Release* and *Debug* versions.
To test your build just go into the :file:`Build/bin/Debug` or :file:`Build/bin/Release` directory and start a couple of applications like the *contours.exe*. If they run, you are done. Otherwise, something definitely went awfully wrong. In this case you should contact us via our :opencv_group:`user group <>`. To test your build just go into the :file:`Build/bin/Debug` or :file:`Build/bin/Release` directory and start a couple of applications like the *contours.exe*. If they run, you are done. Otherwise, something definitely went awfully wrong. In this case you should contact us at our :opencv_qa:`Q&A forum <>`.
If everything is okay the *contours.exe* output should resemble the following image (if built with Qt support): If everything is okay the *contours.exe* output should resemble the following image (if built with Qt support):
.. image:: images/WindowsQtContoursOutput.png .. image:: images/WindowsQtContoursOutput.png

@ -86,7 +86,7 @@ The names of the libraries are as follow:
opencv_(The Name of the module)(The version Number of the library you use)d.lib opencv_(The Name of the module)(The version Number of the library you use)d.lib
A full list, for the currently latest trunk version would contain: A full list, for the latest version would contain:
.. code-block:: bash .. code-block:: bash

@ -129,7 +129,7 @@ Explanation
3. **Train the SVM** 3. **Train the SVM**
We call the method `CvSVM::train <http://opencv.itseez.com/modules/ml/doc/support_vector_machines.html#cvsvm-train>`_ to build the SVM model. We call the method `CvSVM::train <http://docs.opencv.org/modules/ml/doc/support_vector_machines.html#cvsvm-train>`_ to build the SVM model.
.. code-block:: cpp .. code-block:: cpp

@ -1 +0,0 @@
cmake -GXcode -DCMAKE_TOOLCHAIN_FILE=../opencv/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake -DCMAKE_INSTALL_PREFIX=../OpenCV_iPhoneOS ../opencv

@ -1 +0,0 @@
cmake -GXcode -DCMAKE_TOOLCHAIN_FILE=../opencv/ios/cmake/Toolchains/Toolchain-iPhoneSimulator_Xcode.cmake -DCMAKE_INSTALL_PREFIX=../OpenCV_iPhoneSimulator ../opencv

@ -1,15 +0,0 @@
Assuming that your build directory is on the same level that opencv source,
From the build directory run
../opencv/ios/configure-device_xcode.sh
or
../opencv/ios/configure-simulator_xcode.sh
Then from the same folder invoke
xcodebuild -sdk iphoneos -configuration Release -target ALL_BUILD
xcodebuild -sdk iphoneos -configuration Release -target install install
or
xcodebuild -sdk iphonesimulator -configuration Release -target ALL_BUILD
xcodebuild -sdk iphonesimulator -configuration Release -target install install

@ -1,7 +1,7 @@
#include "opencv2/contrib.hpp" #include "opencv2/contrib.hpp"
#ifdef WIN32 #if defined(WIN32) || defined(_WIN32)
#include <windows.h> #include <windows.h>
#include <tchar.h> #include <tchar.h>
#else #else

@ -570,6 +570,9 @@ Various Ptr constructors.
.. ocv:function:: Ptr::Ptr(_Tp* _obj) .. ocv:function:: Ptr::Ptr(_Tp* _obj)
.. ocv:function:: Ptr::Ptr(const Ptr& ptr) .. ocv:function:: Ptr::Ptr(const Ptr& ptr)
:param _obj: Object for copy.
:param ptr: Object for copy.
Ptr::~Ptr Ptr::~Ptr
--------- ---------
The Ptr destructor. The Ptr destructor.
@ -582,6 +585,8 @@ Assignment operator.
.. ocv:function:: Ptr& Ptr::operator = (const Ptr& ptr) .. ocv:function:: Ptr& Ptr::operator = (const Ptr& ptr)
:param ptr: Object for assignment.
Decrements own reference counter (with ``release()``) and increments ptr's reference counter. Decrements own reference counter (with ``release()``) and increments ptr's reference counter.
Ptr::addref Ptr::addref
@ -1542,6 +1547,7 @@ Adds elements to the bottom of the matrix.
.. ocv:function:: void Mat::push_back( const Mat& m ) .. ocv:function:: void Mat::push_back( const Mat& m )
:param elem: Added element(s). :param elem: Added element(s).
:param m: Added line(s).
The methods add one or more elements to the bottom of the matrix. They emulate the corresponding method of the STL vector class. When ``elem`` is ``Mat`` , its type and the number of columns must be the same as in the container matrix. The methods add one or more elements to the bottom of the matrix. They emulate the corresponding method of the STL vector class. When ``elem`` is ``Mat`` , its type and the number of columns must be the same as in the container matrix.
@ -2209,7 +2215,6 @@ Various SparseMat constructors.
:param dims: Array dimensionality. :param dims: Array dimensionality.
:param _sizes: Sparce matrix size on all dementions. :param _sizes: Sparce matrix size on all dementions.
:param _type: Sparse matrix data type. :param _type: Sparse matrix data type.
:param try1d: if try1d is true and matrix is a single-column matrix (Nx1), then the sparse matrix will be 1-dimensional.
SparseMat::~SparseMat SparseMat::~SparseMat
--------------------- ---------------------
@ -2224,6 +2229,8 @@ Provides sparse matrix assignment operators.
.. ocv:function:: SparseMat& SparseMat::operator = (const SparseMat& m) .. ocv:function:: SparseMat& SparseMat::operator = (const SparseMat& m)
.. ocv:function:: SparseMat& SparseMat::operator = (const Mat& m) .. ocv:function:: SparseMat& SparseMat::operator = (const Mat& m)
:param m: Matrix for assignment.
The last variant is equivalent to the corresponding constructor with try1d=false. The last variant is equivalent to the corresponding constructor with try1d=false.
@ -2251,6 +2258,10 @@ Convert sparse matrix with possible type change and scaling.
.. ocv:function:: void SparseMat::convertTo( SparseMat& m, int rtype, double alpha=1 ) const .. ocv:function:: void SparseMat::convertTo( SparseMat& m, int rtype, double alpha=1 ) const
.. ocv:function:: void SparseMat::convertTo( Mat& m, int rtype, double alpha=1, double beta=0 ) const .. ocv:function:: void SparseMat::convertTo( Mat& m, int rtype, double alpha=1, double beta=0 ) const
:param m: Destination matrix.
:param rtype: Destination matrix type.
:param alpha: Conversion multiplier.
The first version converts arbitrary sparse matrix to dense matrix and multiplies all the matrix elements by the specified scalar. The first version converts arbitrary sparse matrix to dense matrix and multiplies all the matrix elements by the specified scalar.
The second versiob converts sparse matrix to dense matrix with optional type conversion and scaling. The second versiob converts sparse matrix to dense matrix with optional type conversion and scaling.
When rtype=-1, the destination element type will be the same as the sparse matrix element type. When rtype=-1, the destination element type will be the same as the sparse matrix element type.
@ -2343,7 +2354,7 @@ The method returns the number of matrix channels.
SparseMat::size SparseMat::size
--------------- ---------------
Returns the array of sizes or matrix size by i dimention and 0 if the matrix is not allocated. Returns the array of sizes or matrix size by i dimension and 0 if the matrix is not allocated.
.. ocv:function:: const int* SparseMat::size() const .. ocv:function:: const int* SparseMat::size() const
.. ocv:function:: int SparseMat::size(int i) const .. ocv:function:: int SparseMat::size(int i) const
@ -2371,6 +2382,11 @@ Compute element hash value from the element indices.
.. ocv:function:: size_t SparseMat::hash(int i0, int i1, int i2) const .. ocv:function:: size_t SparseMat::hash(int i0, int i1, int i2) const
.. ocv:function:: size_t SparseMat::hash(const int* idx) const .. ocv:function:: size_t SparseMat::hash(const int* idx) const
:param i0: The first dimension index.
:param i1: The second dimension index.
:param i2: The third dimension index.
:param idx: Array of element indices for multidimensional matices.
SparseMat::ptr SparseMat::ptr
-------------- --------------
Low-level element-access functions, special variants for 1D, 2D, 3D cases, and the generic one for n-D case. Low-level element-access functions, special variants for 1D, 2D, 3D cases, and the generic one for n-D case.
@ -2380,6 +2396,12 @@ Low-level element-access functions, special variants for 1D, 2D, 3D cases, and t
.. ocv:function:: uchar* SparseMat::ptr(int i0, int i1, int i2, bool createMissing, size_t* hashval=0) .. ocv:function:: uchar* SparseMat::ptr(int i0, int i1, int i2, bool createMissing, size_t* hashval=0)
.. ocv:function:: uchar* SparseMat::ptr(const int* idx, bool createMissing, size_t* hashval=0) .. ocv:function:: uchar* SparseMat::ptr(const int* idx, bool createMissing, size_t* hashval=0)
:param i0: The first dimension index.
:param i1: The second dimension index.
:param i2: The third dimension index.
:param idx: Array of element indices for multidimensional matices.
:param createMissing: Create new element with 0 value if it does not exist in SparseMat.
Return pointer to the matrix element. If the element is there (it is non-zero), the pointer to it is returned. Return pointer to the matrix element. If the element is there (it is non-zero), the pointer to it is returned.
If it is not there and ``createMissing=false``, NULL pointer is returned. If it is not there and ``createMissing=true``, If it is not there and ``createMissing=false``, NULL pointer is returned. If it is not there and ``createMissing=true``,
the new elementis created and initialized with 0. Pointer to it is returned. If the optional hashval pointer is not ``NULL``, the new elementis created and initialized with 0. Pointer to it is returned. If the optional hashval pointer is not ``NULL``,
@ -2393,6 +2415,11 @@ Erase the specified matrix element. When there is no such an element, the method
.. ocv:function:: void SparseMat::erase(int i0, int i1, int i2, size_t* hashval=0) .. ocv:function:: void SparseMat::erase(int i0, int i1, int i2, size_t* hashval=0)
.. ocv:function:: void SparseMat::erase(const int* idx, size_t* hashval=0) .. ocv:function:: void SparseMat::erase(const int* idx, size_t* hashval=0)
:param i0: The first dimension index.
:param i1: The second dimension index.
:param i2: The third dimension index.
:param idx: Array of element indices for multidimensional matices.
SparseMat\_ SparseMat\_
----------- -----------
.. ocv:class:: SparseMat_ .. ocv:class:: SparseMat_

@ -15,12 +15,18 @@ Finds centers of clusters and groups input samples around the clusters.
:param samples: Floating-point matrix of input samples, one row per sample. :param samples: Floating-point matrix of input samples, one row per sample.
:param data: Data for clustering.
:param cluster_count: Number of clusters to split the set by. :param cluster_count: Number of clusters to split the set by.
:param K: Number of clusters to split the set by.
:param labels: Input/output integer array that stores the cluster indices for every sample. :param labels: Input/output integer array that stores the cluster indices for every sample.
:param criteria: The algorithm termination criteria, that is, the maximum number of iterations and/or the desired accuracy. The accuracy is specified as ``criteria.epsilon``. As soon as each of the cluster centers moves by less than ``criteria.epsilon`` on some iteration, the algorithm stops. :param criteria: The algorithm termination criteria, that is, the maximum number of iterations and/or the desired accuracy. The accuracy is specified as ``criteria.epsilon``. As soon as each of the cluster centers moves by less than ``criteria.epsilon`` on some iteration, the algorithm stops.
:param termcrit: The algorithm termination criteria, that is, the maximum number of iterations and/or the desired accuracy.
:param attempts: Flag to specify the number of times the algorithm is executed using different initial labellings. The algorithm returns the labels that yield the best compactness (see the last function parameter). :param attempts: Flag to specify the number of times the algorithm is executed using different initial labellings. The algorithm returns the labels that yield the best compactness (see the last function parameter).
:param rng: CvRNG state initialized by RNG(). :param rng: CvRNG state initialized by RNG().
@ -35,6 +41,8 @@ Finds centers of clusters and groups input samples around the clusters.
:param centers: Output matrix of the cluster centers, one row per each cluster center. :param centers: Output matrix of the cluster centers, one row per each cluster center.
:param _centers: Output matrix of the cluster centers, one row per each cluster center.
:param compactness: The returned value that is described below. :param compactness: The returned value that is described below.
The function ``kmeans`` implements a k-means algorithm that finds the The function ``kmeans`` implements a k-means algorithm that finds the

@ -225,6 +225,8 @@ Calculates the width and height of a text string.
:param text: Input text string. :param text: Input text string.
:param text_string: Input text string in C format.
:param fontFace: Font to use. See the :ocv:func:`putText` for details. :param fontFace: Font to use. See the :ocv:func:`putText` for details.
:param fontScale: Font scale. See the :ocv:func:`putText` for details. :param fontScale: Font scale. See the :ocv:func:`putText` for details.
@ -233,6 +235,12 @@ Calculates the width and height of a text string.
:param baseLine: Output parameter - y-coordinate of the baseline relative to the bottom-most text point. :param baseLine: Output parameter - y-coordinate of the baseline relative to the bottom-most text point.
:param baseline: Output parameter - y-coordinate of the baseline relative to the bottom-most text point.
:param font: Font description in terms of old C API.
:param text_size: Output parameter - The size of a box that contains the specified text.
The function ``getTextSize`` calculates and returns the size of a box that contains the specified text. The function ``getTextSize`` calculates and returns the size of a box that contains the specified text.
That is, the following code renders some text, the tight box surrounding it, and the baseline: :: That is, the following code renders some text, the tight box surrounding it, and the baseline: ::

@ -1033,6 +1033,8 @@ Returns the determinant of a square floating-point matrix.
:param mtx: input matrix that must have ``CV_32FC1`` or ``CV_64FC1`` type and square size. :param mtx: input matrix that must have ``CV_32FC1`` or ``CV_64FC1`` type and square size.
:param mat: input matrix that must have ``CV_32FC1`` or ``CV_64FC1`` type and square size.
The function ``determinant`` calculates and returns the determinant of the specified matrix. For small matrices ( ``mtx.cols=mtx.rows<=3`` ), The function ``determinant`` calculates and returns the determinant of the specified matrix. For small matrices ( ``mtx.cols=mtx.rows<=3`` ),
the direct method is used. For larger matrices, the function uses LU factorization with partial pivoting. the direct method is used. For larger matrices, the function uses LU factorization with partial pivoting.

@ -165,6 +165,8 @@ Checks a condition at runtime and throws exception if it fails
.. ocv:function:: CV_Assert(expr) .. ocv:function:: CV_Assert(expr)
:param expr: Expression for check.
The macros ``CV_Assert`` (and ``CV_DbgAssert``) evaluate the specified expression. If it is 0, the macros raise an error (see :ocv:func:`error` ). The macro ``CV_Assert`` checks the condition in both Debug and Release configurations while ``CV_DbgAssert`` is only retained in the Debug configuration. The macros ``CV_Assert`` (and ``CV_DbgAssert``) evaluate the specified expression. If it is 0, the macros raise an error (see :ocv:func:`error` ). The macro ``CV_Assert`` checks the condition in both Debug and Release configurations while ``CV_DbgAssert`` is only retained in the Debug configuration.
@ -180,8 +182,14 @@ Signals an error and raises an exception.
:param status: Error code. Normally, it is a negative value. The list of pre-defined error codes can be found in ``cxerror.h`` . :param status: Error code. Normally, it is a negative value. The list of pre-defined error codes can be found in ``cxerror.h`` .
:param func_name: The function name where error occurs.
:param err_msg: Text of the error message. :param err_msg: Text of the error message.
:param file_name: The file name where error occurs.
:param line: The line number where error occurs.
:param args: ``printf`` -like formatted error message in parentheses. :param args: ``printf`` -like formatted error message in parentheses.
The function and the helper macros ``CV_Error`` and ``CV_Error_``: :: The function and the helper macros ``CV_Error`` and ``CV_Error_``: ::
@ -241,6 +249,7 @@ Allocates an aligned memory buffer.
.. ocv:cfunction:: void* cvAlloc( size_t size ) .. ocv:cfunction:: void* cvAlloc( size_t size )
:param size: Allocated buffer size. :param size: Allocated buffer size.
:param bufSize: Allocated buffer size.
The function allocates the buffer of the specified size and returns it. When the buffer size is 16 bytes or more, the returned buffer is aligned to 16 bytes. The function allocates the buffer of the specified size and returns it. When the buffer size is 16 bytes or more, the returned buffer is aligned to 16 bytes.

@ -181,6 +181,17 @@ Opens a file.
.. ocv:function:: bool FileStorage::open(const String& filename, int flags, const String& encoding=String()) .. ocv:function:: bool FileStorage::open(const String& filename, int flags, const String& encoding=String())
:param filename: Name of the file to open or the text string to read the data from.
Extension of the file (``.xml`` or ``.yml``/``.yaml``) determines its format (XML or YAML respectively).
Also you can append ``.gz`` to work with compressed files, for example ``myHugeMatrix.xml.gz``.
If both ``FileStorage::WRITE`` and ``FileStorage::MEMORY`` flags are specified, ``source``
is used just to specify the output file format (e.g. ``mydata.xml``, ``.yml`` etc.).
:param flags: Mode of operation. See FileStorage constructor for more details.
:param encoding: Encoding of the file. Note that UTF-16 XML encoding is not supported currently and you should use 8-bit encoding instead of it.
See description of parameters in :ocv:func:`FileStorage::FileStorage`. The method calls :ocv:func:`FileStorage::release` before opening the file. See description of parameters in :ocv:func:`FileStorage::FileStorage`. The method calls :ocv:func:`FileStorage::release` before opening the file.

@ -1130,8 +1130,6 @@ public:
//! converts dense 2d matrix to the sparse form //! converts dense 2d matrix to the sparse form
/*! /*!
\param m the input matrix \param m the input matrix
\param try1d if true and m is a single-column matrix (Nx1),
then the sparse matrix will be 1-dimensional.
*/ */
explicit SparseMat(const Mat& m); explicit SparseMat(const Mat& m);
//! converts old-style sparse matrix to the new-style. All the data is copied //! converts old-style sparse matrix to the new-style. All the data is copied

@ -71,30 +71,6 @@
# endif # endif
#endif #endif
#ifdef _OPENMP
# define HAVE_OPENMP
#endif
#ifdef __APPLE__
# define HAVE_GCD
#endif
#if defined _MSC_VER && _MSC_VER >= 1600
# define HAVE_CONCURRENCY
#endif
#if defined HAVE_TBB
# define CV_PARALLEL_FRAMEWORK "tbb"
#elif defined HAVE_CSTRIPES
# define CV_PARALLEL_FRAMEWORK "cstripes"
#elif defined HAVE_OPENMP
# define CV_PARALLEL_FRAMEWORK "openmp"
#elif defined HAVE_GCD
# define CV_PARALLEL_FRAMEWORK "gcd"
#elif defined HAVE_CONCURRENCY
# define CV_PARALLEL_FRAMEWORK "ms-concurrency"
#endif
namespace cv namespace cv
{ {
#ifdef HAVE_TBB #ifdef HAVE_TBB
@ -145,6 +121,10 @@ namespace cv
body(range); body(range);
} }
#endif #endif
// Returns a static string if there is a parallel framework,
// NULL otherwise.
CV_EXPORTS const char* currentParallelFramework();
} //namespace cv } //namespace cv
#define CV_INIT_ALGORITHM(classname, algname, memberinit) \ #define CV_INIT_ALGORITHM(classname, algname, memberinit) \

@ -61,6 +61,17 @@
#endif #endif
#endif #endif
#ifdef _OPENMP
#define HAVE_OPENMP
#endif
#ifdef __APPLE__
#define HAVE_GCD
#endif
#if defined _MSC_VER && _MSC_VER >= 1600
#define HAVE_CONCURRENCY
#endif
/* IMPORTANT: always use the same order of defines /* IMPORTANT: always use the same order of defines
1. HAVE_TBB - 3rdparty library, should be explicitly enabled 1. HAVE_TBB - 3rdparty library, should be explicitly enabled
@ -99,6 +110,18 @@
#endif #endif
#endif #endif
#if defined HAVE_TBB && TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
# define CV_PARALLEL_FRAMEWORK "tbb"
#elif defined HAVE_CSTRIPES
# define CV_PARALLEL_FRAMEWORK "cstripes"
#elif defined HAVE_OPENMP
# define CV_PARALLEL_FRAMEWORK "openmp"
#elif defined HAVE_GCD
# define CV_PARALLEL_FRAMEWORK "gcd"
#elif defined HAVE_CONCURRENCY
# define CV_PARALLEL_FRAMEWORK "ms-concurrency"
#endif
namespace cv namespace cv
{ {
ParallelLoopBody::~ParallelLoopBody() {} ParallelLoopBody::~ParallelLoopBody() {}
@ -465,6 +488,14 @@ int cv::getNumberOfCPUs(void)
#endif #endif
} }
const char* cv::currentParallelFramework() {
#ifdef CV_PARALLEL_FRAMEWORK
return CV_PARALLEL_FRAMEWORK;
#else
return NULL;
#endif
}
CV_IMPL void cvSetNumThreads(int nt) CV_IMPL void cvSetNumThreads(int nt)
{ {
cv::setNumThreads(nt); cv::setNumThreads(nt);

@ -44,4 +44,11 @@
using namespace perf; using namespace perf;
CV_PERF_TEST_MAIN(gpu, printCudaInfo()) static const char * impls[] = {
#ifdef HAVE_CUDA
"cuda",
#endif
"plain"
};
CV_PERF_TEST_MAIN_WITH_IMPLS(gpu, impls, printCudaInfo())

@ -233,7 +233,7 @@ endif()
if(IOS) if(IOS)
add_definitions(-DHAVE_IOS=1) add_definitions(-DHAVE_IOS=1)
list(APPEND highgui_srcs src/cap_ios_abstract_camera.mm src/cap_ios_photo_camera.mm src/cap_ios_video_camera.mm) list(APPEND highgui_srcs src/ios_conversions.mm src/cap_ios_abstract_camera.mm src/cap_ios_photo_camera.mm src/cap_ios_video_camera.mm)
list(APPEND HIGHGUI_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework AssetsLibrary") list(APPEND HIGHGUI_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework AssetsLibrary")
endif() endif()

@ -559,9 +559,11 @@ CVAPI(int) cvGetCaptureDomain( CvCapture* capture);
/* "black box" video file writer structure */ /* "black box" video file writer structure */
typedef struct CvVideoWriter CvVideoWriter; typedef struct CvVideoWriter CvVideoWriter;
#define CV_FOURCC_MACRO(c1, c2, c3, c4) (((c1) & 255) + (((c2) & 255) << 8) + (((c3) & 255) << 16) + (((c4) & 255) << 24))
CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4) CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4)
{ {
return (c1 & 255) + ((c2 & 255) << 8) + ((c3 & 255) << 16) + ((c4 & 255) << 24); return CV_FOURCC_MACRO(c1, c2, c3, c4);
} }
#define CV_FOURCC_PROMPT -1 /* Open Codec Selection Dialog (Windows only) */ #define CV_FOURCC_PROMPT -1 /* Open Codec Selection Dialog (Windows only) */

@ -0,0 +1,49 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "opencv2/core/core.hpp"
#import "opencv2/highgui/cap_ios.h"
UIImage* MatToUIImage(const cv::Mat& image);
void UIImageToMat(const UIImage* image,
cv::Mat& m, bool alphaExist = false);

@ -11,11 +11,21 @@ using std::tr1::get;
typedef perf::TestBaseWithParam<std::string> VideoCapture_Reading; typedef perf::TestBaseWithParam<std::string> VideoCapture_Reading;
#if defined(HAVE_MSMF)
// MPEG2 is not supported by Media Foundation yet
// http://social.msdn.microsoft.com/Forums/en-US/mediafoundationdevelopment/thread/39a36231-8c01-40af-9af5-3c105d684429
PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_buck_bunny.avi",
"highgui/video/big_buck_bunny.mov",
"highgui/video/big_buck_bunny.mp4",
"highgui/video/big_buck_bunny.wmv" ) )
#else
PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_buck_bunny.avi", PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_buck_bunny.avi",
"highgui/video/big_buck_bunny.mov", "highgui/video/big_buck_bunny.mov",
"highgui/video/big_buck_bunny.mp4", "highgui/video/big_buck_bunny.mp4",
"highgui/video/big_buck_bunny.mpg", "highgui/video/big_buck_bunny.mpg",
"highgui/video/big_buck_bunny.wmv" ) ) "highgui/video/big_buck_bunny.wmv" ) )
#endif
{ {
string filename = getDataPath(GetParam()); string filename = getDataPath(GetParam());

@ -22,10 +22,16 @@ PERF_TEST_P(VideoWriter_Writing, WriteFrame,
{ {
string filename = getDataPath(get<0>(GetParam())); string filename = getDataPath(get<0>(GetParam()));
bool isColor = get<1>(GetParam()); bool isColor = get<1>(GetParam());
Mat image = imread(filename, 1);
VideoWriter writer(cv::tempfile(".avi"), VideoWriter::fourcc('X', 'V', 'I', 'D'), 25, cv::Size(640, 480), isColor); #if defined(HAVE_MSMF) && !defined(HAVE_VFW) && !defined(HAVE_FFMPEG) // VFW has greater priority
VideoWriter writer(cv::tempfile(".wmv"), VideoWriter::fourcc('W', 'M', 'V', '3'),
TEST_CYCLE() { Mat image = imread(filename, 1); writer << image; } 25, cv::Size(image.cols, image.rows), isColor);
#else
VideoWriter writer(cv::tempfile(".avi"), VideoWriter::fourcc('X', 'V', 'I', 'D'),
25, cv::Size(image.cols, image.rows), isColor);
#endif
TEST_CYCLE() { image = imread(filename, 1); writer << image; }
bool dummy = writer.isOpened(); bool dummy = writer.isOpened();
SANITY_CHECK(dummy); SANITY_CHECK(dummy);

@ -21,6 +21,7 @@
defined(HAVE_QUICKTIME) || \ defined(HAVE_QUICKTIME) || \
defined(HAVE_AVFOUNDATION) || \ defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) || \ defined(HAVE_FFMPEG) || \
defined(HAVE_MSMF) || \
defined(HAVE_VFW) defined(HAVE_VFW)
/*defined(HAVE_OPENNI) too specialized */ \ /*defined(HAVE_OPENNI) too specialized */ \
@ -34,6 +35,7 @@
defined(HAVE_QUICKTIME) || \ defined(HAVE_QUICKTIME) || \
defined(HAVE_AVFOUNDATION) || \ defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) || \ defined(HAVE_FFMPEG) || \
defined(HAVE_MSMF) || \
defined(HAVE_VFW) defined(HAVE_VFW)
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1 # define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1
#else #else

@ -117,6 +117,9 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
#ifdef HAVE_DSHOW #ifdef HAVE_DSHOW
CV_CAP_DSHOW, CV_CAP_DSHOW,
#endif #endif
#ifdef HAVE_MSMF
CV_CAP_MSMF,
#endif
#if 1 #if 1
CV_CAP_IEEE1394, // identical to CV_CAP_DC1394 CV_CAP_IEEE1394, // identical to CV_CAP_DC1394
#endif #endif
@ -196,21 +199,20 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
switch (domains[i]) switch (domains[i])
{ {
#ifdef HAVE_MSMF #ifdef HAVE_DSHOW
case CV_CAP_MSMF: case CV_CAP_DSHOW:
capture = cvCreateCameraCapture_MSMF (index); capture = cvCreateCameraCapture_DShow (index);
if (capture) if (capture)
return capture; return capture;
break; break;
#endif #endif
#ifdef HAVE_DSHOW #ifdef HAVE_MSMF
case CV_CAP_DSHOW: case CV_CAP_MSMF:
capture = cvCreateCameraCapture_DShow (index); capture = cvCreateCameraCapture_MSMF (index);
if (capture) if (capture)
return capture; return capture;
break; break;
#endif #endif
#ifdef HAVE_TYZX #ifdef HAVE_TYZX
case CV_CAP_STEREO: case CV_CAP_STEREO:
capture = cvCreateCameraCapture_TYZX (index); capture = cvCreateCameraCapture_TYZX (index);
@ -218,14 +220,12 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
return capture; return capture;
break; break;
#endif #endif
case CV_CAP_VFW:
#ifdef HAVE_VFW #ifdef HAVE_VFW
case CV_CAP_VFW:
capture = cvCreateCameraCapture_VFW (index); capture = cvCreateCameraCapture_VFW (index);
if (capture) if (capture)
return capture; return capture;
#endif #endif
#if defined HAVE_LIBV4L || defined HAVE_CAMV4L || defined HAVE_CAMV4L2 || defined HAVE_VIDEOIO #if defined HAVE_LIBV4L || defined HAVE_CAMV4L || defined HAVE_CAMV4L2 || defined HAVE_VIDEOIO
capture = cvCreateCameraCapture_V4L (index); capture = cvCreateCameraCapture_V4L (index);
if (capture) if (capture)
@ -359,6 +359,16 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
if (! result) if (! result)
result = cvCreateFileCapture_FFMPEG_proxy (filename); result = cvCreateFileCapture_FFMPEG_proxy (filename);
#ifdef HAVE_VFW
if (! result)
result = cvCreateFileCapture_VFW (filename);
#endif
#ifdef HAVE_MSMF
if (! result)
result = cvCreateFileCapture_MSMF (filename);
#endif
#ifdef HAVE_XINE #ifdef HAVE_XINE
if (! result) if (! result)
result = cvCreateFileCapture_XINE (filename); result = cvCreateFileCapture_XINE (filename);
@ -407,6 +417,16 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
if(!result) if(!result)
result = cvCreateVideoWriter_FFMPEG_proxy (filename, fourcc, fps, frameSize, is_color); result = cvCreateVideoWriter_FFMPEG_proxy (filename, fourcc, fps, frameSize, is_color);
#ifdef HAVE_VFW
if(!result)
result = cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, is_color);
#endif
#ifdef HAVE_MSMF
if (!result)
result = cvCreateVideoWriter_MSMF(filename, fourcc, fps, frameSize, is_color);
#endif
/* #ifdef HAVE_XINE /* #ifdef HAVE_XINE
if(!result) if(!result)
result = cvCreateVideoWriter_XINE(filename, fourcc, fps, frameSize, is_color); result = cvCreateVideoWriter_XINE(filename, fourcc, fps, frameSize, is_color);

@ -304,6 +304,11 @@ bool CvCaptureCAM_DC1394_v2_CPP::startCapture()
return false; return false;
if (isoSpeed > 0) if (isoSpeed > 0)
{ {
// if capable set operation mode to 1394b for iso speeds above 400
if (isoSpeed > 400 && dcCam->bmode_capable == DC1394_TRUE)
{
dc1394_video_set_operation_mode(dcCam, DC1394_OPERATION_MODE_1394B);
}
code = dc1394_video_set_iso_speed(dcCam, code = dc1394_video_set_iso_speed(dcCam,
isoSpeed <= 100 ? DC1394_ISO_SPEED_100 : isoSpeed <= 100 ? DC1394_ISO_SPEED_100 :
isoSpeed <= 200 ? DC1394_ISO_SPEED_200 : isoSpeed <= 200 ? DC1394_ISO_SPEED_200 :

@ -209,11 +209,7 @@ CvCapture* cvCreateFileCapture_FFMPEG_proxy(const char * filename)
if( result->open( filename )) if( result->open( filename ))
return result; return result;
delete result; delete result;
#ifdef HAVE_VFW
return cvCreateFileCapture_VFW(filename);
#else
return 0; return 0;
#endif
} }
class CvVideoWriter_FFMPEG_proxy : class CvVideoWriter_FFMPEG_proxy :
@ -263,9 +259,5 @@ CvVideoWriter* cvCreateVideoWriter_FFMPEG_proxy( const char* filename, int fourc
if( result->open( filename, fourcc, fps, frameSize, isColor != 0 )) if( result->open( filename, fourcc, fps, frameSize, isColor != 0 ))
return result; return result;
delete result; delete result;
#ifdef HAVE_VFW
return cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, isColor);
#else
return 0; return 0;
#endif
} }

@ -14,7 +14,9 @@ It has been tested with the motempl sample program
First Patch: August 24, 2004 Travis Wood TravisOCV@tkwood.com First Patch: August 24, 2004 Travis Wood TravisOCV@tkwood.com
For Release: OpenCV-Linux Beta4 opencv-0.9.6 For Release: OpenCV-Linux Beta4 opencv-0.9.6
Tested On: LMLBT44 with 8 video inputs Tested On: LMLBT44 with 8 video inputs
Problems? Post problems/fixes to OpenCV group on groups.yahoo.com Problems? Post your questions at answers.opencv.org,
Report bugs at code.opencv.org,
Submit your fixes at https://github.com/Itseez/opencv/
Patched Comments: Patched Comments:
TW: The cv cam utils that came with the initial release of OpenCV for LINUX Beta4 TW: The cv cam utils that came with the initial release of OpenCV for LINUX Beta4

File diff suppressed because it is too large Load Diff

@ -14,7 +14,9 @@ It has been tested with the motempl sample program
First Patch: August 24, 2004 Travis Wood TravisOCV@tkwood.com First Patch: August 24, 2004 Travis Wood TravisOCV@tkwood.com
For Release: OpenCV-Linux Beta4 opencv-0.9.6 For Release: OpenCV-Linux Beta4 opencv-0.9.6
Tested On: LMLBT44 with 8 video inputs Tested On: LMLBT44 with 8 video inputs
Problems? Post problems/fixes to OpenCV group on groups.yahoo.com Problems? Post your questions at answers.opencv.org,
Report bugs at code.opencv.org,
Submit your fixes at https://github.com/Itseez/opencv/
Patched Comments: Patched Comments:
TW: The cv cam utils that came with the initial release of OpenCV for LINUX Beta4 TW: The cv cam utils that came with the initial release of OpenCV for LINUX Beta4

@ -613,8 +613,10 @@ bool CvVideoWriter_VFW::open( const char* filename, int _fourcc, double _fps, Cv
close(); close();
return false; return false;
} }
return true;
} }
return true; else
return false;
} }

@ -0,0 +1,117 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#import "opencv2/highgui/cap_ios.h"
#include "precomp.hpp"
UIImage* MatToUIImage(const cv::Mat& image) {
NSData *data = [NSData dataWithBytes:image.data
length:image.elemSize()*image.total()];
CGColorSpaceRef colorSpace;
if (image.elemSize() == 1) {
colorSpace = CGColorSpaceCreateDeviceGray();
} else {
colorSpace = CGColorSpaceCreateDeviceRGB();
}
CGDataProviderRef provider =
CGDataProviderCreateWithCFData((__bridge CFDataRef)data);
// Creating CGImage from cv::Mat
CGImageRef imageRef = CGImageCreate(image.cols,
image.rows,
8,
8 * image.elemSize(),
image.step.p[0],
colorSpace,
kCGImageAlphaNone|
kCGBitmapByteOrderDefault,
provider,
NULL,
false,
kCGRenderingIntentDefault
);
// Getting UIImage from CGImage
UIImage *finalImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
CGDataProviderRelease(provider);
CGColorSpaceRelease(colorSpace);
return finalImage;
}
void UIImageToMat(const UIImage* image,
cv::Mat& m, bool alphaExist) {
CGColorSpaceRef colorSpace = CGImageGetColorSpace(image.CGImage);
CGFloat cols = image.size.width, rows = image.size.height;
CGContextRef contextRef;
CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedLast;
if (CGColorSpaceGetModel(colorSpace) == 0)
{
m.create(rows, cols, CV_8UC1); // 8 bits per component, 1 channel
bitmapInfo = kCGImageAlphaNone;
if (!alphaExist)
bitmapInfo = kCGImageAlphaNone;
contextRef = CGBitmapContextCreate(m.data, m.cols, m.rows, 8,
m.step[0], colorSpace,
bitmapInfo);
}
else
{
m.create(rows, cols, CV_8UC4); // 8 bits per component, 4 channels
if (!alphaExist)
bitmapInfo = kCGImageAlphaNoneSkipLast |
kCGBitmapByteOrderDefault;
contextRef = CGBitmapContextCreate(m.data, m.cols, m.rows, 8,
m.step[0], colorSpace,
bitmapInfo);
}
CGContextDrawImage(contextRef, CGRectMake(0, 0, cols, rows),
image.CGImage);
CGContextRelease(contextRef);
CGColorSpaceRelease(colorSpace);
}

@ -120,6 +120,9 @@ CvVideoWriter* cvCreateVideoWriter_VFW( const char* filename, int fourcc,
double fps, CvSize frameSize, int is_color ); double fps, CvSize frameSize, int is_color );
CvCapture* cvCreateCameraCapture_DShow( int index ); CvCapture* cvCreateCameraCapture_DShow( int index );
CvCapture* cvCreateCameraCapture_MSMF( int index ); CvCapture* cvCreateCameraCapture_MSMF( int index );
CvCapture* cvCreateFileCapture_MSMF (const char* filename);
CvVideoWriter* cvCreateVideoWriter_MSMF( const char* filename, int fourcc,
double fps, CvSize frameSize, int is_color );
CvCapture* cvCreateCameraCapture_OpenNI( int index ); CvCapture* cvCreateCameraCapture_OpenNI( int index );
CvCapture* cvCreateFileCapture_OpenNI( const char* filename ); CvCapture* cvCreateFileCapture_OpenNI( const char* filename );
CvCapture* cvCreateCameraCapture_Android( int index ); CvCapture* cvCreateCameraCapture_Android( int index );

@ -38,6 +38,7 @@
//--------------------Google Code 2010 -- Yannick Verdie--------------------// //--------------------Google Code 2010 -- Yannick Verdie--------------------//
#include "precomp.hpp"
#if defined(HAVE_QT) #if defined(HAVE_QT)

@ -46,7 +46,8 @@
defined(HAVE_QUICKTIME) || \ defined(HAVE_QUICKTIME) || \
defined(HAVE_AVFOUNDATION) || \ defined(HAVE_AVFOUNDATION) || \
/*defined(HAVE_OPENNI) || too specialized */ \ /*defined(HAVE_OPENNI) || too specialized */ \
defined(HAVE_FFMPEG) defined(HAVE_FFMPEG) || \
defined(HAVE_MSMF)
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1 # define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
#else #else
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0 # define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
@ -56,7 +57,8 @@
defined(HAVE_GSTREAMER) || \ defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \ defined(HAVE_QUICKTIME) || \
defined(HAVE_AVFOUNDATION) || \ defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) defined(HAVE_FFMPEG) || \
defined(HAVE_MSMF)
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1 # define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1
#else #else
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 0 # define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 0

@ -54,6 +54,35 @@ string fourccToString(int fourcc)
return format("%c%c%c%c", fourcc & 255, (fourcc >> 8) & 255, (fourcc >> 16) & 255, (fourcc >> 24) & 255); return format("%c%c%c%c", fourcc & 255, (fourcc >> 8) & 255, (fourcc >> 16) & 255, (fourcc >> 24) & 255);
} }
#ifdef HAVE_MSMF
const VideoFormat g_specific_fmt_list[] =
{
/*VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', '2', '5')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', '5', '0')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'c', ' ')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'h', '1')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'h', 'd')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 's', 'd')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 's', 'l')),
VideoFormat("wmv", CV_FOURCC_MACRO('H', '2', '6', '3')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', '4', 'S', '2')),
VideoFormat("avi", CV_FOURCC_MACRO('M', 'J', 'P', 'G')),
VideoFormat("mp4", CV_FOURCC_MACRO('M', 'P', '4', 'S')),
VideoFormat("mp4", CV_FOURCC_MACRO('M', 'P', '4', 'V')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', 'P', '4', '3')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', 'P', 'G', '1')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', 'S', 'S', '1')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', 'S', 'S', '2')),*/
#if !defined(_M_ARM)
VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '1')),
VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '2')),
#endif
VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '3')),
VideoFormat("avi", CV_FOURCC_MACRO('H', '2', '6', '4')),
//VideoFormat("wmv", CV_FOURCC_MACRO('W', 'V', 'C', '1')),
VideoFormat()
};
#else
const VideoFormat g_specific_fmt_list[] = const VideoFormat g_specific_fmt_list[] =
{ {
VideoFormat("avi", VideoWriter::fourcc('X', 'V', 'I', 'D')), VideoFormat("avi", VideoWriter::fourcc('X', 'V', 'I', 'D')),
@ -63,17 +92,17 @@ const VideoFormat g_specific_fmt_list[] =
VideoFormat("mkv", VideoWriter::fourcc('X', 'V', 'I', 'D')), VideoFormat("mkv", VideoWriter::fourcc('X', 'V', 'I', 'D')),
VideoFormat("mkv", VideoWriter::fourcc('M', 'P', 'E', 'G')), VideoFormat("mkv", VideoWriter::fourcc('M', 'P', 'E', 'G')),
VideoFormat("mkv", VideoWriter::fourcc('M', 'J', 'P', 'G')), VideoFormat("mkv", VideoWriter::fourcc('M', 'J', 'P', 'G')),
VideoFormat("mov", VideoWriter::fourcc('m', 'p', '4', 'v')), VideoFormat("mov", VideoWriter::fourcc('m', 'p', '4', 'v')),
VideoFormat() VideoFormat()
}; };
#endif
} }
class CV_HighGuiTest : public cvtest::BaseTest class CV_HighGuiTest : public cvtest::BaseTest
{ {
protected: protected:
void ImageTest(const string& dir); void ImageTest (const string& dir);
void VideoTest (const string& dir, const cvtest::VideoFormat& fmt); void VideoTest (const string& dir, const cvtest::VideoFormat& fmt);
void SpecificImageTest (const string& dir); void SpecificImageTest (const string& dir);
void SpecificVideoTest (const string& dir, const cvtest::VideoFormat& fmt); void SpecificVideoTest (const string& dir, const cvtest::VideoFormat& fmt);
@ -242,19 +271,19 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt
for(;;) for(;;)
{ {
IplImage * img = cvQueryFrame( cap ); IplImage* img = cvQueryFrame( cap );
if (!img) if (!img)
break; break;
frames.push_back(cv::cvarrToMat(img, true)); frames.push_back(cv::cvarrToMat(img, true));
if (writer == 0) if (writer == NULL)
{ {
writer = cvCreateVideoWriter(tmp_name.c_str(), fmt.fourcc, 24, cvGetSize(img)); writer = cvCreateVideoWriter(tmp_name.c_str(), fmt.fourcc, 24, cvGetSize(img));
if (writer == 0) if (writer == NULL)
{ {
ts->printf(ts->LOG, "can't create writer (with fourcc : %d)\n", ts->printf(ts->LOG, "can't create writer (with fourcc : %s)\n",
cvtest::fourccToString(fmt.fourcc).c_str()); cvtest::fourccToString(fmt.fourcc).c_str());
cvReleaseCapture( &cap ); cvReleaseCapture( &cap );
ts->set_failed_test_info(ts->FAIL_MISMATCH); ts->set_failed_test_info(ts->FAIL_MISMATCH);
@ -290,15 +319,22 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt
double psnr = PSNR(img1, img); double psnr = PSNR(img1, img);
if (psnr < thresDbell) if (psnr < thresDbell)
{ {
printf("Too low psnr = %gdb\n", psnr); ts->printf(ts->LOG, "Too low frame %d psnr = %gdb\n", i, psnr);
// imwrite("img.png", img);
// imwrite("img1.png", img1);
ts->set_failed_test_info(ts->FAIL_MISMATCH); ts->set_failed_test_info(ts->FAIL_MISMATCH);
//imwrite("original.png", img);
//imwrite("after_test.png", img1);
//Mat diff;
//absdiff(img, img1, diff);
//imwrite("diff.png", diff);
break; break;
} }
} }
printf("Before saved release for %s\n", tmp_name.c_str());
cvReleaseCapture( &saved ); cvReleaseCapture( &saved );
printf("After release\n");
ts->printf(ts->LOG, "end test function : ImagesVideo \n"); ts->printf(ts->LOG, "end test function : ImagesVideo \n");
} }

@ -258,7 +258,7 @@ PERF_TEST_P(Size_CvtMode, cvtColor8u,
declare.time(100); declare.time(100);
declare.in(src, WARMUP_RNG).out(dst); declare.in(src, WARMUP_RNG).out(dst);
int runs = sz.width <= 320 ? 70 : 1; int runs = sz.width <= 320 ? 70 : 5;
TEST_CYCLE_MULTIRUN(runs) cvtColor(src, dst, mode, ch.dcn); TEST_CYCLE_MULTIRUN(runs) cvtColor(src, dst, mode, ch.dcn);
SANITY_CHECK(dst, 1); SANITY_CHECK(dst, 1);

@ -85,7 +85,8 @@ PERF_TEST_P(MatInfo_Size_Scale, ResizeAreaFast,
declare.in(src, WARMUP_RNG).out(dst); declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() resize(src, dst, dst.size(), 0, 0, INTER_AREA); int runs = 15;
TEST_CYCLE_MULTIRUN(runs) resize(src, dst, dst.size(), 0, 0, INTER_AREA);
//difference equal to 1 is allowed because of different possible rounding modes: round-to-nearest vs bankers' rounding //difference equal to 1 is allowed because of different possible rounding modes: round-to-nearest vs bankers' rounding
SANITY_CHECK(dst, 1); SANITY_CHECK(dst, 1);

@ -51,7 +51,8 @@ PERF_TEST_P(Size_Only, threshold_otsu, testing::Values(TYPICAL_MAT_SIZES))
declare.in(src, WARMUP_RNG).out(dst); declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE() threshold(src, dst, 0, maxval, THRESH_BINARY|THRESH_OTSU); int runs = 15;
TEST_CYCLE_MULTIRUN(runs) threshold(src, dst, 0, maxval, THRESH_BINARY|THRESH_OTSU);
SANITY_CHECK(dst); SANITY_CHECK(dst);
} }

@ -17,8 +17,6 @@ import android.util.Log;
/** /**
* This only class is Android specific. * This only class is Android specific.
*
* @see <a href="http://opencv.itseez.com">OpenCV</a>
*/ */
public class OpenCVTestRunner extends InstrumentationTestRunner { public class OpenCVTestRunner extends InstrumentationTestRunner {

@ -6,7 +6,6 @@ import android.content.Context;
import android.graphics.ImageFormat; import android.graphics.ImageFormat;
import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture;
import android.hardware.Camera; import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;
import android.hardware.Camera.PreviewCallback; import android.hardware.Camera.PreviewCallback;
import android.os.Build; import android.os.Build;
import android.util.AttributeSet; import android.util.AttributeSet;

@ -27,6 +27,11 @@ public class OpenCVLoader
*/ */
public static final String OPENCV_VERSION_2_4_5 = "2.4.5"; public static final String OPENCV_VERSION_2_4_5 = "2.4.5";
/**
* OpenCV Library version 2.4.6.
*/
public static final String OPENCV_VERSION_2_4_6 = "2.4.6";
/** /**
* Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java"). * Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java").

@ -56,7 +56,7 @@ public class VideoCapture {
* * CV_CAP_PROP_FRAME_WIDTH width of the frames in the video stream. * * CV_CAP_PROP_FRAME_WIDTH width of the frames in the video stream.
* * CV_CAP_PROP_FRAME_HEIGHT height of the frames in the video stream. * * CV_CAP_PROP_FRAME_HEIGHT height of the frames in the video stream.
* *
* @see <a href="http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-get">org.opencv.highgui.VideoCapture.get</a> * @see <a href="http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-get">org.opencv.highgui.VideoCapture.get</a>
*/ */
public double get(int propId) public double get(int propId)
{ {
@ -178,7 +178,7 @@ public class VideoCapture {
* * CV_CAP_PROP_FRAME_HEIGHT height of the frames in the video stream. * * CV_CAP_PROP_FRAME_HEIGHT height of the frames in the video stream.
* @param value value of the property. * @param value value of the property.
* *
* @see <a href="http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-set">org.opencv.highgui.VideoCapture.set</a> * @see <a href="http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-set">org.opencv.highgui.VideoCapture.set</a>
*/ */
public boolean set(int propId, double value) public boolean set(int propId, double value)
{ {

@ -1,4 +1,11 @@
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
#include "opencv2/ts/gpu_perf.hpp" #include "opencv2/ts/gpu_perf.hpp"
CV_PERF_TEST_MAIN(nonfree, perf::printCudaInfo()) static const char * impls[] = {
#ifdef HAVE_CUDA
"cuda",
#endif
"plain"
};
CV_PERF_TEST_MAIN_WITH_IMPLS(nonfree, impls, perf::printCudaInfo())

@ -515,22 +515,7 @@ namespace cv
CV_EXPORTS void equalizeHist(const oclMat &mat_src, oclMat &mat_dst); CV_EXPORTS void equalizeHist(const oclMat &mat_src, oclMat &mat_dst);
//! only 8UC1 is supported now //! only 8UC1 is supported now
class CV_EXPORTS CLAHE CV_EXPORTS Ptr<cv::CLAHE> createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8));
{
public:
virtual void apply(const oclMat &src, oclMat &dst) = 0;
virtual void setClipLimit(double clipLimit) = 0;
virtual double getClipLimit() const = 0;
virtual void setTilesGridSize(Size tileGridSize) = 0;
virtual Size getTilesGridSize() const = 0;
virtual void collectGarbage() = 0;
virtual ~CLAHE() {}
};
CV_EXPORTS Ptr<cv::ocl::CLAHE> createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8));
//! bilateralFilter //! bilateralFilter
// supports 8UC1 8UC4 // supports 8UC1 8UC4
@ -1554,6 +1539,45 @@ namespace cv
bool isDeviceArch11_; bool isDeviceArch11_;
}; };
class CV_EXPORTS FarnebackOpticalFlow
{
public:
FarnebackOpticalFlow();
int numLevels;
double pyrScale;
bool fastPyramids;
int winSize;
int numIters;
int polyN;
double polySigma;
int flags;
void operator ()(const oclMat &frame0, const oclMat &frame1, oclMat &flowx, oclMat &flowy);
void releaseMemory();
private:
void prepareGaussian(
int n, double sigma, float *g, float *xg, float *xxg,
double &ig11, double &ig03, double &ig33, double &ig55);
void setPolynomialExpansionConsts(int n, double sigma);
void updateFlow_boxFilter(
const oclMat& R0, const oclMat& R1, oclMat& flowx, oclMat &flowy,
oclMat& M, oclMat &bufM, int blockSize, bool updateMatrices);
void updateFlow_gaussianBlur(
const oclMat& R0, const oclMat& R1, oclMat& flowx, oclMat& flowy,
oclMat& M, oclMat &bufM, int blockSize, bool updateMatrices);
oclMat frames_[2];
oclMat pyrLevel_[2], M_, bufM_, R_[2], blurredFrame_[2];
std::vector<oclMat> pyramid0_, pyramid1_;
};
//////////////// build warping maps //////////////////// //////////////// build warping maps ////////////////////
//! builds plane warping maps //! builds plane warping maps
CV_EXPORTS void buildWarpPlaneMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat &R, const Mat &T, float scale, oclMat &map_x, oclMat &map_y); CV_EXPORTS void buildWarpPlaneMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat &R, const Mat &T, float scale, oclMat &map_x, oclMat &map_y);

@ -42,43 +42,31 @@
#include "precomp.hpp" #include "precomp.hpp"
int main(int argc, const char *argv[]) static int cvErrorCallback(int /*status*/, const char * /*func_name*/,
const char *err_msg, const char * /*file_name*/,
int /*line*/, void * /*userdata*/)
{ {
vector<ocl::Info> oclinfo; TestSystem::instance().printError(err_msg);
int num_devices = getDevice(oclinfo); return 0;
}
if (num_devices < 1)
{
cerr << "no device found\n";
return -1;
}
// set this to overwrite binary cache every time the test starts
ocl::setBinaryDiskCache(ocl::CACHE_UPDATE);
int devidx = 0;
for (size_t i = 0; i < oclinfo.size(); i++)
{
for (size_t j = 0; j < oclinfo[i].DeviceName.size(); j++)
{
printf("device %d: %s\n", devidx++, oclinfo[i].DeviceName[j].c_str());
}
}
int main(int argc, const char *argv[])
{
const char *keys = const char *keys =
"{ h help | false | print help message }" "{ h help | false | print help message }"
"{ f filter | | filter for test }" "{ f filter | | filter for test }"
"{ w workdir | | set working directory }" "{ w workdir | | set working directory }"
"{ l list | false | show all tests }" "{ l list | false | show all tests }"
"{ d device | 0 | device id }" "{ d device | 0 | device id }"
"{ c cpu_ocl | false | use cpu as ocl device}"
"{ i iters | 10 | iteration count }" "{ i iters | 10 | iteration count }"
"{ m warmup | 1 | gpu warm up iteration count}" "{ m warmup | 1 | gpu warm up iteration count}"
"{ t xtop | 1.1 | xfactor top boundary}" "{ t xtop | 1.1 | xfactor top boundary}"
"{ b xbottom | 0.9 | xfactor bottom boundary}" "{ b xbottom | 0.9 | xfactor bottom boundary}"
"{ v verify | false | only run gpu once to verify if problems occur}"; "{ v verify | false | only run gpu once to verify if problems occur}";
redirectError(cvErrorCallback);
CommandLineParser cmd(argc, argv, keys); CommandLineParser cmd(argc, argv, keys);
if (cmd.has("help")) if (cmd.has("help"))
{ {
cout << "Avaible options:" << endl; cout << "Avaible options:" << endl;
@ -86,14 +74,40 @@ int main(int argc, const char *argv[])
return 0; return 0;
} }
int device = cmd.get<int>("device"); // get ocl devices
bool use_cpu = cmd.get<bool>("c");
vector<ocl::Info> oclinfo;
int num_devices = 0;
if(use_cpu)
num_devices = getDevice(oclinfo, ocl::CVCL_DEVICE_TYPE_CPU);
else
num_devices = getDevice(oclinfo);
if (num_devices < 1)
{
cerr << "no device found\n";
return -1;
}
// show device info
int devidx = 0;
for (size_t i = 0; i < oclinfo.size(); i++)
{
for (size_t j = 0; j < oclinfo[i].DeviceName.size(); j++)
{
cout << "device " << devidx++ << ": " << oclinfo[i].DeviceName[j] << endl;
}
}
int device = cmd.get<int>("device");
if (device < 0 || device >= num_devices) if (device < 0 || device >= num_devices)
{ {
cerr << "Invalid device ID" << endl; cerr << "Invalid device ID" << endl;
return -1; return -1;
} }
// set this to overwrite binary cache every time the test starts
ocl::setBinaryDiskCache(ocl::CACHE_UPDATE);
if (cmd.get<bool>("verify")) if (cmd.get<bool>("verify"))
{ {
TestSystem::instance().setNumIters(1); TestSystem::instance().setNumIters(1);
@ -102,7 +116,6 @@ int main(int argc, const char *argv[])
} }
devidx = 0; devidx = 0;
for (size_t i = 0; i < oclinfo.size(); i++) for (size_t i = 0; i < oclinfo.size(); i++)
{ {
for (size_t j = 0; j < oclinfo[i].DeviceName.size(); j++, devidx++) for (size_t j = 0; j < oclinfo[i].DeviceName.size(); j++, devidx++)
@ -111,7 +124,7 @@ int main(int argc, const char *argv[])
{ {
ocl::setDevice(oclinfo[i], (int)j); ocl::setDevice(oclinfo[i], (int)j);
TestSystem::instance().setRecordName(oclinfo[i].DeviceName[j]); TestSystem::instance().setRecordName(oclinfo[i].DeviceName[j]);
printf("\nuse %d: %s\n", devidx, oclinfo[i].DeviceName[j].c_str()); cout << "use " << devidx << ": " <<oclinfo[i].DeviceName[j] << endl;
goto END_DEV; goto END_DEV;
} }
} }

@ -932,8 +932,8 @@ PERFTEST(CLAHE)
double clipLimit = 40.0; double clipLimit = 40.0;
cv::Ptr<cv::CLAHE> clahe = cv::createCLAHE(clipLimit); cv::Ptr<cv::CLAHE> clahe = cv::createCLAHE(clipLimit);
cv::Ptr<cv::ocl::CLAHE> d_clahe = cv::ocl::createCLAHE(clipLimit); cv::Ptr<cv::CLAHE> d_clahe = cv::ocl::createCLAHE(clipLimit);
for (int size = Min_Size; size <= Max_Size; size *= Multiple) for (int size = Min_Size; size <= Max_Size; size *= Multiple)
{ {

@ -136,11 +136,13 @@ PERFTEST(PyrLKOpticalFlow)
size_t mismatch = 0; size_t mismatch = 0;
for (int i = 0; i < (int)nextPts.size(); ++i) for (int i = 0; i < (int)nextPts.size(); ++i)
{ {
if(status[i] != ocl_status.at<unsigned char>(0, i)){ if(status[i] != ocl_status.at<unsigned char>(0, i))
{
mismatch++; mismatch++;
continue; continue;
} }
if(status[i]){ if(status[i])
{
Point2f gpu_rst = ocl_nextPts.at<Point2f>(0, i); Point2f gpu_rst = ocl_nextPts.at<Point2f>(0, i);
Point2f cpu_rst = nextPts[i]; Point2f cpu_rst = nextPts[i];
if(fabs(gpu_rst.x - cpu_rst.x) >= 1. || fabs(gpu_rst.y - cpu_rst.y) >= 1.) if(fabs(gpu_rst.x - cpu_rst.x) >= 1. || fabs(gpu_rst.y - cpu_rst.y) >= 1.)
@ -193,17 +195,17 @@ PERFTEST(tvl1flow)
WARMUP_ON; WARMUP_ON;
d_alg(d0, d1, d_flowx, d_flowy); d_alg(d0, d1, d_flowx, d_flowy);
WARMUP_OFF; WARMUP_OFF;
/* /*
double diff1 = 0.0, diff2 = 0.0; double diff1 = 0.0, diff2 = 0.0;
if(ExceptedMatSimilar(gold[0], cv::Mat(d_flowx), 3e-3, diff1) == 1 if(ExceptedMatSimilar(gold[0], cv::Mat(d_flowx), 3e-3, diff1) == 1
&&ExceptedMatSimilar(gold[1], cv::Mat(d_flowy), 3e-3, diff2) == 1) &&ExceptedMatSimilar(gold[1], cv::Mat(d_flowy), 3e-3, diff2) == 1)
TestSystem::instance().setAccurate(1); TestSystem::instance().setAccurate(1);
else else
TestSystem::instance().setAccurate(0); TestSystem::instance().setAccurate(0);
TestSystem::instance().setDiff(diff1); TestSystem::instance().setDiff(diff1);
TestSystem::instance().setDiff(diff2); TestSystem::instance().setDiff(diff2);
*/ */
GPU_ON; GPU_ON;
@ -226,3 +228,129 @@ PERFTEST(tvl1flow)
TestSystem::instance().ExceptedMatSimilar(gold[0], flowx, 3e-3); TestSystem::instance().ExceptedMatSimilar(gold[0], flowx, 3e-3);
TestSystem::instance().ExceptedMatSimilar(gold[1], flowy, 3e-3); TestSystem::instance().ExceptedMatSimilar(gold[1], flowy, 3e-3);
} }
///////////// FarnebackOpticalFlow ////////////////////////
PERFTEST(FarnebackOpticalFlow)
{
cv::Mat frame0 = imread("rubberwhale1.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame0.empty());
cv::Mat frame1 = imread("rubberwhale2.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame1.empty());
cv::ocl::oclMat d_frame0(frame0), d_frame1(frame1);
int polyNs[2] = { 5, 7 };
double polySigmas[2] = { 1.1, 1.5 };
int farneFlags[2] = { 0, cv::OPTFLOW_FARNEBACK_GAUSSIAN };
bool UseInitFlows[2] = { false, true };
double pyrScale = 0.5;
string farneFlagStrs[2] = { "BoxFilter", "GaussianBlur" };
string useInitFlowStrs[2] = { "", "UseInitFlow" };
for ( int i = 0; i < 2; ++i)
{
int polyN = polyNs[i];
double polySigma = polySigmas[i];
for ( int j = 0; j < 2; ++j)
{
int flags = farneFlags[j];
for ( int k = 0; k < 2; ++k)
{
bool useInitFlow = UseInitFlows[k];
SUBTEST << "polyN(" << polyN << "); " << farneFlagStrs[j] << "; " << useInitFlowStrs[k];
cv::ocl::FarnebackOpticalFlow farn;
farn.pyrScale = pyrScale;
farn.polyN = polyN;
farn.polySigma = polySigma;
farn.flags = flags;
cv::ocl::oclMat d_flowx, d_flowy;
cv::Mat flow, flowBuf, flowxBuf, flowyBuf;
WARMUP_ON;
farn(d_frame0, d_frame1, d_flowx, d_flowy);
if (useInitFlow)
{
cv::Mat flowxy[] = {cv::Mat(d_flowx), cv::Mat(d_flowy)};
cv::merge(flowxy, 2, flow);
flow.copyTo(flowBuf);
flowxy[0].copyTo(flowxBuf);
flowxy[1].copyTo(flowyBuf);
farn.flags |= cv::OPTFLOW_USE_INITIAL_FLOW;
farn(d_frame0, d_frame1, d_flowx, d_flowy);
}
WARMUP_OFF;
cv::calcOpticalFlowFarneback(
frame0, frame1, flow, farn.pyrScale, farn.numLevels, farn.winSize,
farn.numIters, farn.polyN, farn.polySigma, farn.flags);
std::vector<cv::Mat> flowxy;
cv::split(flow, flowxy);
Mat md_flowx = cv::Mat(d_flowx);
Mat md_flowy = cv::Mat(d_flowy);
TestSystem::instance().ExceptedMatSimilar(flowxy[0], md_flowx, 0.1);
TestSystem::instance().ExceptedMatSimilar(flowxy[1], md_flowy, 0.1);
if (useInitFlow)
{
cv::Mat flowx, flowy;
farn.flags = (flags | cv::OPTFLOW_USE_INITIAL_FLOW);
CPU_ON;
cv::calcOpticalFlowFarneback(
frame0, frame1, flowBuf, farn.pyrScale, farn.numLevels, farn.winSize,
farn.numIters, farn.polyN, farn.polySigma, farn.flags);
CPU_OFF;
GPU_ON;
farn(d_frame0, d_frame1, d_flowx, d_flowy);
GPU_OFF;
GPU_FULL_ON;
d_frame0.upload(frame0);
d_frame1.upload(frame1);
d_flowx.upload(flowxBuf);
d_flowy.upload(flowyBuf);
farn(d_frame0, d_frame1, d_flowx, d_flowy);
d_flowx.download(flowx);
d_flowy.download(flowy);
GPU_FULL_OFF;
}
else
{
cv::Mat flow, flowx, flowy;
cv::ocl::oclMat d_flowx, d_flowy;
farn.flags = flags;
CPU_ON;
cv::calcOpticalFlowFarneback(
frame0, frame1, flow, farn.pyrScale, farn.numLevels, farn.winSize,
farn.numIters, farn.polyN, farn.polySigma, farn.flags);
CPU_OFF;
GPU_ON;
farn(d_frame0, d_frame1, d_flowx, d_flowy);
GPU_OFF;
GPU_FULL_ON;
d_frame0.upload(frame0);
d_frame1.upload(frame1);
farn(d_frame0, d_frame1, d_flowx, d_flowy);
d_flowx.download(flowx);
d_flowy.download(flowy);
GPU_FULL_OFF;
}
}
}
}
}

@ -42,7 +42,9 @@
#include "precomp.hpp" #include "precomp.hpp"
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
#ifndef NOMINMAX
#define NOMINMAX #define NOMINMAX
#endif
# include <windows.h> # include <windows.h>
#endif #endif
@ -278,7 +280,7 @@ enum GTestColor {
}; };
#if GTEST_OS_WINDOWS&&!GTEST_OS_WINDOWS_MOBILE #if GTEST_OS_WINDOWS&&!GTEST_OS_WINDOWS_MOBILE
// Returns the character attribute for the given color. // Returns the character attribute for the given color.
WORD GetColorAttribute(GTestColor color) { static WORD GetColorAttribute(GTestColor color) {
switch (color) { switch (color) {
case COLOR_RED: return FOREGROUND_RED; case COLOR_RED: return FOREGROUND_RED;
case COLOR_GREEN: return FOREGROUND_GREEN; case COLOR_GREEN: return FOREGROUND_GREEN;

@ -141,7 +141,7 @@ typedef struct
int imgoff; int imgoff;
float factor; float factor;
} detect_piramid_info; } detect_piramid_info;
#ifdef WIN32 #ifdef _MSC_VER
#define _ALIGNED_ON(_ALIGNMENT) __declspec(align(_ALIGNMENT)) #define _ALIGNED_ON(_ALIGNMENT) __declspec(align(_ALIGNMENT))
typedef _ALIGNED_ON(128) struct GpuHidHaarTreeNode typedef _ALIGNED_ON(128) struct GpuHidHaarTreeNode

@ -1812,8 +1812,14 @@ void cv::ocl::device::hog::normalize_hists(int nbins,
openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads, openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads,
localThreads, args, -1, -1, "-D CPU"); localThreads, args, -1, -1, "-D CPU");
else else
{
cl_kernel kernel = openCLGetKernelFromSource(clCxt, &objdetect_hog, kernelName);
int wave_size = queryDeviceInfo<WAVEFRONT_SIZE, int>(kernel);
char opt[32] = {0};
sprintf(opt, "-D WAVE_SIZE=%d", wave_size);
openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads, openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads,
localThreads, args, -1, -1); localThreads, args, -1, -1, opt);
}
} }
void cv::ocl::device::hog::classify_hists(int win_height, int win_width, void cv::ocl::device::hog::classify_hists(int win_height, int win_width,
@ -1875,8 +1881,14 @@ void cv::ocl::device::hog::classify_hists(int win_height, int win_width,
openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads, openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads,
localThreads, args, -1, -1, "-D CPU"); localThreads, args, -1, -1, "-D CPU");
else else
{
cl_kernel kernel = openCLGetKernelFromSource(clCxt, &objdetect_hog, kernelName);
int wave_size = queryDeviceInfo<WAVEFRONT_SIZE, int>(kernel);
char opt[32] = {0};
sprintf(opt, "-D WAVE_SIZE=%d", wave_size);
openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads, openCLExecuteKernel2(clCxt, &objdetect_hog, kernelName, globalThreads,
localThreads, args, -1, -1); localThreads, args, -1, -1, opt);
}
} }
void cv::ocl::device::hog::extract_descrs_by_rows(int win_height, int win_width, void cv::ocl::device::hog::extract_descrs_by_rows(int win_height, int win_width,

@ -1585,14 +1585,14 @@ namespace cv
namespace namespace
{ {
class CLAHE_Impl : public cv::ocl::CLAHE class CLAHE_Impl : public cv::CLAHE
{ {
public: public:
CLAHE_Impl(double clipLimit = 40.0, int tilesX = 8, int tilesY = 8); CLAHE_Impl(double clipLimit = 40.0, int tilesX = 8, int tilesY = 8);
cv::AlgorithmInfo* info() const; cv::AlgorithmInfo* info() const;
void apply(const oclMat &src, oclMat &dst); void apply(cv::InputArray src, cv::OutputArray dst);
void setClipLimit(double clipLimit); void setClipLimit(double clipLimit);
double getClipLimit() const; double getClipLimit() const;
@ -1610,14 +1610,19 @@ namespace cv
oclMat srcExt_; oclMat srcExt_;
oclMat lut_; oclMat lut_;
}; };
CLAHE_Impl::CLAHE_Impl(double clipLimit, int tilesX, int tilesY) : CLAHE_Impl::CLAHE_Impl(double clipLimit, int tilesX, int tilesY) :
clipLimit_(clipLimit), tilesX_(tilesX), tilesY_(tilesY) clipLimit_(clipLimit), tilesX_(tilesX), tilesY_(tilesY)
{ {
} }
void CLAHE_Impl::apply(const oclMat &src, oclMat &dst) CV_INIT_ALGORITHM(CLAHE_Impl, "CLAHE_OCL",
obj.info()->addParam(obj, "clipLimit", obj.clipLimit_);
obj.info()->addParam(obj, "tilesX", obj.tilesX_);
obj.info()->addParam(obj, "tilesY", obj.tilesY_))
void CLAHE_Impl::apply(cv::InputArray src_raw, cv::OutputArray dst_raw)
{ {
oclMat& src = getOclMatRef(src_raw);
oclMat& dst = getOclMatRef(dst_raw);
CV_Assert( src.type() == CV_8UC1 ); CV_Assert( src.type() == CV_8UC1 );
dst.create( src.size(), src.type() ); dst.create( src.size(), src.type() );
@ -1685,7 +1690,7 @@ namespace cv
} }
} }
cv::Ptr<cv::ocl::CLAHE> createCLAHE(double clipLimit, cv::Size tileGridSize) cv::Ptr<cv::CLAHE> createCLAHE(double clipLimit, cv::Size tileGridSize)
{ {
return new CLAHE_Impl(clipLimit, tileGridSize.width, tileGridSize.height); return new CLAHE_Impl(clipLimit, tileGridSize.width, tileGridSize.height);
} }

@ -120,9 +120,6 @@ namespace cv
codeCache.clear(); codeCache.clear();
cacheSize = 0; cacheSize = 0;
} }
// not to be exported to dynamic lib
void setBinaryDiskCacheImpl(int mode, String path, Info::Impl * impl);
struct Info::Impl struct Info::Impl
{ {
cl_platform_id oclplatform; cl_platform_id oclplatform;
@ -141,9 +138,6 @@ namespace cv
char extra_options[512]; char extra_options[512];
int double_support; int double_support;
int unified_memory; //1 means integrated GPU, otherwise this value is 0 int unified_memory; //1 means integrated GPU, otherwise this value is 0
bool enable_disk_cache;
bool update_disk_cache;
String binpath;
int refcounter; int refcounter;
Impl(); Impl();
@ -171,6 +165,16 @@ namespace cv
void releaseResources(); void releaseResources();
}; };
// global variables to hold binary cache properties
static int enable_disk_cache =
#ifdef _DEBUG
false;
#else
true;
#endif
static int update_disk_cache = false;
static String binpath = "";
Info::Impl::Impl() Info::Impl::Impl()
:oclplatform(0), :oclplatform(0),
oclcontext(0), oclcontext(0),
@ -181,13 +185,9 @@ namespace cv
maxComputeUnits(0), maxComputeUnits(0),
double_support(0), double_support(0),
unified_memory(0), unified_memory(0),
enable_disk_cache(false),
update_disk_cache(false),
binpath("./"),
refcounter(1) refcounter(1)
{ {
memset(extra_options, 0, 512); memset(extra_options, 0, 512);
setBinaryDiskCacheImpl(CACHE_RELEASE, String("./"), this);
} }
void Info::Impl::releaseResources() void Info::Impl::releaseResources()
@ -196,7 +196,8 @@ namespace cv
if(clCmdQueue) if(clCmdQueue)
{ {
openCLSafeCall(clReleaseCommandQueue(clCmdQueue)); //temporarily disable command queue release as it causes program hang at exit
//openCLSafeCall(clReleaseCommandQueue(clCmdQueue));
clCmdQueue = 0; clCmdQueue = 0;
} }
@ -508,29 +509,30 @@ namespace cv
return openCLGetKernelFromSource(clCxt, source, kernelName, NULL); return openCLGetKernelFromSource(clCxt, source, kernelName, NULL);
} }
void setBinaryDiskCacheImpl(int mode, String path, Info::Impl * impl) void setBinaryDiskCache(int mode, String path)
{ {
impl->update_disk_cache = (mode & CACHE_UPDATE) == CACHE_UPDATE; if(mode == CACHE_NONE)
impl->enable_disk_cache = {
update_disk_cache = 0;
enable_disk_cache = 0;
return;
}
update_disk_cache |= (mode & CACHE_UPDATE) == CACHE_UPDATE;
enable_disk_cache |=
#ifdef _DEBUG #ifdef _DEBUG
(mode & CACHE_DEBUG) == CACHE_DEBUG; (mode & CACHE_DEBUG) == CACHE_DEBUG;
#else #else
(mode & CACHE_RELEASE) == CACHE_RELEASE; (mode & CACHE_RELEASE) == CACHE_RELEASE;
#endif #endif
if(impl->enable_disk_cache && !path.empty()) if(enable_disk_cache && !path.empty())
{ {
impl->binpath = path; binpath = path;
} }
} }
void setBinaryDiskCache(int mode, cv::String path)
{
setBinaryDiskCacheImpl(mode, path, Context::getContext()->impl);
}
void setBinpath(const char *path) void setBinpath(const char *path)
{ {
Context *clcxt = Context::getContext(); binpath = path;
clcxt->impl->binpath = path;
} }
int savetofile(const Context*, cl_program &program, const char *fileName) int savetofile(const Context*, cl_program &program, const char *fileName)
@ -598,15 +600,15 @@ namespace cv
strcat(all_build_options, build_options); strcat(all_build_options, build_options);
if(all_build_options != NULL) if(all_build_options != NULL)
{ {
filename = clCxt->impl->binpath + kernelName + "_" + clCxt->impl->devName[clCxt->impl->devnum] + all_build_options + ".clb"; filename = binpath + kernelName + "_" + clCxt->impl->devName[clCxt->impl->devnum] + all_build_options + ".clb";
} }
else else
{ {
filename = clCxt->impl->binpath + kernelName + "_" + clCxt->impl->devName[clCxt->impl->devnum] + ".clb"; filename = binpath + kernelName + "_" + clCxt->impl->devName[clCxt->impl->devnum] + ".clb";
} }
FILE *fp = clCxt->impl->enable_disk_cache ? fopen(filename.c_str(), "rb") : NULL; FILE *fp = enable_disk_cache ? fopen(filename.c_str(), "rb") : NULL;
if(fp == NULL || clCxt->impl->update_disk_cache) if(fp == NULL || update_disk_cache)
{ {
if(fp != NULL) if(fp != NULL)
fclose(fp); fclose(fp);
@ -615,7 +617,7 @@ namespace cv
clCxt->impl->oclcontext, 1, source, NULL, &status); clCxt->impl->oclcontext, 1, source, NULL, &status);
openCLVerifyCall(status); openCLVerifyCall(status);
status = clBuildProgram(program, 1, &(clCxt->impl->devices[clCxt->impl->devnum]), all_build_options, NULL, NULL); status = clBuildProgram(program, 1, &(clCxt->impl->devices[clCxt->impl->devnum]), all_build_options, NULL, NULL);
if(status == CL_SUCCESS && clCxt->impl->enable_disk_cache) if(status == CL_SUCCESS && enable_disk_cache)
savetofile(clCxt, program, filename.c_str()); savetofile(clCxt, program, filename.c_str());
} }
else else
@ -1087,26 +1089,3 @@ namespace cv
}//namespace ocl }//namespace ocl
}//namespace cv }//namespace cv
#if defined BUILD_SHARED_LIBS && defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE
#include <windows.h>
BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID );
BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID )
{
if( fdwReason == DLL_PROCESS_DETACH )
{
// application hangs if call clReleaseCommandQueue here, so release context only
// without context release application hangs as well
context_tear_down = 1;
Context* cv_ctx = Context::getContext();
if(cv_ctx)
{
cl_context ctx = cv_ctx->impl->oclcontext;
if(ctx)
openCLSafeCall(clReleaseContext(ctx));
}
}
return TRUE;
}
#endif

@ -149,7 +149,7 @@ namespace cv
cl_image_format format; cl_image_format format;
int err; int err;
int depth = mat.depth(); int depth = mat.depth();
int channels = mat.channels(); int channels = mat.oclchannels();
switch(depth) switch(depth)
{ {

@ -16,7 +16,7 @@
// Third party copyrights are property of their respective owners. // Third party copyrights are property of their respective owners.
// //
// @Authors // @Authors
// Sen Liu, sen@multicorewareinc.com // Sen Liu, swjtuls1987@126.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
@ -280,8 +280,8 @@ static void ocl_cvMoments( const void* array, CvMoments* mom, int binary )
blocky = size.height/TILE_SIZE; blocky = size.height/TILE_SIZE;
else else
blocky = size.height/TILE_SIZE + 1; blocky = size.height/TILE_SIZE + 1;
cv::ocl::oclMat dst_m(blocky * 10, blockx, CV_64FC1); oclMat dst_m(blocky * 10, blockx, CV_64FC1);
cl_mem sum = openCLCreateBuffer(src.clCxt,CL_MEM_READ_WRITE,10*sizeof(double)); oclMat sum(1, 10, CV_64FC1);
int tile_width = std::min(size.width,TILE_SIZE); int tile_width = std::min(size.width,TILE_SIZE);
int tile_height = std::min(size.height,TILE_SIZE); int tile_height = std::min(size.height,TILE_SIZE);
size_t localThreads[3] = { tile_height, 1, 1}; size_t localThreads[3] = { tile_height, 1, 1};
@ -291,19 +291,16 @@ static void ocl_cvMoments( const void* array, CvMoments* mom, int binary )
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.rows ));
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.cols ));
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.step )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&src.step ));
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&tileSize.width ));
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&tileSize.height ));
args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst_m.data )); args.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst_m.data ));
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst_m.cols )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst_m.cols ));
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst_m.step )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst_m.step ));
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&blocky )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&blocky ));
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&type ));
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&depth )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&depth ));
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&cn )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&cn ));
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&coi )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&coi ));
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&binary )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&binary ));
args.push_back( std::make_pair( sizeof(cl_int) , (void *)&TILE_SIZE )); args.push_back( std::make_pair( sizeof(cl_int) , (void *)&TILE_SIZE ));
openCLExecuteKernel(dst_m.clCxt, &moments, "CvMoments", globalThreads, localThreads, args, -1, depth); openCLExecuteKernel(Context::getContext(), &moments, "CvMoments", globalThreads, localThreads, args, -1, depth);
size_t localThreadss[3] = { 128, 1, 1}; size_t localThreadss[3] = { 128, 1, 1};
size_t globalThreadss[3] = { 128, 1, 1}; size_t globalThreadss[3] = { 128, 1, 1};
@ -315,10 +312,9 @@ static void ocl_cvMoments( const void* array, CvMoments* mom, int binary )
args_sum.push_back( std::make_pair( sizeof(cl_mem) , (void *)&sum )); args_sum.push_back( std::make_pair( sizeof(cl_mem) , (void *)&sum ));
args_sum.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst_m.data )); args_sum.push_back( std::make_pair( sizeof(cl_mem) , (void *)&dst_m.data ));
args_sum.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst_m.step )); args_sum.push_back( std::make_pair( sizeof(cl_int) , (void *)&dst_m.step ));
openCLExecuteKernel(dst_m.clCxt, &moments, "dst_sum", globalThreadss, localThreadss, args_sum, -1, -1); openCLExecuteKernel(Context::getContext(), &moments, "dst_sum", globalThreadss, localThreadss, args_sum, -1, -1);
double* dstsum = new double[10];
memset(dstsum,0,10*sizeof(double)); Mat dstsum(sum);
openCLReadBuffer(dst_m.clCxt,sum,(void *)dstsum,10*sizeof(double));
mom->m00 = dstsum[0]; mom->m00 = dstsum[0];
mom->m10 = dstsum[1]; mom->m10 = dstsum[1];
mom->m01 = dstsum[2]; mom->m01 = dstsum[2];
@ -329,8 +325,7 @@ static void ocl_cvMoments( const void* array, CvMoments* mom, int binary )
mom->m21 = dstsum[7]; mom->m21 = dstsum[7];
mom->m12 = dstsum[8]; mom->m12 = dstsum[8];
mom->m03 = dstsum[9]; mom->m03 = dstsum[9];
delete [] dstsum;
openCLSafeCall(clReleaseMemObject(sum));
icvCompleteMomentState( mom ); icvCompleteMomentState( mom );
} }

@ -173,10 +173,10 @@ __kernel void dst_sum(int src_rows, int src_cols, int tile_height, int tile_widt
sum[i] = dst_sum[i][0]; sum[i] = dst_sum[i][0];
} }
__kernel void CvMoments_D0(__global uchar16* src_data, int src_rows, int src_cols, int src_step, int tileSize_width, int tileSize_height, __kernel void CvMoments_D0(__global uchar16* src_data, int src_rows, int src_cols, int src_step,
__global F* dst_m, __global F* dst_m,
int dst_cols, int dst_step, int blocky, int dst_cols, int dst_step, int blocky,
int type, int depth, int cn, int coi, int binary, int TILE_SIZE) int depth, int cn, int coi, int binary, int TILE_SIZE)
{ {
uchar tmp_coi[16]; // get the coi data uchar tmp_coi[16]; // get the coi data
uchar16 tmp[16]; uchar16 tmp[16];
@ -192,35 +192,43 @@ __kernel void CvMoments_D0(__global uchar16* src_data, int src_rows, int src_col
int x = wgidx*TILE_SIZE; // vector length of uchar int x = wgidx*TILE_SIZE; // vector length of uchar
int kcn = (cn==2)?2:4; int kcn = (cn==2)?2:4;
int rstep = min(src_step, TILE_SIZE); int rstep = min(src_step, TILE_SIZE);
tileSize_height = min(TILE_SIZE, src_rows - y); int tileSize_height = min(TILE_SIZE, src_rows - y);
tileSize_width = min(TILE_SIZE, src_cols - x); int tileSize_width = min(TILE_SIZE, src_cols - x);
if( tileSize_width < TILE_SIZE ) if ( y+lidy < src_rows )
for(int i = tileSize_width; i < rstep; i++ ) {
*((__global uchar*)src_data+(y+lidy)*src_step+x+i) = 0; if( tileSize_width < TILE_SIZE )
if( coi > 0 ) //channel of interest for(int i = tileSize_width; i < rstep && (x+i) < src_cols; i++ )
for(int i = 0; i < tileSize_width; i += VLEN_C) *((__global uchar*)src_data+(y+lidy)*src_step+x+i) = 0;
{
for(int j=0; j<VLEN_C; j++) if( coi > 0 ) //channel of interest
tmp_coi[j] = *((__global uchar*)src_data+(y+lidy)*src_step+(x+i+j)*kcn+coi-1); for(int i = 0; i < tileSize_width; i += VLEN_C)
tmp[i/VLEN_C] = (uchar16)(tmp_coi[0],tmp_coi[1],tmp_coi[2],tmp_coi[3],tmp_coi[4],tmp_coi[5],tmp_coi[6],tmp_coi[7], {
tmp_coi[8],tmp_coi[9],tmp_coi[10],tmp_coi[11],tmp_coi[12],tmp_coi[13],tmp_coi[14],tmp_coi[15]); for(int j=0; j<VLEN_C; j++)
} tmp_coi[j] = *((__global uchar*)src_data+(y+lidy)*src_step+(x+i+j)*kcn+coi-1);
else tmp[i/VLEN_C] = (uchar16)(tmp_coi[0],tmp_coi[1],tmp_coi[2],tmp_coi[3],tmp_coi[4],tmp_coi[5],tmp_coi[6],tmp_coi[7],
for(int i=0; i < tileSize_width; i+=VLEN_C) tmp_coi[8],tmp_coi[9],tmp_coi[10],tmp_coi[11],tmp_coi[12],tmp_coi[13],tmp_coi[14],tmp_coi[15]);
tmp[i/VLEN_C] = *(src_data+(y+lidy)*src_step/VLEN_C+(x+i)/VLEN_C); }
else
for(int i=0; i < tileSize_width; i+=VLEN_C)
tmp[i/VLEN_C] = *(src_data+(y+lidy)*src_step/VLEN_C+(x+i)/VLEN_C);
}
uchar16 zero = (uchar16)(0); uchar16 zero = (uchar16)(0);
uchar16 full = (uchar16)(255); uchar16 full = (uchar16)(255);
if( binary ) if( binary )
for(int i=0; i < tileSize_width; i+=VLEN_C) for(int i=0; i < tileSize_width; i+=VLEN_C)
tmp[i/VLEN_C] = (tmp[i/VLEN_C]!=zero)?full:zero; tmp[i/VLEN_C] = (tmp[i/VLEN_C]!=zero)?full:zero;
F mom[10]; F mom[10];
__local int m[10][128]; __local int m[10][128];
if(lidy == 0) if(lidy < 128)
{
for(int i=0; i<10; i++) for(int i=0; i<10; i++)
for(int j=0; j<128; j++) m[i][lidy]=0;
m[i][j]=0; }
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
int lm[10] = {0}; int lm[10] = {0};
int16 x0 = (int16)(0); int16 x0 = (int16)(0);
int16 x1 = (int16)(0); int16 x1 = (int16)(0);
@ -281,6 +289,7 @@ __kernel void CvMoments_D0(__global uchar16* src_data, int src_rows, int src_col
m[i][lidy-j/2] = lm[i]; m[i][lidy-j/2] = lm[i];
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
} }
if(lidy == 0&&lidx == 0) if(lidy == 0&&lidx == 0)
{ {
for( int mt = 0; mt < 10; mt++ ) for( int mt = 0; mt < 10; mt++ )
@ -328,10 +337,10 @@ __kernel void CvMoments_D0(__global uchar16* src_data, int src_rows, int src_col
} }
} }
__kernel void CvMoments_D2(__global ushort8* src_data, int src_rows, int src_cols, int src_step, int tileSize_width, int tileSize_height, __kernel void CvMoments_D2(__global ushort8* src_data, int src_rows, int src_cols, int src_step,
__global F* dst_m, __global F* dst_m,
int dst_cols, int dst_step, int blocky, int dst_cols, int dst_step, int blocky,
int type, int depth, int cn, int coi, int binary, const int TILE_SIZE) int depth, int cn, int coi, int binary, const int TILE_SIZE)
{ {
ushort tmp_coi[8]; // get the coi data ushort tmp_coi[8]; // get the coi data
ushort8 tmp[32]; ushort8 tmp[32];
@ -346,21 +355,26 @@ __kernel void CvMoments_D2(__global ushort8* src_data, int src_rows, int src_col
int x = wgidx*TILE_SIZE; // real X index of pixel int x = wgidx*TILE_SIZE; // real X index of pixel
int kcn = (cn==2)?2:4; int kcn = (cn==2)?2:4;
int rstep = min(src_step/2, TILE_SIZE); int rstep = min(src_step/2, TILE_SIZE);
tileSize_height = min(TILE_SIZE, src_rows - y); int tileSize_height = min(TILE_SIZE, src_rows - y);
tileSize_width = min(TILE_SIZE, src_cols -x); int tileSize_width = min(TILE_SIZE, src_cols -x);
if(src_cols > TILE_SIZE && tileSize_width < TILE_SIZE)
for(int i=tileSize_width; i < rstep; i++ ) if ( y+lidy < src_rows )
*((__global ushort*)src_data+(y+lidy)*src_step/2+x+i) = 0; {
if( coi > 0 ) if(src_cols > TILE_SIZE && tileSize_width < TILE_SIZE)
for(int i=0; i < tileSize_width; i+=VLEN_US) for(int i=tileSize_width; i < rstep && (x+i) < src_cols; i++ )
{ *((__global ushort*)src_data+(y+lidy)*src_step/2+x+i) = 0;
for(int j=0; j<VLEN_US; j++) if( coi > 0 )
tmp_coi[j] = *((__global ushort*)src_data+(y+lidy)*(int)src_step/2+(x+i+j)*kcn+coi-1); for(int i=0; i < tileSize_width; i+=VLEN_US)
tmp[i/VLEN_US] = (ushort8)(tmp_coi[0],tmp_coi[1],tmp_coi[2],tmp_coi[3],tmp_coi[4],tmp_coi[5],tmp_coi[6],tmp_coi[7]); {
} for(int j=0; j<VLEN_US; j++)
else tmp_coi[j] = *((__global ushort*)src_data+(y+lidy)*(int)src_step/2+(x+i+j)*kcn+coi-1);
for(int i=0; i < tileSize_width; i+=VLEN_US) tmp[i/VLEN_US] = (ushort8)(tmp_coi[0],tmp_coi[1],tmp_coi[2],tmp_coi[3],tmp_coi[4],tmp_coi[5],tmp_coi[6],tmp_coi[7]);
tmp[i/VLEN_US] = *(src_data+(y+lidy)*src_step/(2*VLEN_US)+(x+i)/VLEN_US); }
else
for(int i=0; i < tileSize_width; i+=VLEN_US)
tmp[i/VLEN_US] = *(src_data+(y+lidy)*src_step/(2*VLEN_US)+(x+i)/VLEN_US);
}
ushort8 zero = (ushort8)(0); ushort8 zero = (ushort8)(0);
ushort8 full = (ushort8)(255); ushort8 full = (ushort8)(255);
if( binary ) if( binary )
@ -368,11 +382,11 @@ __kernel void CvMoments_D2(__global ushort8* src_data, int src_rows, int src_col
tmp[i/VLEN_US] = (tmp[i/VLEN_US]!=zero)?full:zero; tmp[i/VLEN_US] = (tmp[i/VLEN_US]!=zero)?full:zero;
F mom[10]; F mom[10];
__local long m[10][128]; __local long m[10][128];
if(lidy == 0) if(lidy < 128)
for(int i=0; i<10; i++) for(int i=0; i<10; i++)
for(int j=0; j<128; j++) m[i][lidy]=0;
m[i][j]=0;
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
long lm[10] = {0}; long lm[10] = {0};
int8 x0 = (int8)(0); int8 x0 = (int8)(0);
int8 x1 = (int8)(0); int8 x1 = (int8)(0);
@ -422,17 +436,22 @@ __kernel void CvMoments_D2(__global ushort8* src_data, int src_rows, int src_col
lm[0] = x0.s0; // m00 lm[0] = x0.s0; // m00
} }
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
for( int j = TILE_SIZE/2; j >= 1; j = j/2 ) for( int j = TILE_SIZE/2; j >= 1; j = j/2 )
{ {
if(lidy < j) if(lidy < j)
for( int i = 0; i < 10; i++ ) for( int i = 0; i < 10; i++ )
lm[i] = lm[i] + m[i][lidy]; lm[i] = lm[i] + m[i][lidy];
barrier(CLK_LOCAL_MEM_FENCE); }
barrier(CLK_LOCAL_MEM_FENCE);
for( int j = TILE_SIZE/2; j >= 1; j = j/2 )
{
if(lidy >= j/2&&lidy < j) if(lidy >= j/2&&lidy < j)
for( int i = 0; i < 10; i++ ) for( int i = 0; i < 10; i++ )
m[i][lidy-j/2] = lm[i]; m[i][lidy-j/2] = lm[i];
barrier(CLK_LOCAL_MEM_FENCE);
} }
barrier(CLK_LOCAL_MEM_FENCE);
if(lidy == 0&&lidx == 0) if(lidy == 0&&lidx == 0)
{ {
for(int mt = 0; mt < 10; mt++ ) for(int mt = 0; mt < 10; mt++ )
@ -482,10 +501,10 @@ __kernel void CvMoments_D2(__global ushort8* src_data, int src_rows, int src_col
} }
} }
__kernel void CvMoments_D3(__global short8* src_data, int src_rows, int src_cols, int src_step, int tileSize_width, int tileSize_height, __kernel void CvMoments_D3(__global short8* src_data, int src_rows, int src_cols, int src_step,
__global F* dst_m, __global F* dst_m,
int dst_cols, int dst_step, int blocky, int dst_cols, int dst_step, int blocky,
int type, int depth, int cn, int coi, int binary, const int TILE_SIZE) int depth, int cn, int coi, int binary, const int TILE_SIZE)
{ {
short tmp_coi[8]; // get the coi data short tmp_coi[8]; // get the coi data
short8 tmp[32]; short8 tmp[32];
@ -500,21 +519,26 @@ __kernel void CvMoments_D3(__global short8* src_data, int src_rows, int src_cols
int x = wgidx*TILE_SIZE; // real X index of pixel int x = wgidx*TILE_SIZE; // real X index of pixel
int kcn = (cn==2)?2:4; int kcn = (cn==2)?2:4;
int rstep = min(src_step/2, TILE_SIZE); int rstep = min(src_step/2, TILE_SIZE);
tileSize_height = min(TILE_SIZE, src_rows - y); int tileSize_height = min(TILE_SIZE, src_rows - y);
tileSize_width = min(TILE_SIZE, src_cols -x); int tileSize_width = min(TILE_SIZE, src_cols -x);
if(tileSize_width < TILE_SIZE)
for(int i = tileSize_width; i < rstep; i++ ) if ( y+lidy < src_rows )
*((__global short*)src_data+(y+lidy)*src_step/2+x+i) = 0; {
if( coi > 0 ) if(tileSize_width < TILE_SIZE)
for(int i=0; i < tileSize_width; i+=VLEN_S) for(int i = tileSize_width; i < rstep && (x+i) < src_cols; i++ )
{ *((__global short*)src_data+(y+lidy)*src_step/2+x+i) = 0;
for(int j=0; j<VLEN_S; j++) if( coi > 0 )
tmp_coi[j] = *((__global short*)src_data+(y+lidy)*src_step/2+(x+i+j)*kcn+coi-1); for(int i=0; i < tileSize_width; i+=VLEN_S)
tmp[i/VLEN_S] = (short8)(tmp_coi[0],tmp_coi[1],tmp_coi[2],tmp_coi[3],tmp_coi[4],tmp_coi[5],tmp_coi[6],tmp_coi[7]); {
} for(int j=0; j<VLEN_S; j++)
else tmp_coi[j] = *((__global short*)src_data+(y+lidy)*src_step/2+(x+i+j)*kcn+coi-1);
for(int i=0; i < tileSize_width; i+=VLEN_S) tmp[i/VLEN_S] = (short8)(tmp_coi[0],tmp_coi[1],tmp_coi[2],tmp_coi[3],tmp_coi[4],tmp_coi[5],tmp_coi[6],tmp_coi[7]);
tmp[i/VLEN_S] = *(src_data+(y+lidy)*src_step/(2*VLEN_S)+(x+i)/VLEN_S); }
else
for(int i=0; i < tileSize_width; i+=VLEN_S)
tmp[i/VLEN_S] = *(src_data+(y+lidy)*src_step/(2*VLEN_S)+(x+i)/VLEN_S);
}
short8 zero = (short8)(0); short8 zero = (short8)(0);
short8 full = (short8)(255); short8 full = (short8)(255);
if( binary ) if( binary )
@ -523,10 +547,9 @@ __kernel void CvMoments_D3(__global short8* src_data, int src_rows, int src_cols
F mom[10]; F mom[10];
__local long m[10][128]; __local long m[10][128];
if(lidy == 0) if(lidy < 128)
for(int i=0; i<10; i++) for(int i=0; i<10; i++)
for(int j=0; j<128; j++) m[i][lidy]=0;
m[i][j]=0;
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
long lm[10] = {0}; long lm[10] = {0};
int8 x0 = (int8)(0); int8 x0 = (int8)(0);
@ -637,10 +660,10 @@ __kernel void CvMoments_D3(__global short8* src_data, int src_rows, int src_cols
} }
} }
__kernel void CvMoments_D5( __global float* src_data, int src_rows, int src_cols, int src_step, int tileSize_width, int tileSize_height, __kernel void CvMoments_D5( __global float* src_data, int src_rows, int src_cols, int src_step,
__global F* dst_m, __global F* dst_m,
int dst_cols, int dst_step, int blocky, int dst_cols, int dst_step, int blocky,
int type, int depth, int cn, int coi, int binary, const int TILE_SIZE) int depth, int cn, int coi, int binary, const int TILE_SIZE)
{ {
float tmp_coi[4]; // get the coi data float tmp_coi[4]; // get the coi data
float4 tmp[64] ; float4 tmp[64] ;
@ -654,33 +677,30 @@ __kernel void CvMoments_D5( __global float* src_data, int src_rows, int src_cols
int y = wgidy*TILE_SIZE; // real Y index of pixel int y = wgidy*TILE_SIZE; // real Y index of pixel
int x = wgidx*TILE_SIZE; // real X index of pixel int x = wgidx*TILE_SIZE; // real X index of pixel
int kcn = (cn==2)?2:4; int kcn = (cn==2)?2:4;
src_step /= sizeof(*src_data); int rstep = min(src_step/4, TILE_SIZE);
int rstep = min(src_step, TILE_SIZE); int tileSize_height = min(TILE_SIZE, src_rows - y);
tileSize_height = min(TILE_SIZE, src_rows - y); int tileSize_width = min(TILE_SIZE, src_cols -x);
tileSize_width = min(TILE_SIZE, src_cols -x);
int maxIdx = mul24(src_rows, src_cols); int maxIdx = mul24(src_rows, src_cols);
int yOff = (y+lidy)*src_step; int yOff = (y+lidy)*src_step;
int index; int index;
if(tileSize_width < TILE_SIZE && yOff < src_rows)
for(int i = tileSize_width; i < rstep && (yOff+x+i) < maxIdx; i++ ) if ( y+lidy < src_rows )
*(src_data+yOff+x+i) = 0; {
if( coi > 0 ) if(tileSize_width < TILE_SIZE)
for(int i=0; i < tileSize_width; i+=VLEN_F) for(int i = tileSize_width; i < rstep && (x+i) < src_cols; i++ )
{ *((__global float*)src_data+(y+lidy)*src_step/4+x+i) = 0;
#pragma unroll if( coi > 0 )
for(int j=0; j<4; j++) for(int i=0; i < tileSize_width; i+=VLEN_F)
{ {
index = yOff+(x+i+j)*kcn+coi-1; for(int j=0; j<4; j++)
if (index < maxIdx) tmp_coi[j] = *(src_data+(y+lidy)*src_step/4+(x+i+j)*kcn+coi-1);
tmp_coi[j] = *(src_data+index); tmp[i/VLEN_F] = (float4)(tmp_coi[0],tmp_coi[1],tmp_coi[2],tmp_coi[3]);
else
tmp_coi[j] = 0;
} }
tmp[i/VLEN_F] = (float4)(tmp_coi[0],tmp_coi[1],tmp_coi[2],tmp_coi[3]); else
} for(int i=0; i < tileSize_width; i+=VLEN_F)
else tmp[i/VLEN_F] = (float4)(*(src_data+(y+lidy)*src_step/4+x+i),*(src_data+(y+lidy)*src_step/4+x+i+1),*(src_data+(y+lidy)*src_step/4+x+i+2),*(src_data+(y+lidy)*src_step/4+x+i+3));
for(int i=0; i < tileSize_width && (yOff+x+i) < maxIdx; i+=VLEN_F) }
tmp[i/VLEN_F] = (*(__global float4 *)(src_data+yOff+x+i));
float4 zero = (float4)(0); float4 zero = (float4)(0);
float4 full = (float4)(255); float4 full = (float4)(255);
if( binary ) if( binary )
@ -688,10 +708,9 @@ __kernel void CvMoments_D5( __global float* src_data, int src_rows, int src_cols
tmp[i/VLEN_F] = (tmp[i/VLEN_F]!=zero)?full:zero; tmp[i/VLEN_F] = (tmp[i/VLEN_F]!=zero)?full:zero;
F mom[10]; F mom[10];
__local F m[10][128]; __local F m[10][128];
if(lidy == 0) if(lidy < 128)
for(int i = 0; i < 10; i ++) for(int i = 0; i < 10; i ++)
for(int j = 0; j < 128; j ++) m[i][lidy] = 0;
m[i][j] = 0;
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
F lm[10] = {0}; F lm[10] = {0};
F4 x0 = (F4)(0); F4 x0 = (F4)(0);
@ -770,66 +789,42 @@ __kernel void CvMoments_D5( __global float* src_data, int src_rows, int src_cols
// accumulate moments computed in each tile // accumulate moments computed in each tile
dst_step /= sizeof(F); dst_step /= sizeof(F);
int dst_x_off = mad24(wgidy, dst_cols, wgidx);
int dst_off = 0;
int max_dst_index = 10 * blocky * get_global_size(1);
// + m00 ( = m00' ) // + m00 ( = m00' )
dst_off = mad24(DST_ROW_00 * blocky, dst_step, dst_x_off); *(dst_m + mad24(DST_ROW_00 * blocky, dst_step, mad24(wgidy, dst_cols, wgidx))) = mom[0];
if (dst_off < max_dst_index)
*(dst_m + dst_off) = mom[0];
// + m10 ( = m10' + x*m00' ) // + m10 ( = m10' + x*m00' )
dst_off = mad24(DST_ROW_10 * blocky, dst_step, dst_x_off); *(dst_m + mad24(DST_ROW_10 * blocky, dst_step, mad24(wgidy, dst_cols, wgidx))) = mom[1] + xm;
if (dst_off < max_dst_index)
*(dst_m + dst_off) = mom[1] + xm;
// + m01 ( = m01' + y*m00' ) // + m01 ( = m01' + y*m00' )
dst_off = mad24(DST_ROW_01 * blocky, dst_step, dst_x_off); *(dst_m + mad24(DST_ROW_01 * blocky, dst_step, mad24(wgidy, dst_cols, wgidx))) = mom[2] + ym;
if (dst_off < max_dst_index)
*(dst_m + dst_off) = mom[2] + ym;
// + m20 ( = m20' + 2*x*m10' + x*x*m00' ) // + m20 ( = m20' + 2*x*m10' + x*x*m00' )
dst_off = mad24(DST_ROW_20 * blocky, dst_step, dst_x_off); *(dst_m + mad24(DST_ROW_20 * blocky, dst_step, mad24(wgidy, dst_cols, wgidx))) = mom[3] + x * (mom[1] * 2 + xm);
if (dst_off < max_dst_index)
*(dst_m + dst_off) = mom[3] + x * (mom[1] * 2 + xm);
// + m11 ( = m11' + x*m01' + y*m10' + x*y*m00' ) // + m11 ( = m11' + x*m01' + y*m10' + x*y*m00' )
dst_off = mad24(DST_ROW_11 * blocky, dst_step, dst_x_off); *(dst_m + mad24(DST_ROW_11 * blocky, dst_step, mad24(wgidy, dst_cols, wgidx))) = mom[4] + x * (mom[2] + ym) + y * mom[1];
if (dst_off < max_dst_index)
*(dst_m + dst_off) = mom[4] + x * (mom[2] + ym) + y * mom[1];
// + m02 ( = m02' + 2*y*m01' + y*y*m00' ) // + m02 ( = m02' + 2*y*m01' + y*y*m00' )
dst_off = mad24(DST_ROW_02 * blocky, dst_step, dst_x_off); *(dst_m + mad24(DST_ROW_02 * blocky, dst_step, mad24(wgidy, dst_cols, wgidx))) = mom[5] + y * (mom[2] * 2 + ym);
if (dst_off < max_dst_index)
*(dst_m + dst_off) = mom[5] + y * (mom[2] * 2 + ym);
// + m30 ( = m30' + 3*x*m20' + 3*x*x*m10' + x*x*x*m00' ) // + m30 ( = m30' + 3*x*m20' + 3*x*x*m10' + x*x*x*m00' )
dst_off = mad24(DST_ROW_30 * blocky, dst_step, dst_x_off); *(dst_m + mad24(DST_ROW_30 * blocky, dst_step, mad24(wgidy, dst_cols, wgidx))) = mom[6] + x * (3. * mom[3] + x * (3. * mom[1] + xm));
if (dst_off < max_dst_index)
*(dst_m + dst_off) = mom[6] + x * (3. * mom[3] + x * (3. * mom[1] + xm));
// + m21 ( = m21' + x*(2*m11' + 2*y*m10' + x*m01' + x*y*m00') + y*m20') // + m21 ( = m21' + x*(2*m11' + 2*y*m10' + x*m01' + x*y*m00') + y*m20')
dst_off = mad24(DST_ROW_21 * blocky, dst_step, dst_x_off); *(dst_m + mad24(DST_ROW_21 * blocky, dst_step, mad24(wgidy, dst_cols, wgidx))) = mom[7] + x * (2 * (mom[4] + y * mom[1]) + x * (mom[2] + ym)) + y * mom[3];
if (dst_off < max_dst_index)
*(dst_m + dst_off) = mom[7] + x * (2 * (mom[4] + y * mom[1]) + x * (mom[2] + ym)) + y * mom[3];
// + m12 ( = m12' + y*(2*m11' + 2*x*m01' + y*m10' + x*y*m00') + x*m02') // + m12 ( = m12' + y*(2*m11' + 2*x*m01' + y*m10' + x*y*m00') + x*m02')
dst_off = mad24(DST_ROW_12 * blocky, dst_step, dst_x_off); *(dst_m + mad24(DST_ROW_12 * blocky, dst_step, mad24(wgidy, dst_cols, wgidx))) = mom[8] + y * (2 * (mom[4] + x * mom[2]) + y * (mom[1] + xm)) + x * mom[5];
if (dst_off < max_dst_index)
*(dst_m + dst_off) = mom[8] + y * (2 * (mom[4] + x * mom[2]) + y * (mom[1] + xm)) + x * mom[5];
// + m03 ( = m03' + 3*y*m02' + 3*y*y*m01' + y*y*y*m00' ) // + m03 ( = m03' + 3*y*m02' + 3*y*y*m01' + y*y*y*m00' )
dst_off = mad24(DST_ROW_03 * blocky, dst_step, dst_x_off); *(dst_m + mad24(DST_ROW_03 * blocky, dst_step, mad24(wgidy, dst_cols, wgidx))) = mom[9] + y * (3. * mom[5] + y * (3. * mom[2] + ym));
if (dst_off < max_dst_index)
*(dst_m + dst_off) = mom[9] + y * (3. * mom[5] + y * (3. * mom[2] + ym));
} }
} }
__kernel void CvMoments_D6(__global F* src_data, int src_rows, int src_cols, int src_step, int tileSize_width, int tileSize_height, __kernel void CvMoments_D6(__global F* src_data, int src_rows, int src_cols, int src_step,
__global F* dst_m, __global F* dst_m,
int dst_cols, int dst_step, int blocky, int dst_cols, int dst_step, int blocky,
int type, int depth, int cn, int coi, int binary, const int TILE_SIZE) int depth, int cn, int coi, int binary, const int TILE_SIZE)
{ {
F tmp_coi[4]; // get the coi data F tmp_coi[4]; // get the coi data
F4 tmp[64]; F4 tmp[64];
@ -844,22 +839,26 @@ __kernel void CvMoments_D6(__global F* src_data, int src_rows, int src_cols, in
int x = wgidx*TILE_SIZE; // real X index of pixel int x = wgidx*TILE_SIZE; // real X index of pixel
int kcn = (cn==2)?2:4; int kcn = (cn==2)?2:4;
int rstep = min(src_step/8, TILE_SIZE); int rstep = min(src_step/8, TILE_SIZE);
tileSize_height = min(TILE_SIZE, src_rows - y); int tileSize_height = min(TILE_SIZE, src_rows - y);
tileSize_width = min(TILE_SIZE, src_cols - x); int tileSize_width = min(TILE_SIZE, src_cols - x);
if ( y+lidy < src_rows )
{
if(tileSize_width < TILE_SIZE)
for(int i = tileSize_width; i < rstep && (x+i) < src_cols; i++ )
*((__global F*)src_data+(y+lidy)*src_step/8+x+i) = 0;
if( coi > 0 )
for(int i=0; i < tileSize_width; i+=VLEN_D)
{
for(int j=0; j<4 && ((x+i+j)*kcn+coi-1)<src_cols; j++)
tmp_coi[j] = *(src_data+(y+lidy)*src_step/8+(x+i+j)*kcn+coi-1);
tmp[i/VLEN_D] = (F4)(tmp_coi[0],tmp_coi[1],tmp_coi[2],tmp_coi[3]);
}
else
for(int i=0; i < tileSize_width && (x+i+3) < src_cols; i+=VLEN_D)
tmp[i/VLEN_D] = (F4)(*(src_data+(y+lidy)*src_step/8+x+i),*(src_data+(y+lidy)*src_step/8+x+i+1),*(src_data+(y+lidy)*src_step/8+x+i+2),*(src_data+(y+lidy)*src_step/8+x+i+3));
}
if(tileSize_width < TILE_SIZE)
for(int i = tileSize_width; i < rstep; i++ )
*((__global F*)src_data+(y+lidy)*src_step/8+x+i) = 0;
if( coi > 0 )
for(int i=0; i < tileSize_width; i+=VLEN_D)
{
for(int j=0; j<4; j++)
tmp_coi[j] = *(src_data+(y+lidy)*src_step/8+(x+i+j)*kcn+coi-1);
tmp[i/VLEN_D] = (F4)(tmp_coi[0],tmp_coi[1],tmp_coi[2],tmp_coi[3]);
}
else
for(int i=0; i < tileSize_width; i+=VLEN_D)
tmp[i/VLEN_D] = (F4)(*(src_data+(y+lidy)*src_step/8+x+i),*(src_data+(y+lidy)*src_step/8+x+i+1),*(src_data+(y+lidy)*src_step/8+x+i+2),*(src_data+(y+lidy)*src_step/8+x+i+3));
F4 zero = (F4)(0); F4 zero = (F4)(0);
F4 full = (F4)(255); F4 full = (F4)(255);
if( binary ) if( binary )
@ -867,10 +866,9 @@ __kernel void CvMoments_D6(__global F* src_data, int src_rows, int src_cols, in
tmp[i/VLEN_D] = (tmp[i/VLEN_D]!=zero)?full:zero; tmp[i/VLEN_D] = (tmp[i/VLEN_D]!=zero)?full:zero;
F mom[10]; F mom[10];
__local F m[10][128]; __local F m[10][128];
if(lidy == 0) if(lidy < 128)
for(int i=0; i<10; i++) for(int i=0; i<10; i++)
for(int j=0; j<128; j++) m[i][lidy]=0;
m[i][j]=0;
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
F lm[10] = {0}; F lm[10] = {0};
F4 x0 = (F4)(0); F4 x0 = (F4)(0);
@ -907,7 +905,6 @@ __kernel void CvMoments_D6(__global F* src_data, int src_rows, int src_cols, in
m[1][lidy-bheight] = x1.s0; // m10 m[1][lidy-bheight] = x1.s0; // m10
m[0][lidy-bheight] = x0.s0; // m00 m[0][lidy-bheight] = x0.s0; // m00
} }
else if(lidy < bheight) else if(lidy < bheight)
{ {
lm[9] = ((F)py) * sy; // m03 lm[9] = ((F)py) * sy; // m03
@ -922,6 +919,7 @@ __kernel void CvMoments_D6(__global F* src_data, int src_rows, int src_cols, in
lm[0] = x0.s0; // m00 lm[0] = x0.s0; // m00
} }
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
for( int j = TILE_SIZE/2; j >= 1; j = j/2 ) for( int j = TILE_SIZE/2; j >= 1; j = j/2 )
{ {
if(lidy < j) if(lidy < j)

@ -133,7 +133,9 @@ __kernel void compute_hists_lut_kernel(
final_hist[(cell_x * 2 + cell_y) * cnbins + bin_id] = final_hist[(cell_x * 2 + cell_y) * cnbins + bin_id] =
hist_[0] + hist_[1] + hist_[2]; hist_[0] + hist_[1] + hist_[2];
} }
#ifdef CPU
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
#endif
int tid = (cell_y * CELLS_PER_BLOCK_Y + cell_x) * 12 + cell_thread_x; int tid = (cell_y * CELLS_PER_BLOCK_Y + cell_x) * 12 + cell_thread_x;
if ((tid < cblock_hist_size) && (gid < blocks_total)) if ((tid < cblock_hist_size) && (gid < blocks_total))
@ -225,8 +227,9 @@ __kernel void compute_hists_kernel(
final_hist[(cell_x * 2 + cell_y) * cnbins + bin_id] = final_hist[(cell_x * 2 + cell_y) * cnbins + bin_id] =
hist_[0] + hist_[1] + hist_[2]; hist_[0] + hist_[1] + hist_[2];
} }
#ifdef CPU
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
#endif
int tid = (cell_y * CELLS_PER_BLOCK_Y + cell_x) * 12 + cell_thread_x; int tid = (cell_y * CELLS_PER_BLOCK_Y + cell_x) * 12 + cell_thread_x;
if ((tid < cblock_hist_size) && (gid < blocks_total)) if ((tid < cblock_hist_size) && (gid < blocks_total))
{ {
@ -318,6 +321,10 @@ float reduce_smem(volatile __local float* smem, int size)
if (tid < 32) if (tid < 32)
{ {
if (size >= 64) smem[tid] = sum = sum + smem[tid + 32]; if (size >= 64) smem[tid] = sum = sum + smem[tid + 32];
#if WAVE_SIZE < 32
} barrier(CLK_LOCAL_MEM_FENCE);
if (tid < 16) {
#endif
if (size >= 32) smem[tid] = sum = sum + smem[tid + 16]; if (size >= 32) smem[tid] = sum = sum + smem[tid + 16];
if (size >= 16) smem[tid] = sum = sum + smem[tid + 8]; if (size >= 16) smem[tid] = sum = sum + smem[tid + 8];
if (size >= 8) smem[tid] = sum = sum + smem[tid + 4]; if (size >= 8) smem[tid] = sum = sum + smem[tid + 4];
@ -418,6 +425,9 @@ __kernel void classify_hists_180_kernel(
{ {
smem[tid] = product = product + smem[tid + 32]; smem[tid] = product = product + smem[tid + 32];
} }
#if WAVE_SIZE < 32
barrier(CLK_LOCAL_MEM_FENCE);
#endif
if (tid < 16) if (tid < 16)
{ {
smem[tid] = product = product + smem[tid + 16]; smem[tid] = product = product + smem[tid + 16];
@ -487,6 +497,10 @@ __kernel void classify_hists_252_kernel(
if (tid < 32) if (tid < 32)
{ {
smem[tid] = product = product + smem[tid + 32]; smem[tid] = product = product + smem[tid + 32];
#if WAVE_SIZE < 32
} barrier(CLK_LOCAL_MEM_FENCE);
if (tid < 16) {
#endif
smem[tid] = product = product + smem[tid + 16]; smem[tid] = product = product + smem[tid + 16];
smem[tid] = product = product + smem[tid + 8]; smem[tid] = product = product + smem[tid + 8];
smem[tid] = product = product + smem[tid + 4]; smem[tid] = product = product + smem[tid + 4];
@ -553,6 +567,10 @@ __kernel void classify_hists_kernel(
if (tid < 32) if (tid < 32)
{ {
smem[tid] = product = product + smem[tid + 32]; smem[tid] = product = product + smem[tid + 32];
#if WAVE_SIZE < 32
} barrier(CLK_LOCAL_MEM_FENCE);
if (tid < 16) {
#endif
smem[tid] = product = product + smem[tid + 16]; smem[tid] = product = product + smem[tid + 16];
smem[tid] = product = product + smem[tid + 8]; smem[tid] = product = product + smem[tid + 8];
smem[tid] = product = product + smem[tid + 4]; smem[tid] = product = product + smem[tid + 4];

@ -0,0 +1,450 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Sen Liu, swjtuls1987@126.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other oclMaterials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#define tx get_local_id(0)
#define ty get_local_id(1)
#define bx get_group_id(0)
#define bdx get_local_size(0)
#define BORDER_SIZE 5
#define MAX_KSIZE_HALF 100
#ifndef polyN
#define polyN 5
#endif
__kernel void polynomialExpansion(__global float * dst,
__global __const float * src,
__global __const float * c_g,
__global __const float * c_xg,
__global __const float * c_xxg,
__local float * smem,
const float4 ig,
const int height, const int width,
int dstStep, int srcStep)
{
const int y = get_global_id(1);
const int x = bx * (bdx - 2*polyN) + tx - polyN;
dstStep /= sizeof(*dst);
srcStep /= sizeof(*src);
int xWarped;
__local float *row = smem + tx;
if (y < height && y >= 0)
{
xWarped = min(max(x, 0), width - 1);
row[0] = src[mad24(y, srcStep, xWarped)] * c_g[0];
row[bdx] = 0.f;
row[2*bdx] = 0.f;
#pragma unroll
for (int k = 1; k <= polyN; ++k)
{
float t0 = src[mad24(max(y - k, 0), srcStep, xWarped)];
float t1 = src[mad24(min(y + k, height - 1), srcStep, xWarped)];
row[0] += c_g[k] * (t0 + t1);
row[bdx] += c_xg[k] * (t1 - t0);
row[2*bdx] += c_xxg[k] * (t0 + t1);
}
}
barrier(CLK_LOCAL_MEM_FENCE);
if (y < height && y >= 0 && tx >= polyN && tx + polyN < bdx && x < width)
{
float b1 = c_g[0] * row[0];
float b3 = c_g[0] * row[bdx];
float b5 = c_g[0] * row[2*bdx];
float b2 = 0, b4 = 0, b6 = 0;
#pragma unroll
for (int k = 1; k <= polyN; ++k)
{
b1 += (row[k] + row[-k]) * c_g[k];
b4 += (row[k] + row[-k]) * c_xxg[k];
b2 += (row[k] - row[-k]) * c_xg[k];
b3 += (row[k + bdx] + row[-k + bdx]) * c_g[k];
b6 += (row[k + bdx] - row[-k + bdx]) * c_xg[k];
b5 += (row[k + 2*bdx] + row[-k + 2*bdx]) * c_g[k];
}
dst[mad24(y, dstStep, xWarped)] = b3*ig.s0;
dst[mad24(height + y, dstStep, xWarped)] = b2*ig.s0;
dst[mad24(2*height + y, dstStep, xWarped)] = b1*ig.s1 + b5*ig.s2;
dst[mad24(3*height + y, dstStep, xWarped)] = b1*ig.s1 + b4*ig.s2;
dst[mad24(4*height + y, dstStep, xWarped)] = b6*ig.s3;
}
}
inline int idx_row_low(const int y, const int last_row)
{
return abs(y) % (last_row + 1);
}
inline int idx_row_high(const int y, const int last_row)
{
return abs(last_row - abs(last_row - y)) % (last_row + 1);
}
inline int idx_row(const int y, const int last_row)
{
return idx_row_low(idx_row_high(y, last_row), last_row);
}
inline int idx_col_low(const int x, const int last_col)
{
return abs(x) % (last_col + 1);
}
inline int idx_col_high(const int x, const int last_col)
{
return abs(last_col - abs(last_col - x)) % (last_col + 1);
}
inline int idx_col(const int x, const int last_col)
{
return idx_col_low(idx_col_high(x, last_col), last_col);
}
__kernel void gaussianBlur(__global float * dst,
__global const float * src,
__global const float * c_gKer,
__local float * smem,
const int height, const int width,
int dstStep, int srcStep,
const int ksizeHalf)
{
const int y = get_global_id(1);
const int x = get_global_id(0);
dstStep /= sizeof(*dst);
srcStep /= sizeof(*src);
__local float *row = smem + ty * (bdx + 2*ksizeHalf);
if (y < height)
{
// Vertical pass
for (int i = tx; i < bdx + 2*ksizeHalf; i += bdx)
{
int xExt = (int)(bx * bdx) + i - ksizeHalf;
xExt = idx_col(xExt, width - 1);
row[i] = src[mad24(y, srcStep, xExt)] * c_gKer[0];
for (int j = 1; j <= ksizeHalf; ++j)
row[i] += (src[mad24(idx_row_low(y - j, height - 1), srcStep, xExt)]
+ src[mad24(idx_row_high(y + j, height - 1), srcStep, xExt)]) * c_gKer[j];
}
}
barrier(CLK_LOCAL_MEM_FENCE);
if (y < height && y >= 0 && x < width && x >= 0)
{
// Horizontal pass
row += tx + ksizeHalf;
float res = row[0] * c_gKer[0];
for (int i = 1; i <= ksizeHalf; ++i)
res += (row[-i] + row[i]) * c_gKer[i];
dst[mad24(y, dstStep, x)] = res;
}
}
__constant float c_border[BORDER_SIZE + 1] = { 0.14f, 0.14f, 0.4472f, 0.4472f, 0.4472f, 1.f };
__kernel void updateMatrices(__global float * M,
__global const float * flowx, __global const float * flowy,
__global const float * R0, __global const float * R1,
const int height, const int width,
int mStep, int xStep, int yStep, int R0Step, int R1Step)
{
const int y = get_global_id(1);
const int x = get_global_id(0);
mStep /= sizeof(*M);
xStep /= sizeof(*flowx);
yStep /= sizeof(*flowy);
R0Step /= sizeof(*R0);
R1Step /= sizeof(*R1);
if (y < height && y >= 0 && x < width && x >= 0)
{
float dx = flowx[mad24(y, xStep, x)];
float dy = flowy[mad24(y, yStep, x)];
float fx = x + dx;
float fy = y + dy;
int x1 = convert_int(floor(fx));
int y1 = convert_int(floor(fy));
fx -= x1;
fy -= y1;
float r2, r3, r4, r5, r6;
if (x1 >= 0 && y1 >= 0 && x1 < width - 1 && y1 < height - 1)
{
float a00 = (1.f - fx) * (1.f - fy);
float a01 = fx * (1.f - fy);
float a10 = (1.f - fx) * fy;
float a11 = fx * fy;
r2 = a00 * R1[mad24(y1, R1Step, x1)] +
a01 * R1[mad24(y1, R1Step, x1 + 1)] +
a10 * R1[mad24(y1 + 1, R1Step, x1)] +
a11 * R1[mad24(y1 + 1, R1Step, x1 + 1)];
r3 = a00 * R1[mad24(height + y1, R1Step, x1)] +
a01 * R1[mad24(height + y1, R1Step, x1 + 1)] +
a10 * R1[mad24(height + y1 + 1, R1Step, x1)] +
a11 * R1[mad24(height + y1 + 1, R1Step, x1 + 1)];
r4 = a00 * R1[mad24(2*height + y1, R1Step, x1)] +
a01 * R1[mad24(2*height + y1, R1Step, x1 + 1)] +
a10 * R1[mad24(2*height + y1 + 1, R1Step, x1)] +
a11 * R1[mad24(2*height + y1 + 1, R1Step, x1 + 1)];
r5 = a00 * R1[mad24(3*height + y1, R1Step, x1)] +
a01 * R1[mad24(3*height + y1, R1Step, x1 + 1)] +
a10 * R1[mad24(3*height + y1 + 1, R1Step, x1)] +
a11 * R1[mad24(3*height + y1 + 1, R1Step, x1 + 1)];
r6 = a00 * R1[mad24(4*height + y1, R1Step, x1)] +
a01 * R1[mad24(4*height + y1, R1Step, x1 + 1)] +
a10 * R1[mad24(4*height + y1 + 1, R1Step, x1)] +
a11 * R1[mad24(4*height + y1 + 1, R1Step, x1 + 1)];
r4 = (R0[mad24(2*height + y, R0Step, x)] + r4) * 0.5f;
r5 = (R0[mad24(3*height + y, R0Step, x)] + r5) * 0.5f;
r6 = (R0[mad24(4*height + y, R0Step, x)] + r6) * 0.25f;
}
else
{
r2 = r3 = 0.f;
r4 = R0[mad24(2*height + y, R0Step, x)];
r5 = R0[mad24(3*height + y, R0Step, x)];
r6 = R0[mad24(4*height + y, R0Step, x)] * 0.5f;
}
r2 = (R0[mad24(y, R0Step, x)] - r2) * 0.5f;
r3 = (R0[mad24(height + y, R0Step, x)] - r3) * 0.5f;
r2 += r4*dy + r6*dx;
r3 += r6*dy + r5*dx;
float scale =
c_border[min(x, BORDER_SIZE)] *
c_border[min(y, BORDER_SIZE)] *
c_border[min(width - x - 1, BORDER_SIZE)] *
c_border[min(height - y - 1, BORDER_SIZE)];
r2 *= scale;
r3 *= scale;
r4 *= scale;
r5 *= scale;
r6 *= scale;
M[mad24(y, mStep, x)] = r4*r4 + r6*r6;
M[mad24(height + y, mStep, x)] = (r4 + r5)*r6;
M[mad24(2*height + y, mStep, x)] = r5*r5 + r6*r6;
M[mad24(3*height + y, mStep, x)] = r4*r2 + r6*r3;
M[mad24(4*height + y, mStep, x)] = r6*r2 + r5*r3;
}
}
__kernel void boxFilter5(__global float * dst,
__global const float * src,
__local float * smem,
const int height, const int width,
int dstStep, int srcStep,
const int ksizeHalf)
{
const int y = get_global_id(1);
const int x = get_global_id(0);
const float boxAreaInv = 1.f / ((1 + 2*ksizeHalf) * (1 + 2*ksizeHalf));
const int smw = bdx + 2*ksizeHalf; // shared memory "width"
__local float *row = smem + 5 * ty * smw;
dstStep /= sizeof(*dst);
srcStep /= sizeof(*src);
if (y < height)
{
// Vertical pass
for (int i = tx; i < bdx + 2*ksizeHalf; i += bdx)
{
int xExt = (int)(bx * bdx) + i - ksizeHalf;
xExt = min(max(xExt, 0), width - 1);
#pragma unroll
for (int k = 0; k < 5; ++k)
row[k*smw + i] = src[mad24(k*height + y, srcStep, xExt)];
for (int j = 1; j <= ksizeHalf; ++j)
#pragma unroll
for (int k = 0; k < 5; ++k)
row[k*smw + i] +=
src[mad24(k*height + max(y - j, 0), srcStep, xExt)] +
src[mad24(k*height + min(y + j, height - 1), srcStep, xExt)];
}
}
barrier(CLK_LOCAL_MEM_FENCE);
if (y < height && y >= 0 && x < width && x >= 0)
{
// Horizontal pass
row += tx + ksizeHalf;
float res[5];
#pragma unroll
for (int k = 0; k < 5; ++k)
res[k] = row[k*smw];
for (int i = 1; i <= ksizeHalf; ++i)
#pragma unroll
for (int k = 0; k < 5; ++k)
res[k] += row[k*smw - i] + row[k*smw + i];
#pragma unroll
for (int k = 0; k < 5; ++k)
dst[mad24(k*height + y, dstStep, x)] = res[k] * boxAreaInv;
}
}
__kernel void updateFlow(__global float4 * flowx, __global float4 * flowy,
__global const float4 * M,
const int height, const int width,
int xStep, int yStep, int mStep)
{
const int y = get_global_id(1);
const int x = get_global_id(0);
xStep /= sizeof(*flowx);
yStep /= sizeof(*flowy);
mStep /= sizeof(*M);
if (y < height && y >= 0 && x < width && x >= 0)
{
float4 g11 = M[mad24(y, mStep, x)];
float4 g12 = M[mad24(height + y, mStep, x)];
float4 g22 = M[mad24(2*height + y, mStep, x)];
float4 h1 = M[mad24(3*height + y, mStep, x)];
float4 h2 = M[mad24(4*height + y, mStep, x)];
float4 detInv = (float4)(1.f) / (g11*g22 - g12*g12 + (float4)(1e-3f));
flowx[mad24(y, xStep, x)] = (g11*h2 - g12*h1) * detInv;
flowy[mad24(y, yStep, x)] = (g22*h1 - g12*h2) * detInv;
}
}
__kernel void gaussianBlur5(__global float * dst,
__global const float * src,
__global const float * c_gKer,
__local float * smem,
const int height, const int width,
int dstStep, int srcStep,
const int ksizeHalf)
{
const int y = get_global_id(1);
const int x = get_global_id(0);
const int smw = bdx + 2*ksizeHalf; // shared memory "width"
__local volatile float *row = smem + 5 * ty * smw;
dstStep /= sizeof(*dst);
srcStep /= sizeof(*src);
if (y < height)
{
// Vertical pass
for (int i = tx; i < bdx + 2*ksizeHalf; i += bdx)
{
int xExt = (int)(bx * bdx) + i - ksizeHalf;
xExt = idx_col(xExt, width - 1);
#pragma unroll
for (int k = 0; k < 5; ++k)
row[k*smw + i] = src[mad24(k*height + y, srcStep, xExt)] * c_gKer[0];
for (int j = 1; j <= ksizeHalf; ++j)
#pragma unroll
for (int k = 0; k < 5; ++k)
row[k*smw + i] +=
(src[mad24(k*height + idx_row_low(y - j, height - 1), srcStep, xExt)] +
src[mad24(k*height + idx_row_high(y + j, height - 1), srcStep, xExt)]) * c_gKer[j];
}
}
barrier(CLK_LOCAL_MEM_FENCE);
if (y < height && y >= 0 && x < width && x >= 0)
{
// Horizontal pass
row += tx + ksizeHalf;
float res[5];
#pragma unroll
for (int k = 0; k < 5; ++k)
res[k] = row[k*smw] * c_gKer[0];
for (int i = 1; i <= ksizeHalf; ++i)
#pragma unroll
for (int k = 0; k < 5; ++k)
res[k] += (row[k*smw - i] + row[k*smw + i]) * c_gKer[i];
#pragma unroll
for (int k = 0; k < 5; ++k)
dst[mad24(k*height + y, dstStep, x)] = res[k];
}
}

@ -162,8 +162,8 @@ __kernel void stereoKernel(__global unsigned char *left, __global unsigned char
int y_tex; int y_tex;
int x_tex = X - radius; int x_tex = X - radius;
if (x_tex >= cwidth) //if (x_tex >= cwidth)
return; // return;
for(int d = STEREO_MIND; d < maxdisp; d += STEREO_DISP_STEP) for(int d = STEREO_MIND; d < maxdisp; d += STEREO_DISP_STEP)
{ {
@ -258,27 +258,13 @@ float sobel(__global unsigned char *input, int x, int y, int rows, int cols)
float CalcSums(__local float *cols, __local float *cols_cache, int winsz) float CalcSums(__local float *cols, __local float *cols_cache, int winsz)
{ {
float cache = 0; unsigned int cache = cols[0];
float cache2 = 0;
int winsz2 = winsz/2;
int x = get_local_id(0);
int group_size_x = get_local_size(0);
for(int i = 1; i <= winsz2; i++) #pragma unroll
for(int i = 1; i <= winsz; i++)
cache += cols[i]; cache += cols[i];
cols_cache[0] = cache; return cache;
barrier(CLK_LOCAL_MEM_FENCE);
if (x < group_size_x - winsz2)
cache2 = cols_cache[winsz2];
else
for(int i = winsz2 + 1; i < winsz; i++)
cache2 += cols[i];
return cols[0] + cache + cache2;
} }
#define RpT (2 * ROWSperTHREAD) // got experimentally #define RpT (2 * ROWSperTHREAD) // got experimentally
@ -301,8 +287,7 @@ __kernel void textureness_kernel(__global unsigned char *disp, int disp_rows, in
int beg_row = group_id_y * RpT; int beg_row = group_id_y * RpT;
int end_row = min(beg_row + RpT, disp_rows); int end_row = min(beg_row + RpT, disp_rows);
// if (x < disp_cols)
// {
int y = beg_row; int y = beg_row;
float sum = 0; float sum = 0;
@ -340,11 +325,15 @@ __kernel void textureness_kernel(__global unsigned char *disp, int disp_rows, in
} }
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
float sum_win = CalcSums(cols, cols_cache + local_id_x, winsz) * 255;
if (sum_win < threshold) if (x < disp_cols)
disp[y * disp_step + x] = 0; {
float sum_win = CalcSums(cols, cols_cache + local_id_x, winsz) * 255;
if (sum_win < threshold)
disp[y * disp_step + x] = 0;
}
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
} }
// }
} }

@ -0,0 +1,540 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Sen Liu, swjtuls1987@126.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other oclMaterials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
#include "opencv2/video/tracking.hpp"
using namespace std;
using namespace cv;
using namespace cv::ocl;
#define MIN_SIZE 32
namespace cv
{
namespace ocl
{
///////////////////////////OpenCL kernel strings///////////////////////////
extern const char *optical_flow_farneback;
}
}
namespace cv {
namespace ocl {
namespace optflow_farneback
{
oclMat g;
oclMat xg;
oclMat xxg;
oclMat gKer;
float ig[4];
inline int divUp(int total, int grain)
{
return (total + grain - 1) / grain;
}
inline void setGaussianBlurKernel(const float *c_gKer, int ksizeHalf)
{
cv::Mat t_gKer(1, ksizeHalf + 1, CV_32FC1, const_cast<float *>(c_gKer));
gKer.upload(t_gKer);
}
static void gaussianBlurOcl(const oclMat &src, int ksizeHalf, oclMat &dst)
{
string kernelName("gaussianBlur");
size_t localThreads[3] = { 256, 1, 1 };
size_t globalThreads[3] = { divUp(src.cols, localThreads[0]) * localThreads[0], src.rows, 1 };
int smem_size = (localThreads[0] + 2*ksizeHalf) * sizeof(float);
CV_Assert(dst.size() == src.size());
std::vector< std::pair<size_t, const void *> > args;
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&dst.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&src.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&gKer.data));
args.push_back(std::make_pair(smem_size, (void *)NULL));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.rows));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.cols));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.step));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.step));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&ksizeHalf));
openCLExecuteKernel(Context::getContext(), &optical_flow_farneback, kernelName,
globalThreads, localThreads, args, -1, -1);
}
static void polynomialExpansionOcl(const oclMat &src, int polyN, oclMat &dst)
{
string kernelName("polynomialExpansion");
size_t localThreads[3] = { 256, 1, 1 };
size_t globalThreads[3] = { divUp(src.cols, localThreads[0] - 2*polyN) * localThreads[0], src.rows, 1 };
int smem_size = 3 * localThreads[0] * sizeof(float);
std::vector< std::pair<size_t, const void *> > args;
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&dst.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&src.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&g.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&xg.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&xxg.data));
args.push_back(std::make_pair(smem_size, (void *)NULL));
args.push_back(std::make_pair(sizeof(cl_float4), (void *)&ig));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.rows));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.cols));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.step));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.step));
char opt [128];
sprintf(opt, "-D polyN=%d", polyN);
openCLExecuteKernel(Context::getContext(), &optical_flow_farneback, kernelName,
globalThreads, localThreads, args, -1, -1, opt);
}
static void updateMatricesOcl(const oclMat &flowx, const oclMat &flowy, const oclMat &R0, const oclMat &R1, oclMat &M)
{
string kernelName("updateMatrices");
size_t localThreads[3] = { 32, 8, 1 };
size_t globalThreads[3] = { divUp(flowx.cols, localThreads[0]) * localThreads[0],
divUp(flowx.rows, localThreads[1]) * localThreads[1],
1
};
std::vector< std::pair<size_t, const void *> > args;
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&M.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&flowx.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&flowy.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&R0.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&R1.data));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&flowx.rows));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&flowx.cols));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&M.step));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&flowx.step));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&flowy.step));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&R0.step));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&R1.step));
openCLExecuteKernel(Context::getContext(), &optical_flow_farneback, kernelName,
globalThreads, localThreads, args, -1, -1);
}
static void boxFilter5Ocl(const oclMat &src, int ksizeHalf, oclMat &dst)
{
string kernelName("boxFilter5");
int height = src.rows / 5;
size_t localThreads[3] = { 256, 1, 1 };
size_t globalThreads[3] = { divUp(src.cols, localThreads[0]) * localThreads[0], height, 1 };
int smem_size = (localThreads[0] + 2*ksizeHalf) * 5 * sizeof(float);
std::vector< std::pair<size_t, const void *> > args;
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&dst.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&src.data));
args.push_back(std::make_pair(smem_size, (void *)NULL));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&height));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.cols));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.step));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.step));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&ksizeHalf));
openCLExecuteKernel(Context::getContext(), &optical_flow_farneback, kernelName,
globalThreads, localThreads, args, -1, -1);
}
static void updateFlowOcl(const oclMat &M, oclMat &flowx, oclMat &flowy)
{
string kernelName("updateFlow");
int cols = divUp(flowx.cols, 4);
size_t localThreads[3] = { 32, 8, 1 };
size_t globalThreads[3] = { divUp(cols, localThreads[0]) * localThreads[0],
divUp(flowx.rows, localThreads[1]) * localThreads[0],
1
};
std::vector< std::pair<size_t, const void *> > args;
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&flowx.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&flowy.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&M.data));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&flowx.rows));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&cols));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&flowx.step));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&flowy.step));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&M.step));
openCLExecuteKernel(Context::getContext(), &optical_flow_farneback, kernelName,
globalThreads, localThreads, args, -1, -1);
}
static void gaussianBlur5Ocl(const oclMat &src, int ksizeHalf, oclMat &dst)
{
string kernelName("gaussianBlur5");
int height = src.rows / 5;
int width = src.cols;
size_t localThreads[3] = { 256, 1, 1 };
size_t globalThreads[3] = { divUp(width, localThreads[0]) * localThreads[0], height, 1 };
int smem_size = (localThreads[0] + 2*ksizeHalf) * 5 * sizeof(float);
std::vector< std::pair<size_t, const void *> > args;
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&dst.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&src.data));
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&gKer.data));
args.push_back(std::make_pair(smem_size, (void *)NULL));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&height));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&width));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&dst.step));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&src.step));
args.push_back(std::make_pair(sizeof(cl_int), (void *)&ksizeHalf));
openCLExecuteKernel(Context::getContext(), &optical_flow_farneback, kernelName,
globalThreads, localThreads, args, -1, -1);
}
}
}
} // namespace cv { namespace ocl { namespace optflow_farneback
static oclMat allocMatFromBuf(int rows, int cols, int type, oclMat &mat)
{
if (!mat.empty() && mat.type() == type && mat.rows >= rows && mat.cols >= cols)
return mat(Rect(0, 0, cols, rows));
return mat = oclMat(rows, cols, type);
}
cv::ocl::FarnebackOpticalFlow::FarnebackOpticalFlow()
{
numLevels = 5;
pyrScale = 0.5;
fastPyramids = false;
winSize = 13;
numIters = 10;
polyN = 5;
polySigma = 1.1;
flags = 0;
}
void cv::ocl::FarnebackOpticalFlow::releaseMemory()
{
frames_[0].release();
frames_[1].release();
pyrLevel_[0].release();
pyrLevel_[1].release();
M_.release();
bufM_.release();
R_[0].release();
R_[1].release();
blurredFrame_[0].release();
blurredFrame_[1].release();
pyramid0_.clear();
pyramid1_.clear();
}
void cv::ocl::FarnebackOpticalFlow::prepareGaussian(
int n, double sigma, float *g, float *xg, float *xxg,
double &ig11, double &ig03, double &ig33, double &ig55)
{
double s = 0.;
for (int x = -n; x <= n; x++)
{
g[x] = (float)std::exp(-x*x/(2*sigma*sigma));
s += g[x];
}
s = 1./s;
for (int x = -n; x <= n; x++)
{
g[x] = (float)(g[x]*s);
xg[x] = (float)(x*g[x]);
xxg[x] = (float)(x*x*g[x]);
}
Mat_<double> G(6, 6);
G.setTo(0);
for (int y = -n; y <= n; y++)
{
for (int x = -n; x <= n; x++)
{
G(0,0) += g[y]*g[x];
G(1,1) += g[y]*g[x]*x*x;
G(3,3) += g[y]*g[x]*x*x*x*x;
G(5,5) += g[y]*g[x]*x*x*y*y;
}
}
//G[0][0] = 1.;
G(2,2) = G(0,3) = G(0,4) = G(3,0) = G(4,0) = G(1,1);
G(4,4) = G(3,3);
G(3,4) = G(4,3) = G(5,5);
// invG:
// [ x e e ]
// [ y ]
// [ y ]
// [ e z ]
// [ e z ]
// [ u ]
Mat_<double> invG = G.inv(DECOMP_CHOLESKY);
ig11 = invG(1,1);
ig03 = invG(0,3);
ig33 = invG(3,3);
ig55 = invG(5,5);
}
void cv::ocl::FarnebackOpticalFlow::setPolynomialExpansionConsts(int n, double sigma)
{
vector<float> buf(n*6 + 3);
float* g = &buf[0] + n;
float* xg = g + n*2 + 1;
float* xxg = xg + n*2 + 1;
if (sigma < FLT_EPSILON)
sigma = n*0.3;
double ig11, ig03, ig33, ig55;
prepareGaussian(n, sigma, g, xg, xxg, ig11, ig03, ig33, ig55);
cv::Mat t_g(1, n + 1, CV_32FC1, g);
cv::Mat t_xg(1, n + 1, CV_32FC1, xg);
cv::Mat t_xxg(1, n + 1, CV_32FC1, xxg);
optflow_farneback::g.upload(t_g);
optflow_farneback::xg.upload(t_xg);
optflow_farneback::xxg.upload(t_xxg);
optflow_farneback::ig[0] = static_cast<float>(ig11);
optflow_farneback::ig[1] = static_cast<float>(ig03);
optflow_farneback::ig[2] = static_cast<float>(ig33);
optflow_farneback::ig[3] = static_cast<float>(ig55);
}
void cv::ocl::FarnebackOpticalFlow::updateFlow_boxFilter(
const oclMat& R0, const oclMat& R1, oclMat& flowx, oclMat &flowy,
oclMat& M, oclMat &bufM, int blockSize, bool updateMatrices)
{
optflow_farneback::boxFilter5Ocl(M, blockSize/2, bufM);
swap(M, bufM);
finish();
optflow_farneback::updateFlowOcl(M, flowx, flowy);
if (updateMatrices)
optflow_farneback::updateMatricesOcl(flowx, flowy, R0, R1, M);
}
void cv::ocl::FarnebackOpticalFlow::updateFlow_gaussianBlur(
const oclMat& R0, const oclMat& R1, oclMat& flowx, oclMat& flowy,
oclMat& M, oclMat &bufM, int blockSize, bool updateMatrices)
{
optflow_farneback::gaussianBlur5Ocl(M, blockSize/2, bufM);
swap(M, bufM);
optflow_farneback::updateFlowOcl(M, flowx, flowy);
if (updateMatrices)
optflow_farneback::updateMatricesOcl(flowx, flowy, R0, R1, M);
}
void cv::ocl::FarnebackOpticalFlow::operator ()(
const oclMat &frame0, const oclMat &frame1, oclMat &flowx, oclMat &flowy)
{
CV_Assert(frame0.channels() == 1 && frame1.channels() == 1);
CV_Assert(frame0.size() == frame1.size());
CV_Assert(polyN == 5 || polyN == 7);
CV_Assert(!fastPyramids || std::abs(pyrScale - 0.5) < 1e-6);
Size size = frame0.size();
oclMat prevFlowX, prevFlowY, curFlowX, curFlowY;
flowx.create(size, CV_32F);
flowy.create(size, CV_32F);
oclMat flowx0 = flowx;
oclMat flowy0 = flowy;
// Crop unnecessary levels
double scale = 1;
int numLevelsCropped = 0;
for (; numLevelsCropped < numLevels; numLevelsCropped++)
{
scale *= pyrScale;
if (size.width*scale < MIN_SIZE || size.height*scale < MIN_SIZE)
break;
}
frame0.convertTo(frames_[0], CV_32F);
frame1.convertTo(frames_[1], CV_32F);
if (fastPyramids)
{
// Build Gaussian pyramids using pyrDown()
pyramid0_.resize(numLevelsCropped + 1);
pyramid1_.resize(numLevelsCropped + 1);
pyramid0_[0] = frames_[0];
pyramid1_[0] = frames_[1];
for (int i = 1; i <= numLevelsCropped; ++i)
{
pyrDown(pyramid0_[i - 1], pyramid0_[i]);
pyrDown(pyramid1_[i - 1], pyramid1_[i]);
}
}
setPolynomialExpansionConsts(polyN, polySigma);
for (int k = numLevelsCropped; k >= 0; k--)
{
scale = 1;
for (int i = 0; i < k; i++)
scale *= pyrScale;
double sigma = (1./scale - 1) * 0.5;
int smoothSize = cvRound(sigma*5) | 1;
smoothSize = std::max(smoothSize, 3);
int width = cvRound(size.width*scale);
int height = cvRound(size.height*scale);
if (fastPyramids)
{
width = pyramid0_[k].cols;
height = pyramid0_[k].rows;
}
if (k > 0)
{
curFlowX.create(height, width, CV_32F);
curFlowY.create(height, width, CV_32F);
}
else
{
curFlowX = flowx0;
curFlowY = flowy0;
}
if (!prevFlowX.data)
{
if (flags & cv::OPTFLOW_USE_INITIAL_FLOW)
{
resize(flowx0, curFlowX, Size(width, height), 0, 0, INTER_LINEAR);
resize(flowy0, curFlowY, Size(width, height), 0, 0, INTER_LINEAR);
multiply(scale, curFlowX, curFlowX);
multiply(scale, curFlowY, curFlowY);
}
else
{
curFlowX.setTo(0);
curFlowY.setTo(0);
}
}
else
{
resize(prevFlowX, curFlowX, Size(width, height), 0, 0, INTER_LINEAR);
resize(prevFlowY, curFlowY, Size(width, height), 0, 0, INTER_LINEAR);
multiply(1./pyrScale, curFlowX, curFlowX);
multiply(1./pyrScale, curFlowY, curFlowY);
}
oclMat M = allocMatFromBuf(5*height, width, CV_32F, M_);
oclMat bufM = allocMatFromBuf(5*height, width, CV_32F, bufM_);
oclMat R[2] =
{
allocMatFromBuf(5*height, width, CV_32F, R_[0]),
allocMatFromBuf(5*height, width, CV_32F, R_[1])
};
if (fastPyramids)
{
optflow_farneback::polynomialExpansionOcl(pyramid0_[k], polyN, R[0]);
optflow_farneback::polynomialExpansionOcl(pyramid1_[k], polyN, R[1]);
}
else
{
oclMat blurredFrame[2] =
{
allocMatFromBuf(size.height, size.width, CV_32F, blurredFrame_[0]),
allocMatFromBuf(size.height, size.width, CV_32F, blurredFrame_[1])
};
oclMat pyrLevel[2] =
{
allocMatFromBuf(height, width, CV_32F, pyrLevel_[0]),
allocMatFromBuf(height, width, CV_32F, pyrLevel_[1])
};
Mat g = getGaussianKernel(smoothSize, sigma, CV_32F);
optflow_farneback::setGaussianBlurKernel(g.ptr<float>(smoothSize/2), smoothSize/2);
for (int i = 0; i < 2; i++)
{
optflow_farneback::gaussianBlurOcl(frames_[i], smoothSize/2, blurredFrame[i]);
resize(blurredFrame[i], pyrLevel[i], Size(width, height), INTER_LINEAR);
optflow_farneback::polynomialExpansionOcl(pyrLevel[i], polyN, R[i]);
}
}
optflow_farneback::updateMatricesOcl(curFlowX, curFlowY, R[0], R[1], M);
if (flags & OPTFLOW_FARNEBACK_GAUSSIAN)
{
Mat g = getGaussianKernel(winSize, winSize/2*0.3f, CV_32F);
optflow_farneback::setGaussianBlurKernel(g.ptr<float>(winSize/2), winSize/2);
}
for (int i = 0; i < numIters; i++)
{
if (flags & OPTFLOW_FARNEBACK_GAUSSIAN)
updateFlow_gaussianBlur(R[0], R[1], curFlowX, curFlowY, M, bufM, winSize, i < numIters-1);
else
updateFlow_boxFilter(R[0], R[1], curFlowX, curFlowY, M, bufM, winSize, i < numIters-1);
}
prevFlowX = curFlowX;
prevFlowY = curFlowY;
}
flowx = curFlowX;
flowy = curFlowY;
}

@ -117,6 +117,8 @@ int main(int argc, char **argv)
} }
setDevice(oclinfo[pid], device); setDevice(oclinfo[pid], device);
setBinaryDiskCache(CACHE_UPDATE);
cout << "Platform name:" << oclinfo[pid].PlatformName << endl; cout << "Platform name:" << oclinfo[pid].PlatformName << endl;
cout << "Device type:" << type << endl << "Device name:" << oclinfo[pid].DeviceName[device] << endl; cout << "Device type:" << type << endl << "Device name:" << oclinfo[pid].DeviceName[device] << endl;
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();

@ -1425,7 +1425,7 @@ PARAM_TEST_CASE(CLAHE, cv::Size, ClipLimit)
TEST_P(CLAHE, Accuracy) TEST_P(CLAHE, Accuracy)
{ {
cv::Ptr<cv::ocl::CLAHE> clahe = cv::ocl::createCLAHE(clipLimit); cv::Ptr<cv::CLAHE> clahe = cv::ocl::createCLAHE(clipLimit);
clahe->apply(g_src, g_dst); clahe->apply(g_src, g_dst);
cv::Mat dst(g_dst); cv::Mat dst(g_dst);

@ -44,12 +44,12 @@ TEST_P(MomentsTest, Mat)
{ {
if(test_contours) if(test_contours)
{ {
Mat src = imread( workdir + "../cpp/pic3.png", 1 ); Mat src = imread( workdir + "../cpp/pic3.png", IMREAD_GRAYSCALE );
Mat src_gray, canny_output; ASSERT_FALSE(src.empty());
cvtColor( src, src_gray, COLOR_BGR2GRAY ); Mat canny_output;
vector<vector<Point> > contours; vector<vector<Point> > contours;
vector<Vec4i> hierarchy; vector<Vec4i> hierarchy;
Canny( src_gray, canny_output, 100, 200, 3 ); Canny( src, canny_output, 100, 200, 3 );
findContours( canny_output, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0) ); findContours( canny_output, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0) );
for( size_t i = 0; i < contours.size(); i++ ) for( size_t i = 0; i < contours.size(); i++ )
{ {

@ -149,17 +149,17 @@ TEST_P(HOG, Detect)
if (winSize.width == 48 && winSize.height == 96) if (winSize.width == 48 && winSize.height == 96)
{ {
// daimler's base // daimler's base
ocl_hog.setSVMDetector(ocl_hog.getPeopleDetector48x96()); ocl_hog.setSVMDetector(hog.getDaimlerPeopleDetector());
hog.setSVMDetector(hog.getDaimlerPeopleDetector()); hog.setSVMDetector(hog.getDaimlerPeopleDetector());
} }
else if (winSize.width == 64 && winSize.height == 128) else if (winSize.width == 64 && winSize.height == 128)
{ {
ocl_hog.setSVMDetector(ocl_hog.getPeopleDetector64x128()); ocl_hog.setSVMDetector(hog.getDefaultPeopleDetector());
hog.setSVMDetector(hog.getDefaultPeopleDetector()); hog.setSVMDetector(hog.getDefaultPeopleDetector());
} }
else else
{ {
ocl_hog.setSVMDetector(ocl_hog.getDefaultPeopleDetector()); ocl_hog.setSVMDetector(hog.getDefaultPeopleDetector());
hog.setSVMDetector(hog.getDefaultPeopleDetector()); hog.setSVMDetector(hog.getDefaultPeopleDetector());
} }

@ -272,6 +272,78 @@ TEST_P(Sparse, Mat)
INSTANTIATE_TEST_CASE_P(OCL_Video, Sparse, Combine( INSTANTIATE_TEST_CASE_P(OCL_Video, Sparse, Combine(
Values(false, true), Values(false, true),
Values(false, true))); Values(false, true)));
//////////////////////////////////////////////////////
// FarnebackOpticalFlow
namespace
{
IMPLEMENT_PARAM_CLASS(PyrScale, double)
IMPLEMENT_PARAM_CLASS(PolyN, int)
CV_FLAGS(FarnebackOptFlowFlags, 0, OPTFLOW_FARNEBACK_GAUSSIAN)
IMPLEMENT_PARAM_CLASS(UseInitFlow, bool)
}
PARAM_TEST_CASE(Farneback, PyrScale, PolyN, FarnebackOptFlowFlags, UseInitFlow)
{
double pyrScale;
int polyN;
int flags;
bool useInitFlow;
virtual void SetUp()
{
pyrScale = GET_PARAM(0);
polyN = GET_PARAM(1);
flags = GET_PARAM(2);
useInitFlow = GET_PARAM(3);
}
};
TEST_P(Farneback, Accuracy)
{
cv::Mat frame0 = imread(workdir + "/rubberwhale1.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame0.empty());
cv::Mat frame1 = imread(workdir + "/rubberwhale2.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame1.empty());
double polySigma = polyN <= 5 ? 1.1 : 1.5;
cv::ocl::FarnebackOpticalFlow farn;
farn.pyrScale = pyrScale;
farn.polyN = polyN;
farn.polySigma = polySigma;
farn.flags = flags;
cv::ocl::oclMat d_flowx, d_flowy;
farn(oclMat(frame0), oclMat(frame1), d_flowx, d_flowy);
cv::Mat flow;
if (useInitFlow)
{
cv::Mat flowxy[] = {cv::Mat(d_flowx), cv::Mat(d_flowy)};
cv::merge(flowxy, 2, flow);
farn.flags |= cv::OPTFLOW_USE_INITIAL_FLOW;
farn(oclMat(frame0), oclMat(frame1), d_flowx, d_flowy);
}
cv::calcOpticalFlowFarneback(
frame0, frame1, flow, farn.pyrScale, farn.numLevels, farn.winSize,
farn.numIters, farn.polyN, farn.polySigma, farn.flags);
std::vector<cv::Mat> flowxy;
cv::split(flow, flowxy);
EXPECT_MAT_SIMILAR(flowxy[0], d_flowx, 0.1);
EXPECT_MAT_SIMILAR(flowxy[1], d_flowy, 0.1);
}
INSTANTIATE_TEST_CASE_P(OCL_Video, Farneback, testing::Combine(
testing::Values(PyrScale(0.3), PyrScale(0.5), PyrScale(0.8)),
testing::Values(PolyN(5), PolyN(7)),
testing::Values(FarnebackOptFlowFlags(0), FarnebackOptFlowFlags(cv::OPTFLOW_FARNEBACK_GAUSSIAN)),
testing::Values(UseInitFlow(false), UseInitFlow(true))));
#endif // HAVE_OPENCL #endif // HAVE_OPENCL

@ -44,4 +44,11 @@
using namespace perf; using namespace perf;
CV_PERF_TEST_MAIN(superres, printCudaInfo()) static const char * impls[] = {
#ifdef HAVE_CUDA
"cuda",
#endif
"plain"
};
CV_PERF_TEST_MAIN_WITH_IMPLS(superres, impls, printCudaInfo())

@ -17566,6 +17566,9 @@ GTEST_DECLARE_string_(color);
// the tests to run. If the filter is not given all tests are executed. // the tests to run. If the filter is not given all tests are executed.
GTEST_DECLARE_string_(filter); GTEST_DECLARE_string_(filter);
// OpenCV extension: same as filter, but for the parameters string.
GTEST_DECLARE_string_(param_filter);
// This flag causes the Google Test to list tests. None of the tests listed // This flag causes the Google Test to list tests. None of the tests listed
// are actually run if the flag is provided. // are actually run if the flag is provided.
GTEST_DECLARE_bool_(list_tests); GTEST_DECLARE_bool_(list_tests);

@ -218,8 +218,7 @@ public:
static bool targetDevice(); static bool targetDevice();
}; };
# define PERF_RUN_GPU() ::perf::GpuPerf::targetDevice() #define PERF_RUN_GPU() ::perf::GpuPerf::targetDevice()
/*****************************************************************************************\ /*****************************************************************************************\
* Container for performance metrics * * Container for performance metrics *
@ -261,7 +260,11 @@ public:
TestBase(); TestBase();
static void Init(int argc, const char* const argv[]); static void Init(int argc, const char* const argv[]);
static void Init(const std::vector<std::string> & availableImpls,
int argc, const char* const argv[]);
static void RecordRunParameters();
static std::string getDataPath(const std::string& relativePath); static std::string getDataPath(const std::string& relativePath);
static std::string getSelectedImpl();
protected: protected:
virtual void PerfTestBody() = 0; virtual void PerfTestBody() = 0;
@ -475,15 +478,29 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os);
void fixture##_##name::PerfTestBody() void fixture##_##name::PerfTestBody()
#define CV_PERF_TEST_MAIN(testsuitname, ...) \ #define CV_PERF_TEST_MAIN_INTERNALS(modulename, impls, ...) \
int main(int argc, char **argv)\
{\
while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construction is needed for VS 2005*/\ while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construction is needed for VS 2005*/\
::perf::Regression::Init(#testsuitname);\ ::perf::Regression::Init(#modulename);\
::perf::TestBase::Init(argc, argv);\ ::perf::TestBase::Init(std::vector<std::string>(impls, impls + sizeof impls / sizeof *impls),\
argc, argv);\
::testing::InitGoogleTest(&argc, argv);\ ::testing::InitGoogleTest(&argc, argv);\
cvtest::printVersionInfo();\ cvtest::printVersionInfo();\
return RUN_ALL_TESTS();\ ::testing::Test::RecordProperty("cv_module_name", #modulename);\
::perf::TestBase::RecordRunParameters();\
return RUN_ALL_TESTS();
// impls must be an array, not a pointer; "plain" should always be one of the implementations
#define CV_PERF_TEST_MAIN_WITH_IMPLS(modulename, impls, ...) \
int main(int argc, char **argv)\
{\
CV_PERF_TEST_MAIN_INTERNALS(modulename, impls, __VA_ARGS__)\
}
#define CV_PERF_TEST_MAIN(modulename, ...) \
int main(int argc, char **argv)\
{\
const char * plain_only[] = { "plain" };\
CV_PERF_TEST_MAIN_INTERNALS(modulename, plain_only, __VA_ARGS__)\
} }
#define TEST_CYCLE_N(n) for(declare.iterations(n); startTimer(), next(); stopTimer()) #define TEST_CYCLE_N(n) for(declare.iterations(n); startTimer(), next(); stopTimer())

@ -1,6 +1,9 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys, re, os.path import collections
import re
import os.path
import sys
from xml.dom.minidom import parse from xml.dom.minidom import parse
class TestInfo(object): class TestInfo(object):
@ -159,12 +162,31 @@ class TestInfo(object):
return 1 return 1
return 0 return 0
# This is a Sequence for compatibility with old scripts,
# which treat parseLogFile's return value as a list.
class TestRunInfo(collections.Sequence):
def __init__(self, properties, tests):
self.properties = properties
self.tests = tests
def __len__(self):
return len(self.tests)
def __getitem__(self, key):
return self.tests[key]
def parseLogFile(filename): def parseLogFile(filename):
tests = []
log = parse(filename) log = parse(filename)
for case in log.getElementsByTagName("testcase"):
tests.append(TestInfo(case)) properties = {
return tests attr_name[3:]: attr_value
for (attr_name, attr_value) in log.documentElement.attributes.items()
if attr_name.startswith('cv_')
}
tests = map(TestInfo, log.getElementsByTagName("testcase"))
return TestRunInfo(properties, tests)
if __name__ == "__main__": if __name__ == "__main__":
@ -173,8 +195,18 @@ if __name__ == "__main__":
exit(0) exit(0)
for arg in sys.argv[1:]: for arg in sys.argv[1:]:
print "Tests found in", arg print "Processing {}...".format(arg)
tests = parseLogFile(arg)
for t in sorted(tests): run = parseLogFile(arg)
print "Properties:"
for (prop_name, prop_value) in run.properties.items():
print "\t{} = {}".format(prop_name, prop_value)
print "Tests:"
for t in sorted(run.tests):
t.dump() t.dump()
print print

@ -1,8 +1,73 @@
#!/usr/bin/env python #!/usr/bin/env python
"""
This script can generate XLS reports from OpenCV tests' XML output files.
To use it, first, create a directory for each machine you ran tests on.
Each such directory will become a sheet in the report. Put each XML file
into the corresponding directory.
Then, create your configuration file(s). You can have a global configuration
file (specified with the -c option), and per-sheet configuration files, which
must be called sheet.conf and placed in the directory corresponding to the sheet.
The settings in the per-sheet configuration file will override those in the
global configuration file, if both are present.
A configuration file must consist of a Python dictionary. The following keys
will be recognized:
* 'comparisons': [{'from': string, 'to': string}]
List of configurations to compare performance between. For each item,
the sheet will have a column showing speedup from configuration named
'from' to configuration named "to".
* 'configuration_matchers': [{'properties': {string: object}, 'name': string}]
Instructions for matching test run property sets to configuration names.
For each found XML file:
1) All attributes of the root element starting with the prefix 'cv_' are
placed in a dictionary, with the cv_ prefix stripped and the cv_module_name
element deleted.
2) The first matcher for which the XML's file property set contains the same
keys with equal values as its 'properties' dictionary is searched for.
A missing property can be matched by using None as the value.
Corollary 1: you should place more specific matchers before less specific
ones.
Corollary 2: an empty 'properties' dictionary matches every property set.
3) If a matching matcher is found, its 'name' string is presumed to be the name
of the configuration the XML file corresponds to. Otherwise, a warning is
printed. A warning is also printed if two different property sets match to the
same configuration name.
* 'configurations': [string]
List of names for compile-time and runtime configurations of OpenCV.
Each item will correspond to a column of the sheet.
* 'module_colors': {string: string}
Mapping from module name to color name. In the sheet, cells containing module
names from this mapping will be colored with the corresponding color. You can
find the list of available colors here:
<http://www.simplistix.co.uk/presentations/python-excel.pdf>.
* 'sheet_name': string
Name for the sheet. If this parameter is missing, the name of sheet's directory
will be used.
Note that all keys are optional, although to get useful results, you'll want to
specify at least 'configurations' and 'configuration_matchers'.
Finally, run the script. Use the --help option for usage information.
"""
from __future__ import division from __future__ import division
import ast import ast
import fnmatch
import logging import logging
import numbers import numbers
import os, os.path import os, os.path
@ -17,21 +82,6 @@ import xlwt
from testlog_parser import parseLogFile from testlog_parser import parseLogFile
# To build XLS report you neet to put your xmls (OpenCV tests output) in the
# following way:
#
# "root" --- folder, representing the whole XLS document. It contains several
# subfolders --- sheet-paths of the XLS document. Each sheet-path contains it's
# subfolders --- config-paths. Config-paths are columns of the sheet and
# they contains xmls files --- output of OpenCV modules testing.
# Config-path means OpenCV build configuration, including different
# options such as NEON, TBB, GPU enabling/disabling.
#
# root
# root\sheet_path
# root\sheet_path\configuration1 (column 1)
# root\sheet_path\configuration2 (column 2)
re_image_size = re.compile(r'^ \d+ x \d+$', re.VERBOSE) re_image_size = re.compile(r'^ \d+ x \d+$', re.VERBOSE)
re_data_type = re.compile(r'^ (?: 8 | 16 | 32 | 64 ) [USF] C [1234] $', re.VERBOSE) re_data_type = re.compile(r'^ (?: 8 | 16 | 32 | 64 ) [USF] C [1234] $', re.VERBOSE)
@ -45,15 +95,64 @@ no_speedup_style = no_time_style
error_speedup_style = xlwt.easyxf('pattern: pattern solid, fore_color orange') error_speedup_style = xlwt.easyxf('pattern: pattern solid, fore_color orange')
header_style = xlwt.easyxf('font: bold true; alignment: horizontal centre, vertical top, wrap True') header_style = xlwt.easyxf('font: bold true; alignment: horizontal centre, vertical top, wrap True')
def collect_xml(collection, configuration, xml_fullname): class Collector(object):
xml_fname = os.path.split(xml_fullname)[1] def __init__(self, config_match_func):
module = xml_fname[:xml_fname.index('_')] self.__config_cache = {}
self.config_match_func = config_match_func
self.tests = {}
# Format a sorted sequence of pairs as if it was a dictionary.
# We can't just use a dictionary instead, since we want to preserve the sorted order of the keys.
@staticmethod
def __format_config_cache_key(pairs):
return '{' + ', '.join(repr(k) + ': ' + repr(v) for (k, v) in pairs) + '}'
def collect_from(self, xml_path):
run = parseLogFile(xml_path)
module = run.properties['module_name']
properties = run.properties.copy()
del properties['module_name']
props_key = tuple(sorted(properties.iteritems())) # dicts can't be keys
if props_key in self.__config_cache:
configuration = self.__config_cache[props_key]
else:
configuration = self.config_match_func(properties)
if configuration is None:
logging.warning('failed to match properties to a configuration: %s',
Collector.__format_config_cache_key(props_key))
else:
same_config_props = [it[0] for it in self.__config_cache.iteritems() if it[1] == configuration]
if len(same_config_props) > 0:
logging.warning('property set %s matches the same configuration %r as property set %s',
Collector.__format_config_cache_key(props_key),
configuration,
Collector.__format_config_cache_key(same_config_props[0]))
self.__config_cache[props_key] = configuration
if configuration is None: return
module_tests = collection.setdefault(module, OrderedDict()) module_tests = self.tests.setdefault(module, OrderedDict())
for test in sorted(parseLogFile(xml_fullname)): for test in run.tests:
test_results = module_tests.setdefault((test.shortName(), test.param()), {}) test_results = module_tests.setdefault((test.shortName(), test.param()), {})
test_results[configuration] = test.get("gmean") if test.status == 'run' else test.status test_results[configuration] = test.get("gmean") if test.status == 'run' else test.status
def make_match_func(matchers):
def match_func(properties):
for matcher in matchers:
if all(properties.get(name) == value
for (name, value) in matcher['properties'].iteritems()):
return matcher['name']
return None
return match_func
def main(): def main():
arg_parser = ArgumentParser(description='Build an XLS performance report.') arg_parser = ArgumentParser(description='Build an XLS performance report.')
@ -83,23 +182,15 @@ def main():
sheet_conf = dict(global_conf.items() + sheet_conf.items()) sheet_conf = dict(global_conf.items() + sheet_conf.items())
if 'configurations' in sheet_conf: config_names = sheet_conf.get('configurations', [])
config_names = sheet_conf['configurations'] config_matchers = sheet_conf.get('configuration_matchers', [])
else:
try:
config_names = [p for p in os.listdir(sheet_path)
if os.path.isdir(os.path.join(sheet_path, p))]
except Exception as e:
logging.warning('error while determining configuration names for %s: %s', sheet_path, e)
continue
collection = {} collector = Collector(make_match_func(config_matchers))
for configuration, configuration_path in \ for root, _, filenames in os.walk(sheet_path):
[(c, os.path.join(sheet_path, c)) for c in config_names]: logging.info('looking in %s', root)
logging.info('processing %s', configuration_path) for filename in fnmatch.filter(filenames, '*.xml'):
for xml_fullname in glob(os.path.join(configuration_path, '*.xml')): collector.collect_from(os.path.join(root, filename))
collect_xml(collection, configuration, xml_fullname)
sheet = wb.add_sheet(sheet_conf.get('sheet_name', os.path.basename(os.path.abspath(sheet_path)))) sheet = wb.add_sheet(sheet_conf.get('sheet_name', os.path.basename(os.path.abspath(sheet_path))))
@ -126,7 +217,7 @@ def main():
module_styles = {module: xlwt.easyxf('pattern: pattern solid, fore_color {}'.format(color)) module_styles = {module: xlwt.easyxf('pattern: pattern solid, fore_color {}'.format(color))
for module, color in module_colors.iteritems()} for module, color in module_colors.iteritems()}
for module, tests in sorted(collection.iteritems()): for module, tests in sorted(collector.tests.iteritems()):
for ((test, param), configs) in tests.iteritems(): for ((test, param), configs) in tests.iteritems():
sheet.write(row, 0, module, module_styles.get(module, xlwt.Style.default_style)) sheet.write(row, 0, module, module_styles.get(module, xlwt.Style.default_style))
sheet.write(row, 1, test) sheet.write(row, 1, test)

@ -1,6 +1,6 @@
#include "opencv2/ts.hpp"
#include "opencv2/core/utility.hpp" #include "opencv2/core/utility.hpp"
#include "opencv2/core/private.hpp" #include "opencv2/core/private.hpp"
#include "opencv2/ts.hpp"
#ifdef GTEST_LINKED_AS_SHARED_LIBRARY #ifdef GTEST_LINKED_AS_SHARED_LIBRARY
#error ts module should not have GTEST_LINKED_AS_SHARED_LIBRARY defined #error ts module should not have GTEST_LINKED_AS_SHARED_LIBRARY defined

@ -2968,13 +2968,12 @@ void printVersionInfo(bool useStdOut)
if(useStdOut) std::cout << "Inner VCS version: " << ver << std::endl; if(useStdOut) std::cout << "Inner VCS version: " << ver << std::endl;
} }
#ifdef CV_PARALLEL_FRAMEWORK const char* parallel_framework = currentParallelFramework();
::testing::Test::RecordProperty("cv_parallel_framework", CV_PARALLEL_FRAMEWORK);
if (useStdOut) if (parallel_framework) {
{ ::testing::Test::RecordProperty("cv_parallel_framework", parallel_framework);
std::cout << "Parallel framework: " << CV_PARALLEL_FRAMEWORK << std::endl; if (useStdOut) std::cout << "Parallel framework: " << parallel_framework << std::endl;
} }
#endif
std::string cpu_features; std::string cpu_features;

@ -497,6 +497,7 @@ const char kBreakOnFailureFlag[] = "break_on_failure";
const char kCatchExceptionsFlag[] = "catch_exceptions"; const char kCatchExceptionsFlag[] = "catch_exceptions";
const char kColorFlag[] = "color"; const char kColorFlag[] = "color";
const char kFilterFlag[] = "filter"; const char kFilterFlag[] = "filter";
const char kParamFilterFlag[] = "param_filter";
const char kListTestsFlag[] = "list_tests"; const char kListTestsFlag[] = "list_tests";
const char kOutputFlag[] = "output"; const char kOutputFlag[] = "output";
const char kPrintTimeFlag[] = "print_time"; const char kPrintTimeFlag[] = "print_time";
@ -575,6 +576,7 @@ class GTestFlagSaver {
death_test_style_ = GTEST_FLAG(death_test_style); death_test_style_ = GTEST_FLAG(death_test_style);
death_test_use_fork_ = GTEST_FLAG(death_test_use_fork); death_test_use_fork_ = GTEST_FLAG(death_test_use_fork);
filter_ = GTEST_FLAG(filter); filter_ = GTEST_FLAG(filter);
param_filter_ = GTEST_FLAG(param_filter);
internal_run_death_test_ = GTEST_FLAG(internal_run_death_test); internal_run_death_test_ = GTEST_FLAG(internal_run_death_test);
list_tests_ = GTEST_FLAG(list_tests); list_tests_ = GTEST_FLAG(list_tests);
output_ = GTEST_FLAG(output); output_ = GTEST_FLAG(output);
@ -596,6 +598,7 @@ class GTestFlagSaver {
GTEST_FLAG(death_test_style) = death_test_style_; GTEST_FLAG(death_test_style) = death_test_style_;
GTEST_FLAG(death_test_use_fork) = death_test_use_fork_; GTEST_FLAG(death_test_use_fork) = death_test_use_fork_;
GTEST_FLAG(filter) = filter_; GTEST_FLAG(filter) = filter_;
GTEST_FLAG(param_filter) = param_filter_;
GTEST_FLAG(internal_run_death_test) = internal_run_death_test_; GTEST_FLAG(internal_run_death_test) = internal_run_death_test_;
GTEST_FLAG(list_tests) = list_tests_; GTEST_FLAG(list_tests) = list_tests_;
GTEST_FLAG(output) = output_; GTEST_FLAG(output) = output_;
@ -617,6 +620,7 @@ class GTestFlagSaver {
std::string death_test_style_; std::string death_test_style_;
bool death_test_use_fork_; bool death_test_use_fork_;
std::string filter_; std::string filter_;
std::string param_filter_;
std::string internal_run_death_test_; std::string internal_run_death_test_;
bool list_tests_; bool list_tests_;
std::string output_; std::string output_;
@ -1699,6 +1703,12 @@ GTEST_DEFINE_string_(
"exclude). A test is run if it matches one of the positive " "exclude). A test is run if it matches one of the positive "
"patterns and does not match any of the negative patterns."); "patterns and does not match any of the negative patterns.");
GTEST_DEFINE_string_(
param_filter,
internal::StringFromGTestEnv("param_filter", kUniversalFilter),
"Same syntax and semantics as for param, but these patterns "
"have to match the test's parameters.");
GTEST_DEFINE_bool_(list_tests, false, GTEST_DEFINE_bool_(list_tests, false,
"List all tests without running them."); "List all tests without running them.");
@ -4188,6 +4198,14 @@ void PrettyUnitTestResultPrinter::OnTestIterationStart(
"Note: %s filter = %s\n", GTEST_NAME_, filter); "Note: %s filter = %s\n", GTEST_NAME_, filter);
} }
const char* const param_filter = GTEST_FLAG(param_filter).c_str();
// Ditto.
if (!String::CStringEquals(param_filter, kUniversalFilter)) {
ColoredPrintf(COLOR_YELLOW,
"Note: %s parameter filter = %s\n", GTEST_NAME_, param_filter);
}
if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) { if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {
const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1); const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);
ColoredPrintf(COLOR_YELLOW, ColoredPrintf(COLOR_YELLOW,
@ -5873,9 +5891,15 @@ int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
kDisableTestFilter); kDisableTestFilter);
test_info->is_disabled_ = is_disabled; test_info->is_disabled_ = is_disabled;
const std::string value_param(test_info->value_param() == NULL ?
"" : test_info->value_param());
const bool matches_filter = const bool matches_filter =
internal::UnitTestOptions::FilterMatchesTest(test_case_name, internal::UnitTestOptions::FilterMatchesTest(test_case_name,
test_name); test_name) &&
internal::UnitTestOptions::MatchesFilter(value_param,
GTEST_FLAG(param_filter).c_str());
test_info->matches_filter_ = matches_filter; test_info->matches_filter_ = matches_filter;
const bool is_runnable = const bool is_runnable =
@ -6223,6 +6247,12 @@ static const char kColorEncodedHelpMessage[] =
" Run only the tests whose name matches one of the positive patterns but\n" " Run only the tests whose name matches one of the positive patterns but\n"
" none of the negative patterns. '?' matches any single character; '*'\n" " none of the negative patterns. '?' matches any single character; '*'\n"
" matches any substring; ':' separates two patterns.\n" " matches any substring; ':' separates two patterns.\n"
" @G--" GTEST_FLAG_PREFIX_ "param_filter=@YPOSITIVE_PATTERNS"
"[@G-@YNEGATIVE_PATTERNS]@D\n"
" Like @G--" GTEST_FLAG_PREFIX_
"filter@D, but applies to the test's parameter. If a\n"
" test is not parameterized, its parameter is considered to be the\n"
" empty string.\n"
" @G--" GTEST_FLAG_PREFIX_ "also_run_disabled_tests@D\n" " @G--" GTEST_FLAG_PREFIX_ "also_run_disabled_tests@D\n"
" Run all disabled tests too.\n" " Run all disabled tests too.\n"
"\n" "\n"
@ -6300,6 +6330,7 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
ParseBoolFlag(arg, kDeathTestUseFork, ParseBoolFlag(arg, kDeathTestUseFork,
&GTEST_FLAG(death_test_use_fork)) || &GTEST_FLAG(death_test_use_fork)) ||
ParseStringFlag(arg, kFilterFlag, &GTEST_FLAG(filter)) || ParseStringFlag(arg, kFilterFlag, &GTEST_FLAG(filter)) ||
ParseStringFlag(arg, kParamFilterFlag, &GTEST_FLAG(param_filter)) ||
ParseStringFlag(arg, kInternalRunDeathTestFlag, ParseStringFlag(arg, kInternalRunDeathTestFlag,
&GTEST_FLAG(internal_run_death_test)) || &GTEST_FLAG(internal_run_death_test)) ||
ParseBoolFlag(arg, kListTestsFlag, &GTEST_FLAG(list_tests)) || ParseBoolFlag(arg, kListTestsFlag, &GTEST_FLAG(list_tests)) ||

@ -14,30 +14,10 @@ int64 TestBase::timeLimitDefault = 0;
unsigned int TestBase::iterationsLimitDefault = (unsigned int)(-1); unsigned int TestBase::iterationsLimitDefault = (unsigned int)(-1);
int64 TestBase::_timeadjustment = 0; int64 TestBase::_timeadjustment = 0;
const std::string command_line_keys = // Item [0] will be considered the default implementation.
"{ perf_max_outliers |8 |percent of allowed outliers}" static std::vector<std::string> available_impls;
"{ perf_min_samples |10 |minimal required numer of samples}"
"{ perf_force_samples |100 |force set maximum number of samples for all tests}"
"{ perf_seed |809564 |seed for random numbers generator}"
"{ perf_threads |-1 |the number of worker threads, if parallel execution is enabled}"
"{ perf_write_sanity | |create new records for sanity checks}"
"{ perf_verify_sanity | |fail tests having no regression data for sanity checks}"
#ifdef ANDROID
"{ perf_time_limit |6.0 |default time limit for a single test (in seconds)}"
"{ perf_affinity_mask |0 |set affinity mask for the main thread}"
"{ perf_log_power_checkpoints | |additional xml logging for power measurement}"
#else
"{ perf_time_limit |3.0 |default time limit for a single test (in seconds)}"
#endif
"{ perf_max_deviation |1.0 |}"
"{ help h | |print help info}"
#ifdef HAVE_CUDA
"{ perf_run_cpu |false |run GPU performance tests for analogical CPU functions}"
"{ perf_cuda_device |0 |run GPU test suite onto specific CUDA capable device}"
"{ perf_cuda_info_only |false |print an information about system and an available CUDA devices and then exit.}"
#endif
;
static std::string param_impl;
static double param_max_outliers; static double param_max_outliers;
static double param_max_deviation; static double param_max_deviation;
static unsigned int param_min_samples; static unsigned int param_min_samples;
@ -48,7 +28,6 @@ static int param_threads;
static bool param_write_sanity; static bool param_write_sanity;
static bool param_verify_sanity; static bool param_verify_sanity;
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
static bool param_run_cpu;
static int param_cuda_device; static int param_cuda_device;
#endif #endif
@ -573,11 +552,12 @@ Regression& Regression::operator() (const std::string& name, cv::InputArray arra
std::string nodename = getCurrentTestNodeName(); std::string nodename = getCurrentTestNodeName();
#ifdef HAVE_CUDA // This is a hack for compatibility and it should eventually get removed.
static const std::string prefix = (param_run_cpu)? "CPU_" : "GPU_"; // gpu's tests don't even have CPU sanity data anymore.
if(suiteName == "gpu") if(suiteName == "gpu")
nodename = prefix + nodename; {
#endif nodename = (PERF_RUN_GPU() ? "GPU_" : "CPU_") + nodename;
}
cv::FileNode n = rootIn[nodename]; cv::FileNode n = rootIn[nodename];
if(n.isNone()) if(n.isNone())
@ -642,6 +622,43 @@ performance_metrics::performance_metrics()
void TestBase::Init(int argc, const char* const argv[]) void TestBase::Init(int argc, const char* const argv[])
{ {
std::vector<std::string> plain_only;
plain_only.push_back("plain");
TestBase::Init(plain_only, argc, argv);
}
void TestBase::Init(const std::vector<std::string> & availableImpls,
int argc, const char* const argv[])
{
available_impls = availableImpls;
const std::string command_line_keys =
"{ perf_max_outliers |8 |percent of allowed outliers}"
"{ perf_min_samples |10 |minimal required numer of samples}"
"{ perf_force_samples |100 |force set maximum number of samples for all tests}"
"{ perf_seed |809564 |seed for random numbers generator}"
"{ perf_threads |-1 |the number of worker threads, if parallel execution is enabled}"
"{ perf_write_sanity |false |create new records for sanity checks}"
"{ perf_verify_sanity |false |fail tests having no regression data for sanity checks}"
"{ perf_impl |" + available_impls[0] +
"|the implementation variant of functions under test}"
"{ perf_list_impls |false |list available implementation variants and exit}"
"{ perf_run_cpu |false |deprecated, equivalent to --perf_impl=plain}"
#ifdef ANDROID
"{ perf_time_limit |6.0 |default time limit for a single test (in seconds)}"
"{ perf_affinity_mask |0 |set affinity mask for the main thread}"
"{ perf_log_power_checkpoints | |additional xml logging for power measurement}"
#else
"{ perf_time_limit |3.0 |default time limit for a single test (in seconds)}"
#endif
"{ perf_max_deviation |1.0 |}"
"{ help h |false |print help info}"
#ifdef HAVE_CUDA
"{ perf_cuda_device |0 |run GPU test suite onto specific CUDA capable device}"
"{ perf_cuda_info_only |false |print an information about system and an available CUDA devices and then exit.}"
#endif
;
cv::CommandLineParser args(argc, argv, command_line_keys); cv::CommandLineParser args(argc, argv, command_line_keys);
if (args.has("help")) if (args.has("help"))
{ {
@ -651,6 +668,7 @@ void TestBase::Init(int argc, const char* const argv[])
::testing::AddGlobalTestEnvironment(new PerfEnvironment); ::testing::AddGlobalTestEnvironment(new PerfEnvironment);
param_impl = args.has("perf_run_cpu") ? "plain" : args.get<std::string>("perf_impl");
param_max_outliers = std::min(100., std::max(0., args.get<double>("perf_max_outliers"))); param_max_outliers = std::min(100., std::max(0., args.get<double>("perf_max_outliers")));
param_min_samples = std::max(1u, args.get<unsigned int>("perf_min_samples")); param_min_samples = std::max(1u, args.get<unsigned int>("perf_min_samples"));
param_max_deviation = std::max(0., args.get<double>("perf_max_deviation")); param_max_deviation = std::max(0., args.get<double>("perf_max_deviation"));
@ -665,19 +683,41 @@ void TestBase::Init(int argc, const char* const argv[])
log_power_checkpoints = args.has("perf_log_power_checkpoints"); log_power_checkpoints = args.has("perf_log_power_checkpoints");
#endif #endif
bool param_list_impls = args.has("perf_list_impls");
if (param_list_impls)
{
fputs("Available implementation variants:", stdout);
for (size_t i = 0; i < available_impls.size(); ++i) {
putchar(' ');
fputs(available_impls[i].c_str(), stdout);
}
putchar('\n');
exit(0);
}
if (std::find(available_impls.begin(), available_impls.end(), param_impl) == available_impls.end())
{
printf("No such implementation: %s\n", param_impl.c_str());
exit(1);
}
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
bool printOnly = args.has("perf_cuda_info_only"); bool printOnly = args.has("perf_cuda_info_only");
if (printOnly) if (printOnly)
exit(0); exit(0);
#endif
if (available_impls.size() > 1)
printf("[----------]\n[ INFO ] \tImplementation variant: %s.\n[----------]\n", param_impl.c_str()), fflush(stdout);
#ifdef HAVE_CUDA
param_run_cpu = args.has("perf_run_cpu");
param_cuda_device = std::max(0, std::min(cv::gpu::getCudaEnabledDeviceCount(), args.get<int>("perf_cuda_device"))); param_cuda_device = std::max(0, std::min(cv::gpu::getCudaEnabledDeviceCount(), args.get<int>("perf_cuda_device")));
if (param_run_cpu) if (param_impl == "cuda")
printf("[----------]\n[ GPU INFO ] \tRun test suite on CPU.\n[----------]\n"), fflush(stdout);
else
{ {
cv::gpu::DeviceInfo info(param_cuda_device); cv::gpu::DeviceInfo info(param_cuda_device);
if (!info.isCompatible()) if (!info.isCompatible())
@ -703,6 +743,18 @@ void TestBase::Init(int argc, const char* const argv[])
_timeadjustment = _calibrate(); _timeadjustment = _calibrate();
} }
void TestBase::RecordRunParameters()
{
::testing::Test::RecordProperty("cv_implementation", param_impl);
::testing::Test::RecordProperty("cv_num_threads", param_threads);
}
std::string TestBase::getSelectedImpl()
{
return param_impl;
}
int64 TestBase::_calibrate() int64 TestBase::_calibrate()
{ {
class _helper : public ::perf::TestBase class _helper : public ::perf::TestBase
@ -1322,11 +1374,7 @@ void perf::sort(std::vector<cv::KeyPoint>& pts, cv::InputOutputArray descriptors
\*****************************************************************************************/ \*****************************************************************************************/
bool perf::GpuPerf::targetDevice() bool perf::GpuPerf::targetDevice()
{ {
#ifdef HAVE_CUDA return param_impl == "cuda";
return !param_run_cpu;
#else
return false;
#endif
} }
/*****************************************************************************************\ /*****************************************************************************************\
@ -1365,4 +1413,3 @@ void PrintTo(const Size& sz, ::std::ostream* os)
} }
} // namespace cv } // namespace cv

@ -48,7 +48,7 @@ See the "15-puzzle" OpenCV sample for details.
super.onResume(); super.onResume();
Log.i(TAG, "Trying to load OpenCV library"); Log.i(TAG, "Trying to load OpenCV library");
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_4, this, mOpenCVCallBack)) if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mOpenCVCallBack))
{ {
Log.e(TAG, "Cannot connect to OpenCV Manager"); Log.e(TAG, "Cannot connect to OpenCV Manager");
} }

@ -55,3 +55,7 @@ OpenCV version constants
.. data:: OPENCV_VERSION_2_4_5 .. data:: OPENCV_VERSION_2_4_5
OpenCV Library version 2.4.5 OpenCV Library version 2.4.5
.. data:: OPENCV_VERSION_2_4_6
OpenCV Library version 2.4.6

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv.engine" package="org.opencv.engine"
android:versionCode="27@ANDROID_PLATFORM_VERSION_CODE@" android:versionCode="28@ANDROID_PLATFORM_VERSION_CODE@"
android:versionName="2.7" > android:versionName="2.8" >
<uses-sdk android:minSdkVersion="@ANDROID_NATIVE_API_LEVEL@" /> <uses-sdk android:minSdkVersion="@ANDROID_NATIVE_API_LEVEL@" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/> <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>

@ -15,7 +15,7 @@ using namespace android;
const int OpenCVEngine::Platform = DetectKnownPlatforms(); const int OpenCVEngine::Platform = DetectKnownPlatforms();
const int OpenCVEngine::CpuID = GetCpuID(); const int OpenCVEngine::CpuID = GetCpuID();
const int OpenCVEngine::KnownVersions[] = {2040000, 2040100, 2040200, 2040300, 2040301, 2040302, 2040400, 2040500}; const int OpenCVEngine::KnownVersions[] = {2040000, 2040100, 2040200, 2040300, 2040301, 2040302, 2040400, 2040500, 2040600};
bool OpenCVEngine::ValidateVersion(int version) bool OpenCVEngine::ValidateVersion(int version)
{ {

@ -14,20 +14,20 @@ manually using adb tool:
.. code-block:: sh .. code-block:: sh
adb install OpenCV-2.4.5-android-sdk/apk/OpenCV_2.4.5_Manager_2.7_<platform>.apk adb install OpenCV-2.4.6-android-sdk/apk/OpenCV_2.4.6_Manager_2.8_<platform>.apk
Use the table below to determine proper OpenCV Manager package for your device: Use the table below to determine proper OpenCV Manager package for your device:
+------------------------------+--------------+---------------------------------------------------+ +------------------------------+--------------+---------------------------------------------------+
| Hardware Platform | Android ver. | Package name | | Hardware Platform | Android ver. | Package name |
+==============================+==============+===================================================+ +==============================+==============+===================================================+
| armeabi-v7a (ARMv7-A + NEON) | >= 2.3 | OpenCV_2.4.5_Manager_2.7_armv7a-neon.apk | | armeabi-v7a (ARMv7-A + NEON) | >= 2.3 | OpenCV_2.4.6_Manager_2.8_armv7a-neon.apk |
+------------------------------+--------------+---------------------------------------------------+ +------------------------------+--------------+---------------------------------------------------+
| armeabi-v7a (ARMv7-A + NEON) | = 2.2 | OpenCV_2.4.5_Manager_2.7_armv7a-neon-android8.apk | | armeabi-v7a (ARMv7-A + NEON) | = 2.2 | OpenCV_2.4.6_Manager_2.8_armv7a-neon-android8.apk |
+------------------------------+--------------+---------------------------------------------------+ +------------------------------+--------------+---------------------------------------------------+
| armeabi (ARMv5, ARMv6) | >= 2.3 | OpenCV_2.4.5_Manager_2.7_armeabi.apk | | armeabi (ARMv5, ARMv6) | >= 2.3 | OpenCV_2.4.6_Manager_2.8_armeabi.apk |
+------------------------------+--------------+---------------------------------------------------+ +------------------------------+--------------+---------------------------------------------------+
| Intel x86 | >= 2.3 | OpenCV_2.4.5_Manager_2.7_x86.apk | | Intel x86 | >= 2.3 | OpenCV_2.4.6_Manager_2.8_x86.apk |
+------------------------------+--------------+---------------------------------------------------+ +------------------------------+--------------+---------------------------------------------------+
| MIPS | >= 2.3 | OpenCV_2.4.5_Manager_2.7_mips.apk | | MIPS | >= 2.3 | OpenCV_2.4.6_Manager_2.8_mips.apk |
+------------------------------+--------------+---------------------------------------------------+ +------------------------------+--------------+---------------------------------------------------+

@ -5,7 +5,7 @@
<key>CFBundleName</key> <key>CFBundleName</key>
<string>OpenCV</string> <string>OpenCV</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>com.itseez.opencv</string> <string>org.opencv</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>${VERSION}</string> <string>${VERSION}</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>

@ -38,7 +38,7 @@ def build_opencv(srcroot, buildroot, target, arch):
# for some reason, if you do not specify CMAKE_BUILD_TYPE, it puts libs to "RELEASE" rather than "Release" # for some reason, if you do not specify CMAKE_BUILD_TYPE, it puts libs to "RELEASE" rather than "Release"
cmakeargs = ("-GXcode " + cmakeargs = ("-GXcode " +
"-DCMAKE_BUILD_TYPE=Release " + "-DCMAKE_BUILD_TYPE=Release " +
"-DCMAKE_TOOLCHAIN_FILE=%s/ios/cmake/Toolchains/Toolchain-%s_Xcode.cmake " + "-DCMAKE_TOOLCHAIN_FILE=%s/platforms/ios/cmake/Toolchains/Toolchain-%s_Xcode.cmake " +
"-DBUILD_opencv_world=ON " + "-DBUILD_opencv_world=ON " +
"-DCMAKE_INSTALL_PREFIX=install") % (srcroot, target) "-DCMAKE_INSTALL_PREFIX=install") % (srcroot, target)
# if cmake cache exists, just rerun cmake to update OpenCV.xproj if necessary # if cmake cache exists, just rerun cmake to update OpenCV.xproj if necessary
@ -92,16 +92,13 @@ def put_framework_together(srcroot, dstroot):
os.system("lipo -create " + wlist + " -o " + dstdir + "/opencv2") os.system("lipo -create " + wlist + " -o " + dstdir + "/opencv2")
# form Info.plist # form Info.plist
srcfile = open(srcroot + "/ios/Info.plist.in", "rt") srcfile = open(srcroot + "/platforms/ios/Info.plist.in", "rt")
dstfile = open(dstdir + "/Resources/Info.plist", "wt") dstfile = open(dstdir + "/Resources/Info.plist", "wt")
for l in srcfile.readlines(): for l in srcfile.readlines():
dstfile.write(l.replace("${VERSION}", opencv_version)) dstfile.write(l.replace("${VERSION}", opencv_version))
srcfile.close() srcfile.close()
dstfile.close() dstfile.close()
# copy cascades
# TODO ...
# make symbolic links # make symbolic links
os.symlink("A", "Versions/Current") os.symlink("A", "Versions/Current")
os.symlink("Versions/Current/Headers", "Headers") os.symlink("Versions/Current/Headers", "Headers")
@ -125,4 +122,4 @@ if __name__ == "__main__":
print "Usage:\n\t./build_framework.py <outputdir>\n\n" print "Usage:\n\t./build_framework.py <outputdir>\n\n"
sys.exit(0) sys.exit(0)
build_framework(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")), os.path.abspath(sys.argv[1])) build_framework(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../..")), os.path.abspath(sys.argv[1]))

@ -4,12 +4,12 @@ set (IPHONEOS TRUE)
# Standard settings # Standard settings
set (CMAKE_SYSTEM_NAME iOS) set (CMAKE_SYSTEM_NAME iOS)
# Include extra modules for the iOS platform files # Include extra modules for the iOS platform files
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/ios/cmake/Modules") set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/cmake/Modules")
# Force the compilers to gcc for iOS # Force the compilers to clang for iOS
include (CMakeForceCompiler) include (CMakeForceCompiler)
#CMAKE_FORCE_C_COMPILER (gcc gcc) #CMAKE_FORCE_C_COMPILER (clang GNU)
#CMAKE_FORCE_CXX_COMPILER (g++ g++) #CMAKE_FORCE_CXX_COMPILER (clang++ GNU)
set (CMAKE_C_SIZEOF_DATA_PTR 4) set (CMAKE_C_SIZEOF_DATA_PTR 4)
set (CMAKE_C_HAS_ISYSROOT 1) set (CMAKE_C_HAS_ISYSROOT 1)

@ -4,12 +4,12 @@ set (IPHONESIMULATOR TRUE)
# Standard settings # Standard settings
set (CMAKE_SYSTEM_NAME iOS) set (CMAKE_SYSTEM_NAME iOS)
# Include extra modules for the iOS platform files # Include extra modules for the iOS platform files
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/ios/cmake/Modules") set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/cmake/Modules")
# Force the compilers to gcc for iOS # Force the compilers to clang for iOS
include (CMakeForceCompiler) include (CMakeForceCompiler)
#CMAKE_FORCE_C_COMPILER (gcc gcc) #CMAKE_FORCE_C_COMPILER (clang GNU)
#CMAKE_FORCE_CXX_COMPILER (g++ g++) #CMAKE_FORCE_CXX_COMPILER (clang++ GNU)
set (CMAKE_C_SIZEOF_DATA_PTR 4) set (CMAKE_C_SIZEOF_DATA_PTR 4)
set (CMAKE_C_HAS_ISYSROOT 1) set (CMAKE_C_HAS_ISYSROOT 1)

@ -0,0 +1,7 @@
Building OpenCV from Source, using CMake and Command Line
=========================================================
cd ~/<my_working_directory>
python opencv/platforms/ios/build_framework.py ios
If everything's fine, a few minutes later you will get ~/<my_working_directory>/ios/opencv2.framework. You can add this framework to your Xcode projects.

@ -1 +1,3 @@
This folder contains toolchains and additional files that are needed for cross compitation. This folder contains toolchains and additional files that are needed for cross compilation.
For more information see introduction tutorials for target platform in documentation:
http://docs.opencv.org/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.html#table-of-content-introduction

@ -6,7 +6,7 @@ import os
architecture = 'armeabi' architecture = 'armeabi'
excludedHeaders = set(['hdf5.h', 'cap_ios.h', 'eigen.hpp', 'cxeigen.hpp']) #TOREMOVE excludedHeaders = set(['hdf5.h', 'cap_ios.h', 'ios.h', 'eigen.hpp', 'cxeigen.hpp']) #TOREMOVE
systemIncludes = ['sources/cxx-stl/gnu-libstdc++/4.6/include', \ systemIncludes = ['sources/cxx-stl/gnu-libstdc++/4.6/include', \
'/opt/android-ndk-r8c/platforms/android-8/arch-arm', # TODO: check if this one could be passed as command line arg '/opt/android-ndk-r8c/platforms/android-8/arch-arm', # TODO: check if this one could be passed as command line arg
'sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include'] 'sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include']

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save