diff --git a/CMakeLists.txt b/CMakeLists.txt index 96b3f8e02..17d8e26af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,7 +153,7 @@ OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON OCV_OPTION(WITH_LIBV4L "Use libv4l for Video 4 Linux support" ON IF (UNIX AND NOT ANDROID) ) OCV_OPTION(WITH_DSHOW "Build VideoIO with DirectShow support" ON IF (WIN32 AND NOT ARM) ) OCV_OPTION(WITH_MSMF "Build VideoIO with Media Foundation support" OFF IF WIN32 ) -OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF IF (NOT ANDROID AND NOT APPLE) ) +OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF IF (NOT ANDROID) ) OCV_OPTION(WITH_XINE "Include Xine support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) ) OCV_OPTION(WITH_CLP "Include Clp support (EPL)" OFF) OCV_OPTION(WITH_OPENCL "Include OpenCL Runtime support" ON IF (NOT IOS) ) @@ -254,7 +254,7 @@ else() set(OPENCV_DOC_INSTALL_PATH share/OpenCV/doc) endif() -if(WIN32) +if(WIN32 AND CMAKE_HOST_SYSTEM_NAME MATCHES Windows) if(DEFINED OpenCV_RUNTIME AND DEFINED OpenCV_ARCH) set(OpenCV_INSTALL_BINARIES_PREFIX "${OpenCV_ARCH}/${OpenCV_RUNTIME}/") else() @@ -294,7 +294,7 @@ if(ANDROID) else() set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib") set(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib${LIB_SUFFIX}") - if(WIN32) + if(WIN32 AND CMAKE_HOST_SYSTEM_NAME MATCHES Windows) if(OpenCV_STATIC) set(OPENCV_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib${LIB_SUFFIX}") else() @@ -1043,7 +1043,8 @@ status(" ant:" ANT_EXECUTABLE THEN "${ANT_EXECUTABLE} (ver ${A if(NOT ANDROID) status(" JNI:" JNI_INCLUDE_DIRS THEN "${JNI_INCLUDE_DIRS}" ELSE NO) endif() -status(" Java tests:" BUILD_TESTS AND (CAN_BUILD_ANDROID_PROJECTS OR HAVE_opencv_java) THEN YES ELSE NO) +status(" Java wrappers:" HAVE_opencv_java THEN YES ELSE NO) +status(" Java tests:" BUILD_TESTS AND opencv_test_java_BINARY_DIR THEN YES ELSE NO) # ========================= matlab ========================= status("") diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index fec7be4d8..6d6ca62e8 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -254,6 +254,7 @@ if(WITH_DSHOW) endif(WITH_DSHOW) # --- VideoInput/Microsoft Media Foundation --- +ocv_clear_vars(HAVE_MSMF) if(WITH_MSMF) check_include_file(Mfapi.h HAVE_MSMF) endif(WITH_MSMF) diff --git a/cmake/OpenCVFindXimea.cmake b/cmake/OpenCVFindXimea.cmake index 5f85a13dd..2d93292c1 100644 --- a/cmake/OpenCVFindXimea.cmake +++ b/cmake/OpenCVFindXimea.cmake @@ -31,6 +31,12 @@ if(WIN32) else() set(XIMEA_FOUND 0) endif() +elseif(APPLE) + if(EXISTS /Library/Frameworks/m3api.framework) + set(XIMEA_FOUND 1) + else() + set(XIMEA_FOUND 0) + endif() else() if(EXISTS /opt/XIMEA) set(XIMEA_FOUND 1) diff --git a/cmake/OpenCVGenConfig.cmake b/cmake/OpenCVGenConfig.cmake index 220772a90..249479d39 100644 --- a/cmake/OpenCVGenConfig.cmake +++ b/cmake/OpenCVGenConfig.cmake @@ -154,13 +154,19 @@ if(WIN32) endif() configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" @ONLY) configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" @ONLY) - if(BUILD_SHARED_LIBS) - install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib" COMPONENT dev) - install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev) - else() - install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib" COMPONENT dev) - install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev) - endif() - install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT dev) - install(FILES "${OpenCV_SOURCE_DIR}/cmake/OpenCVConfig.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/" COMPONENT dev) + if (CMAKE_HOST_SYSTEM_NAME MATCHES Windows) + if(BUILD_SHARED_LIBS) + install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib" COMPONENT dev) + install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev) + else() + install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib" COMPONENT dev) + install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev) + endif() + install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT dev) + install(FILES "${OpenCV_SOURCE_DIR}/cmake/OpenCVConfig.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/" COMPONENT dev) + else () + install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib/cmake/opencv-${OPENCV_VERSION}" COMPONENT dev) + install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib/cmake/opencv-${OPENCV_VERSION}" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev) + install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/opencv-${OPENCV_VERSION}" COMPONENT dev) + endif () endif() diff --git a/doc/_themes/sphinxdoc/layout.html b/doc/_themes/sphinxdoc/layout.html new file mode 100644 index 000000000..106452767 --- /dev/null +++ b/doc/_themes/sphinxdoc/layout.html @@ -0,0 +1,274 @@ +{# + basic/layout.html + ~~~~~~~~~~~~~~~~~ + + Master layout template for Sphinx themes. + + :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +#} +{%- block doctype -%} + +{%- endblock %} +{% set script_files = script_files + [pathto("_static/insertIframe.js", 1)] %} +{%- set reldelim1 = reldelim1 is not defined and ' »' or reldelim1 %} +{%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %} +{%- set render_sidebar = (not embedded) and (not theme_nosidebar|tobool) and + (sidebars != []) %} +{%- set url_root = pathto('', 1) %} +{# XXX necessary? #} +{%- if url_root == '#' %}{% set url_root = '' %}{% endif %} +{%- if not embedded and docstitle %} + {%- set titlesuffix = " — "|safe + docstitle|e %} +{%- else %} + {%- set titlesuffix = "" %} +{%- endif %} + +{%- macro relbar() %} + +{%- endmacro %} + +{%- macro sidebar() %} + {%- if render_sidebar %} +
+
+ {%- block sidebarlogo %} + {%- if logo %} + + {%- endif %} + {%- endblock %} + {%- if sidebars == None %} + {%- block sidebarsearch %} + {%- include "searchbox.html" %} + {%- endblock %} + {%- endif %} + {%- if sidebars != None %} + {#- new style sidebar: explicitly include/exclude templates #} + {%- for sidebartemplate in sidebars %} + {%- include sidebartemplate %} + {%- endfor %} + {%- else %} + {#- old style sidebars: using blocks -- should be deprecated #} + {%- block sidebartoc %} + {%- include "localtoc.html" %} + {%- endblock %} + {%- block sidebarrel %} + {%- include "relations.html" %} + {%- endblock %} + {%- if customsidebar %} + {%- include customsidebar %} + {%- endif %} + {%- endif %} +
+
+ {%- endif %} +{%- endmacro %} + +{%- macro script() %} + + {%- for scriptfile in script_files %} + + {%- endfor %} +{%- endmacro %} + +{%- macro css() %} + + + {%- for cssfile in css_files %} + + {%- endfor %} +{%- endmacro %} + + + + + {{ metatags }} + {%- block htmltitle %} + {{ title|striptags|e }}{{ titlesuffix }} + {%- endblock %} + {{ css() }} + {%- if not embedded %} + {{ script() }} + {%- if use_opensearch %} + + {%- endif %} + {%- if favicon %} + + {%- endif %} + {%- endif %} +{%- block linktags %} + {%- if hasdoc('about') %} + + {%- endif %} + {%- if hasdoc('genindex') %} + + {%- endif %} + {%- if hasdoc('search') %} + + {%- endif %} + {%- if hasdoc('copyright') %} + + {%- endif %} + + {%- if parents %} + + {%- endif %} + {%- if next %} + + {%- endif %} + {%- if prev %} + + {%- endif %} +{%- endblock %} +{%- block extrahead %} + +{%- if not embedded %} + + +{%- endif %} +{% endblock %} + +{%- block header %}{% endblock %} + +{%- block relbar1 %}{{ relbar() }}{% endblock %} + + {%- block sidebar1 %} {# possible location for sidebar #} {% endblock %} + {%- block sidebar2 %}{{ sidebar() }}{% endblock %} + + +{%- block content %} + +
+ {%- block document %} +
+ {%- if render_sidebar %} +
+ {%- endif %} +
+ {% block body %} {% endblock %} +
+ + {%- if render_sidebar %} +
+ {%- endif %} +
+ {%- endblock %} + +
+
+{%- endblock %} + +{%- block relbar2 %}{{ relbar() }}{% endblock %} + +{%- block footer %} + +{%- endblock %} + + diff --git a/doc/_themes/sphinxdoc/searchbox.html b/doc/_themes/sphinxdoc/searchbox.html new file mode 100644 index 000000000..73616d9ed --- /dev/null +++ b/doc/_themes/sphinxdoc/searchbox.html @@ -0,0 +1,21 @@ +{# + basic/searchbox.html + ~~~~~~~~~~~~~~~~~~~~ + + Sphinx sidebar template: quick search box. + + :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +#} +{%- if pagename != "search" and builder != "singlehtml" %} + + +{%- endif %} diff --git a/doc/_themes/sphinxdoc/static/bodybg.png b/doc/_themes/sphinxdoc/static/bodybg.png new file mode 100644 index 000000000..ebe92f669 Binary files /dev/null and b/doc/_themes/sphinxdoc/static/bodybg.png differ diff --git a/doc/_themes/sphinxdoc/static/default.css_t b/doc/_themes/sphinxdoc/static/default.css_t new file mode 100644 index 000000000..ce5ee0635 --- /dev/null +++ b/doc/_themes/sphinxdoc/static/default.css_t @@ -0,0 +1,466 @@ +/* + * sphinxdoc.css_t + * ~~~~~~~~~~~~~~~ + * + * Sphinx stylesheet -- sphinxdoc theme. + * + * :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. + * :license: BSD, see LICENSE for details. + * + */ + +@import url("basic.css"); + +/* -- page layout ----------------------------------------------------------- */ + +body { + font-family: 'Open Sans', 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', + 'Verdana', sans-serif; + font-size: 14px; + text-align: center; + background-image: url(bodybg.png); + color: black; + padding: 0; + border-right: 1px solid #0a507a; + border-left: 1px solid #0a507a; + + margin: 0 auto; + min-width: 780px; + max-width: 1080px; +} + +div.document { + background-color: white; + text-align: left; +} + +div.bodywrapper { + margin: 0 240px 0 0; + border-right: 1px solid #0a507a; +} + +div.body { + margin: 0; + padding: 0.5em 20px 20px 20px; +} + +div.related { + font-size: 1em; + color: white; +} + +div.related ul { + background-image: url(relbg.png); + text-align: left; + border-top: 1px solid #002e50; + border-bottom: 1px solid #002e50; +} + +div.related li + li { + display: inline; +} + +div.related ul li.right { + float: right; + margin-right: 5px; +} + +div.related ul li a { + margin: 0; + padding: 0 5px 0 5px; + line-height: 1.75em; + color: #f9f9f0; + text-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5); +} + +div.related ul li a:hover { + color: white; + text-shadow: 0px 0px 1px rgba(255, 255, 255, 0.5); +} + +div.footer { + background-image: url(footerbg.png); + color: #ccc; + text-shadow: 0 0 .2px rgba(255, 255, 255, 0.8); + padding: 3px 8px 3px 0; + clear: both; + font-size: 0.8em; + text-align: center; +} + +div.sphinxsidebarwrapper { + position: relative; + top: 0px; + padding: 0; +} + +div.sphinxsidebar { + word-wrap: break-word; + margin: 0; + padding: 0 15px 15px 0; + width: 210px; + float: right; + font-size: 1em; + text-align: left; +} + +div.sphinxsidebar .logo { + text-align: center; +} + +div.sphinxsidebar .logo img { + width: 150px; + vertical-align: middle; +} + +div.sphinxsidebar input { + border: 1px solid #aaa; + font-family: 'Open Sans', 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', + 'Verdana', sans-serif; + font-size: 1em; +} + +div.sphinxsidebar #searchbox input[type="text"] { + width: 160px; +} + +div.sphinxsidebar #searchbox input[type="submit"] { + width: 40px; +} + +div.sphinxsidebar h3 { + font-size: 1.5em; + border-top: 1px solid #0a507a; + margin-top: 1em; + margin-bottom: 0.5em; + padding-top: 0.5em; +} + +div.sphinxsidebar h4 { + font-size: 1.2em; + margin-bottom: 0; +} + +div.sphinxsidebar h3, div.sphinxsidebar h4 { + margin-right: -15px; + margin-left: -15px; + padding-right: 14px; + padding-left: 14px; + color: #333; + font-weight: 300; + /*text-shadow: 0px 0px 0.5px rgba(0, 0, 0, 0.4);*/ +} + +div.sphinxsidebarwrapper > h3:first-child { + margin-top: 0.5em; + border: none; +} + +div.sphinxsidebar h3 a { + color: #333; +} + +div.sphinxsidebar ul { + color: #444; + margin-top: 7px; + padding: 0; + line-height: 130%; +} + +div.sphinxsidebar ul ul { + margin-left: 20px; + list-style-image: url(listitem.png); +} + +/* -- body styles ----------------------------------------------------------- */ + +p { + margin: 0.8em 0 0.5em 0; +} + +a, a tt { + color: #2878a2; +} + +a:hover, a tt:hover { + color: #68b8c2; +} + +a tt { + border: 0; +} + +h1, h2, h3, h4, h5, h6 { + color: #0a507a; + background-color: #e5f5ff; + font-weight: 300; +} + +h1 { + margin: 10px 0 0 0; +} + +h2 { + margin: 1.em 0 0.2em 0; + padding: 0; +} + +h3 { + margin: 1em 0 -0.3em 0; +} + +h1 { font-size: 200%; } +h2 { font-size: 160%; } +h3 { font-size: 140%; } +h4 { font-size: 120%; } +h5 { font-size: 110%; } +h6 { font-size: 100%; } + +div a, h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { + text-decoration: none; +} + +div.body h1 a tt, div.body h2 a tt, div.body h3 a tt, +div.body h4 a tt, div.body h5 a tt, div.body h6 a tt { + color: #0a507a !important; + font-size: inherit !important; +} + +a.headerlink { + color: #0a507a !important; + font-size: 12px; + margin-left: 6px; + padding: 0 4px 0 4px; + text-decoration: none !important; + float: right; +} + +a.headerlink:hover { + background-color: #ccc; + color: white!important; +} + +cite, code, tt { + font-family: 'Consolas', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', + monospace; + font-size: 14px; + min-width: 780px; + max-width: 1080px; +} + +tt { + color: #003048; + padding: 1px; +} + +tt.descname, tt.descclassname, tt.xref { + font-size: 12px; +} + +hr { + border: 1px solid #abc; + margin: 2em; +} + +pre { + font-family: 'Consolas', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', + monospace; + font-size: 13px; + letter-spacing: 0.015em; + line-height: 120%; + padding: 0.5em; + border: 1px solid #ccc; + border-radius: 2px; + background-color: #f8f8f8; +} + +pre a { + color: inherit; + text-decoration: none; +} + +td.linenos pre { + padding: 0.5em 0; +} + +td.code pre { + max-width: 740px; + overflow: auto; + overflow-y: hidden; /* fixes display issues on Chrome browsers */ +} + +div.quotebar { + background-color: #f8f8f8; + max-width: 250px; + float: right; + padding: 0px 7px; + border: 1px solid #ccc; + margin-left: 1em; +} + +div.topic { + background-color: #f8f8f8; +} + +table { + border-collapse: collapse; + margin: 0 -0.5em 0 -0.5em; +} + +table td, table th { + padding: 0.2em 0.5em 0.2em 0.5em; +} + +div.note { + background-color: #eee; + border: 1px solid #ccc; +} + +div.seealso { + background-color: #ffc; + border: 1px solid #ff6; +} + +div.topic { + background-color: #eee; +} + +div.warning { + background-color: #ffe4e4; + border: 1px solid #f66; +} + +div.admonition ul li, div.warning ul li, +div.admonition ol li, div.warning ol li { + text-align: left; +} + +div.admonition p.admonition-title + p { + display: inline; +} + +p.admonition-title { + display: inline; +} + +p.admonition-title:after { + content: ":"; +} + +/* ------------------ our styles ----------------*/ + +div.body p, div.body dd, div.body li { + text-align: justify; + line-height: 130%; + margin-top: 1em; + margin-bottom: 1em; +} + +div.toctree-wrapper li, ul.simple li { + margin:0; +} + +/*a.toc-backref { +}*/ + +div.feedback { + /*background-color: #;*/ + /*color: #;*/ + padding: 20px 20px 30px 20px; + border-top: 1px solid #002e50; +} + +div.feedback h2 { + margin: 10px 0 10px 0; +} + +div.feedback a { + /*color: #;*/ + font-weight: bold; +} + +div.math p { + margin-top: 10px; + margin-bottom: 10px; +} + +dl.function > dt:first-child { + margin-bottom: 7px; +} + +dl.cfunction > dt:first-child { + margin-bottom: 7px; + color: #8080B0; +} + +dl.cfunction > dt:first-child tt.descname { + color: #8080B0; +} + +dl.pyfunction > dt:first-child { + margin-bottom: 7px; +} + +dl.jfunction > dt:first-child { + margin-bottom: 7px; +} + +table.field-list { + margin-top: 20px; +} + +em.menuselection, em.guilabel { + font-family: 'Lucida Sans', 'Lucida Sans Unicode', 'Lucida Grande', Verdana, + Arial, Helvetica, sans-serif; +} + +.enumeratevisibleitemswithsquare ul { + list-style: square; + margin-bottom: 0px; + margin-left: 0px; + margin-right: 0px; + margin-top: 0px; +} + +.enumeratevisibleitemswithsquare li { + margin-bottom: 0.2em; + margin-left: 0px; + margin-right: 0px; + margin-top: 0.2em; + } + +.enumeratevisibleitemswithsquare p { + margin-bottom: 0pt; + margin-top: 1pt; +} + +.enumeratevisibleitemswithsquare dl { + margin-bottom: 0px; + margin-left: 0px; + margin-right: 0px; + margin-top: 0px; +} + +.toctableopencv { + width: 100% ; + table-layout: fixed; +} + +.toctableopencv colgroup col:first-child { + width: 100pt !important; + max-width: 100pt !important; + min-width: 100pt !important; +} + +.toctableopencv colgroup col:nth-child(2) { + width: 100% !important; +} + +div.body ul.search li { + text-align: left; +} + +div.linenodiv { + min-width: 1em; + text-align: right; +} diff --git a/doc/_themes/sphinxdoc/static/footerbg.png b/doc/_themes/sphinxdoc/static/footerbg.png new file mode 100644 index 000000000..df783e2c7 Binary files /dev/null and b/doc/_themes/sphinxdoc/static/footerbg.png differ diff --git a/doc/_themes/sphinxdoc/static/headerbg.png b/doc/_themes/sphinxdoc/static/headerbg.png new file mode 100644 index 000000000..22830f99e Binary files /dev/null and b/doc/_themes/sphinxdoc/static/headerbg.png differ diff --git a/doc/_themes/sphinxdoc/static/listitem.png b/doc/_themes/sphinxdoc/static/listitem.png new file mode 100644 index 000000000..e45715f91 Binary files /dev/null and b/doc/_themes/sphinxdoc/static/listitem.png differ diff --git a/doc/_themes/sphinxdoc/static/relbg.png b/doc/_themes/sphinxdoc/static/relbg.png new file mode 100644 index 000000000..2006af7d2 Binary files /dev/null and b/doc/_themes/sphinxdoc/static/relbg.png differ diff --git a/doc/_themes/sphinxdoc/theme.conf b/doc/_themes/sphinxdoc/theme.conf new file mode 100644 index 000000000..1f5132065 --- /dev/null +++ b/doc/_themes/sphinxdoc/theme.conf @@ -0,0 +1,4 @@ +[theme] +inherit = basic +stylesheet = default.css +pygments_style = sphinx diff --git a/doc/conf.py b/doc/conf.py index c6a879d76..97d0b6fac 100755 --- a/doc/conf.py +++ b/doc/conf.py @@ -114,7 +114,7 @@ todo_include_todos=True # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'blue' +html_theme = 'sphinxdoc' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -133,7 +133,7 @@ html_theme_path = ['_themes'] # The name of an image file (relative to this directory) to place at the top # of the sidebar. -html_logo = 'opencv-logo-white.png' +html_logo = 'opencv-logo2.png' # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 diff --git a/doc/py_tutorials/py_calib3d/py_depthmap/py_depthmap.rst b/doc/py_tutorials/py_calib3d/py_depthmap/py_depthmap.rst index 24fc28a46..803ac3769 100644 --- a/doc/py_tutorials/py_calib3d/py_depthmap/py_depthmap.rst +++ b/doc/py_tutorials/py_calib3d/py_depthmap/py_depthmap.rst @@ -48,7 +48,7 @@ Below code snippet shows a simple procedure to create disparity map. plt.imshow(disparity,'gray') plt.show() -Below image contains the original image (left) and its disparity map (right). As you can see, result is contaminated with high degree of noise. By adjusting the values of numDisparities and blockSize, you can get more better result. +Below image contains the original image (left) and its disparity map (right). As you can see, result is contaminated with high degree of noise. By adjusting the values of numDisparities and blockSize, you can get a better result. .. image:: images/disparity_map.jpg :alt: Disparity Map diff --git a/doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.rst b/doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.rst index c5916627f..e4bbeff6d 100644 --- a/doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.rst +++ b/doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.rst @@ -49,7 +49,7 @@ You can modify the pixel values the same way. .. warning:: Numpy is a optimized library for fast array calculations. So simply accessing each and every pixel values and modifying it will be very slow and it is discouraged. -.. note:: Above mentioned method is normally used for selecting a region of array, say first 5 rows and last 3 columns like that. For individual pixel access, Numpy array methods, ``array.item()`` and ``array.itemset()`` is considered to be more better. But it always returns a scalar. So if you want to access all B,G,R values, you need to call ``array.item()`` separately for all. +.. note:: Above mentioned method is normally used for selecting a region of array, say first 5 rows and last 3 columns like that. For individual pixel access, Numpy array methods, ``array.item()`` and ``array.itemset()`` is considered to be better. But it always returns a scalar. So if you want to access all B,G,R values, you need to call ``array.item()`` separately for all. Better pixel accessing and editing method : diff --git a/doc/py_tutorials/py_core/py_optimization/py_optimization.rst b/doc/py_tutorials/py_core/py_optimization/py_optimization.rst index 58d1b78d6..13160fd4d 100644 --- a/doc/py_tutorials/py_core/py_optimization/py_optimization.rst +++ b/doc/py_tutorials/py_core/py_optimization/py_optimization.rst @@ -75,7 +75,7 @@ Measuring Performance in IPython Sometimes you may need to compare the performance of two similar operations. IPython gives you a magic command ``%timeit`` to perform this. It runs the code several times to get more accurate results. Once again, they are suitable to measure single line codes. -For example, do you know which of the following addition operation is more better, ``x = 5; y = x**2``, ``x = 5; y = x*x``, ``x = np.uint8([5]); y = x*x`` or ``y = np.square(x)`` ? We will find it with %timeit in IPython shell. +For example, do you know which of the following addition operation is better, ``x = 5; y = x**2``, ``x = 5; y = x*x``, ``x = np.uint8([5]); y = x*x`` or ``y = np.square(x)`` ? We will find it with %timeit in IPython shell. :: In [10]: x = 5 diff --git a/doc/py_tutorials/py_feature2d/py_features_meaning/py_features_meaning.rst b/doc/py_tutorials/py_feature2d/py_features_meaning/py_features_meaning.rst index d785cd756..bfd03c030 100644 --- a/doc/py_tutorials/py_feature2d/py_features_meaning/py_features_meaning.rst +++ b/doc/py_tutorials/py_feature2d/py_features_meaning/py_features_meaning.rst @@ -29,7 +29,7 @@ Image is very simple. At the top of image, six small image patches are given. Qu A and B are flat surfaces, and they are spread in a lot of area. It is difficult to find the exact location of these patches. -C and D are much more simpler. They are edges of the building. You can find an approximate location, but exact location is still difficult. It is because, along the edge, it is same everywhere. Normal to the edge, it is different. So edge is much more better feature compared to flat area, but not good enough (It is good in jigsaw puzzle for comparing continuity of edges). +C and D are much more simpler. They are edges of the building. You can find an approximate location, but exact location is still difficult. It is because, along the edge, it is same everywhere. Normal to the edge, it is different. So edge is a much better feature compared to flat area, but not good enough (It is good in jigsaw puzzle for comparing continuity of edges). Finally, E and F are some corners of the building. And they can be easily found out. Because at corners, wherever you move this patch, it will look different. So they can be considered as a good feature. So now we move into more simpler (and widely used image) for better understanding. diff --git a/doc/py_tutorials/py_feature2d/py_surf_intro/py_surf_intro.rst b/doc/py_tutorials/py_feature2d/py_surf_intro/py_surf_intro.rst index 6d734dfed..1b8f50d84 100644 --- a/doc/py_tutorials/py_feature2d/py_surf_intro/py_surf_intro.rst +++ b/doc/py_tutorials/py_feature2d/py_surf_intro/py_surf_intro.rst @@ -110,7 +110,7 @@ Now I want to apply U-SURF, so that it won't find the orientation. >>> plt.imshow(img2),plt.show() -See the results below. All the orientations are shown in same direction. It is more faster than previous. If you are working on cases where orientation is not a problem (like panorama stitching) etc, this is more better. +See the results below. All the orientations are shown in same direction. It is more faster than previous. If you are working on cases where orientation is not a problem (like panorama stitching) etc, this is better. .. image:: images/surf_kp2.jpg :alt: Upright-SURF diff --git a/doc/py_tutorials/py_gui/py_drawing_functions/py_drawing_functions.rst b/doc/py_tutorials/py_gui/py_drawing_functions/py_drawing_functions.rst index 55b1eec91..fe8ae737c 100644 --- a/doc/py_tutorials/py_gui/py_drawing_functions/py_drawing_functions.rst +++ b/doc/py_tutorials/py_gui/py_drawing_functions/py_drawing_functions.rst @@ -69,7 +69,7 @@ To draw a polygon, first you need coordinates of vertices. Make those points int .. Note:: If third argument is ``False``, you will get a polylines joining all the points, not a closed shape. -.. Note:: ``cv2.polylines()`` can be used to draw multiple lines. Just create a list of all the lines you want to draw and pass it to the function. All lines will be drawn individually. It is more better and faster way to draw a group of lines than calling ``cv2.line()`` for each line. +.. Note:: ``cv2.polylines()`` can be used to draw multiple lines. Just create a list of all the lines you want to draw and pass it to the function. All lines will be drawn individually. It is a much better and faster way to draw a group of lines than calling ``cv2.line()`` for each line. Adding Text to Images: ------------------------ diff --git a/doc/py_tutorials/py_gui/py_mouse_handling/py_mouse_handling.rst b/doc/py_tutorials/py_gui/py_mouse_handling/py_mouse_handling.rst index 2aa5c27ee..416241189 100644 --- a/doc/py_tutorials/py_gui/py_mouse_handling/py_mouse_handling.rst +++ b/doc/py_tutorials/py_gui/py_mouse_handling/py_mouse_handling.rst @@ -48,7 +48,7 @@ Creating mouse callback function has a specific format which is same everywhere. More Advanced Demo =================== -Now we go for much more better application. In this, we draw either rectangles or circles (depending on the mode we select) by dragging the mouse like we do in Paint application. So our mouse callback function has two parts, one to draw rectangle and other to draw the circles. This specific example will be really helpful in creating and understanding some interactive applications like object tracking, image segmentation etc. +Now we go for a much better application. In this, we draw either rectangles or circles (depending on the mode we select) by dragging the mouse like we do in Paint application. So our mouse callback function has two parts, one to draw rectangle and other to draw the circles. This specific example will be really helpful in creating and understanding some interactive applications like object tracking, image segmentation etc. :: import cv2 diff --git a/doc/py_tutorials/py_imgproc/py_histograms/py_2d_histogram/py_2d_histogram.rst b/doc/py_tutorials/py_imgproc/py_histograms/py_2d_histogram/py_2d_histogram.rst index 8ca103991..1beab913b 100644 --- a/doc/py_tutorials/py_imgproc/py_histograms/py_2d_histogram/py_2d_histogram.rst +++ b/doc/py_tutorials/py_imgproc/py_histograms/py_2d_histogram/py_2d_histogram.rst @@ -64,7 +64,7 @@ The result we get is a two dimensional array of size 180x256. So we can show the Method - 2 : Using Matplotlib ------------------------------ -We can use **matplotlib.pyplot.imshow()** function to plot 2D histogram with different color maps. It gives us much more better idea about the different pixel density. But this also, doesn't gives us idea what color is there on a first look, unless you know the Hue values of different colors. Still I prefer this method. It is simple and better. +We can use **matplotlib.pyplot.imshow()** function to plot 2D histogram with different color maps. It gives us a much better idea about the different pixel density. But this also, doesn't gives us idea what color is there on a first look, unless you know the Hue values of different colors. Still I prefer this method. It is simple and better. .. note:: While using this function, remember, interpolation flag should be ``nearest`` for better results. diff --git a/doc/py_tutorials/py_imgproc/py_histograms/py_histogram_backprojection/py_histogram_backprojection.rst b/doc/py_tutorials/py_imgproc/py_histograms/py_histogram_backprojection/py_histogram_backprojection.rst index ecf56c3b2..f2fc66437 100644 --- a/doc/py_tutorials/py_imgproc/py_histograms/py_histogram_backprojection/py_histogram_backprojection.rst +++ b/doc/py_tutorials/py_imgproc/py_histograms/py_histogram_backprojection/py_histogram_backprojection.rst @@ -15,7 +15,7 @@ It was proposed by **Michael J. Swain , Dana H. Ballard** in their paper **Index **What is it actually in simple words?** It is used for image segmentation or finding objects of interest in an image. In simple words, it creates an image of the same size (but single channel) as that of our input image, where each pixel corresponds to the probability of that pixel belonging to our object. In more simpler worlds, the output image will have our object of interest in more white compared to remaining part. Well, that is an intuitive explanation. (I can't make it more simpler). Histogram Backprojection is used with camshift algorithm etc. -**How do we do it ?** We create a histogram of an image containing our object of interest (in our case, the ground, leaving player and other things). The object should fill the image as far as possible for better results. And a color histogram is preferred over grayscale histogram, because color of the object is more better way to define the object than its grayscale intensity. We then "back-project" this histogram over our test image where we need to find the object, ie in other words, we calculate the probability of every pixel belonging to the ground and show it. The resulting output on proper thresholding gives us the ground alone. +**How do we do it ?** We create a histogram of an image containing our object of interest (in our case, the ground, leaving player and other things). The object should fill the image as far as possible for better results. And a color histogram is preferred over grayscale histogram, because color of the object is a better way to define the object than its grayscale intensity. We then "back-project" this histogram over our test image where we need to find the object, ie in other words, we calculate the probability of every pixel belonging to the ground and show it. The resulting output on proper thresholding gives us the ground alone. Algorithm in Numpy ==================== diff --git a/doc/py_tutorials/py_ml/py_knn/py_knn_understanding/py_knn_understanding.rst b/doc/py_tutorials/py_ml/py_knn/py_knn_understanding/py_knn_understanding.rst index 182d0039e..22f51539a 100644 --- a/doc/py_tutorials/py_ml/py_knn/py_knn_understanding/py_knn_understanding.rst +++ b/doc/py_tutorials/py_ml/py_knn/py_knn_understanding/py_knn_understanding.rst @@ -37,7 +37,7 @@ Now let's see it in OpenCV. kNN in OpenCV =============== -We will do a simple example here, with two families (classes), just like above. Then in the next chapter, we will do much more better example. +We will do a simple example here, with two families (classes), just like above. Then in the next chapter, we will do an even better example. So here, we label the Red family as **Class-0** (so denoted by 0) and Blue family as **Class-1** (denoted by 1). We create 25 families or 25 training data, and label them either Class-0 or Class-1. We do all these with the help of Random Number Generator in Numpy. diff --git a/doc/py_tutorials/py_objdetect/py_face_detection/images/haar.png b/doc/py_tutorials/py_objdetect/py_face_detection/images/haar.png index fa3cee322..08fd268a7 100644 Binary files a/doc/py_tutorials/py_objdetect/py_face_detection/images/haar.png and b/doc/py_tutorials/py_objdetect/py_face_detection/images/haar.png differ diff --git a/doc/py_tutorials/py_video/py_table_of_contents_video/py_table_of_contents_video.rst b/doc/py_tutorials/py_video/py_table_of_contents_video/py_table_of_contents_video.rst index a8c2d3dba..f076cbd70 100644 --- a/doc/py_tutorials/py_video/py_table_of_contents_video/py_table_of_contents_video.rst +++ b/doc/py_tutorials/py_video/py_table_of_contents_video/py_table_of_contents_video.rst @@ -9,7 +9,7 @@ Video Analysis .. cssclass:: toctableopencv =========== ====================================================== - |vdo_1| We have already seen an example of color-based tracking. It is simpler. This time, we see much more better algorithms like "Meanshift", and its upgraded version, "Camshift" to find and track them. + |vdo_1| We have already seen an example of color-based tracking. It is simpler. This time, we see significantly better algorithms like "Meanshift", and its upgraded version, "Camshift" to find and track them. =========== ====================================================== diff --git a/doc/tutorials/images/opencv_ios.png b/doc/tutorials/images/opencv_ios.png index 7937ec17c..ce2031d7c 100644 Binary files a/doc/tutorials/images/opencv_ios.png and b/doc/tutorials/images/opencv_ios.png differ diff --git a/doc/tutorials/introduction/table_of_content_introduction/images/opencv_ios.png b/doc/tutorials/introduction/table_of_content_introduction/images/opencv_ios.png index 7937ec17c..ce2031d7c 100644 Binary files a/doc/tutorials/introduction/table_of_content_introduction/images/opencv_ios.png and b/doc/tutorials/introduction/table_of_content_introduction/images/opencv_ios.png differ diff --git a/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.rst b/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.rst index 2ec616fbc..6788d17e4 100644 --- a/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.rst +++ b/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.rst @@ -90,25 +90,24 @@ A full list, for the latest version would contain: .. code-block:: bash - opencv_calib3d249d.lib - opencv_contrib249d.lib - opencv_core249d.lib - opencv_features2d249d.lib - opencv_flann249d.lib - opencv_gpu249d.lib - opencv_highgui249d.lib - opencv_imgproc249d.lib - opencv_legacy249d.lib - opencv_ml249d.lib - opencv_nonfree249d.lib - opencv_objdetect249d.lib - opencv_ocl249d.lib - opencv_photo249d.lib - opencv_stitching249d.lib - opencv_superres249d.lib - opencv_ts249d.lib - opencv_video249d.lib - opencv_videostab249d.lib + opencv_calib3d300d.lib + opencv_core300d.lib + opencv_features2d300d.lib + opencv_flann300d.lib + opencv_highgui300d.lib + opencv_imgcodecs300d.lib + opencv_imgproc300d.lib + opencv_ml300d.lib + opencv_objdetect300d.lib + opencv_photo300d.lib + opencv_shape300d.lib + opencv_stitching300d.lib + opencv_superres300d.lib + opencv_ts300d.lib + opencv_video300d.lib + opencv_videoio300d.lib + opencv_videostab300d.lib + The letter *d* at the end just indicates that these are the libraries required for the debug. Now click ok to save and do the same with a new property inside the Release rule section. Make sure to omit the *d* letters from the library names and to save the property sheets with the save icon above them. diff --git a/doc/tutorials/ios/hello/images/header_directive.png b/doc/tutorials/ios/hello/images/header_directive.png index 7e41e0bd6..c99899345 100644 Binary files a/doc/tutorials/ios/hello/images/header_directive.png and b/doc/tutorials/ios/hello/images/header_directive.png differ diff --git a/doc/tutorials/ios/hello/images/linking_opencv_ios.png b/doc/tutorials/ios/hello/images/linking_opencv_ios.png index cf82caf23..a470efce8 100644 Binary files a/doc/tutorials/ios/hello/images/linking_opencv_ios.png and b/doc/tutorials/ios/hello/images/linking_opencv_ios.png differ diff --git a/doc/tutorials/ios/hello/images/output.png b/doc/tutorials/ios/hello/images/output.png index 13d943381..cb0f7fb27 100644 Binary files a/doc/tutorials/ios/hello/images/output.png and b/doc/tutorials/ios/hello/images/output.png differ diff --git a/doc/tutorials/ios/hello/images/view_did_load.png b/doc/tutorials/ios/hello/images/view_did_load.png index 6573b1dcd..bb805c268 100644 Binary files a/doc/tutorials/ios/hello/images/view_did_load.png and b/doc/tutorials/ios/hello/images/view_did_load.png differ diff --git a/doc/tutorials/ios/table_of_content_ios/images/image_effects.png b/doc/tutorials/ios/table_of_content_ios/images/image_effects.png old mode 100755 new mode 100644 index 1a675ce74..25edb668f Binary files a/doc/tutorials/ios/table_of_content_ios/images/image_effects.png and b/doc/tutorials/ios/table_of_content_ios/images/image_effects.png differ diff --git a/doc/tutorials/ios/table_of_content_ios/images/intro.png b/doc/tutorials/ios/table_of_content_ios/images/intro.png index 4f54cfb91..5f2dc1aa4 100644 Binary files a/doc/tutorials/ios/table_of_content_ios/images/intro.png and b/doc/tutorials/ios/table_of_content_ios/images/intro.png differ diff --git a/doc/tutorials/ios/video_processing/images/xcode_hello_ios_framework_drag_and_drop.png b/doc/tutorials/ios/video_processing/images/xcode_hello_ios_framework_drag_and_drop.png index 8d935c233..f745f4bbc 100644 Binary files a/doc/tutorials/ios/video_processing/images/xcode_hello_ios_framework_drag_and_drop.png and b/doc/tutorials/ios/video_processing/images/xcode_hello_ios_framework_drag_and_drop.png differ diff --git a/doc/tutorials/ios/video_processing/images/xcode_hello_ios_frameworks_add_dependencies.png b/doc/tutorials/ios/video_processing/images/xcode_hello_ios_frameworks_add_dependencies.png index 394eec2c3..df9c17979 100644 Binary files a/doc/tutorials/ios/video_processing/images/xcode_hello_ios_frameworks_add_dependencies.png and b/doc/tutorials/ios/video_processing/images/xcode_hello_ios_frameworks_add_dependencies.png differ diff --git a/doc/tutorials/ios/video_processing/images/xcode_hello_ios_viewcontroller_layout.png b/doc/tutorials/ios/video_processing/images/xcode_hello_ios_viewcontroller_layout.png index bb523967c..22fc7fc39 100644 Binary files a/doc/tutorials/ios/video_processing/images/xcode_hello_ios_viewcontroller_layout.png and b/doc/tutorials/ios/video_processing/images/xcode_hello_ios_viewcontroller_layout.png differ diff --git a/doc/tutorials/viz/table_of_content_viz/images/image_effects.png b/doc/tutorials/viz/table_of_content_viz/images/image_effects.png old mode 100755 new mode 100644 index 1a675ce74..25edb668f Binary files a/doc/tutorials/viz/table_of_content_viz/images/image_effects.png and b/doc/tutorials/viz/table_of_content_viz/images/image_effects.png differ diff --git a/doc/tutorials/viz/table_of_content_viz/images/intro.png b/doc/tutorials/viz/table_of_content_viz/images/intro.png index 4f54cfb91..5f2dc1aa4 100644 Binary files a/doc/tutorials/viz/table_of_content_viz/images/intro.png and b/doc/tutorials/viz/table_of_content_viz/images/intro.png differ diff --git a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst index bd47467a0..ee476fa7c 100644 --- a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst +++ b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst @@ -580,7 +580,7 @@ Finds an object pose from 3D-2D point correspondences. :param tvec: Output translation vector. - :param useExtrinsicGuess: Parameter used for ITERATIVE. If true (1), the function uses the provided ``rvec`` and ``tvec`` values as initial approximations of the rotation and translation vectors, respectively, and further optimizes them. + :param useExtrinsicGuess: Parameter used for SOLVEPNP_ITERATIVE. If true (1), the function uses the provided ``rvec`` and ``tvec`` values as initial approximations of the rotation and translation vectors, respectively, and further optimizes them. :param flags: Method for solving a PnP problem: @@ -616,7 +616,7 @@ Finds an object pose from 3D-2D point correspondences using the RANSAC scheme. :param tvec: Output translation vector. - :param useExtrinsicGuess: Parameter used for ITERATIVE. If true (1), the function uses the provided ``rvec`` and ``tvec`` values as initial approximations of the rotation and translation vectors, respectively, and further optimizes them. + :param useExtrinsicGuess: Parameter used for SOLVEPNP_ITERATIVE. If true (1), the function uses the provided ``rvec`` and ``tvec`` values as initial approximations of the rotation and translation vectors, respectively, and further optimizes them. :param iterationsCount: Number of iterations. diff --git a/modules/core/doc/basic_structures.rst b/modules/core/doc/basic_structures.rst index 5445adc21..8f75344c2 100644 --- a/modules/core/doc/basic_structures.rst +++ b/modules/core/doc/basic_structures.rst @@ -96,9 +96,11 @@ operation for each of the coordinates. Besides the class members listed in the d pt1 = pt2 - pt3; pt1 = pt2 * a; pt1 = a * pt2; + pt1 = pt2 / a; pt1 += pt2; pt1 -= pt2; pt1 *= a; + pt1 /= a; double value = norm(pt); // L2 norm pt1 == pt2; pt1 != pt2; diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 6d3d0255c..a258e8c4d 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -747,93 +747,6 @@ public: int minusStep, plusStep; }; - - -/*! - Fast Nearest Neighbor Search Class. - - The class implements D. Lowe BBF (Best-Bin-First) algorithm for the last - approximate (or accurate) nearest neighbor search in multi-dimensional spaces. - - First, a set of vectors is passed to KDTree::KDTree() constructor - or KDTree::build() method, where it is reordered. - - Then arbitrary vectors can be passed to KDTree::findNearest() methods, which - find the K nearest neighbors among the vectors from the initial set. - The user can balance between the speed and accuracy of the search by varying Emax - parameter, which is the number of leaves that the algorithm checks. - The larger parameter values yield more accurate results at the expense of lower processing speed. - - \code - KDTree T(points, false); - const int K = 3, Emax = INT_MAX; - int idx[K]; - float dist[K]; - T.findNearest(query_vec, K, Emax, idx, 0, dist); - CV_Assert(dist[0] <= dist[1] && dist[1] <= dist[2]); - \endcode -*/ -class CV_EXPORTS_W KDTree -{ -public: - /*! - The node of the search tree. - */ - struct Node - { - Node() : idx(-1), left(-1), right(-1), boundary(0.f) {} - Node(int _idx, int _left, int _right, float _boundary) - : idx(_idx), left(_left), right(_right), boundary(_boundary) {} - - //! split dimension; >=0 for nodes (dim), < 0 for leaves (index of the point) - int idx; - //! node indices of the left and the right branches - int left, right; - //! go to the left if query_vec[node.idx]<=node.boundary, otherwise go to the right - float boundary; - }; - - //! the default constructor - CV_WRAP KDTree(); - //! the full constructor that builds the search tree - CV_WRAP KDTree(InputArray points, bool copyAndReorderPoints = false); - //! the full constructor that builds the search tree - CV_WRAP KDTree(InputArray points, InputArray _labels, - bool copyAndReorderPoints = false); - //! builds the search tree - CV_WRAP void build(InputArray points, bool copyAndReorderPoints = false); - //! builds the search tree - CV_WRAP void build(InputArray points, InputArray labels, - bool copyAndReorderPoints = false); - //! finds the K nearest neighbors of "vec" while looking at Emax (at most) leaves - CV_WRAP int findNearest(InputArray vec, int K, int Emax, - OutputArray neighborsIdx, - OutputArray neighbors = noArray(), - OutputArray dist = noArray(), - OutputArray labels = noArray()) const; - //! finds all the points from the initial set that belong to the specified box - CV_WRAP void findOrthoRange(InputArray minBounds, - InputArray maxBounds, - OutputArray neighborsIdx, - OutputArray neighbors = noArray(), - OutputArray labels = noArray()) const; - //! returns vectors with the specified indices - CV_WRAP void getPoints(InputArray idx, OutputArray pts, - OutputArray labels = noArray()) const; - //! return a vector with the specified index - const float* getPoint(int ptidx, int* label = 0) const; - //! returns the search space dimensionality - CV_WRAP int dims() const; - - std::vector nodes; //!< all the tree nodes - CV_PROP Mat points; //!< all the points. It can be a reordered copy of the input vector set or the original vector set. - CV_PROP std::vector labels; //!< the parallel array of labels. - CV_PROP int maxDepth; //!< maximum depth of the search tree. Do not modify it - CV_PROP_RW int normType; //!< type of the distance (cv::NORM_L1 or cv::NORM_L2) used for search. Initially set to cv::NORM_L2, but you can modify it -}; - - - /*! Random Number Generator diff --git a/modules/core/include/opencv2/core/base.hpp b/modules/core/include/opencv2/core/base.hpp index 1830ded92..bc70c019e 100644 --- a/modules/core/include/opencv2/core/base.hpp +++ b/modules/core/include/opencv2/core/base.hpp @@ -568,6 +568,41 @@ CV_EXPORTS int getIppStatus(); CV_EXPORTS String getIppErrorLocation(); } // ipp + +#if CV_NEON + +inline int32x2_t cv_vrnd_s32_f32(float32x2_t v) +{ + static int32x2_t v_sign = vdup_n_s32(1 << 31), + v_05 = vreinterpret_s32_f32(vdup_n_f32(0.5f)); + + int32x2_t v_addition = vorr_s32(v_05, vand_s32(v_sign, vreinterpret_s32_f32(v))); + return vcvt_s32_f32(vadd_f32(v, vreinterpret_f32_s32(v_addition))); +} + +inline int32x4_t cv_vrndq_s32_f32(float32x4_t v) +{ + static int32x4_t v_sign = vdupq_n_s32(1 << 31), + v_05 = vreinterpretq_s32_f32(vdupq_n_f32(0.5f)); + + int32x4_t v_addition = vorrq_s32(v_05, vandq_s32(v_sign, vreinterpretq_s32_f32(v))); + return vcvtq_s32_f32(vaddq_f32(v, vreinterpretq_f32_s32(v_addition))); +} + +inline uint32x2_t cv_vrnd_u32_f32(float32x2_t v) +{ + static float32x2_t v_05 = vdup_n_f32(0.5f); + return vcvt_u32_f32(vadd_f32(v, v_05)); +} + +inline uint32x4_t cv_vrndq_u32_f32(float32x4_t v) +{ + static float32x4_t v_05 = vdupq_n_f32(0.5f); + return vcvtq_u32_f32(vaddq_f32(v, v_05)); +} + +#endif + } // cv #endif //__OPENCV_CORE_BASE_HPP__ diff --git a/modules/core/include/opencv2/core/types.hpp b/modules/core/include/opencv2/core/types.hpp index 69c838ae2..dc4c30775 100644 --- a/modules/core/include/opencv2/core/types.hpp +++ b/modules/core/include/opencv2/core/types.hpp @@ -994,6 +994,30 @@ Point_<_Tp>& operator *= (Point_<_Tp>& a, double b) return a; } +template static inline +Point_<_Tp>& operator /= (Point_<_Tp>& a, int b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + return a; +} + +template static inline +Point_<_Tp>& operator /= (Point_<_Tp>& a, float b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + return a; +} + +template static inline +Point_<_Tp>& operator /= (Point_<_Tp>& a, double b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + return a; +} + template static inline double norm(const Point_<_Tp>& pt) { @@ -1080,6 +1104,30 @@ Point3_<_Tp> operator * (const Matx<_Tp, 3, 3>& a, const Point_<_Tp>& b) return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]); } +template static inline +Point_<_Tp> operator / (const Point_<_Tp>& a, int b) +{ + Point_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + +template static inline +Point_<_Tp> operator / (const Point_<_Tp>& a, float b) +{ + Point_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + +template static inline +Point_<_Tp> operator / (const Point_<_Tp>& a, double b) +{ + Point_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + //////////////////////////////// 3D Point /////////////////////////////// @@ -1187,6 +1235,33 @@ Point3_<_Tp>& operator *= (Point3_<_Tp>& a, double b) return a; } +template static inline +Point3_<_Tp>& operator /= (Point3_<_Tp>& a, int b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + a.z = saturate_cast<_Tp>(a.z / b); + return a; +} + +template static inline +Point3_<_Tp>& operator /= (Point3_<_Tp>& a, float b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + a.z = saturate_cast<_Tp>(a.z / b); + return a; +} + +template static inline +Point3_<_Tp>& operator /= (Point3_<_Tp>& a, double b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + a.z = saturate_cast<_Tp>(a.z / b); + return a; +} + template static inline double norm(const Point3_<_Tp>& pt) { @@ -1272,6 +1347,30 @@ Matx<_Tp, 4, 1> operator * (const Matx<_Tp, 4, 4>& a, const Point3_<_Tp>& b) return a * Matx<_Tp, 4, 1>(b.x, b.y, b.z, 1); } +template static inline +Point3_<_Tp> operator / (const Point3_<_Tp>& a, int b) +{ + Point3_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + +template static inline +Point3_<_Tp> operator / (const Point3_<_Tp>& a, float b) +{ + Point3_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + +template static inline +Point3_<_Tp> operator / (const Point3_<_Tp>& a, double b) +{ + Point3_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + ////////////////////////////////// Size ///////////////////////////////// diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp index f835e1b4c..0aecb6995 100644 --- a/modules/core/src/convert.cpp +++ b/modules/core/src/convert.cpp @@ -1244,6 +1244,183 @@ struct cvtScaleAbs_SIMD #elif CV_NEON +template <> +struct cvtScaleAbs_SIMD +{ + int operator () (const uchar * src, uchar * dst, int width, + float scale, float shift) const + { + int x = 0; + float32x4_t v_shift = vdupq_n_f32(shift); + + for ( ; x <= width - 16; x += 16) + { + uint8x16_t v_src = vld1q_u8(src + x); + uint16x8_t v_half = vmovl_u8(vget_low_u8(v_src)); + + uint32x4_t v_quat = vmovl_u16(vget_low_u16(v_half)); + float32x4_t v_dst_0 = vmulq_n_f32(vcvtq_f32_u32(v_quat), scale); + v_dst_0 = vabsq_f32(vaddq_f32(v_dst_0, v_shift)); + + v_quat = vmovl_u16(vget_high_u16(v_half)); + float32x4_t v_dst_1 = vmulq_n_f32(vcvtq_f32_u32(v_quat), scale); + v_dst_1 = vabsq_f32(vaddq_f32(v_dst_1, v_shift)); + + v_half = vmovl_u8(vget_high_u8(v_src)); + + v_quat = vmovl_u16(vget_low_u16(v_half)); + float32x4_t v_dst_2 = vmulq_n_f32(vcvtq_f32_u32(v_quat), scale); + v_dst_2 = vabsq_f32(vaddq_f32(v_dst_2, v_shift)); + + v_quat = vmovl_u16(vget_high_u16(v_half)); + float32x4_t v_dst_3 = vmulq_n_f32(vcvtq_f32_u32(v_quat), scale); + v_dst_3 = vabsq_f32(vaddq_f32(v_dst_3, v_shift)); + + uint16x8_t v_dsti_0 = vcombine_u16(vqmovn_u32(cv_vrndq_u32_f32(v_dst_0)), + vqmovn_u32(cv_vrndq_u32_f32(v_dst_1))); + uint16x8_t v_dsti_1 = vcombine_u16(vqmovn_u32(cv_vrndq_u32_f32(v_dst_2)), + vqmovn_u32(cv_vrndq_u32_f32(v_dst_3))); + + vst1q_u8(dst + x, vcombine_u8(vqmovn_u16(v_dsti_0), vqmovn_u16(v_dsti_1))); + } + + return x; + } +}; + +template <> +struct cvtScaleAbs_SIMD +{ + int operator () (const schar * src, uchar * dst, int width, + float scale, float shift) const + { + int x = 0; + float32x4_t v_shift = vdupq_n_f32(shift); + + for ( ; x <= width - 16; x += 16) + { + int8x16_t v_src = vld1q_s8(src + x); + int16x8_t v_half = vmovl_s8(vget_low_s8(v_src)); + + int32x4_t v_quat = vmovl_s16(vget_low_s16(v_half)); + float32x4_t v_dst_0 = vmulq_n_f32(vcvtq_f32_s32(v_quat), scale); + v_dst_0 = vabsq_f32(vaddq_f32(v_dst_0, v_shift)); + + v_quat = vmovl_s16(vget_high_s16(v_half)); + float32x4_t v_dst_1 = vmulq_n_f32(vcvtq_f32_s32(v_quat), scale); + v_dst_1 = vabsq_f32(vaddq_f32(v_dst_1, v_shift)); + + v_half = vmovl_s8(vget_high_s8(v_src)); + + v_quat = vmovl_s16(vget_low_s16(v_half)); + float32x4_t v_dst_2 = vmulq_n_f32(vcvtq_f32_s32(v_quat), scale); + v_dst_2 = vabsq_f32(vaddq_f32(v_dst_2, v_shift)); + + v_quat = vmovl_s16(vget_high_s16(v_half)); + float32x4_t v_dst_3 = vmulq_n_f32(vcvtq_f32_s32(v_quat), scale); + v_dst_3 = vabsq_f32(vaddq_f32(v_dst_3, v_shift)); + + uint16x8_t v_dsti_0 = vcombine_u16(vqmovn_u32(cv_vrndq_u32_f32(v_dst_0)), + vqmovn_u32(cv_vrndq_u32_f32(v_dst_1))); + uint16x8_t v_dsti_1 = vcombine_u16(vqmovn_u32(cv_vrndq_u32_f32(v_dst_2)), + vqmovn_u32(cv_vrndq_u32_f32(v_dst_3))); + + vst1q_u8(dst + x, vcombine_u8(vqmovn_u16(v_dsti_0), vqmovn_u16(v_dsti_1))); + } + + return x; + } +}; + +template <> +struct cvtScaleAbs_SIMD +{ + int operator () (const ushort * src, uchar * dst, int width, + float scale, float shift) const + { + int x = 0; + float32x4_t v_shift = vdupq_n_f32(shift); + + for ( ; x <= width - 8; x += 8) + { + uint16x8_t v_src = vld1q_u16(src + x); + + uint32x4_t v_half = vmovl_u16(vget_low_u16(v_src)); + float32x4_t v_dst_0 = vmulq_n_f32(vcvtq_f32_u32(v_half), scale); + v_dst_0 = vabsq_f32(vaddq_f32(v_dst_0, v_shift)); + + v_half = vmovl_u16(vget_high_u16(v_src)); + float32x4_t v_dst_1 = vmulq_n_f32(vcvtq_f32_u32(v_half), scale); + v_dst_1 = vabsq_f32(vaddq_f32(v_dst_1, v_shift)); + + uint16x8_t v_dst = vcombine_u16(vqmovn_u32(cv_vrndq_u32_f32(v_dst_0)), + vqmovn_u32(cv_vrndq_u32_f32(v_dst_1))); + + vst1_u8(dst + x, vqmovn_u16(v_dst)); + } + + return x; + } +}; + +template <> +struct cvtScaleAbs_SIMD +{ + int operator () (const short * src, uchar * dst, int width, + float scale, float shift) const + { + int x = 0; + float32x4_t v_shift = vdupq_n_f32(shift); + + for ( ; x <= width - 8; x += 8) + { + int16x8_t v_src = vld1q_s16(src + x); + + int32x4_t v_half = vmovl_s16(vget_low_s16(v_src)); + float32x4_t v_dst_0 = vmulq_n_f32(vcvtq_f32_s32(v_half), scale); + v_dst_0 = vabsq_f32(vaddq_f32(v_dst_0, v_shift)); + + v_half = vmovl_s16(vget_high_s16(v_src)); + float32x4_t v_dst_1 = vmulq_n_f32(vcvtq_f32_s32(v_half), scale); + v_dst_1 = vabsq_f32(vaddq_f32(v_dst_1, v_shift)); + + uint16x8_t v_dst = vcombine_u16(vqmovn_u32(cv_vrndq_u32_f32(v_dst_0)), + vqmovn_u32(cv_vrndq_u32_f32(v_dst_1))); + + vst1_u8(dst + x, vqmovn_u16(v_dst)); + } + + return x; + } +}; + +template <> +struct cvtScaleAbs_SIMD +{ + int operator () (const int * src, uchar * dst, int width, + float scale, float shift) const + { + int x = 0; + float32x4_t v_shift = vdupq_n_f32(shift); + + for ( ; x <= width - 8; x += 8) + { + float32x4_t v_dst_0 = vmulq_n_f32(vcvtq_f32_s32(vld1q_s32(src + x)), scale); + v_dst_0 = vabsq_f32(vaddq_f32(v_dst_0, v_shift)); + uint16x4_t v_dsti_0 = vqmovn_u32(cv_vrndq_u32_f32(v_dst_0)); + + float32x4_t v_dst_1 = vmulq_n_f32(vcvtq_f32_s32(vld1q_s32(src + x + 4)), scale); + v_dst_1 = vabsq_f32(vaddq_f32(v_dst_1, v_shift)); + uint16x4_t v_dsti_1 = vqmovn_u32(cv_vrndq_u32_f32(v_dst_1)); + + uint16x8_t v_dst = vcombine_u16(v_dsti_0, v_dsti_1); + vst1_u8(dst + x, vqmovn_u16(v_dst)); + } + + return x; + } +}; + template <> struct cvtScaleAbs_SIMD { @@ -1257,11 +1434,11 @@ struct cvtScaleAbs_SIMD { float32x4_t v_dst_0 = vmulq_n_f32(vld1q_f32(src + x), scale); v_dst_0 = vabsq_f32(vaddq_f32(v_dst_0, v_shift)); - uint16x4_t v_dsti_0 = vqmovun_s32(vcvtq_s32_f32(v_dst_0)); + uint16x4_t v_dsti_0 = vqmovn_u32(cv_vrndq_u32_f32(v_dst_0)); float32x4_t v_dst_1 = vmulq_n_f32(vld1q_f32(src + x + 4), scale); v_dst_1 = vabsq_f32(vaddq_f32(v_dst_1, v_shift)); - uint16x4_t v_dsti_1 = vqmovun_s32(vcvtq_s32_f32(v_dst_1)); + uint16x4_t v_dsti_1 = vqmovn_u32(cv_vrndq_u32_f32(v_dst_1)); uint16x8_t v_dst = vcombine_u16(v_dsti_0, v_dsti_1); vst1_u8(dst + x, vqmovn_u16(v_dst)); @@ -1314,6 +1491,7 @@ cvtScale_( const T* src, size_t sstep, for( ; size.height--; src += sstep, dst += dstep ) { int x = 0; + #if CV_ENABLE_UNROLLED for( ; x <= size.width - 4; x += 4 ) { @@ -1427,16 +1605,493 @@ cvtScale_( const short* src, size_t sstep, } } +template +struct Cvt_SIMD +{ + int operator() (const T *, DT *, int) const + { + return 0; + } +}; + +#if CV_NEON + +// from uchar + +template <> +struct Cvt_SIMD +{ + int operator() (const uchar * src, schar * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + vst1_s8(dst + x, vqmovn_s16(vreinterpretq_s16_u16(vmovl_u8(vld1_u8(src + x))))); + + return x; + } +}; + + +template <> +struct Cvt_SIMD +{ + int operator() (const uchar * src, ushort * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + vst1q_u16(dst + x, vmovl_u8(vld1_u8(src + x))); + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const uchar * src, short * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + vst1q_s16(dst + x, vreinterpretq_s16_u16(vmovl_u8(vld1_u8(src + x)))); + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const uchar * src, int * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + { + uint16x8_t v_src = vmovl_u8(vld1_u8(src + x)); + vst1q_s32(dst + x, vreinterpretq_s32_u32(vmovl_u16(vget_low_u16(v_src)))); + vst1q_s32(dst + x + 4, vreinterpretq_s32_u32(vmovl_u16(vget_high_u16(v_src)))); + } + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const uchar * src, float * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + { + uint16x8_t v_src = vmovl_u8(vld1_u8(src + x)); + vst1q_f32(dst + x, vcvtq_f32_u32(vmovl_u16(vget_low_u16(v_src)))); + vst1q_f32(dst + x + 4, vcvtq_f32_u32(vmovl_u16(vget_high_u16(v_src)))); + } + + return x; + } +}; + +// from schar + +template <> +struct Cvt_SIMD +{ + int operator() (const schar * src, uchar * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + vst1_u8(dst + x, vqmovun_s16(vmovl_s8(vld1_s8(src + x)))); + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const schar * src, short * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + vst1q_s16(dst + x, vmovl_s8(vld1_s8(src + x))); + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const schar * src, int * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + { + int16x8_t v_src = vmovl_s8(vld1_s8(src + x)); + vst1q_s32(dst + x, vmovl_s16(vget_low_s16(v_src))); + vst1q_s32(dst + x + 4, vmovl_s16(vget_high_s16(v_src))); + } + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const schar * src, float * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + { + int16x8_t v_src = vmovl_s8(vld1_s8(src + x)); + vst1q_f32(dst + x, vcvtq_f32_s32(vmovl_s16(vget_low_s16(v_src)))); + vst1q_f32(dst + x + 4, vcvtq_f32_s32(vmovl_s16(vget_high_s16(v_src)))); + } + + return x; + } +}; + +// from ushort + +template <> +struct Cvt_SIMD +{ + int operator() (const ushort * src, uchar * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 16; x += 16) + { + uint16x8_t v_src1 = vld1q_u16(src + x), v_src2 = vld1q_u16(src + x + 8); + vst1q_u8(dst + x, vcombine_u8(vqmovn_u16(v_src1), vqmovn_u16(v_src2))); + } + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const ushort * src, int * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + { + uint16x8_t v_src = vld1q_u16(src + x); + vst1q_s32(dst + x, vreinterpretq_s32_u32(vmovl_u16(vget_low_u16(v_src)))); + vst1q_s32(dst + x + 4, vreinterpretq_s32_u32(vmovl_u16(vget_high_u16(v_src)))); + } + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const ushort * src, float * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + { + uint16x8_t v_src = vld1q_u16(src + x); + vst1q_f32(dst + x, vcvtq_f32_u32(vmovl_u16(vget_low_u16(v_src)))); + vst1q_f32(dst + x + 4, vcvtq_f32_u32(vmovl_u16(vget_high_u16(v_src)))); + } + + return x; + } +}; + +// from short + +template <> +struct Cvt_SIMD +{ + int operator() (const short * src, uchar * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 16; x += 16) + { + int16x8_t v_src1 = vld1q_s16(src + x), v_src2 = vld1q_s16(src + x + 8); + vst1q_u8(dst + x, vcombine_u8(vqmovun_s16(v_src1), vqmovun_s16(v_src2))); + } + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const short * src, schar * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 16; x += 16) + { + int16x8_t v_src1 = vld1q_s16(src + x), v_src2 = vld1q_s16(src + x + 8); + vst1q_s8(dst + x, vcombine_s8(vqmovn_s16(v_src1), vqmovn_s16(v_src2))); + } + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const short * src, ushort * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + { + int16x8_t v_src = vld1q_s16(src + x); + uint16x4_t v_dst1 = vqmovun_s32(vmovl_s16(vget_low_s16(v_src))); + uint16x4_t v_dst2 = vqmovun_s32(vmovl_s16(vget_high_s16(v_src))); + vst1q_u16(dst + x, vcombine_u16(v_dst1, v_dst2)); + } + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const short * src, int * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + { + int16x8_t v_src = vld1q_s16(src + x); + vst1q_s32(dst + x, vmovl_s16(vget_low_s16(v_src))); + vst1q_s32(dst + x + 4, vmovl_s16(vget_high_s16(v_src))); + } + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const short * src, float * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + { + int16x8_t v_src = vld1q_s16(src + x); + vst1q_f32(dst + x, vcvtq_f32_s32(vmovl_s16(vget_low_s16(v_src)))); + vst1q_f32(dst + x + 4, vcvtq_f32_s32(vmovl_s16(vget_high_s16(v_src)))); + } + + return x; + } +}; + +// from int + +template <> +struct Cvt_SIMD +{ + int operator() (const int * src, uchar * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 16; x += 16) + { + int32x4_t v_src1 = vld1q_s32(src + x), v_src2 = vld1q_s32(src + x + 4); + int32x4_t v_src3 = vld1q_s32(src + x + 8), v_src4 = vld1q_s32(src + x + 12); + uint8x8_t v_dst1 = vqmovn_u16(vcombine_u16(vqmovun_s32(v_src1), vqmovun_s32(v_src2))); + uint8x8_t v_dst2 = vqmovn_u16(vcombine_u16(vqmovun_s32(v_src3), vqmovun_s32(v_src4))); + vst1q_u8(dst + x, vcombine_u8(v_dst1, v_dst2)); + } + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const int * src, schar * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 16; x += 16) + { + int32x4_t v_src1 = vld1q_s32(src + x), v_src2 = vld1q_s32(src + x + 4); + int32x4_t v_src3 = vld1q_s32(src + x + 8), v_src4 = vld1q_s32(src + x + 12); + int8x8_t v_dst1 = vqmovn_s16(vcombine_s16(vqmovn_s32(v_src1), vqmovn_s32(v_src2))); + int8x8_t v_dst2 = vqmovn_s16(vcombine_s16(vqmovn_s32(v_src3), vqmovn_s32(v_src4))); + vst1q_s8(dst + x, vcombine_s8(v_dst1, v_dst2)); + } + + return x; + } +}; + + +template <> +struct Cvt_SIMD +{ + int operator() (const int * src, ushort * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + { + int32x4_t v_src1 = vld1q_s32(src + x), v_src2 = vld1q_s32(src + x + 4); + vst1q_u16(dst + x, vcombine_u16(vqmovun_s32(v_src1), vqmovun_s32(v_src2))); + } + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const int * src, short * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + { + int32x4_t v_src1 = vld1q_s32(src + x), v_src2 = vld1q_s32(src + x + 4); + vst1q_s16(dst + x, vcombine_s16(vqmovn_s32(v_src1), vqmovn_s32(v_src2))); + } + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const int * src, float * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 4; x += 4) + vst1q_f32(dst + x, vcvtq_f32_s32(vld1q_s32(src + x))); + + return x; + } +}; + +// from float + +template <> +struct Cvt_SIMD +{ + int operator() (const float * src, uchar * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 16; x += 16) + { + uint32x4_t v_src1 = cv_vrndq_u32_f32(vld1q_f32(src + x)); + uint32x4_t v_src2 = cv_vrndq_u32_f32(vld1q_f32(src + x + 4)); + uint32x4_t v_src3 = cv_vrndq_u32_f32(vld1q_f32(src + x + 8)); + uint32x4_t v_src4 = cv_vrndq_u32_f32(vld1q_f32(src + x + 12)); + uint8x8_t v_dst1 = vqmovn_u16(vcombine_u16(vqmovn_u32(v_src1), vqmovn_u32(v_src2))); + uint8x8_t v_dst2 = vqmovn_u16(vcombine_u16(vqmovn_u32(v_src3), vqmovn_u32(v_src4))); + vst1q_u8(dst + x, vcombine_u8(v_dst1, v_dst2)); + } + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const float * src, schar * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 16; x += 16) + { + int32x4_t v_src1 = cv_vrndq_s32_f32(vld1q_f32(src + x)); + int32x4_t v_src2 = cv_vrndq_s32_f32(vld1q_f32(src + x + 4)); + int32x4_t v_src3 = cv_vrndq_s32_f32(vld1q_f32(src + x + 8)); + int32x4_t v_src4 = cv_vrndq_s32_f32(vld1q_f32(src + x + 12)); + int8x8_t v_dst1 = vqmovn_s16(vcombine_s16(vqmovn_s32(v_src1), vqmovn_s32(v_src2))); + int8x8_t v_dst2 = vqmovn_s16(vcombine_s16(vqmovn_s32(v_src3), vqmovn_s32(v_src4))); + vst1q_s8(dst + x, vcombine_s8(v_dst1, v_dst2)); + } + + return x; + } +}; + + +template <> +struct Cvt_SIMD +{ + int operator() (const float * src, ushort * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 8; x += 8) + { + uint32x4_t v_src1 = cv_vrndq_u32_f32(vld1q_f32(src + x)); + uint32x4_t v_src2 = cv_vrndq_u32_f32(vld1q_f32(src + x + 4)); + vst1q_u16(dst + x, vcombine_u16(vqmovn_u32(v_src1), vqmovn_u32(v_src2))); + } + + return x; + } +}; + +template <> +struct Cvt_SIMD +{ + int operator() (const float * src, int * dst, int width) const + { + int x = 0; + + for ( ; x <= width - 4; x += 4) + vst1q_s32(dst + x, cv_vrndq_s32_f32(vld1q_f32(src + x))); + + return x; + } +}; + +#endif + template static void cvt_( const T* src, size_t sstep, DT* dst, size_t dstep, Size size ) { sstep /= sizeof(src[0]); dstep /= sizeof(dst[0]); + Cvt_SIMD vop; for( ; size.height--; src += sstep, dst += dstep ) { - int x = 0; + int x = vop(src, dst, size.width); #if CV_ENABLE_UNROLLED for( ; x <= size.width - 4; x += 4 ) { diff --git a/modules/core/src/matmul.cpp b/modules/core/src/matmul.cpp index 7819a15e3..c5ce6d0fb 100644 --- a/modules/core/src/matmul.cpp +++ b/modules/core/src/matmul.cpp @@ -2102,6 +2102,16 @@ static void scaleAdd_32f(const float* src1, const float* src2, float* dst, } } else +#elif CV_NEON + if (true) + { + for ( ; i <= len - 4; i += 4) + { + float32x4_t v_src1 = vld1q_f32(src1 + i), v_src2 = vld1q_f32(src2 + i); + vst1q_f32(dst + i, vaddq_f32(vmulq_n_f32(v_src1, alpha), v_src2)); + } + } + else #endif //vz why do we need unroll here? for( ; i <= len - 4; i += 4 ) diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 3804d3401..d8071c269 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -4504,8 +4504,8 @@ int predictOptimalVectorWidth(InputArray src1, InputArray src2, InputArray src3, if (vectorWidths[0] == 1) { // it's heuristic - vectorWidths[CV_8U] = vectorWidths[CV_8S] = 16; - vectorWidths[CV_16U] = vectorWidths[CV_16S] = 8; + vectorWidths[CV_8U] = vectorWidths[CV_8S] = 4; + vectorWidths[CV_16U] = vectorWidths[CV_16S] = 2; vectorWidths[CV_32S] = vectorWidths[CV_32F] = vectorWidths[CV_64F] = 1; } diff --git a/modules/core/src/stat.cpp b/modules/core/src/stat.cpp index b8ce87ab7..2cc3c8d34 100644 --- a/modules/core/src/stat.cpp +++ b/modules/core/src/stat.cpp @@ -63,14 +63,181 @@ template static inline Scalar rawToScalar(const T& v) * sum * \****************************************************************************************/ +template +struct Sum_SIMD +{ + int operator () (const T *, const uchar *, ST *, int, int) const + { + return 0; + } +}; + +#if CV_NEON + +template <> +struct Sum_SIMD +{ + int operator () (const uchar * src0, const uchar * mask, int * dst, int len, int cn) const + { + if (mask || (cn != 1 && cn != 2 && cn != 4)) + return 0; + + int x = 0; + uint32x4_t v_sum = vdupq_n_u32(0u); + + for ( ; x <= len - 16; x += 16) + { + uint8x16_t v_src = vld1q_u8(src0 + x); + uint16x8_t v_half = vmovl_u8(vget_low_u8(v_src)); + + v_sum = vaddq_u32(v_sum, vmovl_u16(vget_low_u16(v_half))); + v_sum = vaddq_u32(v_sum, vmovl_u16(vget_high_u16(v_half))); + + v_half = vmovl_u8(vget_high_u8(v_src)); + v_sum = vaddq_u32(v_sum, vmovl_u16(vget_low_u16(v_half))); + v_sum = vaddq_u32(v_sum, vmovl_u16(vget_high_u16(v_half))); + } + + for ( ; x <= len - 8; x += 8) + { + uint16x8_t v_src = vmovl_u8(vld1_u8(src0 + x)); + + v_sum = vaddq_u32(v_sum, vmovl_u16(vget_low_u16(v_src))); + v_sum = vaddq_u32(v_sum, vmovl_u16(vget_high_u16(v_src))); + } + + unsigned int CV_DECL_ALIGNED(16) ar[4]; + vst1q_u32(ar, v_sum); + + for (int i = 0; i < 4; i += cn) + for (int j = 0; j < cn; ++j) + dst[j] += ar[j + i]; + + return x / cn; + } +}; + +template <> +struct Sum_SIMD +{ + int operator () (const schar * src0, const uchar * mask, int * dst, int len, int cn) const + { + if (mask || (cn != 1 && cn != 2 && cn != 4)) + return 0; + + int x = 0; + int32x4_t v_sum = vdupq_n_s32(0); + + for ( ; x <= len - 16; x += 16) + { + int8x16_t v_src = vld1q_s8(src0 + x); + int16x8_t v_half = vmovl_s8(vget_low_s8(v_src)); + + v_sum = vaddq_s32(v_sum, vmovl_s16(vget_low_s16(v_half))); + v_sum = vaddq_s32(v_sum, vmovl_s16(vget_high_s16(v_half))); + + v_half = vmovl_s8(vget_high_s8(v_src)); + v_sum = vaddq_s32(v_sum, vmovl_s16(vget_low_s16(v_half))); + v_sum = vaddq_s32(v_sum, vmovl_s16(vget_high_s16(v_half))); + } + + for ( ; x <= len - 8; x += 8) + { + int16x8_t v_src = vmovl_s8(vld1_s8(src0 + x)); + + v_sum = vaddq_s32(v_sum, vmovl_s16(vget_low_s16(v_src))); + v_sum = vaddq_s32(v_sum, vmovl_s16(vget_high_s16(v_src))); + } + + int CV_DECL_ALIGNED(16) ar[4]; + vst1q_s32(ar, v_sum); + + for (int i = 0; i < 4; i += cn) + for (int j = 0; j < cn; ++j) + dst[j] += ar[j + i]; + + return x / cn; + } +}; + +template <> +struct Sum_SIMD +{ + int operator () (const ushort * src0, const uchar * mask, int * dst, int len, int cn) const + { + if (mask || (cn != 1 && cn != 2 && cn != 4)) + return 0; + + int x = 0; + uint32x4_t v_sum = vdupq_n_u32(0u); + + for ( ; x <= len - 8; x += 8) + { + uint16x8_t v_src = vld1q_u16(src0 + x); + + v_sum = vaddq_u32(v_sum, vmovl_u16(vget_low_u16(v_src))); + v_sum = vaddq_u32(v_sum, vmovl_u16(vget_high_u16(v_src))); + } + + for ( ; x <= len - 4; x += 4) + v_sum = vaddq_u32(v_sum, vmovl_u16(vld1_u16(src0 + x))); + + unsigned int CV_DECL_ALIGNED(16) ar[4]; + vst1q_u32(ar, v_sum); + + for (int i = 0; i < 4; i += cn) + for (int j = 0; j < cn; ++j) + dst[j] += ar[j + i]; + + return x / cn; + } +}; + +template <> +struct Sum_SIMD +{ + int operator () (const short * src0, const uchar * mask, int * dst, int len, int cn) const + { + if (mask || (cn != 1 && cn != 2 && cn != 4)) + return 0; + + int x = 0; + int32x4_t v_sum = vdupq_n_s32(0u); + + for ( ; x <= len - 8; x += 8) + { + int16x8_t v_src = vld1q_s16(src0 + x); + + v_sum = vaddq_s32(v_sum, vmovl_s16(vget_low_s16(v_src))); + v_sum = vaddq_s32(v_sum, vmovl_s16(vget_high_s16(v_src))); + } + + for ( ; x <= len - 4; x += 4) + v_sum = vaddq_s32(v_sum, vmovl_s16(vld1_s16(src0 + x))); + + int CV_DECL_ALIGNED(16) ar[4]; + vst1q_s32(ar, v_sum); + + for (int i = 0; i < 4; i += cn) + for (int j = 0; j < cn; ++j) + dst[j] += ar[j + i]; + + return x / cn; + } +}; + +#endif + template static int sum_(const T* src0, const uchar* mask, ST* dst, int len, int cn ) { const T* src = src0; if( !mask ) { - int i=0; - int k = cn % 4; + Sum_SIMD vop; + int i = vop(src0, mask, dst, len, cn), k = cn % 4; + src += i * cn; + if( k == 1 ) { ST s0 = dst[0]; @@ -86,7 +253,7 @@ static int sum_(const T* src0, const uchar* mask, ST* dst, int len, int cn ) else if( k == 2 ) { ST s0 = dst[0], s1 = dst[1]; - for( i = 0; i < len; i++, src += cn ) + for( ; i < len; i++, src += cn ) { s0 += src[0]; s1 += src[1]; @@ -97,7 +264,7 @@ static int sum_(const T* src0, const uchar* mask, ST* dst, int len, int cn ) else if( k == 3 ) { ST s0 = dst[0], s1 = dst[1], s2 = dst[2]; - for( i = 0; i < len; i++, src += cn ) + for( ; i < len; i++, src += cn ) { s0 += src[0]; s1 += src[1]; @@ -110,9 +277,9 @@ static int sum_(const T* src0, const uchar* mask, ST* dst, int len, int cn ) for( ; k < cn; k += 4 ) { - src = src0 + k; + src = src0 + i*cn + k; ST s0 = dst[k], s1 = dst[k+1], s2 = dst[k+2], s3 = dst[k+3]; - for( i = 0; i < len; i++, src += cn ) + for( ; i < len; i++, src += cn ) { s0 += src[0]; s1 += src[1]; s2 += src[2]; s3 += src[3]; diff --git a/modules/features2d/CMakeLists.txt b/modules/features2d/CMakeLists.txt index 0b080cfb9..ad6df9414 100644 --- a/modules/features2d/CMakeLists.txt +++ b/modules/features2d/CMakeLists.txt @@ -1,2 +1,2 @@ set(the_description "2D Features Framework") -ocv_define_module(features2d opencv_imgproc opencv_flann OPTIONAL opencv_highgui) +ocv_define_module(features2d opencv_imgproc opencv_ml opencv_flann OPTIONAL opencv_highgui) diff --git a/modules/features2d/test/test_nearestneighbors.cpp b/modules/features2d/test/test_nearestneighbors.cpp index 0c2c70b7d..df5602520 100644 --- a/modules/features2d/test/test_nearestneighbors.cpp +++ b/modules/features2d/test/test_nearestneighbors.cpp @@ -12,6 +12,7 @@ // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. // Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2014, Itseez 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, @@ -156,91 +157,6 @@ void NearestNeighborTest::run( int /*start_from*/ ) { ts->set_failed_test_info( code ); } -//-------------------------------------------------------------------------------- -class CV_KDTreeTest_CPP : public NearestNeighborTest -{ -public: - CV_KDTreeTest_CPP() {} -protected: - virtual void createModel( const Mat& data ); - virtual int checkGetPoins( const Mat& data ); - virtual int findNeighbors( Mat& points, Mat& neighbors ); - virtual int checkFindBoxed(); - virtual void releaseModel(); - KDTree* tr; -}; - - -void CV_KDTreeTest_CPP::createModel( const Mat& data ) -{ - tr = new KDTree( data, false ); -} - -int CV_KDTreeTest_CPP::checkGetPoins( const Mat& data ) -{ - Mat res1( data.size(), data.type() ), - res3( data.size(), data.type() ); - Mat idxs( 1, data.rows, CV_32SC1 ); - for( int pi = 0; pi < data.rows; pi++ ) - { - idxs.at(0, pi) = pi; - // 1st way - const float* point = tr->getPoint(pi); - for( int di = 0; di < data.cols; di++ ) - res1.at(pi, di) = point[di]; - } - - // 3d way - tr->getPoints( idxs, res3 ); - - if( cvtest::norm( res1, data, NORM_L1) != 0 || - cvtest::norm( res3, data, NORM_L1) != 0) - return cvtest::TS::FAIL_BAD_ACCURACY; - return cvtest::TS::OK; -} - -int CV_KDTreeTest_CPP::checkFindBoxed() -{ - vector min( dims, static_cast(minValue)), max(dims, static_cast(maxValue)); - vector indices; - tr->findOrthoRange( min, max, indices ); - // TODO check indices - if( (int)indices.size() != featuresCount) - return cvtest::TS::FAIL_BAD_ACCURACY; - return cvtest::TS::OK; -} - -int CV_KDTreeTest_CPP::findNeighbors( Mat& points, Mat& neighbors ) -{ - const int emax = 20; - Mat neighbors2( neighbors.size(), CV_32SC1 ); - int j; - for( int pi = 0; pi < points.rows; pi++ ) - { - // 1st way - Mat nrow = neighbors.row(pi); - tr->findNearest( points.row(pi), neighbors.cols, emax, nrow ); - - // 2nd way - vector neighborsIdx2( neighbors2.cols, 0 ); - tr->findNearest( points.row(pi), neighbors2.cols, emax, neighborsIdx2 ); - vector::const_iterator it2 = neighborsIdx2.begin(); - for( j = 0; it2 != neighborsIdx2.end(); ++it2, j++ ) - neighbors2.at(pi,j) = *it2; - } - - // compare results - if( cvtest::norm( neighbors, neighbors2, NORM_L1 ) != 0 ) - return cvtest::TS::FAIL_BAD_ACCURACY; - - return cvtest::TS::OK; -} - -void CV_KDTreeTest_CPP::releaseModel() -{ - delete tr; -} - //-------------------------------------------------------------------------------- class CV_FlannTest : public NearestNeighborTest { @@ -402,7 +318,6 @@ void CV_FlannSavedIndexTest::createModel(const cv::Mat &data) remove( filename.c_str() ); } -TEST(Features2d_KDTree_CPP, regression) { CV_KDTreeTest_CPP test; test.safe_run(); } TEST(Features2d_FLANN_Linear, regression) { CV_FlannLinearIndexTest test; test.safe_run(); } TEST(Features2d_FLANN_KMeans, regression) { CV_FlannKMeansIndexTest test; test.safe_run(); } TEST(Features2d_FLANN_KDTree, regression) { CV_FlannKDTreeIndexTest test; test.safe_run(); } diff --git a/modules/features2d/test/test_precomp.hpp b/modules/features2d/test/test_precomp.hpp index bce72f729..893b29b69 100644 --- a/modules/features2d/test/test_precomp.hpp +++ b/modules/features2d/test/test_precomp.hpp @@ -13,6 +13,7 @@ #include "opencv2/imgproc.hpp" #include "opencv2/features2d.hpp" #include "opencv2/imgcodecs.hpp" +#include "opencv2/ml.hpp" #include #endif diff --git a/modules/highgui/src/agile_wrl.h b/modules/highgui/src/agile_wrl.h new file mode 100644 index 000000000..99fbf4185 --- /dev/null +++ b/modules/highgui/src/agile_wrl.h @@ -0,0 +1,568 @@ +// +// Copyright (C) Microsoft Corporation +// All rights reserved. +// Modified for native C++ WRL support by Gregory Morse +// +// Code in Details namespace is for internal usage within the library code +// + +#ifndef _PLATFORM_AGILE_H_ +#define _PLATFORM_AGILE_H_ + +#ifdef _MSC_VER +#pragma once +#endif // _MSC_VER + +#include +#include + +template class Agile; + +template +struct UnwrapAgile +{ + static const bool _IsAgile = false; +}; +template +struct UnwrapAgile> +{ + static const bool _IsAgile = true; +}; +template +struct UnwrapAgile> +{ + static const bool _IsAgile = true; +}; + +#define IS_AGILE(T) UnwrapAgile::_IsAgile + +#define __is_winrt_agile(T) (std::is_same::value || std::is_base_of::value || std::is_base_of::value) //derived from Microsoft::WRL::FtmBase or IAgileObject + +#define __is_win_interface(T) (std::is_base_of::value || std::is_base_of::value) //derived from IUnknown or IInspectable + +#define __is_win_class(T) (std::is_same::value || std::is_base_of::value) //derived from Microsoft::WRL::RuntimeClass or HSTRING + + namespace Details + { + IUnknown* __stdcall GetObjectContext(); + HRESULT __stdcall GetProxyImpl(IUnknown*, REFIID, IUnknown*, IUnknown**); + HRESULT __stdcall ReleaseInContextImpl(IUnknown*, IUnknown*); + + template +#if _MSC_VER >= 1800 + __declspec(no_refcount) inline HRESULT GetProxy(T *ObjectIn, IUnknown *ContextCallBack, T **Proxy) +#else + inline HRESULT GetProxy(T *ObjectIn, IUnknown *ContextCallBack, T **Proxy) +#endif + { +#if _MSC_VER >= 1800 + return GetProxyImpl(*reinterpret_cast(&ObjectIn), __uuidof(T*), ContextCallBack, reinterpret_cast(Proxy)); +#else + return GetProxyImpl(*reinterpret_cast(&const_cast(ObjectIn)), __uuidof(T*), ContextCallBack, reinterpret_cast(Proxy)); +#endif + } + + template + inline HRESULT ReleaseInContext(T *ObjectIn, IUnknown *ContextCallBack) + { + return ReleaseInContextImpl(ObjectIn, ContextCallBack); + } + + template + class AgileHelper + { + __abi_IUnknown* _p; + bool _release; + public: + AgileHelper(__abi_IUnknown* p, bool release = true) : _p(p), _release(release) + { + } + AgileHelper(AgileHelper&& other) : _p(other._p), _release(other._release) + { + _other._p = nullptr; + _other._release = true; + } + AgileHelper operator=(AgileHelper&& other) + { + _p = other._p; + _release = other._release; + _other._p = nullptr; + _other._release = true; + return *this; + } + + ~AgileHelper() + { + if (_release && _p) + { + _p->__abi_Release(); + } + } + + __declspec(no_refcount) __declspec(no_release_return) + T* operator->() + { + return reinterpret_cast(_p); + } + + __declspec(no_refcount) __declspec(no_release_return) + operator T * () + { + return reinterpret_cast(_p); + } + private: + AgileHelper(const AgileHelper&); + AgileHelper operator=(const AgileHelper&); + }; + template + struct __remove_hat + { + typedef T type; + }; + template + struct __remove_hat + { + typedef T type; + }; + template + struct AgileTypeHelper + { + typename typedef __remove_hat::type type; + typename typedef __remove_hat::type* agileMemberType; + }; + } // namespace Details + +#pragma warning(push) +#pragma warning(disable: 4451) // Usage of ref class inside this context can lead to invalid marshaling of object across contexts + + template < + typename T, + bool TIsNotAgile = (__is_win_class(typename Details::AgileTypeHelper::type) && !__is_winrt_agile(typename Details::AgileTypeHelper::type)) || + __is_win_interface(typename Details::AgileTypeHelper::type) + > + class Agile + { + static_assert(__is_win_class(typename Details::AgileTypeHelper::type) || __is_win_interface(typename Details::AgileTypeHelper::type), "Agile can only be used with ref class or interface class types"); + typename typedef Details::AgileTypeHelper::agileMemberType TypeT; + TypeT _object; + ::Microsoft::WRL::ComPtr _contextCallback; + ULONG_PTR _contextToken; + +#if _MSC_VER >= 1800 + enum class AgileState + { + NonAgilePointer = 0, + AgilePointer = 1, + Unknown = 2 + }; + AgileState _agileState; +#endif + + void CaptureContext() + { + _contextCallback = Details::GetObjectContext(); + __abi_ThrowIfFailed(CoGetContextToken(&_contextToken)); + } + + void SetObject(TypeT object) + { + // Capture context before setting the pointer + // If context capture fails then nothing to cleanup + Release(); + if (object != nullptr) + { + ::Microsoft::WRL::ComPtr checkIfAgile; + HRESULT hr = reinterpret_cast(object)->QueryInterface(__uuidof(IAgileObject), &checkIfAgile); + // Don't Capture context if object is agile + if (hr != S_OK) + { +#if _MSC_VER >= 1800 + _agileState = AgileState::NonAgilePointer; +#endif + CaptureContext(); + } +#if _MSC_VER >= 1800 + else + { + _agileState = AgileState::AgilePointer; + } +#endif + } + _object = object; + } + + public: + Agile() throw() : _object(nullptr), _contextToken(0) +#if _MSC_VER >= 1800 + , _agileState(AgileState::Unknown) +#endif + { + } + + Agile(nullptr_t) throw() : _object(nullptr), _contextToken(0) +#if _MSC_VER >= 1800 + , _agileState(AgileState::Unknown) +#endif + { + } + + explicit Agile(TypeT object) throw() : _object(nullptr), _contextToken(0) +#if _MSC_VER >= 1800 + , _agileState(AgileState::Unknown) +#endif + { + // Assumes that the source object is from the current context + SetObject(object); + } + + Agile(const Agile& object) throw() : _object(nullptr), _contextToken(0) +#if _MSC_VER >= 1800 + , _agileState(AgileState::Unknown) +#endif + { + // Get returns pointer valid for current context + SetObject(object.Get()); + } + + Agile(Agile&& object) throw() : _object(nullptr), _contextToken(0) +#if _MSC_VER >= 1800 + , _agileState(AgileState::Unknown) +#endif + { + // Assumes that the source object is from the current context + Swap(object); + } + + ~Agile() throw() + { + Release(); + } + + TypeT Get() const + { + // Agile object, no proxy required +#if _MSC_VER >= 1800 + if (_agileState == AgileState::AgilePointer || _object == nullptr) +#else + if (_contextToken == 0 || _contextCallback == nullptr || _object == nullptr) +#endif + { + return _object; + } + + // Do the check for same context + ULONG_PTR currentContextToken; + __abi_ThrowIfFailed(CoGetContextToken(¤tContextToken)); + if (currentContextToken == _contextToken) + { + return _object; + } + +#if _MSC_VER >= 1800 + // Different context and holding on to a non agile object + // Do the costly work of getting a proxy + TypeT localObject; + __abi_ThrowIfFailed(Details::GetProxy(_object, _contextCallback.Get(), &localObject)); + + if (_agileState == AgileState::Unknown) +#else + // Object is agile if it implements IAgileObject + // GetAddressOf captures the context with out knowing the type of object that it will hold + if (_object != nullptr) +#endif + { +#if _MSC_VER >= 1800 + // Object is agile if it implements IAgileObject + // GetAddressOf captures the context with out knowing the type of object that it will hold + ::Microsoft::WRL::ComPtr checkIfAgile; + HRESULT hr = reinterpret_cast(localObject)->QueryInterface(__uuidof(IAgileObject), &checkIfAgile); +#else + ::Microsoft::WRL::ComPtr checkIfAgile; + HRESULT hr = reinterpret_cast(_object)->QueryInterface(__uuidof(IAgileObject), &checkIfAgile); +#endif + if (hr == S_OK) + { + auto pThis = const_cast(this); +#if _MSC_VER >= 1800 + pThis->_agileState = AgileState::AgilePointer; +#endif + pThis->_contextToken = 0; + pThis->_contextCallback = nullptr; + return _object; + } +#if _MSC_VER >= 1800 + else + { + auto pThis = const_cast(this); + pThis->_agileState = AgileState::NonAgilePointer; + } +#endif + } + +#if _MSC_VER < 1800 + // Different context and holding on to a non agile object + // Do the costly work of getting a proxy + TypeT localObject; + __abi_ThrowIfFailed(Details::GetProxy(_object, _contextCallback.Get(), &localObject)); +#endif + return localObject; + } + + TypeT* GetAddressOf() throw() + { + Release(); + CaptureContext(); + return &_object; + } + + TypeT* GetAddressOfForInOut() throw() + { + CaptureContext(); + return &_object; + } + + TypeT operator->() const throw() + { + return Get(); + } + + Agile& operator=(nullptr_t) throw() + { + Release(); + return *this; + } + + Agile& operator=(TypeT object) throw() + { + Agile(object).Swap(*this); + return *this; + } + + Agile& operator=(Agile object) throw() + { + // parameter is by copy which gets pointer valid for current context + object.Swap(*this); + return *this; + } + +#if _MSC_VER < 1800 + Agile& operator=(IUnknown* lp) throw() + { + // bump ref count + ::Microsoft::WRL::ComPtr spObject(lp); + + // put it into Platform Object + Platform::Object object; + *(IUnknown**)(&object) = spObject.Detach(); + + SetObject(object); + return *this; + } +#endif + + void Swap(Agile& object) + { + std::swap(_object, object._object); + std::swap(_contextCallback, object._contextCallback); + std::swap(_contextToken, object._contextToken); +#if _MSC_VER >= 1800 + std::swap(_agileState, object._agileState); +#endif + } + + // Release the interface and set to NULL + void Release() throw() + { + if (_object) + { + // Cast to IInspectable (no QI) + IUnknown* pObject = *(IUnknown**)(&_object); + // Set * to null without release + *(IUnknown**)(&_object) = nullptr; + + ULONG_PTR currentContextToken; + __abi_ThrowIfFailed(CoGetContextToken(¤tContextToken)); + if (_contextToken == 0 || _contextCallback == nullptr || _contextToken == currentContextToken) + { + pObject->Release(); + } + else + { + Details::ReleaseInContext(pObject, _contextCallback.Get()); + } + _contextCallback = nullptr; + _contextToken = 0; +#if _MSC_VER >= 1800 + _agileState = AgileState::Unknown; +#endif + } + } + + bool operator==(nullptr_t) const throw() + { + return _object == nullptr; + } + + bool operator==(const Agile& other) const throw() + { + return _object == other._object && _contextToken == other._contextToken; + } + + bool operator<(const Agile& other) const throw() + { + if (reinterpret_cast(_object) < reinterpret_cast(other._object)) + { + return true; + } + + return _object == other._object && _contextToken < other._contextToken; + } + }; + + template + class Agile + { + static_assert(__is_win_class(typename Details::AgileTypeHelper::type) || __is_win_interface(typename Details::AgileTypeHelper::type), "Agile can only be used with ref class or interface class types"); + typename typedef Details::AgileTypeHelper::agileMemberType TypeT; + TypeT _object; + + public: + Agile() throw() : _object(nullptr) + { + } + + Agile(nullptr_t) throw() : _object(nullptr) + { + } + + explicit Agile(TypeT object) throw() : _object(object) + { + } + + Agile(const Agile& object) throw() : _object(object._object) + { + } + + Agile(Agile&& object) throw() : _object(nullptr) + { + Swap(object); + } + + ~Agile() throw() + { + Release(); + } + + TypeT Get() const + { + return _object; + } + + TypeT* GetAddressOf() throw() + { + Release(); + return &_object; + } + + TypeT* GetAddressOfForInOut() throw() + { + return &_object; + } + + TypeT operator->() const throw() + { + return Get(); + } + + Agile& operator=(nullptr_t) throw() + { + Release(); + return *this; + } + + Agile& operator=(TypeT object) throw() + { + if (_object != object) + { + _object = object; + } + return *this; + } + + Agile& operator=(Agile object) throw() + { + object.Swap(*this); + return *this; + } + +#if _MSC_VER < 1800 + Agile& operator=(IUnknown* lp) throw() + { + Release(); + // bump ref count + ::Microsoft::WRL::ComPtr spObject(lp); + + // put it into Platform Object + Platform::Object object; + *(IUnknown**)(&object) = spObject.Detach(); + + _object = object; + return *this; + } +#endif + + // Release the interface and set to NULL + void Release() throw() + { + _object = nullptr; + } + + void Swap(Agile& object) + { + std::swap(_object, object._object); + } + + bool operator==(nullptr_t) const throw() + { + return _object == nullptr; + } + + bool operator==(const Agile& other) const throw() + { + return _object == other._object; + } + + bool operator<(const Agile& other) const throw() + { + return reinterpret_cast(_object) < reinterpret_cast(other._object); + } + }; + +#pragma warning(pop) + + template + bool operator==(nullptr_t, const Agile& a) throw() + { + return a == nullptr; + } + + template + bool operator!=(const Agile& a, nullptr_t) throw() + { + return !(a == nullptr); + } + + template + bool operator!=(nullptr_t, const Agile& a) throw() + { + return !(a == nullptr); + } + + template + bool operator!=(const Agile& a, const Agile& b) throw() + { + return !(a == b); + } + + +#endif // _PLATFORM_AGILE_H_ diff --git a/modules/highgui/src/files_Qt/Milky/48/15.png b/modules/highgui/src/files_Qt/Milky/48/15.png index b54b7d658..524ab7f09 100644 Binary files a/modules/highgui/src/files_Qt/Milky/48/15.png and b/modules/highgui/src/files_Qt/Milky/48/15.png differ diff --git a/modules/highgui/src/files_Qt/Milky/48/36.png b/modules/highgui/src/files_Qt/Milky/48/36.png index c6e17fdd5..a6d75ffd7 100644 Binary files a/modules/highgui/src/files_Qt/Milky/48/36.png and b/modules/highgui/src/files_Qt/Milky/48/36.png differ diff --git a/modules/highgui/src/files_Qt/Milky/48/8.png b/modules/highgui/src/files_Qt/Milky/48/8.png index ab3280f58..7301dccfd 100644 Binary files a/modules/highgui/src/files_Qt/Milky/48/8.png and b/modules/highgui/src/files_Qt/Milky/48/8.png differ diff --git a/modules/highgui/src/files_Qt/Milky/64/20.png b/modules/highgui/src/files_Qt/Milky/64/20.png index cb5cd3788..fbd1fee4f 100644 Binary files a/modules/highgui/src/files_Qt/Milky/64/20.png and b/modules/highgui/src/files_Qt/Milky/64/20.png differ diff --git a/modules/highgui/src/files_Qt/Milky/64/3.png b/modules/highgui/src/files_Qt/Milky/64/3.png index 2b6cdca8a..be382224b 100644 Binary files a/modules/highgui/src/files_Qt/Milky/64/3.png and b/modules/highgui/src/files_Qt/Milky/64/3.png differ diff --git a/modules/highgui/src/ppltasks_winrt.h b/modules/highgui/src/ppltasks_winrt.h index 29dccbd70..1243baea9 100644 --- a/modules/highgui/src/ppltasks_winrt.h +++ b/modules/highgui/src/ppltasks_winrt.h @@ -17,24 +17,44 @@ #pragma once +#ifndef _PPLTASKS_WINRT_H +#define _PPLTASKS_WINRT_H + #include #include +#if _MSC_VER >= 1800 +#include + +// Cannot build using a compiler that is older than dev10 SP1 +#ifdef _MSC_VER +#if _MSC_FULL_VER < 160040219 /*IFSTRIP=IGN*/ +#error ERROR: Visual Studio 2010 SP1 or later is required to build ppltasks +#endif /*IFSTRIP=IGN*/ +#endif +#else #include +#endif #include #include #include #include +#if _MSC_VER >= 1800 +#include +#endif #ifndef __cplusplus_winrt #include #include +#if _MSC_VER >= 1800 +#include "agile_wrl.h" +#endif #include #include #ifndef _UITHREADCTXT_SUPPORT -#ifdef WINAPI_FAMILY +#ifdef WINAPI_FAMILY /*IFSTRIP=IGN*/ // It is safe to include winapifamily as WINAPI_FAMILY was defined by the user #include @@ -45,72 +65,72 @@ #elif WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP /*IFSTRIP=IGN*/ // UI thread context support is not required for desktop and Windows Store apps #define _UITHREADCTXT_SUPPORT 0 -#else +#else /* WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP */ #define _UITHREADCTXT_SUPPORT 1 -#endif +#endif /* WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP */ -#else +#else /* WINAPI_FAMILY */ // Not supported without a WINAPI_FAMILY setting. #define _UITHREADCTXT_SUPPORT 0 -#endif // #ifdef WINAPI_FAMILY +#endif /* WINAPI_FAMILY */ -#endif // #ifndef _UITHREADCTXT_SUPPORT +#endif /* _UITHREADCTXT_SUPPORT */ #if _UITHREADCTXT_SUPPORT #include -#endif // _UITHREADCTXT_SUPPORT +#endif /* _UITHREADCTXT_SUPPORT */ #pragma detect_mismatch("_PPLTASKS_WITH_WINRT", "0") + +#ifdef _DEBUG +#define _DBG_ONLY(X) X +#else +#define _DBG_ONLY(X) +#endif // #ifdef _DEBUG + +// std::copy_exception changed to std::make_exception_ptr from VS 2010 to VS 11. +#ifdef _MSC_VER +#if _MSC_VER < 1700 /*IFSTRIP=IGN*/ +namespace std +{ + template exception_ptr make_exception_ptr(_E _Except) + { + return copy_exception(_Except); + } +} +#endif +#ifndef _PPLTASK_ASYNC_LOGGING +#if _MSC_VER >= 1800 && defined(__cplusplus_winrt) +#define _PPLTASK_ASYNC_LOGGING 1 // Only enable async logging under dev12 winrt +#else +#define _PPLTASK_ASYNC_LOGGING 0 +#endif +#endif +#endif + #pragma pack(push,_CRT_PACKING) #pragma warning(push) #pragma warning(disable: 28197) #pragma warning(disable: 4100) // Unreferenced formal parameter - needed for document generation +#if _MSC_VER >= 1800 +#pragma warning(disable: 4127) // constant express in if condition - we use it for meta programming +#else #pragma warning(disable: 4702) // Unreachable code - it is caused by user lambda throw exceptions +#endif // All CRT public header files are required to be protected from the macro new #pragma push_macro("new") #undef new -#define __is_valid_winrt_type(_Type) (std::is_void<_Type>::value || \ - std::is_same<_Type, BYTE>::value || \ - std::is_same<_Type, INT16>::value || \ - std::is_same<_Type, UINT16>::value || \ - std::is_same<_Type, INT32>::value || \ - std::is_same<_Type, UINT32>::value || \ - std::is_same<_Type, INT64>::value || \ - std::is_same<_Type, UINT64>::value || \ - std::is_same<_Type, FLOAT>::value || \ - std::is_same<_Type, DOUBLE>::value || \ - std::is_same<_Type, WCHAR>::value || \ - std::is_same<_Type, boolean>::value || \ - std::is_same<_Type, HSTRING>::value || \ - std::is_same<_Type, IInspectable *>::value || \ - std::is_same<_Type, GUID>::value || \ - std::is_same<_Type, ABI::Windows::Foundation::DateTime>::value || \ - std::is_same<_Type, ABI::Windows::Foundation::TimeSpan>::value || \ - std::is_same<_Type, ABI::Windows::Foundation::Point>::value || \ - std::is_same<_Type, ABI::Windows::Foundation::Size>::value || \ - std::is_same<_Type, ABI::Windows::Foundation::Rect>::value || \ - std::is_same<_Type, BYTE*>::value || \ - std::is_same<_Type, INT16*>::value || \ - std::is_same<_Type, UINT16*>::value || \ - std::is_same<_Type, INT32*>::value || \ - std::is_same<_Type, UINT32*>::value || \ - std::is_same<_Type, INT64*>::value || \ - std::is_same<_Type, UINT64*>::value || \ - std::is_same<_Type, FLOAT*>::value || \ - std::is_same<_Type, DOUBLE*>::value || \ - std::is_same<_Type, WCHAR*>::value || \ - std::is_same<_Type, boolean*>::value || \ - std::is_same<_Type, HSTRING*>::value || \ - std::is_same<_Type, IInspectable **>::value || \ - std::is_same<_Type, GUID*>::value || \ - std::is_same<_Type, ABI::Windows::Foundation::DateTime*>::value || \ - std::is_same<_Type, ABI::Windows::Foundation::TimeSpan*>::value || \ - std::is_same<_Type, ABI::Windows::Foundation::Point*>::value || \ - std::is_same<_Type, ABI::Windows::Foundation::Size*>::value || \ - std::is_same<_Type, ABI::Windows::Foundation::Rect*>::value) +// stuff ported from Dev11 CRT +// NOTE: this doesn't actually match std::declval. it behaves differently for void! +// so don't blindly change it to std::declval. +namespace stdx +{ + template + _T&& declval(); +} /// /// The Concurrency_winrt namespace provides classes and functions that give you access to the Concurrency Runtime, @@ -119,7 +139,38 @@ /**/ namespace Concurrency_winrt { + // In debug builds, default to 10 frames, unless this is overridden prior to #includ'ing ppltasks.h. In retail builds, default to only one frame. +#ifndef PPL_TASK_SAVE_FRAME_COUNT +#ifdef _DEBUG +#define PPL_TASK_SAVE_FRAME_COUNT 10 +#else +#define PPL_TASK_SAVE_FRAME_COUNT 1 +#endif +#endif + + /// + /// Helper macro to determine how many stack frames need to be saved. When any number less or equal to 1 is specified, + /// only one frame is captured and no stackwalk will be involved. Otherwise, the number of callstack frames will be captured. + /// + /// + /// This needs to be defined as a macro rather than a function so that if we're only gathering one frame, _ReturnAddress() + /// will evaluate to client code, rather than a helper function inside of _TaskCreationCallstack, itself. + /// +#ifdef _CAPTURE_CALLSTACK +#undef _CAPTURE_CALLSTACK +#endif +#if PPL_TASK_SAVE_FRAME_COUNT > 1 +#if !defined(_DEBUG) +#pragma message ("WARNING: Redefinning PPL_TASK_SAVE_FRAME_COUNT under Release build for non-desktop applications is not supported; only one frame will be captured!") +#define _CAPTURE_CALLSTACK() ::Concurrency_winrt::details::_TaskCreationCallstack::_CaptureSingleFrameCallstack(_ReturnAddress()) +#else +#define _CAPTURE_CALLSTACK() ::Concurrency_winrt::details::_TaskCreationCallstack::_CaptureMultiFramesCallstack(PPL_TASK_SAVE_FRAME_COUNT) +#endif +#else +#define _CAPTURE_CALLSTACK() ::Concurrency_winrt::details::_TaskCreationCallstack::_CaptureSingleFrameCallstack(_ReturnAddress()) +#endif /// + /// A type that represents the terminal state of a task. Valid values are completed and canceled. /// /// @@ -151,7 +202,18 @@ template <> class task; /// /// /**/ -_CRTIMP2 bool __cdecl is_task_cancellation_requested(); +#if _MSC_VER >= 1800 +inline bool __cdecl is_task_cancellation_requested() +{ + return ::Concurrency::details::_TaskCollection_t::_Is_cancellation_requested(); +} +#else +inline bool __cdecl is_task_cancellation_requested() +{ + // ConcRT scheduler under the hood is using TaskCollection, which is same as task_group + return ::Concurrency::is_current_task_group_canceling(); +} +#endif /// /// Cancels the currently executing task. This function can be called from within the body of a task to abort the @@ -164,10 +226,56 @@ _CRTIMP2 bool __cdecl is_task_cancellation_requested(); /// /// /**/ -_CRTIMP2 __declspec(noreturn) void __cdecl cancel_current_task(); +//#if _MSC_VER >= 1800 +inline __declspec(noreturn) void __cdecl cancel_current_task() +{ + throw Concurrency::task_canceled(); +} +//#else +//_CRTIMP2 __declspec(noreturn) void __cdecl cancel_current_task(); +//#endif namespace details { +#if _MSC_VER >= 1800 + /// + /// Callstack container, which is used to capture and preserve callstacks in ppltasks. + /// Members of this class is examined by vc debugger, thus there will be no public access methods. + /// Please note that names of this class should be kept stable for debugger examining. + /// + class _TaskCreationCallstack + { + private: + // If _M_SingleFrame != nullptr, there will be only one frame of callstacks, which is stored in _M_SingleFrame; + // otherwise, _M_Frame will store all the callstack frames. + void* _M_SingleFrame; + std::vector _M_frames; + public: + _TaskCreationCallstack() + { + _M_SingleFrame = nullptr; + } + + // Store one frame of callstack. This function works for both Debug / Release CRT. + static _TaskCreationCallstack _CaptureSingleFrameCallstack(void *_SingleFrame) + { + _TaskCreationCallstack _csc; + _csc._M_SingleFrame = _SingleFrame; + return _csc; + } + + // Capture _CaptureFrames number of callstack frames. This function only work properly for Desktop or Debug CRT. + __declspec(noinline) + static _TaskCreationCallstack _CaptureMultiFramesCallstack(size_t _CaptureFrames) + { + _TaskCreationCallstack _csc; + _csc._M_frames.resize(_CaptureFrames); + // skip 2 frames to make sure callstack starts from user code + _csc._M_frames.resize(::Concurrency::details::platform::CaptureCallstack(&_csc._M_frames[0], 2, _CaptureFrames)); + return _csc; + } + }; +#endif typedef UINT32 _Unit_type; struct _TypeSelectorNoAsync {}; @@ -231,12 +339,12 @@ namespace details typedef _Type _Value; }; - struct _NonUserType { public: int _Dummy; }; + //struct _NonUserType { public: int _Dummy; }; template struct _ValueTypeOrRefType { - typedef _NonUserType _Value; + typedef _Unit_type _Value; }; template @@ -245,6 +353,18 @@ namespace details typedef _Type _Value; }; + template + _Ty _UnwrapAsyncActionWithProgressSelector(ABI::Windows::Foundation::IAsyncActionWithProgress_impl<_Ty>*); + + template + _Ty _UnwrapAsyncActionWithProgressSelector(...); + + template + _Progress _UnwrapAsyncOperationWithProgressProgressSelector(ABI::Windows::Foundation::IAsyncOperationWithProgress_impl<_Ty, _Progress>*); + + template + _Progress _UnwrapAsyncOperationWithProgressProgressSelector(...); + template _T2 _ProgressTypeSelector(ABI::Windows::Foundation::IAsyncOperationWithProgress<_T1, _T2>*); @@ -254,42 +374,7 @@ namespace details template struct _GetProgressType { - typedef decltype(_ProgressTypeSelector(std::declval<_Type>())) _Value; - }; - - template