Compare commits
370 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7018f94959 | |||
| 533fde66e3 | |||
| 5bd18155be | |||
| aa6b5ac124 | |||
| ca40a749b6 | |||
| d54d580f79 | |||
| 774d6c1d0a | |||
| 302d80d744 | |||
| 286c6b496d | |||
| 44da1f795f | |||
| 71c4e96e17 | |||
| 60fd5c2a3a | |||
| 8271c4e9c4 | |||
| 1f4fe3bb27 | |||
| a0431acb37 | |||
| e3f1d722e7 | |||
| 1c3c94fd2c | |||
| 45a1063c4a | |||
| 1cc80f10ba | |||
| a160158cb3 | |||
| 6a53cb9307 | |||
| 1920232268 | |||
| 7f4eb4f6c6 | |||
| e88a36621e | |||
| 467f5fc90f | |||
| ad018da224 | |||
| 90a1c6b1f0 | |||
| 93d1ceae43 | |||
| 073a7ff95a | |||
| 5bf1a4c08c | |||
| 562ff9d111 | |||
| 32f6e1a554 | |||
| 10bbcca11e | |||
| 19b3aab23f | |||
| df28bb5ccd | |||
| d4ec359f11 | |||
| 3603102c89 | |||
| a615102947 | |||
| 9c91d0103f | |||
| 37a1767286 | |||
| 03662c0589 | |||
| 7c354c14f7 | |||
| d2ba09e6ff | |||
| 934394c5e2 | |||
| 6c3cadbd73 | |||
| 4dda2002f6 | |||
| 539f8032dc | |||
| f8c5128729 | |||
| 150487feda | |||
| b767613d20 | |||
| 197b2e75e1 | |||
| 3516e14e05 | |||
| d82b918a7b | |||
| f60726b090 | |||
| 1675b23a64 | |||
| aa9da6e433 | |||
| 772f6208db | |||
| 0cf1de8eea | |||
| 5947519ff4 | |||
| 084835ec30 | |||
| a67484668e | |||
| 26fd37b27d | |||
| ccaedaedc8 | |||
| c5de129c36 | |||
| 533dd85299 | |||
| 48dc18ed59 | |||
| bac492fff6 | |||
| 1d2d579bd6 | |||
| 80687c8a56 | |||
| 8a1d3929cc | |||
| 281ce7a054 | |||
| 343f4b3026 | |||
| 882426a9b2 | |||
| cf15b9e8ad | |||
| f4f7522fe7 | |||
| 1b4e3ec35a | |||
| b9d5f3f6e9 | |||
| 587402859e | |||
| 0421da78b3 | |||
| b027a84fa1 | |||
| fbbf4e380f | |||
| faed8f43d6 | |||
| 9a15c7a899 | |||
| 35768ed638 | |||
| 161f50962d | |||
| e638b9e805 | |||
| d7737528d1 | |||
| 18c0511d3c | |||
| 06a1c90679 | |||
| bdb82d181f | |||
| 89833853fa | |||
| 25d125fba1 | |||
| d1229efeec | |||
| fd7a2defae | |||
| fcc481e751 | |||
| 1984aacb27 | |||
| eaaa2d27d5 | |||
| 74d8527f8a | |||
| 57cf3d1766 | |||
| f81b3101e8 | |||
| 81aefed13a | |||
| 41040e589f | |||
| 6eb26c1519 | |||
| ad7a871708 | |||
| 634ffed488 | |||
| ebe36d6e7c | |||
| d68e62c968 | |||
| b027eac173 | |||
| 2ed24876af | |||
| b08a6ccd9d | |||
| d558260a8e | |||
| 023a42ba55 | |||
| 7409f21e9f | |||
| 62f27b28ed | |||
| 599f5ef51b | |||
| 86e12b6074 | |||
| 5dff283b39 | |||
| 341c3d5933 | |||
| 988555a5d9 | |||
| e11333dd83 | |||
| af2434c547 | |||
| a4c883c098 | |||
| 0a531815c5 | |||
| a15db2d9cf | |||
| efc1c39315 | |||
| 3334b1437b | |||
| 34103ef1cb | |||
| e7f348e720 | |||
| da9be8231f | |||
| ed2cdb71e5 | |||
| bbe48eaac6 | |||
| bab826a381 | |||
| 77294855d7 | |||
| d8187f7518 | |||
| 9e83463128 | |||
| e98c9a7ce3 | |||
| 204651e0e2 | |||
| 042892f0d7 | |||
| 7cefaa49dd | |||
| fc41e8850b | |||
| 38b3698b97 | |||
| c2746b5d2a | |||
| daff2a0674 | |||
| ad5c2de97c | |||
| 9c285da329 | |||
| de37cfc224 | |||
| 946c09f58c | |||
| 4e168ffdf3 | |||
| d7bbafd683 | |||
| e90c233551 | |||
| 06897dbdb5 | |||
| 39020fc9cf | |||
| d5489f3a68 | |||
| 5a5a487612 | |||
| 46775ad186 | |||
| 901d9b70b0 | |||
| 0b4e043442 | |||
| d0c3c4c373 | |||
| 6c5dc17a1e | |||
| cf3757448d | |||
| 8578f9c565 | |||
| c9c09262f7 | |||
| faac7f18c7 | |||
| 8d58b238ca | |||
| 51bd56f19d | |||
| b111fb94b7 | |||
| 544dd8b130 | |||
| 246a793d82 | |||
| d31a0eab9e | |||
| ccbc764c02 | |||
| 60a5ada454 | |||
| d3c2b15f82 | |||
| b030d7e6a1 | |||
| 64d8cf1e2e | |||
| d262b04d99 | |||
| cce2d9927e | |||
| 79878a57a9 | |||
| 03fe86f0a3 | |||
| 13a0c14e6c | |||
| 6e022dcb06 | |||
| c38023f4e7 | |||
| cbb5fc0acc | |||
| 2df3abe16b | |||
| ecec53f509 | |||
| 023102c804 | |||
| 52c05e75cc | |||
| 3d48994a72 | |||
| 7b160fa3cb | |||
| 71d3654832 | |||
| 2c29ee9e00 | |||
| aafda43df1 | |||
| 39127d942e | |||
| b068e63618 | |||
| 4b8fb6c246 | |||
| 133d861d65 | |||
| 8539d424b2 | |||
| dcf96b2da7 | |||
| b1ac35e14a | |||
| 43e4946cca | |||
| 1b18ebf28a | |||
| f6cf68094f | |||
| d826bcdbbb | |||
| 070be56e14 | |||
| 939c60bcaa | |||
| 95550c2582 | |||
| ebb0255e19 | |||
| 5c8cd76893 | |||
| 3a8af7d691 | |||
| 7936faf9a3 | |||
| 5c85f816c9 | |||
| 56683e6d11 | |||
| fbac578c79 | |||
| ade46bd428 | |||
| 1138fbb940 | |||
| 436342d5f4 | |||
| b21b8ff9d7 | |||
| fb8fa3fdac | |||
| f45da9866a | |||
| 98421e5970 | |||
| 84bb77e914 | |||
| 6882970248 | |||
| 05e0b3b7e6 | |||
| 6a94862fef | |||
| cb69a5c29a | |||
| 75742fcd01 | |||
| c99ce0f427 | |||
| 660d7cd3ae | |||
| b6e25a9fc7 | |||
| 2b2ce3f6e9 | |||
| 3391caf434 | |||
| 3500c940d4 | |||
| 4d0848b3e8 | |||
| 1f4ddbe5b6 | |||
| 4ef311949b | |||
| 64344f4545 | |||
| 02b32d86d3 | |||
| fc610979bb | |||
| 11a09ef5cc | |||
| f08d88fa78 | |||
| 59c8edfd98 | |||
| 1a1cd9b4e9 | |||
| 7c44a07810 | |||
| cd3aa0184a | |||
| 1020a93fa3 | |||
| 9a5e9d3442 | |||
| 0ea572d772 | |||
| 2bacd8b702 | |||
| aa170cfb5b | |||
| e6f6905868 | |||
| 766600529b | |||
| 09f9b35bc6 | |||
| fea4396023 | |||
| ec99f96c62 | |||
| 2f8b5731da | |||
| 8d4a76925c | |||
| 00367cfb00 | |||
| e63d7de87c | |||
| 511ed4388e | |||
| 8a3b93773d | |||
| bcd63766ce | |||
| 7ea1bf3cf0 | |||
| 3678020c28 | |||
| 976da2f3d3 | |||
| 0d2fab86b4 | |||
| ca40d635e4 | |||
| 651b13f72a | |||
| bea46c90b5 | |||
| 0b4eb6a964 | |||
| 988b108858 | |||
| 44acfc38a1 | |||
| e30939f09b | |||
| 118b27f5b4 | |||
| eded87de5b | |||
| 12207ac763 | |||
| f77aa45cfb | |||
| 7fc764f5e5 | |||
| 06b335b2d7 | |||
| 62e0759ba2 | |||
| a46f119fdf | |||
| c9cb480844 | |||
| 746185652a | |||
| f16503743f | |||
| ea038436e6 | |||
| 6a93b43cae | |||
| 0ebde64701 | |||
| c30fef1f9d | |||
| 55bff44810 | |||
| 75a1743f35 | |||
| 83b7fe1b82 | |||
| 7e2f7f45d7 | |||
| 1f72873c55 | |||
| 7e56cfafbc | |||
| 6ecd553810 | |||
| 55a714c83b | |||
| 1d557e6702 | |||
| 10f89b9c8b | |||
| 4a24ecd176 | |||
| 2cf6cea90f | |||
| c607dadc49 | |||
| 83e2731c94 | |||
| 63e508abd2 | |||
| 006956c324 | |||
| ff2d76ec0d | |||
| bc7b21609a | |||
| f0547e5e05 | |||
| 67b562d543 | |||
| 6c118ebc51 | |||
| 09674623cf | |||
| ecfb1ab4f8 | |||
| a0a8fb4fd9 | |||
| 6c59e39f7c | |||
| e96de8821c | |||
| b382984810 | |||
| 2b4241c10b | |||
| e8376c789d | |||
| e4a9c0f184 | |||
| 5e47aa6300 | |||
| d67c9aabff | |||
| bb5a22c504 | |||
| a9c7db7518 | |||
| c74fed1fcf | |||
| 7c9caab1fb | |||
| aa76ef9a98 | |||
| 78f660024b | |||
| 19a2495067 | |||
| 77275031ab | |||
| 99475e2976 | |||
| 349ff631a5 | |||
| e50ef2dab5 | |||
| 629461c836 | |||
| e2c7adc7c4 | |||
| 36afd4ef55 | |||
| 4c66614e07 | |||
| b1a28a52fa | |||
| 38db7a78df | |||
| 5efd2056f0 | |||
| 1f94b7dfc9 | |||
| ef01044b2f | |||
| 59cf62ad9e | |||
| 50b291995a | |||
| f0d4ccc6cf | |||
| c2341fd446 | |||
| 897d0a9aaf | |||
| c1aee0c312 | |||
| dfdb09386f | |||
| 6fb83f869c | |||
| e6aa8ce932 | |||
| f0f741b796 | |||
| 05ee15f108 | |||
| 5042ab1f32 | |||
| 35e1b322cb | |||
| 9c7e0bfd33 | |||
| 4fb5680d91 | |||
| cccdcac0c8 | |||
| f27a886314 | |||
| 3d25d70627 | |||
| 7ba4212529 | |||
| 6a5a0fe803 | |||
| 990295644e | |||
| 9eb0e7d99b | |||
| 0c30b18769 | |||
| eeed9ce247 | |||
| c9f51d5eed | |||
| 9cb48606ba | |||
| 8e93c19de3 | |||
| e85bacff7b | |||
| 0d19685f95 | |||
| fa749de0dc | |||
| 5aeeaa6fce | |||
| 45e0e5f8e9 |
@@ -136,6 +136,7 @@ OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" ON)
|
||||
OCV_OPTION(WITH_VFW "Include Video for Windows support" ON IF WIN32 )
|
||||
OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON IF (NOT ANDROID AND NOT IOS))
|
||||
OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_GSTREAMER_0_10 "Enable Gstreamer 0.10 support (instead of 1.x)" OFF )
|
||||
OCV_OPTION(WITH_GTK "Include GTK support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_IMAGEIO "ImageIO support for OS X" OFF IF APPLE )
|
||||
OCV_OPTION(WITH_IPP "Include Intel IPP support" OFF IF (MSVC OR X86 OR X86_64) )
|
||||
@@ -159,7 +160,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 HighGUI with DirectShow support" ON IF (WIN32 AND NOT ARM) )
|
||||
OCV_OPTION(WITH_MSMF "Build HighGUI 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_OPENCL "Include OpenCL Runtime support" ON IF (NOT IOS) )
|
||||
OCV_OPTION(WITH_OPENCLAMDFFT "Include AMD OpenCL FFT library support" ON IF (NOT ANDROID AND NOT IOS) )
|
||||
@@ -217,12 +218,17 @@ OCV_OPTION(ENABLE_SSSE3 "Enable SSSE3 instructions"
|
||||
OCV_OPTION(ENABLE_SSE41 "Enable SSE4.1 instructions" OFF IF ((CV_ICC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_SSE42 "Enable SSE4.2 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_AVX "Enable AVX instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_AVX2 "Enable AVX2 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_NEON "Enable NEON instructions" OFF IF CMAKE_COMPILER_IS_GNUCXX AND ARM )
|
||||
OCV_OPTION(ENABLE_VFPV3 "Enable VFPv3-D32 instructions" OFF IF CMAKE_COMPILER_IS_GNUCXX AND ARM )
|
||||
OCV_OPTION(ENABLE_NOISY_WARNINGS "Show all warnings even if they are too noisy" OFF )
|
||||
OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
|
||||
OCV_OPTION(ENABLE_WINRT_MODE "Build with Windows Runtime support" OFF IF WIN32 )
|
||||
OCV_OPTION(ENABLE_WINRT_MODE_NATIVE "Build with Windows Runtime native C++ support" OFF IF WIN32 )
|
||||
OCV_OPTION(ENABLE_LIBVS2013 "Build VS2013 with Visual Studio 2013 libraries" OFF IF WIN32 AND (MSVC_VERSION EQUAL 1800) )
|
||||
OCV_OPTION(ENABLE_WINSDK81 "Build VS2013 with Windows 8.1 SDK" OFF IF WIN32 AND (MSVC_VERSION EQUAL 1800) )
|
||||
OCV_OPTION(ENABLE_WINPHONESDK80 "Build with Windows Phone 8.0 SDK" OFF IF WIN32 AND (MSVC_VERSION EQUAL 1700) )
|
||||
OCV_OPTION(ENABLE_WINPHONESDK81 "Build VS2013 with Windows Phone 8.1 SDK" OFF IF WIN32 AND (MSVC_VERSION EQUAL 1800) )
|
||||
|
||||
# uncategorized options
|
||||
# ===================================================
|
||||
@@ -601,6 +607,12 @@ if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH AND UNIX)
|
||||
install(PROGRAMS "${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh"
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT tests)
|
||||
else()
|
||||
set(OPENCV_PYTHON_TESTS_LIST "")
|
||||
if(BUILD_opencv_python)
|
||||
file(GLOB py_tests modules/python/test/*.py)
|
||||
install(PROGRAMS ${py_tests} DESTINATION ${OPENCV_TEST_INSTALL_PATH} COMPONENT tests)
|
||||
set(OPENCV_PYTHON_TESTS_LIST "test2.py")
|
||||
endif()
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv_testing.sh.in"
|
||||
"${CMAKE_BINARY_DIR}/unix-install/opencv_testing.sh" @ONLY)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/unix-install/opencv_testing.sh"
|
||||
@@ -609,7 +621,6 @@ if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH AND UNIX)
|
||||
"${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh" @ONLY)
|
||||
install(PROGRAMS "${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh"
|
||||
DESTINATION ${OPENCV_TEST_INSTALL_PATH} COMPONENT tests)
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -745,8 +756,8 @@ if(WIN32)
|
||||
status("")
|
||||
status(" Windows RT support:" HAVE_WINRT THEN YES ELSE NO)
|
||||
if (ENABLE_WINRT_MODE OR ENABLE_WINRT_MODE_NATIVE)
|
||||
status(" Windows SDK v8.0:" ${WINDOWS_SDK_PATH})
|
||||
status(" Visual Studio 2012:" ${VISUAL_STUDIO_PATH})
|
||||
status(" Windows (Phone) SDK v8.0/v8.1:" ${WINDOWS_SDK_PATH})
|
||||
status(" Visual Studio 2012/2013:" ${VISUAL_STUDIO_PATH})
|
||||
endif()
|
||||
endif(WIN32)
|
||||
|
||||
@@ -861,10 +872,12 @@ endif(DEFINED WITH_FFMPEG)
|
||||
if(DEFINED WITH_GSTREAMER)
|
||||
status(" GStreamer:" HAVE_GSTREAMER THEN "" ELSE NO)
|
||||
if(HAVE_GSTREAMER)
|
||||
status(" base:" "YES (ver ${ALIASOF_gstreamer-base-0.10_VERSION})")
|
||||
status(" app:" "YES (ver ${ALIASOF_gstreamer-app-0.10_VERSION})")
|
||||
status(" video:" "YES (ver ${ALIASOF_gstreamer-video-0.10_VERSION})")
|
||||
endif()
|
||||
status(" base:" "YES (ver ${GSTREAMER_BASE_VERSION})")
|
||||
status(" video:" "YES (ver ${GSTREAMER_VIDEO_VERSION})")
|
||||
status(" app:" "YES (ver ${GSTREAMER_APP_VERSION})")
|
||||
status(" riff:" "YES (ver ${GSTREAMER_RIFF_VERSION})")
|
||||
status(" pbutils:" "YES (ver ${GSTREAMER_PBUTILS_VERSION})")
|
||||
endif(HAVE_GSTREAMER)
|
||||
endif(DEFINED WITH_GSTREAMER)
|
||||
|
||||
if(DEFINED WITH_OPENNI)
|
||||
@@ -905,8 +918,9 @@ if(DEFINED WITH_V4L)
|
||||
else()
|
||||
set(HAVE_CAMV4L2_STR "NO")
|
||||
endif()
|
||||
status(" V4L/V4L2:" HAVE_LIBV4L THEN "Using libv4l (ver ${ALIASOF_libv4l1_VERSION})"
|
||||
ELSE "${HAVE_CAMV4L_STR}/${HAVE_CAMV4L2_STR}")
|
||||
status(" V4L/V4L2:" HAVE_LIBV4L
|
||||
THEN "Using libv4l1 (ver ${ALIASOF_libv4l1_VERSION}) / libv4l2 (ver ${ALIASOF_libv4l2_VERSION})"
|
||||
ELSE "${HAVE_CAMV4L_STR}/${HAVE_CAMV4L2_STR}")
|
||||
endif(DEFINED WITH_V4L)
|
||||
|
||||
if(DEFINED WITH_DSHOW)
|
||||
|
||||
@@ -29,6 +29,9 @@ set(cvhaartraining_lib_src
|
||||
cvhaarclassifier.cpp
|
||||
cvhaartraining.cpp
|
||||
cvsamples.cpp
|
||||
cvsamplesoutput.cpp
|
||||
cvsamplesoutput.h
|
||||
ioutput.h
|
||||
)
|
||||
|
||||
add_library(opencv_haartraining_engine STATIC ${cvhaartraining_lib_src})
|
||||
|
||||
@@ -50,10 +50,12 @@
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include <ctime>
|
||||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "cvhaartraining.h"
|
||||
#include "ioutput.h"
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
@@ -71,11 +73,12 @@ int main( int argc, char* argv[] )
|
||||
double maxxangle = 1.1;
|
||||
double maxyangle = 1.1;
|
||||
double maxzangle = 0.5;
|
||||
int showsamples = 0;
|
||||
bool showsamples = false;
|
||||
/* the samples are adjusted to this scale in the sample preview window */
|
||||
double scale = 4.0;
|
||||
int width = 24;
|
||||
int height = 24;
|
||||
bool pngoutput = false; /* whether to make the samples in png or in jpg*/
|
||||
|
||||
srand((unsigned int)time(0));
|
||||
|
||||
@@ -92,7 +95,8 @@ int main( int argc, char* argv[] )
|
||||
" [-maxyangle <max_y_rotation_angle = %f>]\n"
|
||||
" [-maxzangle <max_z_rotation_angle = %f>]\n"
|
||||
" [-show [<scale = %f>]]\n"
|
||||
" [-w <sample_width = %d>]\n [-h <sample_height = %d>]\n",
|
||||
" [-w <sample_width = %d>]\n [-h <sample_height = %d>]\n"
|
||||
" [-pngoutput]",
|
||||
argv[0], num, bgcolor, bgthreshold, maxintensitydev,
|
||||
maxxangle, maxyangle, maxzangle, scale, width, height );
|
||||
|
||||
@@ -155,7 +159,7 @@ int main( int argc, char* argv[] )
|
||||
}
|
||||
else if( !strcmp( argv[i], "-show" ) )
|
||||
{
|
||||
showsamples = 1;
|
||||
showsamples = true;
|
||||
if( i+1 < argc && strlen( argv[i+1] ) > 0 && argv[i+1][0] != '-' )
|
||||
{
|
||||
double d;
|
||||
@@ -172,6 +176,10 @@ int main( int argc, char* argv[] )
|
||||
{
|
||||
height = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-pngoutput" ) )
|
||||
{
|
||||
pngoutput = true;
|
||||
}
|
||||
}
|
||||
|
||||
printf( "Info file name: %s\n", ((infoname == NULL) ? nullname : infoname ) );
|
||||
@@ -190,10 +198,14 @@ int main( int argc, char* argv[] )
|
||||
printf( "Show samples: %s\n", (showsamples) ? "TRUE" : "FALSE" );
|
||||
if( showsamples )
|
||||
{
|
||||
printf( "Scale: %g\n", scale );
|
||||
printf( "Scale applied to display : %g\n", scale );
|
||||
}
|
||||
if( !pngoutput)
|
||||
{
|
||||
printf( "Original image will be scaled to:\n");
|
||||
printf( "\tWidth: $backgroundWidth / %d\n", width );
|
||||
printf( "\tHeight: $backgroundHeight / %d\n", height );
|
||||
}
|
||||
printf( "Width: %d\n", width );
|
||||
printf( "Height: %d\n", height );
|
||||
|
||||
/* determine action */
|
||||
if( imagename && vecname )
|
||||
@@ -207,13 +219,24 @@ int main( int argc, char* argv[] )
|
||||
|
||||
printf( "Done\n" );
|
||||
}
|
||||
else if( imagename && bgfilename && infoname )
|
||||
else if( imagename && bgfilename && infoname)
|
||||
{
|
||||
printf( "Create test samples from single image applying distortions...\n" );
|
||||
printf( "Create data set from single image applying distortions...\n"
|
||||
"Output format: %s\n",
|
||||
(( pngoutput ) ? "PNG" : "JPG") );
|
||||
|
||||
cvCreateTestSamples( infoname, imagename, bgcolor, bgthreshold, bgfilename, num,
|
||||
invert, maxintensitydev,
|
||||
maxxangle, maxyangle, maxzangle, showsamples, width, height );
|
||||
std::auto_ptr<DatasetGenerator> creator;
|
||||
if( pngoutput )
|
||||
{
|
||||
creator = std::auto_ptr<DatasetGenerator>( new PngDatasetGenerator( infoname ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
creator = std::auto_ptr<DatasetGenerator>( new JpgDatasetGenerator( infoname ) );
|
||||
}
|
||||
creator->create( imagename, bgcolor, bgthreshold, bgfilename, num,
|
||||
invert, maxintensitydev, maxxangle, maxyangle, maxzangle,
|
||||
showsamples, width, height );
|
||||
|
||||
printf( "Done\n" );
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
#include "cvhaartraining.h"
|
||||
#include "_cvhaartraining.h"
|
||||
|
||||
#include "ioutput.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
@@ -2841,14 +2843,12 @@ void cvCreateTreeCascadeClassifier( const char* dirname,
|
||||
cvReleaseMat( &features_idx );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void cvCreateTrainingSamples( const char* filename,
|
||||
const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
int showsamples,
|
||||
bool showsamples,
|
||||
int winwidth, int winheight )
|
||||
{
|
||||
CvSampleDistortionData data;
|
||||
@@ -2915,7 +2915,7 @@ void cvCreateTrainingSamples( const char* filename,
|
||||
cvShowImage( "Sample", &sample );
|
||||
if( cvWaitKey( 0 ) == 27 )
|
||||
{
|
||||
showsamples = 0;
|
||||
showsamples = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2942,45 +2942,43 @@ void cvCreateTrainingSamples( const char* filename,
|
||||
|
||||
}
|
||||
|
||||
#define CV_INFO_FILENAME "info.dat"
|
||||
DatasetGenerator::DatasetGenerator( IOutput* _writer )
|
||||
:writer(_writer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void cvCreateTestSamples( const char* infoname,
|
||||
const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
int showsamples,
|
||||
int winwidth, int winheight )
|
||||
void DatasetGenerator::showSamples(bool* show, CvMat *img) const
|
||||
{
|
||||
if( *show )
|
||||
{
|
||||
cvShowImage( "Image", img);
|
||||
if( cvWaitKey( 0 ) == 27 )
|
||||
{
|
||||
*show = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DatasetGenerator::create(const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
bool showsamples,
|
||||
int winwidth, int winheight )
|
||||
{
|
||||
CvSampleDistortionData data;
|
||||
|
||||
assert( infoname != NULL );
|
||||
assert( imgfilename != NULL );
|
||||
assert( bgfilename != NULL );
|
||||
|
||||
if( !icvMkDir( infoname ) )
|
||||
{
|
||||
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Unable to create directory hierarchy: %s\n", infoname );
|
||||
#endif /* CV_VERBOSE */
|
||||
|
||||
return;
|
||||
}
|
||||
if( icvStartSampleDistortion( imgfilename, bgcolor, bgthreshold, &data ) )
|
||||
{
|
||||
char fullname[PATH_MAX];
|
||||
char* filename;
|
||||
CvMat win;
|
||||
FILE* info;
|
||||
|
||||
if( icvInitBackgroundReaders( bgfilename, cvSize( 10, 10 ) ) )
|
||||
{
|
||||
int i;
|
||||
int x, y, width, height;
|
||||
float scale;
|
||||
float maxscale;
|
||||
int inverse;
|
||||
|
||||
if( showsamples )
|
||||
@@ -2988,73 +2986,112 @@ void cvCreateTestSamples( const char* infoname,
|
||||
cvNamedWindow( "Image", CV_WINDOW_AUTOSIZE );
|
||||
}
|
||||
|
||||
info = fopen( infoname, "w" );
|
||||
strcpy( fullname, infoname );
|
||||
filename = strrchr( fullname, '\\' );
|
||||
if( filename == NULL )
|
||||
{
|
||||
filename = strrchr( fullname, '/' );
|
||||
}
|
||||
if( filename == NULL )
|
||||
{
|
||||
filename = fullname;
|
||||
}
|
||||
else
|
||||
{
|
||||
filename++;
|
||||
}
|
||||
|
||||
count = MIN( count, cvbgdata->count );
|
||||
inverse = invert;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
icvGetNextFromBackgroundData( cvbgdata, cvbgreader );
|
||||
|
||||
maxscale = MIN( 0.7F * cvbgreader->src.cols / winwidth,
|
||||
0.7F * cvbgreader->src.rows / winheight );
|
||||
if( maxscale < 1.0F ) continue;
|
||||
CvRect boundingBox = getObjectPosition( cvSize( cvbgreader->src.cols,
|
||||
cvbgreader->src.rows ),
|
||||
cvGetSize(data.img),
|
||||
cvSize( winwidth, winheight ) );
|
||||
if(boundingBox.width <= 0 || boundingBox.height <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
scale = (maxscale - 1.0F) * rand() / RAND_MAX + 1.0F;
|
||||
width = (int) (scale * winwidth);
|
||||
height = (int) (scale * winheight);
|
||||
x = (int) ((0.1+0.8 * rand()/RAND_MAX) * (cvbgreader->src.cols - width));
|
||||
y = (int) ((0.1+0.8 * rand()/RAND_MAX) * (cvbgreader->src.rows - height));
|
||||
cvGetSubArr( &cvbgreader->src, &win, boundingBox );
|
||||
|
||||
cvGetSubArr( &cvbgreader->src, &win, cvRect( x, y ,width, height ) );
|
||||
if( invert == CV_RANDOM_INVERT )
|
||||
{
|
||||
inverse = (rand() > (RAND_MAX/2));
|
||||
}
|
||||
|
||||
icvPlaceDistortedSample( &win, inverse, maxintensitydev,
|
||||
maxxangle, maxyangle, maxzangle,
|
||||
1, 0.0, 0.0, &data );
|
||||
|
||||
writer->write( cvbgreader->src, boundingBox );
|
||||
|
||||
sprintf( filename, "%04d_%04d_%04d_%04d_%04d.jpg",
|
||||
(i + 1), x, y, width, height );
|
||||
|
||||
if( info )
|
||||
{
|
||||
fprintf( info, "%s %d %d %d %d %d\n",
|
||||
filename, 1, x, y, width, height );
|
||||
}
|
||||
|
||||
cvSaveImage( fullname, &cvbgreader->src );
|
||||
if( showsamples )
|
||||
{
|
||||
cvShowImage( "Image", &cvbgreader->src );
|
||||
if( cvWaitKey( 0 ) == 27 )
|
||||
{
|
||||
showsamples = 0;
|
||||
}
|
||||
}
|
||||
showSamples(&showsamples, &cvbgreader->src);
|
||||
}
|
||||
if( info ) fclose( info );
|
||||
icvDestroyBackgroundReaders();
|
||||
}
|
||||
icvEndSampleDistortion( &data );
|
||||
}
|
||||
}
|
||||
|
||||
DatasetGenerator::~DatasetGenerator()
|
||||
{
|
||||
delete writer;
|
||||
}
|
||||
|
||||
|
||||
JpgDatasetGenerator::JpgDatasetGenerator( const char* filename )
|
||||
:DatasetGenerator( IOutput::createOutput( filename, IOutput::JPG_DATASET ) )
|
||||
{
|
||||
}
|
||||
|
||||
CvSize JpgDatasetGenerator::scaleObjectSize( const CvSize& bgImgSize,
|
||||
const CvSize& ,
|
||||
const CvSize& sampleSize) const
|
||||
{
|
||||
float scale;
|
||||
float maxscale;
|
||||
|
||||
maxscale = MIN( 0.7F * bgImgSize.width / sampleSize.width,
|
||||
0.7F * bgImgSize.height / sampleSize.height );
|
||||
if( maxscale < 1.0F )
|
||||
{
|
||||
scale = -1.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale = (maxscale - 1.0F) * rand() / RAND_MAX + 1.0F;
|
||||
}
|
||||
|
||||
int width = (int) (scale * sampleSize.width);
|
||||
int height = (int) (scale * sampleSize.height);
|
||||
|
||||
return cvSize( width, height );
|
||||
}
|
||||
|
||||
CvRect DatasetGenerator::getObjectPosition(const CvSize& bgImgSize,
|
||||
const CvSize& imgSize,
|
||||
const CvSize& sampleSize) const
|
||||
{
|
||||
CvSize size = scaleObjectSize( bgImgSize, imgSize, sampleSize );
|
||||
|
||||
int width = size.width;
|
||||
int height = size.height;
|
||||
int x = (int) ((0.1 + 0.8 * rand() / RAND_MAX) * (bgImgSize.width - width));
|
||||
int y = (int) ((0.1 + 0.8 * rand() / RAND_MAX) * (bgImgSize.height - height));
|
||||
|
||||
return cvRect( x, y, width, height );
|
||||
}
|
||||
|
||||
|
||||
PngDatasetGenerator::PngDatasetGenerator(const char* filename)
|
||||
:DatasetGenerator( IOutput::createOutput( filename, IOutput::PNG_DATASET ) )
|
||||
{
|
||||
}
|
||||
|
||||
CvSize PngDatasetGenerator::scaleObjectSize( const CvSize& bgImgSize,
|
||||
const CvSize& imgSize,
|
||||
const CvSize& ) const
|
||||
{
|
||||
float scale;
|
||||
|
||||
scale = MIN( 0.3F * bgImgSize.width / imgSize.width,
|
||||
0.3F * bgImgSize.height / imgSize.height );
|
||||
|
||||
|
||||
int width = (int) (scale * imgSize.width);
|
||||
int height = (int) (scale * imgSize.height);
|
||||
|
||||
return cvSize( width, height );
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
|
||||
@@ -48,6 +48,11 @@
|
||||
#ifndef _CVHAARTRAINING_H_
|
||||
#define _CVHAARTRAINING_H_
|
||||
|
||||
class IOutput;
|
||||
struct CvRect;
|
||||
struct CvSize;
|
||||
struct CvMat;
|
||||
|
||||
/*
|
||||
* cvCreateTrainingSamples
|
||||
*
|
||||
@@ -74,23 +79,30 @@
|
||||
*/
|
||||
#define CV_RANDOM_INVERT 0x7FFFFFFF
|
||||
|
||||
void cvCreateTrainingSamples( const char* filename,
|
||||
void cvCreateTrainingSamples(const char* filename,
|
||||
const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert = 0, int maxintensitydev = 40,
|
||||
double maxxangle = 1.1,
|
||||
double maxyangle = 1.1,
|
||||
double maxzangle = 0.5,
|
||||
int showsamples = 0,
|
||||
bool showsamples = false,
|
||||
int winwidth = 24, int winheight = 24 );
|
||||
|
||||
void cvCreateTestSamples( const char* infoname,
|
||||
const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
void cvCreatePngTrainingSet(const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
int winwidth, int winheight,
|
||||
IOutput *writer );
|
||||
|
||||
void cvCreateTestSamples(const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
int showsamples,
|
||||
int winwidth, int winheight );
|
||||
int winwidth, int winheight,
|
||||
IOutput* writer);
|
||||
|
||||
/*
|
||||
* cvCreateTrainingSamplesFromInfo
|
||||
@@ -189,4 +201,50 @@ void cvCreateTreeCascadeClassifier( const char* dirname,
|
||||
int boosttype, int stumperror,
|
||||
int maxtreesplits, int minpos, bool bg_vecfile = false );
|
||||
|
||||
|
||||
class DatasetGenerator
|
||||
{
|
||||
public:
|
||||
DatasetGenerator( IOutput* _writer );
|
||||
void create( const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
bool showsamples,
|
||||
int winwidth, int winheight);
|
||||
virtual ~DatasetGenerator();
|
||||
private:
|
||||
virtual void showSamples( bool* showSamples, CvMat* img ) const;
|
||||
|
||||
CvRect getObjectPosition( const CvSize& bgImgSize,
|
||||
const CvSize& imgSize,
|
||||
const CvSize& sampleSize ) const;
|
||||
virtual CvSize scaleObjectSize(const CvSize& bgImgSize,
|
||||
const CvSize& imgSize ,
|
||||
const CvSize& sampleSize) const =0 ;
|
||||
private:
|
||||
IOutput* writer;
|
||||
};
|
||||
|
||||
/* Provides the functionality of test set generating */
|
||||
class JpgDatasetGenerator: public DatasetGenerator
|
||||
{
|
||||
public:
|
||||
JpgDatasetGenerator(const char* filename);
|
||||
private:
|
||||
CvSize scaleObjectSize(const CvSize& bgImgSize,
|
||||
const CvSize& ,
|
||||
const CvSize& sampleSize) const;
|
||||
};
|
||||
|
||||
class PngDatasetGenerator: public DatasetGenerator
|
||||
{
|
||||
public:
|
||||
PngDatasetGenerator(const char *filename);
|
||||
private:
|
||||
CvSize scaleObjectSize(const CvSize& bgImgSize,
|
||||
const CvSize& imgSize ,
|
||||
const CvSize& ) const;
|
||||
};
|
||||
|
||||
#endif /* _CVHAARTRAINING_H_ */
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
#include "cvsamplesoutput.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "_cvcommon.h"
|
||||
#include "highgui.h"
|
||||
|
||||
/* print statistic info */
|
||||
#define CV_VERBOSE 1
|
||||
|
||||
IOutput::IOutput()
|
||||
: currentIdx(0)
|
||||
{}
|
||||
|
||||
void IOutput::findFilePathPart(char **partOfPath, char *fullPath)
|
||||
{
|
||||
*partOfPath = strrchr( fullPath, '\\' );
|
||||
if( *partOfPath == NULL )
|
||||
{
|
||||
*partOfPath = strrchr( fullPath, '/' );
|
||||
}
|
||||
if( *partOfPath == NULL )
|
||||
{
|
||||
*partOfPath = fullPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
*partOfPath += 1;
|
||||
}
|
||||
}
|
||||
|
||||
IOutput* IOutput::createOutput(const char *filename,
|
||||
IOutput::OutputType type)
|
||||
{
|
||||
IOutput* output = 0;
|
||||
switch (type) {
|
||||
case IOutput::PNG_DATASET:
|
||||
output = new PngDatasetOutput();
|
||||
break;
|
||||
case IOutput::JPG_DATASET:
|
||||
output = new JpgDatasetOutput();
|
||||
break;
|
||||
default:
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Invalid output type, valid types are: PNG_TRAINING_SET, JPG_TEST_SET");
|
||||
#endif /* CV_VERBOSE */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( output->init( filename ) )
|
||||
return output;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool PngDatasetOutput::init( const char* annotationsListFileName )
|
||||
{
|
||||
IOutput::init( annotationsListFileName );
|
||||
|
||||
if(imgFileName == imgFullPath)
|
||||
{
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Invalid path to annotations file: %s\n"
|
||||
"It should contain a parent directory name\n", imgFullPath );
|
||||
#endif /* CV_VERBOSE */
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const char* annotationsdirname = "/annotations/";
|
||||
const char* positivesdirname = "/pos/";
|
||||
|
||||
imgFileName[-1] = '\0'; //erase slash at the end of the path
|
||||
imgFileName -= 1;
|
||||
|
||||
//copy path to dataset top-level dir
|
||||
strcpy(annotationFullPath, imgFullPath);
|
||||
//find the name of annotation starting from the top-level dataset dir
|
||||
findFilePathPart(&annotationRelativePath, annotationFullPath);
|
||||
if( !strcmp( annotationRelativePath, ".." ) || !strcmp( annotationRelativePath, "." ) )
|
||||
{
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Invalid path to annotations file: %s\n"
|
||||
"It should contain a parent directory name\n", annotationsListFileName );
|
||||
#endif /* CV_VERBOSE */
|
||||
return false;
|
||||
}
|
||||
//find the name of output image starting from the top-level dataset dir
|
||||
findFilePathPart(&imgRelativePath, imgFullPath);
|
||||
annotationFileName = annotationFullPath + strlen(annotationFullPath);
|
||||
|
||||
sprintf(annotationFileName, "%s", annotationsdirname);
|
||||
annotationFileName += strlen(annotationFileName);
|
||||
sprintf(imgFileName, "%s", positivesdirname);
|
||||
imgFileName += strlen(imgFileName);
|
||||
|
||||
if( !icvMkDir( annotationFullPath ) )
|
||||
{
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Unable to create directory hierarchy: %s\n", annotationFullPath );
|
||||
#endif /* CV_VERBOSE */
|
||||
return false;
|
||||
}
|
||||
if( !icvMkDir( imgFullPath ) )
|
||||
{
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Unable to create directory hierarchy: %s\n", imgFullPath );
|
||||
#endif /* CV_VERBOSE */
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PngDatasetOutput::write( const CvMat& img,
|
||||
const CvRect& boundingBox )
|
||||
{
|
||||
CvRect bbox = addBoundingboxBorder(boundingBox);
|
||||
|
||||
sprintf( imgFileName,
|
||||
"%04d_%04d_%04d_%04d_%04d",
|
||||
++currentIdx,
|
||||
bbox.x,
|
||||
bbox.y,
|
||||
bbox.width,
|
||||
bbox.height );
|
||||
|
||||
sprintf( annotationFileName, "%s.txt", imgFileName );
|
||||
fprintf( annotationsList, "%s\n", annotationRelativePath );
|
||||
|
||||
FILE* annotationFile = fopen( annotationFullPath, "w" );
|
||||
if(annotationFile == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
sprintf( imgFileName + strlen(imgFileName), ".%s", extension );
|
||||
|
||||
|
||||
|
||||
fprintf( annotationFile,
|
||||
"Image filename : \"%s\"\n"
|
||||
"Bounding box for object 1 \"PASperson\" (Xmin, Ymin) - (Xmax, Ymax) : (%d, %d) - (%d, %d)",
|
||||
imgRelativePath,
|
||||
bbox.x,
|
||||
bbox.y,
|
||||
bbox.x + bbox.width,
|
||||
bbox.y + bbox.height );
|
||||
fclose( annotationFile );
|
||||
|
||||
cvSaveImage( imgFullPath, &img);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CvRect PngDatasetOutput::addBoundingboxBorder(const CvRect& bbox) const
|
||||
{
|
||||
CvRect boundingBox = bbox;
|
||||
int border = 5;
|
||||
|
||||
boundingBox.x -= border;
|
||||
boundingBox.y -= border;
|
||||
boundingBox.width += 2*border;
|
||||
boundingBox.height += 2*border;
|
||||
|
||||
return boundingBox;
|
||||
}
|
||||
|
||||
IOutput::~IOutput()
|
||||
{
|
||||
if(annotationsList)
|
||||
{
|
||||
fclose(annotationsList);
|
||||
}
|
||||
}
|
||||
|
||||
bool IOutput::init(const char *filename)
|
||||
{
|
||||
assert( filename != NULL );
|
||||
|
||||
if( !icvMkDir( filename ) )
|
||||
{
|
||||
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Unable to create directory hierarchy: %s\n", filename );
|
||||
#endif /* CV_VERBOSE */
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
annotationsList = fopen( filename, "w" );
|
||||
if( annotationsList == NULL )
|
||||
{
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Unable to create info file: %s\n", filename );
|
||||
#endif /* CV_VERBOSE */
|
||||
return false;
|
||||
}
|
||||
strcpy( imgFullPath, filename );
|
||||
|
||||
findFilePathPart( &imgFileName, imgFullPath );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JpgDatasetOutput::write( const CvMat& img,
|
||||
const CvRect& boundingBox )
|
||||
{
|
||||
sprintf( imgFileName, "%04d_%04d_%04d_%04d_%04d.jpg",
|
||||
++currentIdx,
|
||||
boundingBox.x,
|
||||
boundingBox.y,
|
||||
boundingBox.width,
|
||||
boundingBox.height );
|
||||
|
||||
fprintf( annotationsList, "%s %d %d %d %d %d\n",
|
||||
imgFileName,
|
||||
1,
|
||||
boundingBox.x,
|
||||
boundingBox.y,
|
||||
boundingBox.width,
|
||||
boundingBox.height );
|
||||
|
||||
cvSaveImage( imgFullPath, &img);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef CVSAMPLESOUTPUT_H
|
||||
#define CVSAMPLESOUTPUT_H
|
||||
|
||||
#include "ioutput.h"
|
||||
|
||||
class PngDatasetOutput: public IOutput
|
||||
{
|
||||
friend IOutput* IOutput::createOutput(const char *filename, OutputType type);
|
||||
public:
|
||||
virtual bool write( const CvMat& img,
|
||||
const CvRect& boundingBox);
|
||||
|
||||
virtual ~PngDatasetOutput(){}
|
||||
private:
|
||||
PngDatasetOutput()
|
||||
: extension("png")
|
||||
, destImgWidth(640)
|
||||
, destImgHeight(480)
|
||||
{}
|
||||
|
||||
virtual bool init(const char* annotationsListFileName );
|
||||
|
||||
CvRect addBoundingboxBorder(const CvRect& bbox) const;
|
||||
private:
|
||||
|
||||
char annotationFullPath[PATH_MAX];
|
||||
char* annotationFileName;
|
||||
char* annotationRelativePath;
|
||||
char* imgRelativePath;
|
||||
const char* extension;
|
||||
|
||||
int destImgWidth;
|
||||
int destImgHeight ;
|
||||
};
|
||||
|
||||
class JpgDatasetOutput: public IOutput
|
||||
{
|
||||
friend IOutput* IOutput::createOutput(const char *filename, OutputType type);
|
||||
public:
|
||||
virtual bool write( const CvMat& img,
|
||||
const CvRect& boundingBox );
|
||||
virtual ~JpgDatasetOutput(){}
|
||||
private:
|
||||
JpgDatasetOutput(){}
|
||||
};
|
||||
#endif // CVSAMPLESOUTPUT_H
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef IOUTPUT_H
|
||||
#define IOUTPUT_H
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "_cvcommon.h"
|
||||
|
||||
struct CvMat;
|
||||
struct CvRect;
|
||||
|
||||
class IOutput
|
||||
{
|
||||
public:
|
||||
enum OutputType {PNG_DATASET, JPG_DATASET};
|
||||
public:
|
||||
virtual bool write( const CvMat& img,
|
||||
const CvRect& boundingBox ) =0;
|
||||
|
||||
virtual ~IOutput();
|
||||
|
||||
static IOutput* createOutput( const char *filename, OutputType type );
|
||||
protected:
|
||||
IOutput();
|
||||
/* finds the beginning of the last token in the path */
|
||||
void findFilePathPart( char **partOfPath, char *fullPath );
|
||||
virtual bool init( const char* filename );
|
||||
protected:
|
||||
int currentIdx;
|
||||
char imgFullPath[PATH_MAX];
|
||||
char* imgFileName;
|
||||
FILE* annotationsList;
|
||||
};
|
||||
|
||||
#endif // IOUTPUT_H
|
||||
@@ -198,7 +198,7 @@ bool CvCascadeClassifier::train( const string _cascadeDirName,
|
||||
cout << endl << "===== TRAINING " << i << "-stage =====" << endl;
|
||||
cout << "<BEGIN" << endl;
|
||||
|
||||
if ( !updateTrainingSet( tempLeafFARate ) )
|
||||
if ( !updateTrainingSet( requiredLeafFARate, tempLeafFARate ) )
|
||||
{
|
||||
cout << "Train dataset for temp stage can not be filled. "
|
||||
"Branch training terminated." << endl;
|
||||
@@ -284,17 +284,17 @@ int CvCascadeClassifier::predict( int sampleIdx )
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool CvCascadeClassifier::updateTrainingSet( double& acceptanceRatio)
|
||||
bool CvCascadeClassifier::updateTrainingSet( double minimumAcceptanceRatio, double& acceptanceRatio)
|
||||
{
|
||||
int64 posConsumed = 0, negConsumed = 0;
|
||||
imgReader.restart();
|
||||
int posCount = fillPassedSamples( 0, numPos, true, posConsumed );
|
||||
int posCount = fillPassedSamples( 0, numPos, true, 0, posConsumed );
|
||||
if( !posCount )
|
||||
return false;
|
||||
cout << "POS count : consumed " << posCount << " : " << (int)posConsumed << endl;
|
||||
|
||||
int proNumNeg = cvRound( ( ((double)numNeg) * ((double)posCount) ) / numPos ); // apply only a fraction of negative samples. double is required since overflow is possible
|
||||
int negCount = fillPassedSamples( posCount, proNumNeg, false, negConsumed );
|
||||
int negCount = fillPassedSamples( posCount, proNumNeg, false, minimumAcceptanceRatio, negConsumed );
|
||||
if ( !negCount )
|
||||
return false;
|
||||
|
||||
@@ -304,7 +304,7 @@ bool CvCascadeClassifier::updateTrainingSet( double& acceptanceRatio)
|
||||
return true;
|
||||
}
|
||||
|
||||
int CvCascadeClassifier::fillPassedSamples( int first, int count, bool isPositive, int64& consumed )
|
||||
int CvCascadeClassifier::fillPassedSamples( int first, int count, bool isPositive, double minimumAcceptanceRatio, int64& consumed )
|
||||
{
|
||||
int getcount = 0;
|
||||
Mat img(cascadeParams.winSize, CV_8UC1);
|
||||
@@ -312,6 +312,9 @@ int CvCascadeClassifier::fillPassedSamples( int first, int count, bool isPositiv
|
||||
{
|
||||
for( ; ; )
|
||||
{
|
||||
if( consumed != 0 && ((double)getcount+1)/(double)(int64)consumed <= minimumAcceptanceRatio )
|
||||
return getcount;
|
||||
|
||||
bool isGetImg = isPositive ? imgReader.getPos( img ) :
|
||||
imgReader.getNeg( img );
|
||||
if( !isGetImg )
|
||||
@@ -506,6 +509,8 @@ void CvCascadeClassifier::save( const string filename, bool baseFormat )
|
||||
|
||||
bool CvCascadeClassifier::load( const string cascadeDirName )
|
||||
{
|
||||
cout << "Training parameters are loaded from the parameter file in data folder!" << endl;
|
||||
cout << "Please empty the data folder if you want to use your own set of parameters." << endl;
|
||||
FileStorage fs( cascadeDirName + CC_PARAMS_FILENAME, FileStorage::READ );
|
||||
if ( !fs.isOpened() )
|
||||
return false;
|
||||
|
||||
@@ -101,8 +101,8 @@ private:
|
||||
int predict( int sampleIdx );
|
||||
void save( const std::string cascadeDirName, bool baseFormat = false );
|
||||
bool load( const std::string cascadeDirName );
|
||||
bool updateTrainingSet( double& acceptanceRatio );
|
||||
int fillPassedSamples( int first, int count, bool isPositive, int64& consumed );
|
||||
bool updateTrainingSet( double minimumAcceptanceRatio, double& acceptanceRatio );
|
||||
int fillPassedSamples( int first, int count, bool isPositive, double requiredAcceptanceRatio, int64& consumed );
|
||||
|
||||
void writeParams( cv::FileStorage &fs ) const;
|
||||
void writeStages( cv::FileStorage &fs, const cv::Mat& featureMap ) const;
|
||||
|
||||
@@ -6,34 +6,62 @@ endif()
|
||||
|
||||
set(HAVE_WINRT FALSE)
|
||||
|
||||
# search Windows Platform SDK
|
||||
message(STATUS "Checking for Windows Platform SDK")
|
||||
GET_FILENAME_COMPONENT(WINDOWS_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]" ABSOLUTE CACHE)
|
||||
if(WINDOWS_SDK_PATH STREQUAL "")
|
||||
set(HAVE_MSPDK FALSE)
|
||||
message(STATUS "Windows Platform SDK 8.0 was not found")
|
||||
# search Windows (Phone) Platform SDK
|
||||
message(STATUS "Checking for Windows (Phone) Platform SDK 8.0/8.1")
|
||||
unset(WINDOWS_SDK_PATH CACHE)
|
||||
GET_FILENAME_COMPONENT(WINDOWS_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhoneApp\\v8.1;InstallationFolder]" ABSOLUTE CACHE)
|
||||
if((NOT ENABLE_WINPHONESDK81) OR (NOT (MSVC_VERSION EQUAL 1800)) OR (WINDOWS_SDK_PATH STREQUAL ""))
|
||||
unset(WINDOWS_SDK_PATH CACHE)
|
||||
GET_FILENAME_COMPONENT(WINDOWS_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.0;InstallationFolder]" ABSOLUTE CACHE)
|
||||
if((NOT ENABLE_WINPHONESDK80) OR (MSVC_VERSION LESS 1700) OR (WINDOWS_SDK_PATH STREQUAL ""))
|
||||
unset(WINDOWS_SDK_PATH CACHE)
|
||||
GET_FILENAME_COMPONENT(WINDOWS_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]" ABSOLUTE CACHE)
|
||||
if((NOT ENABLE_WINSDK81) OR (NOT (MSVC_VERSION EQUAL 1800)) OR (WINDOWS_SDK_PATH STREQUAL ""))
|
||||
set(HAVE_MSPDK FALSE)
|
||||
unset(WINDOWS_SDK_PATH CACHE)
|
||||
GET_FILENAME_COMPONENT(WINDOWS_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]" ABSOLUTE CACHE)
|
||||
if(WINDOWS_SDK_PATH STREQUAL "")
|
||||
set(HAVE_MSPDK FALSE)
|
||||
message(STATUS "Windows (Phone) Platform SDK 8.0/8.1 was not found")
|
||||
else()
|
||||
set(HAVE_MSPDK TRUE)
|
||||
endif()
|
||||
else()
|
||||
set(HAVE_MSPDK TRUE)
|
||||
endif()
|
||||
else()
|
||||
set(HAVE_MSPDK TRUE)
|
||||
endif()
|
||||
else()
|
||||
set(HAVE_MSPDK TRUE)
|
||||
endif()
|
||||
|
||||
#search for Visual Studio 11.0 install directory
|
||||
message(STATUS "Checking for Visual Studio 2012")
|
||||
GET_FILENAME_COMPONENT(VISUAL_STUDIO_PATH [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VS;ProductDir] REALPATH CACHE)
|
||||
if(VISUAL_STUDIO_PATH STREQUAL "")
|
||||
set(HAVE_MSVC2012 FALSE)
|
||||
message(STATUS "Visual Studio 2012 was not found")
|
||||
#search for Visual Studio 11.0/12.0 install directory
|
||||
message(STATUS "Checking for Visual Studio 2012/2013")
|
||||
unset(VISUAL_STUDIO_PATH CACHE)
|
||||
GET_FILENAME_COMPONENT(VISUAL_STUDIO_PATH [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0\\Setup\\VS;ProductDir] REALPATH CACHE)
|
||||
if((NOT ENABLE_LIBVS2013) OR (NOT (MSVC_VERSION EQUAL 1800)) OR (VISUAL_STUDIO_PATH STREQUAL ""))
|
||||
set(HAVE_MSVC2013 FALSE)
|
||||
unset(VISUAL_STUDIO_PATH CACHE)
|
||||
GET_FILENAME_COMPONENT(VISUAL_STUDIO_PATH [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VS;ProductDir] REALPATH CACHE)
|
||||
if(VISUAL_STUDIO_PATH STREQUAL "")
|
||||
set(HAVE_MSVC2012 FALSE)
|
||||
message(STATUS "Visual Studio 2012/2013 not found")
|
||||
else()
|
||||
set(HAVE_MSVC2012 TRUE)
|
||||
endif()
|
||||
else()
|
||||
set(HAVE_MSVC2012 TRUE)
|
||||
set(HAVE_MSVC2013 TRUE)
|
||||
endif()
|
||||
|
||||
try_compile(HAVE_WINRT_SDK
|
||||
"${OpenCV_BINARY_DIR}"
|
||||
"${OpenCV_SOURCE_DIR}/cmake/checks/winrttest.cpp")
|
||||
|
||||
if(ENABLE_WINRT_MODE AND HAVE_WINRT_SDK AND HAVE_MSVC2012 AND HAVE_MSPDK)
|
||||
if(ENABLE_WINRT_MODE AND HAVE_WINRT_SDK AND (HAVE_MSVC2012 OR HAVE_MSVC2013) AND HAVE_MSPDK)
|
||||
set(HAVE_WINRT TRUE)
|
||||
set(HAVE_WINRT_CX TRUE)
|
||||
elseif(ENABLE_WINRT_MODE_NATIVE AND HAVE_WINRT_SDK AND HAVE_MSVC2012 AND HAVE_MSPDK)
|
||||
elseif(ENABLE_WINRT_MODE_NATIVE AND HAVE_WINRT_SDK AND (HAVE_MSVC2012 OR HAVE_MSVC2013) AND HAVE_MSPDK)
|
||||
set(HAVE_WINRT TRUE)
|
||||
set(HAVE_WINRT_CX FALSE)
|
||||
endif()
|
||||
|
||||
@@ -140,7 +140,11 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
# SSE3 and further should be disabled under MingW because it generates compiler errors
|
||||
if(NOT MINGW)
|
||||
if(ENABLE_AVX)
|
||||
add_extra_compiler_option(-mavx)
|
||||
ocv_check_flag_support(CXX "-mavx" _varname)
|
||||
endif()
|
||||
|
||||
if(ENABLE_AVX2)
|
||||
ocv_check_flag_support(CXX "-mavx2" _varname)
|
||||
endif()
|
||||
|
||||
# GCC depresses SSEx instructions when -mavx is used. Instead, it generates new AVX instructions or AVX equivalence for all SSEx instructions when needed.
|
||||
@@ -216,10 +220,6 @@ if(MSVC)
|
||||
set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} /Zi")
|
||||
endif()
|
||||
|
||||
if(ENABLE_AVX AND NOT MSVC_VERSION LESS 1600)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:AVX")
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSE4_1 AND CV_ICC AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE4.1")
|
||||
endif()
|
||||
@@ -238,7 +238,7 @@ if(MSVC)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSE OR ENABLE_SSE2 OR ENABLE_SSE3 OR ENABLE_SSE4_1 OR ENABLE_AVX)
|
||||
if(ENABLE_SSE OR ENABLE_SSE2 OR ENABLE_SSE3 OR ENABLE_SSE4_1 OR ENABLE_AVX OR ENABLE_AVX2)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /Oi")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -38,7 +38,9 @@ if(PYTHON_EXECUTABLE)
|
||||
|
||||
if(NOT ANDROID AND NOT IOS)
|
||||
ocv_check_environment_variables(PYTHON_LIBRARY PYTHON_INCLUDE_DIR)
|
||||
if(CMAKE_VERSION VERSION_GREATER 2.8.8 AND PYTHON_VERSION_FULL)
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
find_host_package(PythonLibs ${PYTHON_VERSION_MAJOR_MINOR})
|
||||
elseif(CMAKE_VERSION VERSION_GREATER 2.8.8 AND PYTHON_VERSION_FULL)
|
||||
find_host_package(PythonLibs ${PYTHON_VERSION_FULL} EXACT)
|
||||
else()
|
||||
find_host_package(PythonLibs ${PYTHON_VERSION_FULL})
|
||||
|
||||
@@ -12,15 +12,42 @@ endif(WITH_VFW)
|
||||
|
||||
# --- GStreamer ---
|
||||
ocv_clear_vars(HAVE_GSTREAMER)
|
||||
if(WITH_GSTREAMER)
|
||||
CHECK_MODULE(gstreamer-base-0.10 HAVE_GSTREAMER)
|
||||
if(HAVE_GSTREAMER)
|
||||
CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER)
|
||||
# try to find gstreamer 1.x first
|
||||
if(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
|
||||
CHECK_MODULE(gstreamer-base-1.0 HAVE_GSTREAMER_BASE)
|
||||
CHECK_MODULE(gstreamer-video-1.0 HAVE_GSTREAMER_VIDEO)
|
||||
CHECK_MODULE(gstreamer-app-1.0 HAVE_GSTREAMER_APP)
|
||||
CHECK_MODULE(gstreamer-riff-1.0 HAVE_GSTREAMER_RIFF)
|
||||
CHECK_MODULE(gstreamer-pbutils-1.0 HAVE_GSTREAMER_PBUTILS)
|
||||
|
||||
if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS)
|
||||
set(HAVE_GSTREAMER TRUE)
|
||||
set(GSTREAMER_BASE_VERSION ${ALIASOF_gstreamer-base-1.0_VERSION})
|
||||
set(GSTREAMER_VIDEO_VERSION ${ALIASOF_gstreamer-video-1.0_VERSION})
|
||||
set(GSTREAMER_APP_VERSION ${ALIASOF_gstreamer-app-1.0_VERSION})
|
||||
set(GSTREAMER_RIFF_VERSION ${ALIASOF_gstreamer-riff-1.0_VERSION})
|
||||
set(GSTREAMER_PBUTILS_VERSION ${ALIASOF_gstreamer-pbutils-1.0_VERSION})
|
||||
endif()
|
||||
if(HAVE_GSTREAMER)
|
||||
CHECK_MODULE(gstreamer-video-0.10 HAVE_GSTREAMER)
|
||||
|
||||
endif(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
|
||||
|
||||
# if gstreamer 1.x was not found, or we specified we wanted 0.10, try to find it
|
||||
if(WITH_GSTREAMER_0_10 OR NOT HAVE_GSTREAMER)
|
||||
CHECK_MODULE(gstreamer-base-0.10 HAVE_GSTREAMER_BASE)
|
||||
CHECK_MODULE(gstreamer-video-0.10 HAVE_GSTREAMER_VIDEO)
|
||||
CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER_APP)
|
||||
CHECK_MODULE(gstreamer-riff-0.10 HAVE_GSTREAMER_RIFF)
|
||||
CHECK_MODULE(gstreamer-pbutils-0.10 HAVE_GSTREAMER_PBUTILS)
|
||||
|
||||
if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS)
|
||||
set(HAVE_GSTREAMER TRUE)
|
||||
set(GSTREAMER_BASE_VERSION ${ALIASOF_gstreamer-base-0.10_VERSION})
|
||||
set(GSTREAMER_VIDEO_VERSION ${ALIASOF_gstreamer-video-0.10_VERSION})
|
||||
set(GSTREAMER_APP_VERSION ${ALIASOF_gstreamer-app-0.10_VERSION})
|
||||
set(GSTREAMER_RIFF_VERSION ${ALIASOF_gstreamer-riff-0.10_VERSION})
|
||||
set(GSTREAMER_PBUTILS_VERSION ${ALIASOF_gstreamer-pbutils-0.10_VERSION})
|
||||
endif()
|
||||
endif(WITH_GSTREAMER)
|
||||
endif(WITH_GSTREAMER_0_10 OR NOT HAVE_GSTREAMER)
|
||||
|
||||
# --- unicap ---
|
||||
ocv_clear_vars(HAVE_UNICAP)
|
||||
@@ -126,7 +153,13 @@ endif(WITH_XINE)
|
||||
ocv_clear_vars(HAVE_LIBV4L HAVE_CAMV4L HAVE_CAMV4L2 HAVE_VIDEOIO)
|
||||
if(WITH_V4L)
|
||||
if(WITH_LIBV4L)
|
||||
CHECK_MODULE(libv4l1 HAVE_LIBV4L)
|
||||
CHECK_MODULE(libv4l1 HAVE_LIBV4L1)
|
||||
CHECK_MODULE(libv4l2 HAVE_LIBV4L2)
|
||||
if(HAVE_LIBV4L1 AND HAVE_LIBV4L2)
|
||||
set(HAVE_LIBV4L YES)
|
||||
else()
|
||||
set(HAVE_LIBV4L NO)
|
||||
endif()
|
||||
endif()
|
||||
CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L)
|
||||
CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2)
|
||||
@@ -222,6 +255,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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -526,6 +526,28 @@ macro(ocv_glob_module_sources)
|
||||
list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp")
|
||||
endif()
|
||||
|
||||
if(ENABLE_AVX)
|
||||
file(GLOB avx_srcs "src/avx/*.cpp")
|
||||
foreach(src ${avx_srcs})
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS -mavx)
|
||||
elseif(MSVC AND NOT MSVC_VERSION LESS 1600)
|
||||
set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS /arch:AVX)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(ENABLE_AVX2)
|
||||
file(GLOB avx2_srcs "src/avx2/*.cpp")
|
||||
foreach(src ${avx2_srcs})
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS -mavx2)
|
||||
elseif(MSVC AND NOT MSVC_VERSION LESS 1800)
|
||||
set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS /arch:AVX2)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
source_group("Include" FILES ${lib_hdrs})
|
||||
source_group("Include\\detail" FILES ${lib_hdrs_detail})
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
# Use patched version of CPACK to build accurate set of Debian packages
|
||||
# https://github.com/asmorkalov/CMake/tree/deb_generator_improvement
|
||||
|
||||
if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
set(CPACK_set_DESTDIR "on")
|
||||
|
||||
@@ -18,6 +21,8 @@ OpenCV makes it easy for businesses to utilize and modify the code.")
|
||||
set(CPACK_PACKAGE_VERSION "${OPENCV_VCSVERSION}")
|
||||
endif(NOT OPENCV_CUSTOM_PACKAGE_INFO)
|
||||
|
||||
set(CPACK_STRIP_FILES 1)
|
||||
|
||||
#arch
|
||||
if(X86)
|
||||
set(CPACK_DEBIAN_ARCHITECTURE "i386")
|
||||
@@ -64,36 +69,61 @@ set(CPACK_COMPONENT_dev_DEPENDS libs)
|
||||
set(CPACK_COMPONENT_docs_DEPENDS libs)
|
||||
set(CPACK_COMPONENT_java_DEPENDS libs)
|
||||
set(CPACK_COMPONENT_python_DEPENDS libs)
|
||||
set(CPACK_DEB_python_PACKAGE_DEPENDS "python${PYTHON_VERSION_MAJOR_MINOR}")
|
||||
set(CPACK_COMPONENT_tests_DEPENDS libs)
|
||||
if (HAVE_opencv_python)
|
||||
set(CPACK_DEB_tests_PACKAGE_DEPENDS "python${PYTHON_VERSION_MAJOR_MINOR}, python-py | python-pytest")
|
||||
endif()
|
||||
|
||||
if(HAVE_CUDA)
|
||||
string(REPLACE "." "-" cuda_version_suffix ${CUDA_VERSION})
|
||||
set(CPACK_DEB_libs_PACKAGE_DEPENDS "cuda-core-libs-${cuda_version_suffix}, cuda-extra-libs-${cuda_version_suffix}")
|
||||
if(CUDA_VERSION VERSION_LESS "6.5")
|
||||
set(CPACK_DEB_libs_PACKAGE_DEPENDS "cuda-core-libs-${cuda_version_suffix}, cuda-extra-libs-${cuda_version_suffix}")
|
||||
set(CPACK_DEB_dev_PACKAGE_DEPENDS "cuda-headers-${cuda_version_suffix}")
|
||||
else()
|
||||
set(CPACK_DEB_libs_PACKAGE_DEPENDS "cuda-cudart-${cuda_version_suffix}, cuda-npp-${cuda_version_suffix}")
|
||||
set(CPACK_DEB_dev_PACKAGE_DEPENDS "cuda-cudart-dev-${cuda_version_suffix}, cuda-npp-dev-${cuda_version_suffix}")
|
||||
if(HAVE_CUFFT)
|
||||
set(CPACK_DEB_libs_PACKAGE_DEPENDS "${CPACK_DEB_libs_PACKAGE_DEPENDS}, cuda-cufft-${cuda_version_suffix}")
|
||||
set(CPACK_DEB_dev_PACKAGE_DEPENDS "${CPACK_DEB_dev_PACKAGE_DEPENDS}, cuda-cufft-dev-${cuda_version_suffix}")
|
||||
endif()
|
||||
if(HAVE_HAVE_CUBLAS)
|
||||
set(CPACK_DEB_libs_PACKAGE_DEPENDS "${CPACK_DEB_libs_PACKAGE_DEPENDS}, cuda-cublas-${cuda_version_suffix}")
|
||||
set(CPACK_DEB_dev_PACKAGE_DEPENDS "${CPACK_DEB_dev_PACKAGE_DEPENDS}, cuda-cublas-dev-${cuda_version_suffix}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CPACK_COMPONENT_dev_DEPENDS libs)
|
||||
set(CPACK_DEB_dev_PACKAGE_DEPENDS "cuda-headers-${cuda_version_suffix}")
|
||||
endif()
|
||||
|
||||
if(NOT OPENCV_CUSTOM_PACKAGE_INFO)
|
||||
set(CPACK_COMPONENT_libs_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}")
|
||||
set(CPACK_COMPONENT_libs_DESCRIPTION "Open Computer Vision Library")
|
||||
set(CPACK_COMPONENT_libs_SECTION "libs")
|
||||
|
||||
set(CPACK_COMPONENT_python_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-python")
|
||||
set(CPACK_COMPONENT_python_DESCRIPTION "Python bindings for Open Source Computer Vision Library")
|
||||
set(CPACK_COMPONENT_python_SECTION "python")
|
||||
|
||||
set(CPACK_COMPONENT_java_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-java")
|
||||
set(CPACK_COMPONENT_java_DESCRIPTION "Java bindings for Open Source Computer Vision Library")
|
||||
set(CPACK_COMPONENT_java_SECTION "java")
|
||||
|
||||
set(CPACK_COMPONENT_dev_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-dev")
|
||||
set(CPACK_COMPONENT_dev_DESCRIPTION "Development files for Open Source Computer Vision Library")
|
||||
set(CPACK_COMPONENT_dev_SECTION "libdevel")
|
||||
|
||||
set(CPACK_COMPONENT_docs_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-docs")
|
||||
set(CPACK_COMPONENT_docs_DESCRIPTION "Documentation for Open Source Computer Vision Library")
|
||||
set(CPACK_COMPONENT_docs_SECTION "doc")
|
||||
|
||||
set(CPACK_COMPONENT_samples_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-samples")
|
||||
set(CPACK_COMPONENT_samples_DESCRIPTION "Samples for Open Source Computer Vision Library")
|
||||
set(CPACK_COMPONENT_samples_SECTION "devel")
|
||||
|
||||
set(CPACK_COMPONENT_tests_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-tests")
|
||||
set(CPACK_COMPONENT_tests_DESCRIPTION "Accuracy and performance tests for Open Source Computer Vision Library")
|
||||
set(CPACK_COMPONENT_tests_SECTION "misc")
|
||||
endif(NOT OPENCV_CUSTOM_PACKAGE_INFO)
|
||||
|
||||
if(NOT OPENCV_CUSTOM_PACKAGE_LAYOUT)
|
||||
|
||||
@@ -60,7 +60,11 @@ set(OpenCV_USE_CUFFT @HAVE_CUFFT@)
|
||||
set(OpenCV_USE_NVCUVID @HAVE_NVCUVID@)
|
||||
|
||||
# Android API level from which OpenCV has been compiled is remembered
|
||||
set(OpenCV_ANDROID_NATIVE_API_LEVEL @OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE@)
|
||||
if(ANDROID)
|
||||
set(OpenCV_ANDROID_NATIVE_API_LEVEL @OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE@)
|
||||
else()
|
||||
set(OpenCV_ANDROID_NATIVE_API_LEVEL 0)
|
||||
endif()
|
||||
|
||||
# Some additional settings are required if OpenCV is built as static libs
|
||||
set(OpenCV_SHARED @BUILD_SHARED_LIBS@)
|
||||
@@ -71,8 +75,8 @@ set(OpenCV_USE_MANGLED_PATHS @OpenCV_USE_MANGLED_PATHS_CONFIGCMAKE@)
|
||||
# Extract the directory where *this* file has been installed (determined at cmake run-time)
|
||||
get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACHE)
|
||||
|
||||
if(NOT WIN32 OR OpenCV_ANDROID_NATIVE_API_LEVEL GREATER 0)
|
||||
if(OpenCV_ANDROID_NATIVE_API_LEVEL GREATER 0)
|
||||
if(NOT WIN32 OR ANDROID)
|
||||
if(ANDROID)
|
||||
set(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../../..")
|
||||
else()
|
||||
set(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../..")
|
||||
|
||||
@@ -18,11 +18,14 @@ if [ -z `which adb` ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
accuracy=`find "$OPENCV_TEST_PATH/$TARGET_ARCH" -maxdepth 1 -executable -name "opencv_test_*" -not -name opencv_test_ocl`
|
||||
performance=`find "$OPENCV_TEST_PATH/$TARGET_ARCH" -maxdepth 1 -executable -name "opencv_perf_*" -not -name opencv_perf_ocl`
|
||||
|
||||
adb push $OPENCV_TEST_DATA_PATH /sdcard/opencv_testdata
|
||||
|
||||
adb shell "mkdir -p /data/local/tmp/opencv_test"
|
||||
SUMMARY_STATUS=0
|
||||
for t in "$OPENCV_TEST_PATH/$TARGET_ARCH/"opencv_test_* "$OPENCV_TEST_PATH/$TARGET_ARCH/"opencv_perf_*;
|
||||
for t in $accuracy $performance;
|
||||
do
|
||||
test_name=`basename "$t"`
|
||||
report="$test_name-`date --rfc-3339=date`.xml"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
OPENCV_TEST_PATH=@CMAKE_INSTALL_PREFIX@/@OPENCV_TEST_INSTALL_PATH@
|
||||
OPENCV_PYTHON_TESTS=@OPENCV_PYTHON_TESTS_LIST@
|
||||
export OPENCV_TEST_DATA_PATH=@CMAKE_INSTALL_PREFIX@/share/OpenCV/testdata
|
||||
|
||||
SUMMARY_STATUS=0
|
||||
@@ -14,6 +15,16 @@ do
|
||||
fi
|
||||
done
|
||||
|
||||
for t in $OPENCV_PYTHON_TESTS;
|
||||
do
|
||||
report="`basename "$t"`-`date --rfc-3339=date`.xml"
|
||||
py.test --junitxml $report "$OPENCV_TEST_PATH"/$t
|
||||
TEST_STATUS=$?
|
||||
if [ $TEST_STATUS -ne 0 ]; then
|
||||
SUMMARY_STATUS=$TEST_STATUS
|
||||
fi
|
||||
done
|
||||
|
||||
rm -f /tmp/__opencv_temp.*
|
||||
|
||||
if [ $SUMMARY_STATUS -eq 0 ]; then
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<!--
|
||||
This is 20x34 detector of profile faces using LBP features.
|
||||
It was created by Attila Novak during GSoC 2012.
|
||||
Note that the detector only detects faces rotated to the right,
|
||||
so you may want to run it on the original and on
|
||||
the flipped image to detect different profile faces.
|
||||
-->
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
This is 20x34 detector of profile faces using LBP features.
|
||||
It was created by Attila Novak during GSoC 2012.
|
||||
Note that the detector only detects faces rotated to the right,
|
||||
so you may want to run it on the original and on
|
||||
the flipped image to detect different profile faces.
|
||||
-->
|
||||
<opencv_storage>
|
||||
<cascade>
|
||||
<stageType>BOOST</stageType>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
This is 12x80 detector of the silverware (forks, spoons, knives) using LBP features.
|
||||
It was created by Attila Novak during GSoC 2012.
|
||||
@@ -6,7 +7,6 @@
|
||||
(probably should run detector several times).
|
||||
It also assumes the "top view" when the camera optical axis is orthogonal to the table plane.
|
||||
-->
|
||||
<?xml version="1.0"?>
|
||||
<opencv_storage>
|
||||
<cascade>
|
||||
<stageType>BOOST</stageType>
|
||||
|
||||
@@ -192,7 +192,7 @@ Explanation
|
||||
|
||||
image.convertTo(new_image, -1, alpha, beta);
|
||||
|
||||
where :convert_to:`convertTo <>` would effectively perform *new_image = a*image + beta*. However, we wanted to show you how to access each pixel. In any case, both methods give the same result.
|
||||
where :convert_to:`convertTo <>` would effectively perform *new_image = a*image + beta*. However, we wanted to show you how to access each pixel. In any case, both methods give the same result but convertTo is more optimized and works a lot faster.
|
||||
|
||||
Result
|
||||
=======
|
||||
|
||||
@@ -31,15 +31,15 @@ Here's a sample code of how to achieve all the stuff enumerated at the goal list
|
||||
Explanation
|
||||
===========
|
||||
|
||||
Here we talk only about XML and YAML file inputs. Your output (and its respective input) file may have only one of these extensions and the structure coming from this. They are two kinds of data structures you may serialize: *mappings* (like the STL map) and *element sequence* (like the STL vector>. The difference between these is that in a map every element has a unique name through what you may access it. For sequences you need to go through them to query a specific item.
|
||||
Here we talk only about XML and YAML file inputs. Your output (and its respective input) file may have only one of these extensions and the structure coming from this. They are two kinds of data structures you may serialize: *mappings* (like the STL map) and *element sequence* (like the STL vector). The difference between these is that in a map every element has a unique name through what you may access it. For sequences you need to go through them to query a specific item.
|
||||
|
||||
1. **XML\\YAML File Open and Close.** Before you write any content to such file you need to open it and at the end to close it. The XML\YAML data structure in OpenCV is :xmlymlpers:`FileStorage <filestorage>`. To specify that this structure to which file binds on your hard drive you can use either its constructor or the *open()* function of this:
|
||||
1. **XML/YAML File Open and Close.** Before you write any content to such file you need to open it and at the end to close it. The XML/YAML data structure in OpenCV is :xmlymlpers:`FileStorage <filestorage>`. To specify that this structure to which file binds on your hard drive you can use either its constructor or the *open()* function of this:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
string filename = "I.xml";
|
||||
FileStorage fs(filename, FileStorage::WRITE);
|
||||
\\...
|
||||
//...
|
||||
fs.open(filename, FileStorage::READ);
|
||||
|
||||
Either one of this you use the second argument is a constant specifying the type of operations you'll be able to on them: WRITE, READ or APPEND. The extension specified in the file name also determinates the output format that will be used. The output may be even compressed if you specify an extension such as *.xml.gz*.
|
||||
@@ -64,7 +64,7 @@ Here we talk only about XML and YAML file inputs. Your output (and its respectiv
|
||||
fs["iterationNr"] >> itNr;
|
||||
itNr = (int) fs["iterationNr"];
|
||||
|
||||
#. **Input\\Output of OpenCV Data structures.** Well these behave exactly just as the basic C++ types:
|
||||
#. **Input/Output of OpenCV Data structures.** Well these behave exactly just as the basic C++ types:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@@ -77,7 +77,7 @@ Here we talk only about XML and YAML file inputs. Your output (and its respectiv
|
||||
fs["R"] >> R; // Read cv::Mat
|
||||
fs["T"] >> T;
|
||||
|
||||
#. **Input\\Output of vectors (arrays) and associative maps.** As I mentioned beforehand we can output maps and sequences (array, vector) too. Again we first print the name of the variable and then we have to specify if our output is either a sequence or map.
|
||||
#. **Input/Output of vectors (arrays) and associative maps.** As I mentioned beforehand, we can output maps and sequences (array, vector) too. Again we first print the name of the variable and then we have to specify if our output is either a sequence or map.
|
||||
|
||||
For sequence before the first element print the "[" character and after the last one the "]" character:
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ Although *Mat* works really well as an image container, it is also a general mat
|
||||
|
||||
For instance, *CV_8UC3* means we use unsigned char types that are 8 bit long and each pixel has three of these to form the three channels. This are predefined for up to four channel numbers. The :basicstructures:`Scalar <scalar>` is four element short vector. Specify this and you can initialize all matrix points with a custom value. If you need more you can create the type with the upper macro, setting the channel number in parenthesis as you can see below.
|
||||
|
||||
+ Use C\\C++ arrays and initialize via constructor
|
||||
+ Use C/C++ arrays and initialize via constructor
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp
|
||||
:language: cpp
|
||||
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 8.1 KiB |
@@ -48,10 +48,10 @@ The structure of package contents looks as follows:
|
||||
|
||||
::
|
||||
|
||||
OpenCV-2.4.9-android-sdk
|
||||
OpenCV-2.4.10-android-sdk
|
||||
|_ apk
|
||||
| |_ OpenCV_2.4.9_binary_pack_armv7a.apk
|
||||
| |_ OpenCV_2.4.9_Manager_2.18_XXX.apk
|
||||
| |_ OpenCV_2.4.10_binary_pack_armv7a.apk
|
||||
| |_ OpenCV_2.4.10_Manager_2.19_XXX.apk
|
||||
|
|
||||
|_ doc
|
||||
|_ samples
|
||||
@@ -157,10 +157,10 @@ Get the OpenCV4Android SDK
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
unzip ~/Downloads/OpenCV-2.4.9-android-sdk.zip
|
||||
unzip ~/Downloads/OpenCV-2.4.10-android-sdk.zip
|
||||
|
||||
.. |opencv_android_bin_pack| replace:: :file:`OpenCV-2.4.9-android-sdk.zip`
|
||||
.. _opencv_android_bin_pack_url: http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.9/OpenCV-2.4.9-android-sdk.zip/download
|
||||
.. |opencv_android_bin_pack| replace:: :file:`OpenCV-2.4.10-android-sdk.zip`
|
||||
.. _opencv_android_bin_pack_url: http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.10/OpenCV-2.4.10-android-sdk.zip/download
|
||||
.. |opencv_android_bin_pack_url| replace:: |opencv_android_bin_pack|
|
||||
.. |seven_zip| replace:: 7-Zip
|
||||
.. _seven_zip: http://www.7-zip.org/
|
||||
@@ -295,7 +295,7 @@ Well, running samples from Eclipse is very simple:
|
||||
.. code-block:: sh
|
||||
:linenos:
|
||||
|
||||
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.9_Manager_2.18_armv7a-neon.apk
|
||||
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.10_Manager_2.19_armv7a-neon.apk
|
||||
|
||||
.. note:: ``armeabi``, ``armv7a-neon``, ``arm7a-neon-android8``, ``mips`` and ``x86`` stand for
|
||||
platform targets:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Introduction into Android Development
|
||||
*************************************
|
||||
|
||||
This guide was designed to help you in learning Android development basics and seting up your
|
||||
This guide was designed to help you in learning Android development basics and setting up your
|
||||
working environment quickly. It was written with Windows 7 in mind, though it would work with Linux
|
||||
(Ubuntu), Mac OS X and any other OS supported by Android SDK.
|
||||
|
||||
|
||||
@@ -55,14 +55,14 @@ Manager to access OpenCV libraries externally installed in the target system.
|
||||
:guilabel:`File -> Import -> Existing project in your workspace`.
|
||||
|
||||
Press :guilabel:`Browse` button and locate OpenCV4Android SDK
|
||||
(:file:`OpenCV-2.4.9-android-sdk/sdk`).
|
||||
(:file:`OpenCV-2.4.10-android-sdk/sdk`).
|
||||
|
||||
.. image:: images/eclipse_opencv_dependency0.png
|
||||
:alt: Add dependency from OpenCV library
|
||||
:align: center
|
||||
|
||||
#. In application project add a reference to the OpenCV Java SDK in
|
||||
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.9``.
|
||||
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.10``.
|
||||
|
||||
.. image:: images/eclipse_opencv_dependency1.png
|
||||
:alt: Add dependency from OpenCV library
|
||||
@@ -128,27 +128,27 @@ described above.
|
||||
#. Add the OpenCV library project to your workspace the same way as for the async initialization
|
||||
above. Use menu :guilabel:`File -> Import -> Existing project in your workspace`,
|
||||
press :guilabel:`Browse` button and select OpenCV SDK path
|
||||
(:file:`OpenCV-2.4.9-android-sdk/sdk`).
|
||||
(:file:`OpenCV-2.4.10-android-sdk/sdk`).
|
||||
|
||||
.. image:: images/eclipse_opencv_dependency0.png
|
||||
:alt: Add dependency from OpenCV library
|
||||
:align: center
|
||||
|
||||
#. In the application project add a reference to the OpenCV4Android SDK in
|
||||
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.9``;
|
||||
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.10``;
|
||||
|
||||
.. image:: images/eclipse_opencv_dependency1.png
|
||||
:alt: Add dependency from OpenCV library
|
||||
:align: center
|
||||
|
||||
#. If your application project **doesn't have a JNI part**, just copy the corresponding OpenCV
|
||||
native libs from :file:`<OpenCV-2.4.9-android-sdk>/sdk/native/libs/<target_arch>` to your
|
||||
native libs from :file:`<OpenCV-2.4.10-android-sdk>/sdk/native/libs/<target_arch>` to your
|
||||
project directory to folder :file:`libs/<target_arch>`.
|
||||
|
||||
In case of the application project **with a JNI part**, instead of manual libraries copying you
|
||||
need to modify your ``Android.mk`` file:
|
||||
add the following two code lines after the ``"include $(CLEAR_VARS)"`` and before
|
||||
``"include path_to_OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk"``
|
||||
``"include path_to_OpenCV-2.4.10-android-sdk/sdk/native/jni/OpenCV.mk"``
|
||||
|
||||
.. code-block:: make
|
||||
:linenos:
|
||||
@@ -221,7 +221,7 @@ taken:
|
||||
|
||||
.. code-block:: make
|
||||
|
||||
include C:\Work\OpenCV4Android\OpenCV-2.4.9-android-sdk\sdk\native\jni\OpenCV.mk
|
||||
include C:\Work\OpenCV4Android\OpenCV-2.4.10-android-sdk\sdk\native\jni\OpenCV.mk
|
||||
|
||||
Should be inserted into the :file:`jni/Android.mk` file **after** this line:
|
||||
|
||||
|
||||
@@ -83,8 +83,8 @@ After checking that the image data was loaded correctly, we want to display our
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
+ *CV_WINDOW_AUTOSIZE* is the only supported one if you do not use the Qt backend. In this case the window size will take up the size of the image it shows. No resize permitted!
|
||||
+ *CV_WINDOW_NORMAL* on Qt you may use this to allow window resize. The image will resize itself according to the current window size. By using the | operator you also need to specify if you would like the image to keep its aspect ratio (*CV_WINDOW_KEEPRATIO*) or not (*CV_WINDOW_FREERATIO*).
|
||||
+ *WINDOW_AUTOSIZE* is the only supported one if you do not use the Qt backend. In this case the window size will take up the size of the image it shows. No resize permitted!
|
||||
+ *WINDOW_NORMAL* on Qt you may use this to allow window resize. The image will resize itself according to the current window size. By using the | operator you also need to specify if you would like the image to keep its aspect ratio (*WINDOW_KEEPRATIO*) or not (*WINDOW_FREERATIO*).
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/introduction/display_image/display_image.cpp
|
||||
:language: cpp
|
||||
|
||||
@@ -46,7 +46,7 @@ Let's use a simple program such as DisplayImage.cpp shown below.
|
||||
printf("No image data \n");
|
||||
return -1;
|
||||
}
|
||||
namedWindow("Display Image", CV_WINDOW_AUTOSIZE );
|
||||
namedWindow("Display Image", WINDOW_AUTOSIZE );
|
||||
imshow("Display Image", image);
|
||||
|
||||
waitKey(0);
|
||||
|
||||
@@ -7,22 +7,24 @@ These steps have been tested for Ubuntu 10.04 but should work with other distros
|
||||
Required Packages
|
||||
=================
|
||||
|
||||
* GCC 4.4.x or later. This can be installed with:
|
||||
* GCC 4.4.x or later
|
||||
* CMake 2.6 or higher
|
||||
* Git
|
||||
* GTK+2.x or higher, including headers (libgtk2.0-dev)
|
||||
* pkg-config
|
||||
* Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy)
|
||||
* ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev
|
||||
* [optional] libtbb2 libtbb-dev
|
||||
* [optional] libdc1394 2.x
|
||||
* [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev, libdc1394-22-dev
|
||||
|
||||
The packages can be installed using a terminal and the following commands or by using Synaptic Manager:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo apt-get install build-essential
|
||||
|
||||
* CMake 2.6 or higher;
|
||||
* Git;
|
||||
* GTK+2.x or higher, including headers (libgtk2.0-dev);
|
||||
* pkg-config;
|
||||
* Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy);
|
||||
* ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev;
|
||||
* [optional] libdc1394 2.x;
|
||||
* [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev.
|
||||
|
||||
All the libraries above can be installed via Terminal or by using Synaptic Manager.
|
||||
[compiler] sudo apt-get install build-essential
|
||||
[required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
|
||||
[optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
|
||||
|
||||
Getting OpenCV Source Code
|
||||
==========================
|
||||
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 8.1 KiB |
@@ -55,7 +55,7 @@ Building the OpenCV library from scratch requires a couple of tools installed be
|
||||
.. |TortoiseGit| replace:: TortoiseGit
|
||||
.. _TortoiseGit: http://code.google.com/p/tortoisegit/wiki/Download
|
||||
.. |Python_Libraries| replace:: Python libraries
|
||||
.. _Python_Libraries: http://www.python.org/getit/
|
||||
.. _Python_Libraries: http://www.python.org/downloads/
|
||||
.. |Numpy| replace:: Numpy
|
||||
.. _Numpy: http://numpy.scipy.org/
|
||||
.. |IntelTBB| replace:: Intel |copy| Threading Building Blocks (*TBB*)
|
||||
|
||||
@@ -90,17 +90,25 @@ A full list, for the latest version would contain:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
opencv_core231d.lib
|
||||
opencv_imgproc231d.lib
|
||||
opencv_highgui231d.lib
|
||||
opencv_ml231d.lib
|
||||
opencv_video231d.lib
|
||||
opencv_features2d231d.lib
|
||||
opencv_calib3d231d.lib
|
||||
opencv_objdetect231d.lib
|
||||
opencv_contrib231d.lib
|
||||
opencv_legacy231d.lib
|
||||
opencv_flann231d.lib
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@@ -78,6 +78,8 @@ Make sure your active solution configuration (:menuselection:`Build --> Configur
|
||||
|
||||
Build your solution (:menuselection:`Build --> Build Solution`, or press *F7*).
|
||||
|
||||
Before continuing, do not forget to add the command line argument of your input image to your project (:menuselection:`Right click on project --> Properties --> Configuration Properties --> Debugging` and then set the field ``Command Arguments`` with the location of the image).
|
||||
|
||||
Now set a breakpoint on the source line that says
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 160 KiB After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 183 KiB After Width: | Height: | Size: 144 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 17 KiB |
@@ -105,8 +105,8 @@ Explanation
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
Mat trainingDataMat(3, 2, CV_32FC1, trainingData);
|
||||
Mat labelsMat (3, 1, CV_32FC1, labels);
|
||||
Mat trainingDataMat(4, 2, CV_32FC1, trainingData);
|
||||
Mat labelsMat (4, 1, CV_32FC1, labels);
|
||||
|
||||
2. **Set up SVM's parameters**
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -1,6 +1,6 @@
|
||||
*******
|
||||
HighGUI
|
||||
*******
|
||||
*****************************************
|
||||
Senz3D and Intel Perceptual Computing SDK
|
||||
*****************************************
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
*******
|
||||
HighGUI
|
||||
*******
|
||||
*****************
|
||||
Kinect and OpenNI
|
||||
*****************
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
@@ -6,7 +6,7 @@ Cascade Classifier Training
|
||||
|
||||
Introduction
|
||||
============
|
||||
The work with a cascade classifier inlcudes two major stages: training and detection.
|
||||
The work with a cascade classifier includes two major stages: training and detection.
|
||||
Detection stage is described in a documentation of ``objdetect`` module of general OpenCV documentation. Documentation gives some basic information about cascade classifier.
|
||||
Current guide is describing how to train a cascade classifier: preparation of a training data and running the training application.
|
||||
|
||||
@@ -14,26 +14,30 @@ Important notes
|
||||
---------------
|
||||
There are two applications in OpenCV to train cascade classifier: ``opencv_haartraining`` and ``opencv_traincascade``. ``opencv_traincascade`` is a newer version, written in C++ in accordance to OpenCV 2.x API. But the main difference between this two applications is that ``opencv_traincascade`` supports both Haar [Viola2001]_ and LBP [Liao2007]_ (Local Binary Patterns) features. LBP features are integer in contrast to Haar features, so both training and detection with LBP are several times faster then with Haar features. Regarding the LBP and Haar detection quality, it depends on training: the quality of training dataset first of all and training parameters too. It's possible to train a LBP-based classifier that will provide almost the same quality as Haar-based one.
|
||||
|
||||
``opencv_traincascade`` and ``opencv_haartraining`` store the trained classifier in different file formats. Note, the newer cascade detection interface (see ``CascadeClassifier`` class in ``objdetect`` module) support both formats. ``opencv_traincascade`` can save (export) a trained cascade in the older format. But ``opencv_traincascade`` and ``opencv_haartraining`` can not load (import) a classifier in another format for the futher training after interruption.
|
||||
``opencv_traincascade`` and ``opencv_haartraining`` store the trained classifier in different file formats. Note, the newer cascade detection interface (see ``CascadeClassifier`` class in ``objdetect`` module) support both formats. ``opencv_traincascade`` can save (export) a trained cascade in the older format. But ``opencv_traincascade`` and ``opencv_haartraining`` can not load (import) a classifier in another format for the further training after interruption.
|
||||
|
||||
Note that ``opencv_traincascade`` application can use TBB for multi-threading. To use it in multicore mode OpenCV must be built with TBB.
|
||||
|
||||
Also there are some auxilary utilities related to the training.
|
||||
Also there are some auxiliary utilities related to the training.
|
||||
|
||||
* ``opencv_createsamples`` is used to prepare a training dataset of positive and test samples. ``opencv_createsamples`` produces dataset of positive samples in a format that is supported by both ``opencv_haartraining`` and ``opencv_traincascade`` applications. The output is a file with \*.vec extension, it is a binary format which contains images.
|
||||
|
||||
* ``opencv_performance`` may be used to evaluate the quality of classifiers, but for trained by ``opencv_haartraining`` only. It takes a collection of marked up images, runs the classifier and reports the performance, i.e. number of found objects, number of missed objects, number of false alarms and other information.
|
||||
|
||||
Since ``opencv_haartraining`` is an obsolete application, only ``opencv_traincascade`` will be described futher. ``opencv_createsamples`` utility is needed to prepare a training data for ``opencv_traincascade``, so it will be described too.
|
||||
Since ``opencv_haartraining`` is an obsolete application, only ``opencv_traincascade`` will be described further. ``opencv_createsamples`` utility is needed to prepare a training data for ``opencv_traincascade``, so it will be described too.
|
||||
|
||||
|
||||
``opencv_createsamples`` utility
|
||||
================================
|
||||
An ``opencv_createsamples`` utility provides functionality for dataset generating, writing and viewing. The term *dataset* is used here for both training set and test set.
|
||||
|
||||
Training data preparation
|
||||
=========================
|
||||
For training we need a set of samples. There are two types of samples: negative and positive. Negative samples correspond to non-object images. Positive samples correspond to images with detected objects. Set of negative samples must be prepared manually, whereas set of positive samples is created using ``opencv_createsamples`` utility.
|
||||
|
||||
Negative Samples
|
||||
----------------
|
||||
Negative samples are taken from arbitrary images. These images must not contain detected objects. Negative samples are enumerated in a special file. It is a text file in which each line contains an image filename (relative to the directory of the description file) of negative sample image. This file must be created manually. Note that negative samples and sample images are also called background samples or background samples images, and are used interchangeably in this document. Described images may be of different sizes. But each image should be (but not nessesarily) larger then a training window size, because these images are used to subsample negative image to the training size.
|
||||
Negative samples are taken from arbitrary images. These images must not contain detected objects. Negative samples are enumerated in a special file. It is a text file in which each line contains an image filename (relative to the directory of the description file) of negative sample image. This file must be created manually. Note that negative samples and sample images are also called background samples or background samples images, and are used interchangeably in this document. Described images may be of different sizes. But each image should be (but not necessarily) larger then a training window size, because these images are used to subsample negative image to the training size.
|
||||
|
||||
An example of description file:
|
||||
|
||||
@@ -57,7 +61,7 @@ Positive Samples
|
||||
----------------
|
||||
Positive samples are created by ``opencv_createsamples`` utility. They may be created from a single image with object or from a collection of previously marked up images.
|
||||
|
||||
Please note that you need a large dataset of positive samples before you give it to the mentioned utility, because it only applies perspective transformation. For example you may need only one positive sample for absolutely rigid object like an OpenCV logo, but you definetely need hundreds and even thousands of positive samples for faces. In the case of faces you should consider all the race and age groups, emotions and perhaps beard styles.
|
||||
Please note that you need a large dataset of positive samples before you give it to the mentioned utility, because it only applies perspective transformation. For example you may need only one positive sample for absolutely rigid object like an OpenCV logo, but you definitely need hundreds and even thousands of positive samples for faces. In the case of faces you should consider all the race and age groups, emotions and perhaps beard styles.
|
||||
|
||||
So, a single object image may contain a company logo. Then a large set of positive samples is created from the given object image by random rotating, changing the logo intensity as well as placing the logo on arbitrary background. The amount and range of randomness can be controlled by command line arguments of ``opencv_createsamples`` utility.
|
||||
|
||||
@@ -117,9 +121,96 @@ Command line arguments:
|
||||
|
||||
Height (in pixels) of the output samples.
|
||||
|
||||
For following procedure is used to create a sample object instance:
|
||||
* ``-pngoutput``
|
||||
|
||||
With this option switched on ``opencv_createsamples`` tool generates a collection of PNG samples and a number of associated annotation files, instead of a single ``vec`` file.
|
||||
|
||||
The ``opencv_createsamples`` utility may work in a number of modes, namely:
|
||||
|
||||
* Creating training set from a single image and a collection of backgrounds:
|
||||
* with a single ``vec`` file as an output;
|
||||
* with a collection of JPG images and a file with annotations list as an output;
|
||||
* with a collection of PNG images and associated files with annotations as an output;
|
||||
* Converting the marked-up collection of samples into a ``vec`` format;
|
||||
* Showing the content of the ``vec`` file.
|
||||
|
||||
Creating training set from a single image and a collection of backgrounds with a single ``vec`` file as an output
|
||||
-----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
The following procedure is used to create a sample object instance:
|
||||
The source image is rotated randomly around all three axes. The chosen angle is limited my ``-max?angle``. Then pixels having the intensity from [``bg_color-bg_color_threshold``; ``bg_color+bg_color_threshold``] range are interpreted as transparent. White noise is added to the intensities of the foreground. If the ``-inv`` key is specified then foreground pixel intensities are inverted. If ``-randinv`` key is specified then algorithm randomly selects whether inversion should be applied to this sample. Finally, the obtained image is placed onto an arbitrary background from the background description file, resized to the desired size specified by ``-w`` and ``-h`` and stored to the vec-file, specified by the ``-vec`` command line option.
|
||||
|
||||
Creating training set as a collection of PNG images
|
||||
---------------------------------------------------
|
||||
|
||||
To obtain such behaviour the ``-img``, ``-bg``, ``-info`` and ``-pngoutput`` keys should be specified. The file name specified with ``-info`` key should include at least one level of directory hierarchy, that directory
|
||||
will be used as the top-level directory for the training set.
|
||||
For example, with the ``opencv_createsamples`` called as following:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
opencv_createsamples -img /home/user/logo.png -bg /home/user/bg.txt -info /home/user/annotations.lst -pngoutput -maxxangle 0.1 -maxyangle 0.1 -maxzangle 0.1
|
||||
|
||||
The output will have the following structure:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
/home/user/
|
||||
annotations/
|
||||
0001_0107_0099_0195_0139.txt
|
||||
0002_0107_0115_0195_0139.txt
|
||||
...
|
||||
neg/
|
||||
<background files here>
|
||||
pos/
|
||||
0001_0107_0099_0195_0139.png
|
||||
0002_0107_0115_0195_0139.png
|
||||
...
|
||||
annotations.lst
|
||||
|
||||
With ``*.txt`` files in ``annotations`` directory containing information about object bounding box on the sample in a next format:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Image filename : "/home/user/pos/0002_0107_0115_0195_0139.png"
|
||||
Bounding box for object 1 "PASperson" (Xmin, Ymin) - (Xmax, Ymax) : (107, 115) - (302, 254)
|
||||
|
||||
And ``annotations.lst`` file containing the list of all annotations file:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
/home/user/annotations/0001_0109_0209_0195_0139.txt
|
||||
/home/user/annotations/0002_0241_0245_0139_0100.txt
|
||||
|
||||
Creating test set as a collection of JPG images
|
||||
-----------------------------------------------
|
||||
|
||||
This variant of ``opencv_createsamples`` usage is very similar to the previous one, but generates the output in a different format;
|
||||
To obtain such behaviour the ``-img``, ``-bg`` and ``-info`` keys should be specified.
|
||||
For example, with the ``opencv_createsamples`` called as following:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
opencv_createsamples -img /home/user/logo.png -bg /home/user/bg.txt -info annotations.lst -maxxangle 0.1 -maxyangle 0.1 -maxzangle 0.1
|
||||
|
||||
Directory structure:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
info.dat
|
||||
img1.jpg
|
||||
img2.jpg
|
||||
|
||||
File info.dat:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
img1.jpg 1 140 100 45 45
|
||||
img2.jpg 2 100 200 50 50 50 30 25 25
|
||||
|
||||
Converting the marked-up collection of samples into a ``vec`` format
|
||||
--------------------------------------------------------------------
|
||||
|
||||
Positive samples also may be obtained from a collection of previously marked up images. This collection is described by a text file similar to background description file. Each line of this file corresponds to an image. The first element of the line is the filename. It is followed by the number of object instances. The following numbers are the coordinates of objects bounding rectangles (x, y, width, height).
|
||||
|
||||
An example of description file:
|
||||
@@ -150,6 +241,9 @@ In order to create positive samples from such collection, ``-info`` argument sho
|
||||
|
||||
The scheme of samples creation in this case is as follows. The object instances are taken from images. Then they are resized to target samples size and stored in output vec-file. No distortion is applied, so the only affecting arguments are ``-w``, ``-h``, ``-show`` and ``-num``.
|
||||
|
||||
Showing the content of the ``vec`` file
|
||||
---------------------------------------
|
||||
|
||||
``opencv_createsamples`` utility may be used for examining samples stored in positive samples file. In order to do this only ``-vec``, ``-w`` and ``-h`` parameters should be specified.
|
||||
|
||||
Note that for training, it does not matter how vec-files with positive samples are generated. But ``opencv_createsamples`` utility is the only one way to collect/create a vector file of positive samples, provided by OpenCV.
|
||||
@@ -158,7 +252,7 @@ Example of vec-file is available here ``opencv/data/vec_files/trainingfaces_24-2
|
||||
|
||||
Cascade Training
|
||||
================
|
||||
The next step is the training of classifier. As mentioned above ``opencv_traincascade`` or ``opencv_haartraining`` may be used to train a cascade classifier, but only the newer ``opencv_traincascade`` will be described futher.
|
||||
The next step is the training of classifier. As mentioned above ``opencv_traincascade`` or ``opencv_haartraining`` may be used to train a cascade classifier, but only the newer ``opencv_traincascade`` will be described further.
|
||||
|
||||
Command line arguments of ``opencv_traincascade`` application grouped by purposes:
|
||||
|
||||
|
||||
@@ -7,6 +7,6 @@ OpenCV User Guide
|
||||
|
||||
ug_mat.rst
|
||||
ug_features2d.rst
|
||||
ug_highgui.rst
|
||||
ug_kinect.rst
|
||||
ug_traincascade.rst
|
||||
ug_intelperc.rst
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#elif defined(ANDROID_r4_3_0) || defined(ANDROID_r4_4_0)
|
||||
# include <gui/IGraphicBufferProducer.h>
|
||||
# include <gui/BufferQueue.h>
|
||||
# include <ui/GraphicBuffer.h>
|
||||
#else
|
||||
# include <surfaceflinger/ISurface.h>
|
||||
#endif
|
||||
@@ -681,6 +682,7 @@ CameraHandler* CameraHandler::initCameraConnect(const CameraCallback& callback,
|
||||
# elif defined(ANDROID_r4_4_0)
|
||||
void* buffer_queue_obj = operator new(sizeof(BufferQueue) + MAGIC_TAIL);
|
||||
handler->queue = new(buffer_queue_obj) BufferQueue();
|
||||
handler->queue->setConsumerUsageBits(GraphicBuffer::USAGE_HW_TEXTURE);
|
||||
void* consumer_listener_obj = operator new(sizeof(ConsumerListenerStub) + MAGIC_TAIL);
|
||||
handler->listener = new(consumer_listener_obj) ConsumerListenerStub();
|
||||
handler->queue->consumerConnect(handler->listener, true);
|
||||
@@ -1085,6 +1087,7 @@ void CameraHandler::applyProperties(CameraHandler** ppcameraHandler)
|
||||
# elif defined(ANDROID_r4_4_0)
|
||||
void* buffer_queue_obj = operator new(sizeof(BufferQueue) + MAGIC_TAIL);
|
||||
handler->queue = new(buffer_queue_obj) BufferQueue();
|
||||
handler->queue->setConsumerUsageBits(GraphicBuffer::USAGE_HW_TEXTURE);
|
||||
handler->queue->consumerConnect(handler->listener, true);
|
||||
bufferStatus = handler->camera->setPreviewTarget(handler->queue);
|
||||
if (bufferStatus != 0)
|
||||
|
||||
@@ -217,9 +217,9 @@ Computes useful camera characteristics from the camera matrix.
|
||||
|
||||
:param imageSize: Input image size in pixels.
|
||||
|
||||
:param apertureWidth: Physical width of the sensor.
|
||||
:param apertureWidth: Physical width in mm of the sensor.
|
||||
|
||||
:param apertureHeight: Physical height of the sensor.
|
||||
:param apertureHeight: Physical height in mm of the sensor.
|
||||
|
||||
:param fovx: Output field of view in degrees along the horizontal sensor axis.
|
||||
|
||||
@@ -227,13 +227,15 @@ Computes useful camera characteristics from the camera matrix.
|
||||
|
||||
:param focalLength: Focal length of the lens in mm.
|
||||
|
||||
:param principalPoint: Principal point in pixels.
|
||||
:param principalPoint: Principal point in mm.
|
||||
|
||||
:param aspectRatio: :math:`f_y/f_x`
|
||||
|
||||
The function computes various useful camera characteristics from the previously estimated camera matrix.
|
||||
|
||||
.. note::
|
||||
|
||||
Do keep in mind that the unity measure 'mm' stands for whatever unit of measure one chooses for the chessboard pitch (it can thus be any value).
|
||||
|
||||
composeRT
|
||||
-------------
|
||||
@@ -744,7 +746,7 @@ is minimized. If the parameter ``method`` is set to the default value 0, the fun
|
||||
uses all the point pairs to compute an initial homography estimate with a simple least-squares scheme.
|
||||
|
||||
However, if not all of the point pairs (
|
||||
:math:`srcPoints_i`,:math:`dstPoints_i` ) fit the rigid perspective transformation (that is, there
|
||||
:math:`srcPoints_i`, :math:`dstPoints_i` ) fit the rigid perspective transformation (that is, there
|
||||
are some outliers), this initial estimate will be poor.
|
||||
In this case, you can use one of the two robust methods. Both methods, ``RANSAC`` and ``LMeDS`` , try many different random subsets
|
||||
of the corresponding point pairs (of four pairs each), estimate
|
||||
@@ -767,7 +769,7 @@ if there are no outliers and the noise is rather small, use the default method (
|
||||
|
||||
The function is used to find initial intrinsic and extrinsic matrices.
|
||||
Homography matrix is determined up to a scale. Thus, it is normalized so that
|
||||
:math:`h_{33}=1` .
|
||||
:math:`h_{33}=1`. Note that whenever an H matrix cannot be estimated, an empty one will be returned.
|
||||
|
||||
.. seealso::
|
||||
|
||||
@@ -1483,10 +1485,372 @@ Reconstructs points by triangulation.
|
||||
|
||||
The function reconstructs 3-dimensional points (in homogeneous coordinates) by using their observations with a stereo camera. Projections matrices can be obtained from :ocv:func:`stereoRectify`.
|
||||
|
||||
.. note::
|
||||
|
||||
Keep in mind that all input data should be of float type in order for this function to work.
|
||||
|
||||
.. seealso::
|
||||
|
||||
:ocv:func:`reprojectImageTo3D`
|
||||
|
||||
fisheye
|
||||
----------
|
||||
|
||||
The methods in this namespace use a so-called fisheye camera model. ::
|
||||
|
||||
namespace fisheye
|
||||
{
|
||||
//! projects 3D points using fisheye model
|
||||
void projectPoints(InputArray objectPoints, OutputArray imagePoints, const Affine3d& affine,
|
||||
InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray());
|
||||
|
||||
//! projects points using fisheye model
|
||||
void projectPoints(InputArray objectPoints, OutputArray imagePoints, InputArray rvec, InputArray tvec,
|
||||
InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray());
|
||||
|
||||
//! distorts 2D points using fisheye model
|
||||
void distortPoints(InputArray undistorted, OutputArray distorted, InputArray K, InputArray D, double alpha = 0);
|
||||
|
||||
//! undistorts 2D points using fisheye model
|
||||
void undistortPoints(InputArray distorted, OutputArray undistorted,
|
||||
InputArray K, InputArray D, InputArray R = noArray(), InputArray P = noArray());
|
||||
|
||||
//! computing undistortion and rectification maps for image transform by cv::remap()
|
||||
//! If D is empty zero distortion is used, if R or P is empty identity matrixes are used
|
||||
void initUndistortRectifyMap(InputArray K, InputArray D, InputArray R, InputArray P,
|
||||
const cv::Size& size, int m1type, OutputArray map1, OutputArray map2);
|
||||
|
||||
//! undistorts image, optionally changes resolution and camera matrix.
|
||||
void undistortImage(InputArray distorted, OutputArray undistorted,
|
||||
InputArray K, InputArray D, InputArray Knew = cv::noArray(), const Size& new_size = Size());
|
||||
|
||||
//! estimates new camera matrix for undistortion or rectification
|
||||
void estimateNewCameraMatrixForUndistortRectify(InputArray K, InputArray D, const Size &image_size, InputArray R,
|
||||
OutputArray P, double balance = 0.0, const Size& new_size = Size(), double fov_scale = 1.0);
|
||||
|
||||
//! performs camera calibaration
|
||||
double calibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, const Size& image_size,
|
||||
InputOutputArray K, InputOutputArray D, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, int flags = 0,
|
||||
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON));
|
||||
|
||||
//! stereo rectification estimation
|
||||
void stereoRectify(InputArray K1, InputArray D1, InputArray K2, InputArray D2, const Size &imageSize, InputArray R, InputArray tvec,
|
||||
OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags, const Size &newImageSize = Size(),
|
||||
double balance = 0.0, double fov_scale = 1.0);
|
||||
|
||||
//! performs stereo calibration
|
||||
double stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2,
|
||||
InputOutputArray K1, InputOutputArray D1, InputOutputArray K2, InputOutputArray D2, Size imageSize,
|
||||
OutputArray R, OutputArray T, int flags = CALIB_FIX_INTRINSIC,
|
||||
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON));
|
||||
};
|
||||
|
||||
|
||||
Definitions:
|
||||
Let P be a point in 3D of coordinates X in the world reference frame (stored in the matrix X)
|
||||
The coordinate vector of P in the camera reference frame is:
|
||||
|
||||
.. class:: center
|
||||
.. math::
|
||||
|
||||
Xc = R X + T
|
||||
|
||||
where R is the rotation matrix corresponding to the rotation vector om: R = rodrigues(om);
|
||||
call x, y and z the 3 coordinates of Xc:
|
||||
|
||||
.. class:: center
|
||||
.. math::
|
||||
x = Xc_1 \\
|
||||
y = Xc_2 \\
|
||||
z = Xc_3
|
||||
|
||||
The pinehole projection coordinates of P is [a; b] where
|
||||
|
||||
.. class:: center
|
||||
.. math::
|
||||
|
||||
a = x / z \ and \ b = y / z \\
|
||||
r^2 = a^2 + b^2 \\
|
||||
\theta = atan(r)
|
||||
|
||||
Fisheye distortion:
|
||||
|
||||
.. class:: center
|
||||
.. math::
|
||||
|
||||
\theta_d = \theta (1 + k_1 \theta^2 + k_2 \theta^4 + k_3 \theta^6 + k_4 \theta^8)
|
||||
|
||||
The distorted point coordinates are [x'; y'] where
|
||||
|
||||
..class:: center
|
||||
.. math::
|
||||
|
||||
x' = (\theta_d / r) x \\
|
||||
y' = (\theta_d / r) y
|
||||
|
||||
Finally, conversion into pixel coordinates: The final pixel coordinates vector [u; v] where:
|
||||
|
||||
.. class:: center
|
||||
.. math::
|
||||
|
||||
u = f_x (x' + \alpha y') + c_x \\
|
||||
v = f_y yy + c_y
|
||||
|
||||
fisheye::projectPoints
|
||||
---------------------------
|
||||
Projects points using fisheye model
|
||||
|
||||
.. ocv:function:: void fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints, const Affine3d& affine, InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray())
|
||||
|
||||
.. ocv:function:: void fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints, InputArray rvec, InputArray tvec, InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray())
|
||||
|
||||
:param objectPoints: Array of object points, 1xN/Nx1 3-channel (or ``vector<Point3f>`` ), where N is the number of points in the view.
|
||||
|
||||
:param rvec: Rotation vector. See :ocv:func:`Rodrigues` for details.
|
||||
|
||||
:param tvec: Translation vector.
|
||||
|
||||
:param K: Camera matrix :math:`K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{_1}`.
|
||||
|
||||
:param D: Input vector of distortion coefficients :math:`(k_1, k_2, k_3, k_4)`.
|
||||
|
||||
:param alpha: The skew coefficient.
|
||||
|
||||
:param imagePoints: Output array of image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, or ``vector<Point2f>``.
|
||||
|
||||
:param jacobian: Optional output 2Nx15 jacobian matrix of derivatives of image points with respect to components of the focal lengths, coordinates of the principal point, distortion coefficients, rotation vector, translation vector, and the skew. In the old interface different components of the jacobian are returned via different output parameters.
|
||||
|
||||
The function computes projections of 3D points to the image plane given intrinsic and extrinsic camera parameters. Optionally, the function computes Jacobians - matrices of partial derivatives of image points coordinates (as functions of all the input parameters) with respect to the particular parameters, intrinsic and/or extrinsic.
|
||||
|
||||
fisheye::distortPoints
|
||||
-------------------------
|
||||
Distorts 2D points using fisheye model.
|
||||
|
||||
.. ocv:function:: void fisheye::distortPoints(InputArray undistorted, OutputArray distorted, InputArray K, InputArray D, double alpha = 0)
|
||||
|
||||
:param undistorted: Array of object points, 1xN/Nx1 2-channel (or ``vector<Point2f>`` ), where N is the number of points in the view.
|
||||
|
||||
:param K: Camera matrix :math:`K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{_1}`.
|
||||
|
||||
:param D: Input vector of distortion coefficients :math:`(k_1, k_2, k_3, k_4)`.
|
||||
|
||||
:param alpha: The skew coefficient.
|
||||
|
||||
:param distorted: Output array of image points, 1xN/Nx1 2-channel, or ``vector<Point2f>`` .
|
||||
|
||||
fisheye::undistortPoints
|
||||
-----------------------------
|
||||
Undistorts 2D points using fisheye model
|
||||
|
||||
.. ocv:function:: void fisheye::undistortPoints(InputArray distorted, OutputArray undistorted, InputArray K, InputArray D, InputArray R = noArray(), InputArray P = noArray())
|
||||
|
||||
:param distorted: Array of object points, 1xN/Nx1 2-channel (or ``vector<Point2f>`` ), where N is the number of points in the view.
|
||||
|
||||
:param K: Camera matrix :math:`K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{_1}`.
|
||||
|
||||
:param D: Input vector of distortion coefficients :math:`(k_1, k_2, k_3, k_4)`.
|
||||
|
||||
:param R: Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel
|
||||
|
||||
:param P: New camera matrix (3x3) or new projection matrix (3x4)
|
||||
|
||||
:param undistorted: Output array of image points, 1xN/Nx1 2-channel, or ``vector<Point2f>`` .
|
||||
|
||||
|
||||
fisheye::initUndistortRectifyMap
|
||||
-------------------------------------
|
||||
Computes undistortion and rectification maps for image transform by cv::remap(). If D is empty zero distortion is used, if R or P is empty identity matrixes are used.
|
||||
|
||||
.. ocv:function:: void fisheye::initUndistortRectifyMap(InputArray K, InputArray D, InputArray R, InputArray P, const cv::Size& size, int m1type, OutputArray map1, OutputArray map2)
|
||||
|
||||
:param K: Camera matrix :math:`K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{_1}`.
|
||||
|
||||
:param D: Input vector of distortion coefficients :math:`(k_1, k_2, k_3, k_4)`.
|
||||
|
||||
:param R: Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel
|
||||
|
||||
:param P: New camera matrix (3x3) or new projection matrix (3x4)
|
||||
|
||||
:param size: Undistorted image size.
|
||||
|
||||
:param m1type: Type of the first output map that can be CV_32FC1 or CV_16SC2 . See convertMaps() for details.
|
||||
|
||||
:param map1: The first output map.
|
||||
|
||||
:param map2: The second output map.
|
||||
|
||||
fisheye::undistortImage
|
||||
-----------------------
|
||||
Transforms an image to compensate for fisheye lens distortion.
|
||||
|
||||
.. ocv:function:: void fisheye::undistortImage(InputArray distorted, OutputArray undistorted, InputArray K, InputArray D, InputArray Knew = cv::noArray(), const Size& new_size = Size())
|
||||
|
||||
:param distorted: image with fisheye lens distortion.
|
||||
|
||||
:param K: Camera matrix :math:`K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{_1}`.
|
||||
|
||||
:param D: Input vector of distortion coefficients :math:`(k_1, k_2, k_3, k_4)`.
|
||||
|
||||
:param Knew: Camera matrix of the distorted image. By default, it is the identity matrix but you may additionally scale and shift the result by using a different matrix.
|
||||
|
||||
:param undistorted: Output image with compensated fisheye lens distortion.
|
||||
|
||||
The function transforms an image to compensate radial and tangential lens distortion.
|
||||
|
||||
The function is simply a combination of
|
||||
:ocv:func:`fisheye::initUndistortRectifyMap` (with unity ``R`` ) and
|
||||
:ocv:func:`remap` (with bilinear interpolation). See the former function for details of the transformation being performed.
|
||||
|
||||
See below the results of undistortImage.
|
||||
* a\) result of :ocv:func:`undistort` of perspective camera model (all possible coefficients (k_1, k_2, k_3, k_4, k_5, k_6) of distortion were optimized under calibration)
|
||||
* b\) result of :ocv:func:`fisheye::undistortImage` of fisheye camera model (all possible coefficients (k_1, k_2, k_3, k_4) of fisheye distortion were optimized under calibration)
|
||||
* c\) original image was captured with fisheye lens
|
||||
|
||||
Pictures a) and b) almost the same. But if we consider points of image located far from the center of image, we can notice that on image a) these points are distorted.
|
||||
|
||||
.. image:: pics/fisheye_undistorted.jpg
|
||||
|
||||
|
||||
fisheye::estimateNewCameraMatrixForUndistortRectify
|
||||
----------------------------------------------------------
|
||||
Estimates new camera matrix for undistortion or rectification.
|
||||
|
||||
.. ocv:function:: void fisheye::estimateNewCameraMatrixForUndistortRectify(InputArray K, InputArray D, const Size &image_size, InputArray R, OutputArray P, double balance = 0.0, const Size& new_size = Size(), double fov_scale = 1.0)
|
||||
|
||||
:param K: Camera matrix :math:`K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{_1}`.
|
||||
|
||||
:param D: Input vector of distortion coefficients :math:`(k_1, k_2, k_3, k_4)`.
|
||||
|
||||
:param R: Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel
|
||||
|
||||
:param P: New camera matrix (3x3) or new projection matrix (3x4)
|
||||
|
||||
:param balance: Sets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1].
|
||||
|
||||
:param fov_scale: Divisor for new focal length.
|
||||
|
||||
fisheye::stereoRectify
|
||||
------------------------------
|
||||
Stereo rectification for fisheye camera model
|
||||
|
||||
.. ocv:function:: void fisheye::stereoRectify(InputArray K1, InputArray D1, InputArray K2, InputArray D2, const Size &imageSize, InputArray R, InputArray tvec, OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags, const Size &newImageSize = Size(), double balance = 0.0, double fov_scale = 1.0)
|
||||
|
||||
:param K1: First camera matrix.
|
||||
|
||||
:param K2: Second camera matrix.
|
||||
|
||||
:param D1: First camera distortion parameters.
|
||||
|
||||
:param D2: Second camera distortion parameters.
|
||||
|
||||
:param imageSize: Size of the image used for stereo calibration.
|
||||
|
||||
:param rotation: Rotation matrix between the coordinate systems of the first and the second cameras.
|
||||
|
||||
:param tvec: Translation vector between coordinate systems of the cameras.
|
||||
|
||||
:param R1: Output 3x3 rectification transform (rotation matrix) for the first camera.
|
||||
|
||||
:param R2: Output 3x3 rectification transform (rotation matrix) for the second camera.
|
||||
|
||||
:param P1: Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera.
|
||||
|
||||
:param P2: Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera.
|
||||
|
||||
:param Q: Output :math:`4 \times 4` disparity-to-depth mapping matrix (see :ocv:func:`reprojectImageTo3D` ).
|
||||
|
||||
:param flags: Operation flags that may be zero or ``CV_CALIB_ZERO_DISPARITY`` . If the flag is set, the function makes the principal points of each camera have the same pixel coordinates in the rectified views. And if the flag is not set, the function may still shift the images in the horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the useful image area.
|
||||
|
||||
:param alpha: Free scaling parameter. If it is -1 or absent, the function performs the default scaling. Otherwise, the parameter should be between 0 and 1. ``alpha=0`` means that the rectified images are zoomed and shifted so that only valid pixels are visible (no black areas after rectification). ``alpha=1`` means that the rectified image is decimated and shifted so that all the pixels from the original images from the cameras are retained in the rectified images (no source image pixels are lost). Obviously, any intermediate value yields an intermediate result between those two extreme cases.
|
||||
|
||||
:param newImageSize: New image resolution after rectification. The same size should be passed to :ocv:func:`initUndistortRectifyMap` (see the ``stereo_calib.cpp`` sample in OpenCV samples directory). When (0,0) is passed (default), it is set to the original ``imageSize`` . Setting it to larger value can help you preserve details in the original image, especially when there is a big radial distortion.
|
||||
|
||||
:param roi1: Optional output rectangles inside the rectified images where all the pixels are valid. If ``alpha=0`` , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below).
|
||||
|
||||
:param roi2: Optional output rectangles inside the rectified images where all the pixels are valid. If ``alpha=0`` , the ROIs cover the whole images. Otherwise, they are likely to be smaller (see the picture below).
|
||||
|
||||
:param balance: Sets the new focal length in range between the min focal length and the max focal length. Balance is in range of [0, 1].
|
||||
|
||||
:param fov_scale: Divisor for new focal length.
|
||||
|
||||
|
||||
|
||||
fisheye::calibrate
|
||||
----------------------------
|
||||
Performs camera calibaration
|
||||
|
||||
.. ocv:function:: double fisheye::calibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, const Size& image_size, InputOutputArray K, InputOutputArray D, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, int flags = 0, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON))
|
||||
|
||||
:param objectPoints: vector of vectors of calibration pattern points in the calibration pattern coordinate space.
|
||||
|
||||
:param imagePoints: vector of vectors of the projections of calibration pattern points. ``imagePoints.size()`` and ``objectPoints.size()`` and ``imagePoints[i].size()`` must be equal to ``objectPoints[i].size()`` for each ``i``.
|
||||
|
||||
:param image_size: Size of the image used only to initialize the intrinsic camera matrix.
|
||||
|
||||
:param K: Output 3x3 floating-point camera matrix :math:`A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}` . If ``fisheye::CALIB_USE_INTRINSIC_GUESS``/ is specified, some or all of ``fx, fy, cx, cy`` must be initialized before calling the function.
|
||||
|
||||
:param D: Output vector of distortion coefficients :math:`(k_1, k_2, k_3, k_4)`.
|
||||
|
||||
:param rvecs: Output vector of rotation vectors (see :ocv:func:`Rodrigues` ) estimated for each pattern view. That is, each k-th rotation vector together with the corresponding k-th translation vector (see the next output parameter description) brings the calibration pattern from the model coordinate space (in which object points are specified) to the world coordinate space, that is, a real position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
|
||||
|
||||
:param tvecs: Output vector of translation vectors estimated for each pattern view.
|
||||
|
||||
:param flags: Different flags that may be zero or a combination of the following values:
|
||||
|
||||
* **fisheye::CALIB_USE_INTRINSIC_GUESS** ``cameraMatrix`` contains valid initial values of ``fx, fy, cx, cy`` that are optimized further. Otherwise, ``(cx, cy)`` is initially set to the image center ( ``imageSize`` is used), and focal distances are computed in a least-squares fashion.
|
||||
|
||||
* **fisheye::CALIB_RECOMPUTE_EXTRINSIC** Extrinsic will be recomputed after each iteration of intrinsic optimization.
|
||||
|
||||
* **fisheye::CALIB_CHECK_COND** The functions will check validity of condition number.
|
||||
|
||||
* **fisheye::CALIB_FIX_SKEW** Skew coefficient (alpha) is set to zero and stay zero.
|
||||
|
||||
* **fisheye::CALIB_FIX_K1..4** Selected distortion coefficients are set to zeros and stay zero.
|
||||
|
||||
:param criteria: Termination criteria for the iterative optimization algorithm.
|
||||
|
||||
|
||||
fisheye::stereoCalibrate
|
||||
----------------------------
|
||||
Performs stereo calibration
|
||||
|
||||
.. ocv:function:: double fisheye::stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, InputOutputArray K1, InputOutputArray D1, InputOutputArray K2, InputOutputArray D2, Size imageSize, OutputArray R, OutputArray T, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON))
|
||||
|
||||
:param objectPoints: Vector of vectors of the calibration pattern points.
|
||||
|
||||
:param imagePoints1: Vector of vectors of the projections of the calibration pattern points, observed by the first camera.
|
||||
|
||||
:param imagePoints2: Vector of vectors of the projections of the calibration pattern points, observed by the second camera.
|
||||
|
||||
:param K1: Input/output first camera matrix: :math:`\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}` , :math:`j = 0,\, 1` . If any of ``fisheye::CALIB_USE_INTRINSIC_GUESS`` , ``fisheye::CV_CALIB_FIX_INTRINSIC`` are specified, some or all of the matrix components must be initialized.
|
||||
|
||||
:param D1: Input/output vector of distortion coefficients :math:`(k_1, k_2, k_3, k_4)` of 4 elements.
|
||||
|
||||
:param K2: Input/output second camera matrix. The parameter is similar to ``K1`` .
|
||||
|
||||
:param D2: Input/output lens distortion coefficients for the second camera. The parameter is similar to ``D1`` .
|
||||
|
||||
:param imageSize: Size of the image used only to initialize intrinsic camera matrix.
|
||||
|
||||
:param R: Output rotation matrix between the 1st and the 2nd camera coordinate systems.
|
||||
|
||||
:param T: Output translation vector between the coordinate systems of the cameras.
|
||||
|
||||
:param flags: Different flags that may be zero or a combination of the following values:
|
||||
|
||||
* **fisheye::CV_CALIB_FIX_INTRINSIC** Fix ``K1, K2?`` and ``D1, D2?`` so that only ``R, T`` matrices are estimated.
|
||||
|
||||
* **fisheye::CALIB_USE_INTRINSIC_GUESS** ``K1, K2`` contains valid initial values of ``fx, fy, cx, cy`` that are optimized further. Otherwise, ``(cx, cy)`` is initially set to the image center (``imageSize`` is used), and focal distances are computed in a least-squares fashion.
|
||||
|
||||
* **fisheye::CALIB_RECOMPUTE_EXTRINSIC** Extrinsic will be recomputed after each iteration of intrinsic optimization.
|
||||
|
||||
* **fisheye::CALIB_CHECK_COND** The functions will check validity of condition number.
|
||||
|
||||
* **fisheye::CALIB_FIX_SKEW** Skew coefficient (alpha) is set to zero and stay zero.
|
||||
|
||||
* **fisheye::CALIB_FIX_K1..4** Selected distortion coefficients are set to zeros and stay zero.
|
||||
|
||||
:param criteria: Termination criteria for the iterative optimization algorithm.
|
||||
|
||||
.. [BT98] Birchfield, S. and Tomasi, C. A pixel dissimilarity measure that is insensitive to image sampling. IEEE Transactions on Pattern Analysis and Machine Intelligence. 1998.
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 84 KiB |
@@ -45,6 +45,7 @@
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/core/affine.hpp"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -744,8 +745,67 @@ CV_EXPORTS_W int estimateAffine3D(InputArray src, InputArray dst,
|
||||
OutputArray out, OutputArray inliers,
|
||||
double ransacThreshold=3, double confidence=0.99);
|
||||
|
||||
namespace fisheye
|
||||
{
|
||||
enum{
|
||||
CALIB_USE_INTRINSIC_GUESS = 1,
|
||||
CALIB_RECOMPUTE_EXTRINSIC = 2,
|
||||
CALIB_CHECK_COND = 4,
|
||||
CALIB_FIX_SKEW = 8,
|
||||
CALIB_FIX_K1 = 16,
|
||||
CALIB_FIX_K2 = 32,
|
||||
CALIB_FIX_K3 = 64,
|
||||
CALIB_FIX_K4 = 128,
|
||||
CALIB_FIX_INTRINSIC = 256
|
||||
};
|
||||
|
||||
//! projects 3D points using fisheye model
|
||||
CV_EXPORTS void projectPoints(InputArray objectPoints, OutputArray imagePoints, const Affine3d& affine,
|
||||
InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray());
|
||||
|
||||
//! projects points using fisheye model
|
||||
CV_EXPORTS void projectPoints(InputArray objectPoints, OutputArray imagePoints, InputArray rvec, InputArray tvec,
|
||||
InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray());
|
||||
|
||||
//! distorts 2D points using fisheye model
|
||||
CV_EXPORTS void distortPoints(InputArray undistorted, OutputArray distorted, InputArray K, InputArray D, double alpha = 0);
|
||||
|
||||
//! undistorts 2D points using fisheye model
|
||||
CV_EXPORTS void undistortPoints(InputArray distorted, OutputArray undistorted,
|
||||
InputArray K, InputArray D, InputArray R = noArray(), InputArray P = noArray());
|
||||
|
||||
//! computing undistortion and rectification maps for image transform by cv::remap()
|
||||
//! If D is empty zero distortion is used, if R or P is empty identity matrixes are used
|
||||
CV_EXPORTS void initUndistortRectifyMap(InputArray K, InputArray D, InputArray R, InputArray P,
|
||||
const cv::Size& size, int m1type, OutputArray map1, OutputArray map2);
|
||||
|
||||
//! undistorts image, optionally changes resolution and camera matrix. If Knew zero identity matrix is used
|
||||
CV_EXPORTS void undistortImage(InputArray distorted, OutputArray undistorted,
|
||||
InputArray K, InputArray D, InputArray Knew = cv::noArray(), const Size& new_size = Size());
|
||||
|
||||
//! estimates new camera matrix for undistortion or rectification
|
||||
CV_EXPORTS void estimateNewCameraMatrixForUndistortRectify(InputArray K, InputArray D, const Size &image_size, InputArray R,
|
||||
OutputArray P, double balance = 0.0, const Size& new_size = Size(), double fov_scale = 1.0);
|
||||
|
||||
//! performs camera calibaration
|
||||
CV_EXPORTS double calibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, const Size& image_size,
|
||||
InputOutputArray K, InputOutputArray D, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, int flags = 0,
|
||||
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON));
|
||||
|
||||
//! stereo rectification estimation
|
||||
CV_EXPORTS void stereoRectify(InputArray K1, InputArray D1, InputArray K2, InputArray D2, const Size &imageSize, InputArray R, InputArray tvec,
|
||||
OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags, const Size &newImageSize = Size(),
|
||||
double balance = 0.0, double fov_scale = 1.0);
|
||||
|
||||
//! performs stereo calibaration
|
||||
CV_EXPORTS double stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2,
|
||||
InputOutputArray K1, InputOutputArray D1, InputOutputArray K2, InputOutputArray D2, Size imageSize,
|
||||
OutputArray R, OutputArray T, int flags = CALIB_FIX_INTRINSIC,
|
||||
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef FISHEYE_INTERNAL_H
|
||||
#define FISHEYE_INTERNAL_H
|
||||
#include "precomp.hpp"
|
||||
|
||||
namespace cv { namespace internal {
|
||||
|
||||
struct CV_EXPORTS IntrinsicParams
|
||||
{
|
||||
Vec2d f;
|
||||
Vec2d c;
|
||||
Vec4d k;
|
||||
double alpha;
|
||||
std::vector<int> isEstimate;
|
||||
|
||||
IntrinsicParams();
|
||||
IntrinsicParams(Vec2d f, Vec2d c, Vec4d k, double alpha = 0);
|
||||
IntrinsicParams operator+(const Mat& a);
|
||||
IntrinsicParams& operator =(const Mat& a);
|
||||
void Init(const cv::Vec2d& f, const cv::Vec2d& c, const cv::Vec4d& k = Vec4d(0,0,0,0), const double& alpha = 0);
|
||||
};
|
||||
|
||||
void projectPoints(cv::InputArray objectPoints, cv::OutputArray imagePoints,
|
||||
cv::InputArray _rvec,cv::InputArray _tvec,
|
||||
const IntrinsicParams& param, cv::OutputArray jacobian);
|
||||
|
||||
void ComputeExtrinsicRefine(const Mat& imagePoints, const Mat& objectPoints, Mat& rvec,
|
||||
Mat& tvec, Mat& J, const int MaxIter,
|
||||
const IntrinsicParams& param, const double thresh_cond);
|
||||
CV_EXPORTS Mat ComputeHomography(Mat m, Mat M);
|
||||
|
||||
CV_EXPORTS Mat NormalizePixels(const Mat& imagePoints, const IntrinsicParams& param);
|
||||
|
||||
void InitExtrinsics(const Mat& _imagePoints, const Mat& _objectPoints, const IntrinsicParams& param, Mat& omckk, Mat& Tckk);
|
||||
|
||||
void CalibrateExtrinsics(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints,
|
||||
const IntrinsicParams& param, const int check_cond,
|
||||
const double thresh_cond, InputOutputArray omc, InputOutputArray Tc);
|
||||
|
||||
void ComputeJacobians(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints,
|
||||
const IntrinsicParams& param, InputArray omc, InputArray Tc,
|
||||
const int& check_cond, const double& thresh_cond, Mat& JJ2_inv, Mat& ex3);
|
||||
|
||||
CV_EXPORTS void EstimateUncertainties(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints,
|
||||
const IntrinsicParams& params, InputArray omc, InputArray Tc,
|
||||
IntrinsicParams& errors, Vec2d& std_err, double thresh_cond, int check_cond, double& rms);
|
||||
|
||||
void dAB(cv::InputArray A, InputArray B, OutputArray dABdA, OutputArray dABdB);
|
||||
|
||||
void JRodriguesMatlab(const Mat& src, Mat& dst);
|
||||
|
||||
void compose_motion(InputArray _om1, InputArray _T1, InputArray _om2, InputArray _T2,
|
||||
Mat& om3, Mat& T3, Mat& dom3dom1, Mat& dom3dT1, Mat& dom3dom2,
|
||||
Mat& dom3dT2, Mat& dT3dom1, Mat& dT3dT1, Mat& dT3dom2, Mat& dT3dT2);
|
||||
|
||||
double median(const Mat& row);
|
||||
|
||||
Vec3d median3d(InputArray m);
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -137,11 +137,13 @@ namespace cv
|
||||
CameraParameters camera;
|
||||
};
|
||||
|
||||
template <typename OpointType, typename IpointType>
|
||||
static void pnpTask(const vector<char>& pointsMask, const Mat& objectPoints, const Mat& imagePoints,
|
||||
const Parameters& params, vector<int>& inliers, Mat& rvec, Mat& tvec,
|
||||
const Mat& rvecInit, const Mat& tvecInit, Mutex& resultsMutex)
|
||||
{
|
||||
Mat modelObjectPoints(1, MIN_POINTS_COUNT, CV_32FC3), modelImagePoints(1, MIN_POINTS_COUNT, CV_32FC2);
|
||||
Mat modelObjectPoints(1, MIN_POINTS_COUNT, CV_MAKETYPE(DataDepth<OpointType>::value, 3));
|
||||
Mat modelImagePoints(1, MIN_POINTS_COUNT, CV_MAKETYPE(DataDepth<IpointType>::value, 2));
|
||||
for (int i = 0, colIndex = 0; i < (int)pointsMask.size(); i++)
|
||||
{
|
||||
if (pointsMask[i])
|
||||
@@ -160,7 +162,7 @@ namespace cv
|
||||
for (int i = 0; i < MIN_POINTS_COUNT; i++)
|
||||
for (int j = i + 1; j < MIN_POINTS_COUNT; j++)
|
||||
{
|
||||
if (norm(modelObjectPoints.at<Vec3f>(0, i) - modelObjectPoints.at<Vec3f>(0, j)) < eps)
|
||||
if (norm(modelObjectPoints.at<Vec<OpointType,3> >(0, i) - modelObjectPoints.at<Vec<OpointType,3> >(0, j)) < eps)
|
||||
num_same_points++;
|
||||
}
|
||||
if (num_same_points > 0)
|
||||
@@ -174,7 +176,7 @@ namespace cv
|
||||
params.useExtrinsicGuess, params.flags);
|
||||
|
||||
|
||||
vector<Point2f> projected_points;
|
||||
vector<Point_<OpointType> > projected_points;
|
||||
projected_points.resize(objectPoints.cols);
|
||||
projectPoints(objectPoints, localRvec, localTvec, params.camera.intrinsics, params.camera.distortion, projected_points);
|
||||
|
||||
@@ -184,9 +186,11 @@ namespace cv
|
||||
vector<int> localInliers;
|
||||
for (int i = 0; i < objectPoints.cols; i++)
|
||||
{
|
||||
Point2f p(imagePoints.at<Vec2f>(0, i)[0], imagePoints.at<Vec2f>(0, i)[1]);
|
||||
//Although p is a 2D point it needs the same type as the object points to enable the norm calculation
|
||||
Point_<OpointType> p((OpointType)imagePoints.at<Vec<IpointType,2> >(0, i)[0],
|
||||
(OpointType)imagePoints.at<Vec<IpointType,2> >(0, i)[1]);
|
||||
if ((norm(p - projected_points[i]) < params.reprojectionError)
|
||||
&& (rotatedPoints.at<Vec3f>(0, i)[2] > 0)) //hack
|
||||
&& (rotatedPoints.at<Vec<OpointType,3> >(0, i)[2] > 0)) //hack
|
||||
{
|
||||
localInliers.push_back(i);
|
||||
}
|
||||
@@ -206,6 +210,30 @@ namespace cv
|
||||
}
|
||||
}
|
||||
|
||||
static void pnpTask(const vector<char>& pointsMask, const Mat& objectPoints, const Mat& imagePoints,
|
||||
const Parameters& params, vector<int>& inliers, Mat& rvec, Mat& tvec,
|
||||
const Mat& rvecInit, const Mat& tvecInit, Mutex& resultsMutex)
|
||||
{
|
||||
CV_Assert(objectPoints.depth() == CV_64F || objectPoints.depth() == CV_32F);
|
||||
CV_Assert(imagePoints.depth() == CV_64F || imagePoints.depth() == CV_32F);
|
||||
const bool objectDoublePrecision = objectPoints.depth() == CV_64F;
|
||||
const bool imageDoublePrecision = imagePoints.depth() == CV_64F;
|
||||
if(objectDoublePrecision)
|
||||
{
|
||||
if(imageDoublePrecision)
|
||||
pnpTask<double, double>(pointsMask, objectPoints, imagePoints, params, inliers, rvec, tvec, rvecInit, tvecInit, resultsMutex);
|
||||
else
|
||||
pnpTask<double, float>(pointsMask, objectPoints, imagePoints, params, inliers, rvec, tvec, rvecInit, tvecInit, resultsMutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(imageDoublePrecision)
|
||||
pnpTask<float, double>(pointsMask, objectPoints, imagePoints, params, inliers, rvec, tvec, rvecInit, tvecInit, resultsMutex);
|
||||
else
|
||||
pnpTask<float, float>(pointsMask, objectPoints, imagePoints, params, inliers, rvec, tvec, rvecInit, tvecInit, resultsMutex);
|
||||
}
|
||||
}
|
||||
|
||||
class PnPSolver
|
||||
{
|
||||
public:
|
||||
@@ -281,10 +309,10 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints,
|
||||
Mat cameraMatrix = _cameraMatrix.getMat(), distCoeffs = _distCoeffs.getMat();
|
||||
|
||||
CV_Assert(opoints.isContinuous());
|
||||
CV_Assert(opoints.depth() == CV_32F);
|
||||
CV_Assert(opoints.depth() == CV_32F || opoints.depth() == CV_64F);
|
||||
CV_Assert((opoints.rows == 1 && opoints.channels() == 3) || opoints.cols*opoints.channels() == 3);
|
||||
CV_Assert(ipoints.isContinuous());
|
||||
CV_Assert(ipoints.depth() == CV_32F);
|
||||
CV_Assert(ipoints.depth() == CV_32F || ipoints.depth() == CV_64F);
|
||||
CV_Assert((ipoints.rows == 1 && ipoints.channels() == 2) || ipoints.cols*ipoints.channels() == 2);
|
||||
|
||||
_rvec.create(3, 1, CV_64FC1);
|
||||
@@ -320,7 +348,7 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints,
|
||||
if (flags != CV_P3P)
|
||||
{
|
||||
int i, pointsCount = (int)localInliers.size();
|
||||
Mat inlierObjectPoints(1, pointsCount, CV_32FC3), inlierImagePoints(1, pointsCount, CV_32FC2);
|
||||
Mat inlierObjectPoints(1, pointsCount, CV_MAKE_TYPE(opoints.depth(), 3)), inlierImagePoints(1, pointsCount, CV_MAKE_TYPE(ipoints.depth(), 2));
|
||||
for (i = 0; i < pointsCount; i++)
|
||||
{
|
||||
int index = localInliers[i];
|
||||
|
||||
@@ -224,6 +224,42 @@ prefilterXSobel( const Mat& src, Mat& dst, int ftzero )
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if CV_NEON
|
||||
int16x8_t ftz = vdupq_n_s16 ((short) ftzero);
|
||||
uint8x8_t ftz2 = vdup_n_u8 (cv::saturate_cast<uchar>(ftzero*2));
|
||||
|
||||
for(; x <=size.width-9; x += 8 )
|
||||
{
|
||||
uint8x8_t c0 = vld1_u8 (srow0 + x - 1);
|
||||
uint8x8_t c1 = vld1_u8 (srow1 + x - 1);
|
||||
uint8x8_t d0 = vld1_u8 (srow0 + x + 1);
|
||||
uint8x8_t d1 = vld1_u8 (srow1 + x + 1);
|
||||
|
||||
int16x8_t t0 = vreinterpretq_s16_u16 (vsubl_u8 (d0, c0));
|
||||
int16x8_t t1 = vreinterpretq_s16_u16 (vsubl_u8 (d1, c1));
|
||||
|
||||
uint8x8_t c2 = vld1_u8 (srow2 + x - 1);
|
||||
uint8x8_t c3 = vld1_u8 (srow3 + x - 1);
|
||||
uint8x8_t d2 = vld1_u8 (srow2 + x + 1);
|
||||
uint8x8_t d3 = vld1_u8 (srow3 + x + 1);
|
||||
|
||||
int16x8_t t2 = vreinterpretq_s16_u16 (vsubl_u8 (d2, c2));
|
||||
int16x8_t t3 = vreinterpretq_s16_u16 (vsubl_u8 (d3, c3));
|
||||
|
||||
int16x8_t v0 = vaddq_s16 (vaddq_s16 (t2, t0), vaddq_s16 (t1, t1));
|
||||
int16x8_t v1 = vaddq_s16 (vaddq_s16 (t3, t1), vaddq_s16 (t2, t2));
|
||||
|
||||
|
||||
uint8x8_t v0_u8 = vqmovun_s16 (vaddq_s16 (v0, ftz));
|
||||
uint8x8_t v1_u8 = vqmovun_s16 (vaddq_s16 (v1, ftz));
|
||||
v0_u8 = vmin_u8 (v0_u8, ftz2);
|
||||
v1_u8 = vmin_u8 (v1_u8, ftz2);
|
||||
vqmovun_s16 (vaddq_s16 (v1, ftz));
|
||||
|
||||
vst1_u8 (dptr0 + x, v0_u8);
|
||||
vst1_u8 (dptr1 + x, v1_u8);
|
||||
}
|
||||
#endif
|
||||
|
||||
for( ; x < size.width-1; x++ )
|
||||
{
|
||||
@@ -236,10 +272,19 @@ prefilterXSobel( const Mat& src, Mat& dst, int ftzero )
|
||||
}
|
||||
}
|
||||
|
||||
#if CV_NEON
|
||||
uint8x16_t val0_16 = vdupq_n_u8 (val0);
|
||||
#endif
|
||||
|
||||
for( ; y < size.height; y++ )
|
||||
{
|
||||
uchar* dptr = dst.ptr<uchar>(y);
|
||||
for( x = 0; x < size.width; x++ )
|
||||
x = 0;
|
||||
#if CV_NEON
|
||||
for(; x <= size.width-16; x+=16 )
|
||||
vst1q_u8 (dptr + x, val0_16);
|
||||
#endif
|
||||
for(; x < size.width; x++ )
|
||||
dptr[x] = val0;
|
||||
}
|
||||
}
|
||||
@@ -510,6 +555,7 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
Mat& disp, Mat& cost, const CvStereoBMState& state,
|
||||
uchar* buf, int _dy0, int _dy1 )
|
||||
{
|
||||
|
||||
const int ALIGN = 16;
|
||||
int x, y, d;
|
||||
int wsz = state.SADWindowSize, wsz2 = wsz/2;
|
||||
@@ -525,6 +571,15 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
int uniquenessRatio = state.uniquenessRatio;
|
||||
short FILTERED = (short)((mindisp - 1) << DISPARITY_SHIFT);
|
||||
|
||||
#if CV_NEON
|
||||
CV_Assert (ndisp % 8 == 0);
|
||||
int32_t d0_4_temp [4];
|
||||
for (int i = 0; i < 4; i ++)
|
||||
d0_4_temp[i] = i;
|
||||
int32x4_t d0_4 = vld1q_s32 (d0_4_temp);
|
||||
int32x4_t dd_4 = vdupq_n_s32 (4);
|
||||
#endif
|
||||
|
||||
int *sad, *hsad0, *hsad, *hsad_sub, *htext;
|
||||
uchar *cbuf0, *cbuf;
|
||||
const uchar* lptr0 = left.data + lofs;
|
||||
@@ -560,12 +615,29 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
for( y = -dy0; y < height + dy1; y++, hsad += ndisp, cbuf += ndisp, lptr += sstep, rptr += sstep )
|
||||
{
|
||||
int lval = lptr[0];
|
||||
#if CV_NEON
|
||||
int16x8_t lv = vdupq_n_s16 ((int16_t)lval);
|
||||
|
||||
for( d = 0; d < ndisp; d += 8 )
|
||||
{
|
||||
int16x8_t rv = vreinterpretq_s16_u16 (vmovl_u8 (vld1_u8 (rptr + d)));
|
||||
int32x4_t hsad_l = vld1q_s32 (hsad + d);
|
||||
int32x4_t hsad_h = vld1q_s32 (hsad + d + 4);
|
||||
int16x8_t diff = vabdq_s16 (lv, rv);
|
||||
vst1_u8 (cbuf + d, vmovn_u16(vreinterpretq_u16_s16(diff)));
|
||||
hsad_l = vaddq_s32 (hsad_l, vmovl_s16(vget_low_s16 (diff)));
|
||||
hsad_h = vaddq_s32 (hsad_h, vmovl_s16(vget_high_s16 (diff)));
|
||||
vst1q_s32 ((hsad + d), hsad_l);
|
||||
vst1q_s32 ((hsad + d + 4), hsad_h);
|
||||
}
|
||||
#else
|
||||
for( d = 0; d < ndisp; d++ )
|
||||
{
|
||||
int diff = std::abs(lval - rptr[d]);
|
||||
cbuf[d] = (uchar)diff;
|
||||
hsad[d] = (int)(hsad[d] + diff);
|
||||
}
|
||||
#endif
|
||||
htext[y] += tab[lval];
|
||||
}
|
||||
}
|
||||
@@ -595,12 +667,31 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
hsad += ndisp, lptr += sstep, lptr_sub += sstep, rptr += sstep )
|
||||
{
|
||||
int lval = lptr[0];
|
||||
#if CV_NEON
|
||||
int16x8_t lv = vdupq_n_s16 ((int16_t)lval);
|
||||
for( d = 0; d < ndisp; d += 8 )
|
||||
{
|
||||
int16x8_t rv = vreinterpretq_s16_u16 (vmovl_u8 (vld1_u8 (rptr + d)));
|
||||
int32x4_t hsad_l = vld1q_s32 (hsad + d);
|
||||
int32x4_t hsad_h = vld1q_s32 (hsad + d + 4);
|
||||
int16x8_t cbs = vreinterpretq_s16_u16 (vmovl_u8 (vld1_u8 (cbuf_sub + d)));
|
||||
int16x8_t diff = vabdq_s16 (lv, rv);
|
||||
int32x4_t diff_h = vsubl_s16 (vget_high_s16 (diff), vget_high_s16 (cbs));
|
||||
int32x4_t diff_l = vsubl_s16 (vget_low_s16 (diff), vget_low_s16 (cbs));
|
||||
vst1_u8 (cbuf + d, vmovn_u16(vreinterpretq_u16_s16(diff)));
|
||||
hsad_h = vaddq_s32 (hsad_h, diff_h);
|
||||
hsad_l = vaddq_s32 (hsad_l, diff_l);
|
||||
vst1q_s32 ((hsad + d), hsad_l);
|
||||
vst1q_s32 ((hsad + d + 4), hsad_h);
|
||||
}
|
||||
#else
|
||||
for( d = 0; d < ndisp; d++ )
|
||||
{
|
||||
int diff = std::abs(lval - rptr[d]);
|
||||
cbuf[d] = (uchar)diff;
|
||||
hsad[d] = hsad[d] + diff - cbuf_sub[d];
|
||||
}
|
||||
#endif
|
||||
htext[y] += tab[lval] - tab[lptr_sub[0]];
|
||||
}
|
||||
|
||||
@@ -616,8 +707,24 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
|
||||
hsad = hsad0 + (1 - dy0)*ndisp;
|
||||
for( y = 1 - dy0; y < wsz2; y++, hsad += ndisp )
|
||||
{
|
||||
#if CV_NEON
|
||||
for( d = 0; d <= ndisp-8; d += 8 )
|
||||
{
|
||||
int32x4_t s0 = vld1q_s32 (sad + d);
|
||||
int32x4_t s1 = vld1q_s32 (sad + d + 4);
|
||||
int32x4_t t0 = vld1q_s32 (hsad + d);
|
||||
int32x4_t t1 = vld1q_s32 (hsad + d + 4);
|
||||
s0 = vaddq_s32 (s0, t0);
|
||||
s1 = vaddq_s32 (s1, t1);
|
||||
vst1q_s32 (sad + d, s0);
|
||||
vst1q_s32 (sad + d + 4, s1);
|
||||
}
|
||||
#else
|
||||
for( d = 0; d < ndisp; d++ )
|
||||
sad[d] = (int)(sad[d] + hsad[d]);
|
||||
#endif
|
||||
}
|
||||
int tsum = 0;
|
||||
for( y = -wsz2-1; y < wsz2; y++ )
|
||||
tsum += htext[y];
|
||||
@@ -628,7 +735,61 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
int minsad = INT_MAX, mind = -1;
|
||||
hsad = hsad0 + MIN(y + wsz2, height+dy1-1)*ndisp;
|
||||
hsad_sub = hsad0 + MAX(y - wsz2 - 1, -dy0)*ndisp;
|
||||
#if CV_NEON
|
||||
int32x4_t minsad4 = vdupq_n_s32 (INT_MAX);
|
||||
int32x4_t mind4 = vdupq_n_s32(0), d4 = d0_4;
|
||||
|
||||
for( d = 0; d <= ndisp-8; d += 8 )
|
||||
{
|
||||
int32x4_t u0 = vld1q_s32 (hsad_sub + d);
|
||||
int32x4_t u1 = vld1q_s32 (hsad + d);
|
||||
|
||||
int32x4_t v0 = vld1q_s32 (hsad_sub + d + 4);
|
||||
int32x4_t v1 = vld1q_s32 (hsad + d + 4);
|
||||
|
||||
int32x4_t usad4 = vld1q_s32(sad + d);
|
||||
int32x4_t vsad4 = vld1q_s32(sad + d + 4);
|
||||
|
||||
u1 = vsubq_s32 (u1, u0);
|
||||
v1 = vsubq_s32 (v1, v0);
|
||||
usad4 = vaddq_s32 (usad4, u1);
|
||||
vsad4 = vaddq_s32 (vsad4, v1);
|
||||
|
||||
uint32x4_t mask = vcgtq_s32 (minsad4, usad4);
|
||||
minsad4 = vminq_s32 (minsad4, usad4);
|
||||
mind4 = vbslq_s32(mask, d4, mind4);
|
||||
|
||||
vst1q_s32 (sad + d, usad4);
|
||||
vst1q_s32 (sad + d + 4, vsad4);
|
||||
d4 = vaddq_s32 (d4, dd_4);
|
||||
|
||||
mask = vcgtq_s32 (minsad4, vsad4);
|
||||
minsad4 = vminq_s32 (minsad4, vsad4);
|
||||
mind4 = vbslq_s32(mask, d4, mind4);
|
||||
|
||||
d4 = vaddq_s32 (d4, dd_4);
|
||||
|
||||
}
|
||||
int32x2_t mind4_h = vget_high_s32 (mind4);
|
||||
int32x2_t mind4_l = vget_low_s32 (mind4);
|
||||
int32x2_t minsad4_h = vget_high_s32 (minsad4);
|
||||
int32x2_t minsad4_l = vget_low_s32 (minsad4);
|
||||
|
||||
uint32x2_t mask = vorr_u32 (vclt_s32 (minsad4_h, minsad4_l), vand_u32 (vceq_s32 (minsad4_h, minsad4_l), vclt_s32 (mind4_h, mind4_l)));
|
||||
mind4_h = vbsl_s32 (mask, mind4_h, mind4_l);
|
||||
minsad4_h = vbsl_s32 (mask, minsad4_h, minsad4_l);
|
||||
|
||||
mind4_l = vext_s32 (mind4_h,mind4_h,1);
|
||||
minsad4_l = vext_s32 (minsad4_h,minsad4_h,1);
|
||||
|
||||
mask = vorr_u32 (vclt_s32 (minsad4_h, minsad4_l), vand_u32 (vceq_s32 (minsad4_h, minsad4_l), vclt_s32 (mind4_h, mind4_l)));
|
||||
mind4_h = vbsl_s32 (mask, mind4_h, mind4_l);
|
||||
minsad4_h = vbsl_s32 (mask, minsad4_h, minsad4_l);
|
||||
|
||||
mind = (int) vget_lane_s32 (mind4_h, 0);
|
||||
minsad = sad[mind];
|
||||
|
||||
#else
|
||||
for( d = 0; d < ndisp; d++ )
|
||||
{
|
||||
int currsad = sad[d] + hsad[d] - hsad_sub[d];
|
||||
@@ -639,6 +800,7 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
mind = d;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
tsum += htext[y + wsz2] - htext[y - wsz2 - 1];
|
||||
if( tsum < textureThreshold )
|
||||
{
|
||||
|
||||
@@ -913,18 +913,6 @@ namespace
|
||||
T dp = *dpp;
|
||||
int* lpp = labels + width*p.y + p.x;
|
||||
|
||||
if( p.x < width-1 && !lpp[+1] && dpp[+1] != newVal && std::abs(dp - dpp[+1]) <= maxDiff )
|
||||
{
|
||||
lpp[+1] = curlabel;
|
||||
*ws++ = Point2s(p.x+1, p.y);
|
||||
}
|
||||
|
||||
if( p.x > 0 && !lpp[-1] && dpp[-1] != newVal && std::abs(dp - dpp[-1]) <= maxDiff )
|
||||
{
|
||||
lpp[-1] = curlabel;
|
||||
*ws++ = Point2s(p.x-1, p.y);
|
||||
}
|
||||
|
||||
if( p.y < height-1 && !lpp[+width] && dpp[+dstep] != newVal && std::abs(dp - dpp[+dstep]) <= maxDiff )
|
||||
{
|
||||
lpp[+width] = curlabel;
|
||||
@@ -937,6 +925,18 @@ namespace
|
||||
*ws++ = Point2s(p.x, p.y-1);
|
||||
}
|
||||
|
||||
if( p.x < width-1 && !lpp[+1] && dpp[+1] != newVal && std::abs(dp - dpp[+1]) <= maxDiff )
|
||||
{
|
||||
lpp[+1] = curlabel;
|
||||
*ws++ = Point2s(p.x+1, p.y);
|
||||
}
|
||||
|
||||
if( p.x > 0 && !lpp[-1] && dpp[-1] != newVal && std::abs(dp - dpp[-1]) <= maxDiff )
|
||||
{
|
||||
lpp[-1] = curlabel;
|
||||
*ws++ = Point2s(p.x-1, p.y);
|
||||
}
|
||||
|
||||
// pop most recent and propagate
|
||||
// NB: could try least recent, maybe better convergence
|
||||
p = *--ws;
|
||||
|
||||
@@ -0,0 +1,617 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include <opencv2/ts/gpu_test.hpp>
|
||||
#include "../src/fisheye.hpp"
|
||||
|
||||
class fisheyeTest : public ::testing::Test {
|
||||
|
||||
protected:
|
||||
const static cv::Size imageSize;
|
||||
const static cv::Matx33d K;
|
||||
const static cv::Vec4d D;
|
||||
const static cv::Matx33d R;
|
||||
const static cv::Vec3d T;
|
||||
std::string datasets_repository_path;
|
||||
|
||||
virtual void SetUp() {
|
||||
datasets_repository_path = combine(cvtest::TS::ptr()->get_data_path(), "cameracalibration/fisheye");
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string combine(const std::string& _item1, const std::string& _item2);
|
||||
cv::Mat mergeRectification(const cv::Mat& l, const cv::Mat& r);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// TESTS::
|
||||
|
||||
TEST_F(fisheyeTest, projectPoints)
|
||||
{
|
||||
double cols = this->imageSize.width,
|
||||
rows = this->imageSize.height;
|
||||
|
||||
const int N = 20;
|
||||
cv::Mat distorted0(1, N*N, CV_64FC2), undist1, undist2, distorted1, distorted2;
|
||||
undist2.create(distorted0.size(), CV_MAKETYPE(distorted0.depth(), 3));
|
||||
cv::Vec2d* pts = distorted0.ptr<cv::Vec2d>();
|
||||
|
||||
cv::Vec2d c(this->K(0, 2), this->K(1, 2));
|
||||
for(int y = 0, k = 0; y < N; ++y)
|
||||
for(int x = 0; x < N; ++x)
|
||||
{
|
||||
cv::Vec2d point(x*cols/(N-1.f), y*rows/(N-1.f));
|
||||
pts[k++] = (point - c) * 0.85 + c;
|
||||
}
|
||||
|
||||
cv::fisheye::undistortPoints(distorted0, undist1, this->K, this->D);
|
||||
|
||||
cv::Vec2d* u1 = undist1.ptr<cv::Vec2d>();
|
||||
cv::Vec3d* u2 = undist2.ptr<cv::Vec3d>();
|
||||
for(int i = 0; i < (int)distorted0.total(); ++i)
|
||||
u2[i] = cv::Vec3d(u1[i][0], u1[i][1], 1.0);
|
||||
|
||||
cv::fisheye::distortPoints(undist1, distorted1, this->K, this->D);
|
||||
cv::fisheye::projectPoints(undist2, distorted2, cv::Vec3d::all(0), cv::Vec3d::all(0), this->K, this->D);
|
||||
|
||||
EXPECT_MAT_NEAR(distorted0, distorted1, 1e-10);
|
||||
EXPECT_MAT_NEAR(distorted0, distorted2, 1e-10);
|
||||
}
|
||||
|
||||
TEST_F(fisheyeTest, undistortImage)
|
||||
{
|
||||
cv::Matx33d K = this->K;
|
||||
cv::Mat D = cv::Mat(this->D);
|
||||
std::string file = combine(datasets_repository_path, "/calib-3_stereo_from_JY/left/stereo_pair_014.jpg");
|
||||
cv::Matx33d newK = K;
|
||||
cv::Mat distorted = cv::imread(file), undistorted;
|
||||
{
|
||||
newK(0, 0) = 100;
|
||||
newK(1, 1) = 100;
|
||||
cv::fisheye::undistortImage(distorted, undistorted, K, D, newK);
|
||||
cv::Mat correct = cv::imread(combine(datasets_repository_path, "new_f_100.png"));
|
||||
if (correct.empty())
|
||||
CV_Assert(cv::imwrite(combine(datasets_repository_path, "new_f_100.png"), undistorted));
|
||||
else
|
||||
EXPECT_MAT_NEAR(correct, undistorted, 1e-10);
|
||||
}
|
||||
{
|
||||
double balance = 1.0;
|
||||
cv::fisheye::estimateNewCameraMatrixForUndistortRectify(K, D, distorted.size(), cv::noArray(), newK, balance);
|
||||
cv::fisheye::undistortImage(distorted, undistorted, K, D, newK);
|
||||
cv::Mat correct = cv::imread(combine(datasets_repository_path, "balance_1.0.png"));
|
||||
if (correct.empty())
|
||||
CV_Assert(cv::imwrite(combine(datasets_repository_path, "balance_1.0.png"), undistorted));
|
||||
else
|
||||
EXPECT_MAT_NEAR(correct, undistorted, 1e-10);
|
||||
}
|
||||
|
||||
{
|
||||
double balance = 0.0;
|
||||
cv::fisheye::estimateNewCameraMatrixForUndistortRectify(K, D, distorted.size(), cv::noArray(), newK, balance);
|
||||
cv::fisheye::undistortImage(distorted, undistorted, K, D, newK);
|
||||
cv::Mat correct = cv::imread(combine(datasets_repository_path, "balance_0.0.png"));
|
||||
if (correct.empty())
|
||||
CV_Assert(cv::imwrite(combine(datasets_repository_path, "balance_0.0.png"), undistorted));
|
||||
else
|
||||
EXPECT_MAT_NEAR(correct, undistorted, 1e-10);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(fisheyeTest, jacobians)
|
||||
{
|
||||
int n = 10;
|
||||
cv::Mat X(1, n, CV_64FC3);
|
||||
cv::Mat om(3, 1, CV_64F), T(3, 1, CV_64F);
|
||||
cv::Mat f(2, 1, CV_64F), c(2, 1, CV_64F);
|
||||
cv::Mat k(4, 1, CV_64F);
|
||||
double alpha;
|
||||
|
||||
cv::RNG r;
|
||||
|
||||
r.fill(X, cv::RNG::NORMAL, 2, 1);
|
||||
X = cv::abs(X) * 10;
|
||||
|
||||
r.fill(om, cv::RNG::NORMAL, 0, 1);
|
||||
om = cv::abs(om);
|
||||
|
||||
r.fill(T, cv::RNG::NORMAL, 0, 1);
|
||||
T = cv::abs(T); T.at<double>(2) = 4; T *= 10;
|
||||
|
||||
r.fill(f, cv::RNG::NORMAL, 0, 1);
|
||||
f = cv::abs(f) * 1000;
|
||||
|
||||
r.fill(c, cv::RNG::NORMAL, 0, 1);
|
||||
c = cv::abs(c) * 1000;
|
||||
|
||||
r.fill(k, cv::RNG::NORMAL, 0, 1);
|
||||
k*= 0.5;
|
||||
|
||||
alpha = 0.01*r.gaussian(1);
|
||||
|
||||
cv::Mat x1, x2, xpred;
|
||||
cv::Matx33d K(f.at<double>(0), alpha * f.at<double>(0), c.at<double>(0),
|
||||
0, f.at<double>(1), c.at<double>(1),
|
||||
0, 0, 1);
|
||||
|
||||
cv::Mat jacobians;
|
||||
cv::fisheye::projectPoints(X, x1, om, T, K, k, alpha, jacobians);
|
||||
|
||||
//test on T:
|
||||
cv::Mat dT(3, 1, CV_64FC1);
|
||||
r.fill(dT, cv::RNG::NORMAL, 0, 1);
|
||||
dT *= 1e-9*cv::norm(T);
|
||||
cv::Mat T2 = T + dT;
|
||||
cv::fisheye::projectPoints(X, x2, om, T2, K, k, alpha, cv::noArray());
|
||||
xpred = x1 + cv::Mat(jacobians.colRange(11,14) * dT).reshape(2, 1);
|
||||
CV_Assert (cv::norm(x2 - xpred) < 1e-10);
|
||||
|
||||
//test on om:
|
||||
cv::Mat dom(3, 1, CV_64FC1);
|
||||
r.fill(dom, cv::RNG::NORMAL, 0, 1);
|
||||
dom *= 1e-9*cv::norm(om);
|
||||
cv::Mat om2 = om + dom;
|
||||
cv::fisheye::projectPoints(X, x2, om2, T, K, k, alpha, cv::noArray());
|
||||
xpred = x1 + cv::Mat(jacobians.colRange(8,11) * dom).reshape(2, 1);
|
||||
CV_Assert (cv::norm(x2 - xpred) < 1e-10);
|
||||
|
||||
//test on f:
|
||||
cv::Mat df(2, 1, CV_64FC1);
|
||||
r.fill(df, cv::RNG::NORMAL, 0, 1);
|
||||
df *= 1e-9*cv::norm(f);
|
||||
cv::Matx33d K2 = K + cv::Matx33d(df.at<double>(0), df.at<double>(0) * alpha, 0, 0, df.at<double>(1), 0, 0, 0, 0);
|
||||
cv::fisheye::projectPoints(X, x2, om, T, K2, k, alpha, cv::noArray());
|
||||
xpred = x1 + cv::Mat(jacobians.colRange(0,2) * df).reshape(2, 1);
|
||||
CV_Assert (cv::norm(x2 - xpred) < 1e-10);
|
||||
|
||||
//test on c:
|
||||
cv::Mat dc(2, 1, CV_64FC1);
|
||||
r.fill(dc, cv::RNG::NORMAL, 0, 1);
|
||||
dc *= 1e-9*cv::norm(c);
|
||||
K2 = K + cv::Matx33d(0, 0, dc.at<double>(0), 0, 0, dc.at<double>(1), 0, 0, 0);
|
||||
cv::fisheye::projectPoints(X, x2, om, T, K2, k, alpha, cv::noArray());
|
||||
xpred = x1 + cv::Mat(jacobians.colRange(2,4) * dc).reshape(2, 1);
|
||||
CV_Assert (cv::norm(x2 - xpred) < 1e-10);
|
||||
|
||||
//test on k:
|
||||
cv::Mat dk(4, 1, CV_64FC1);
|
||||
r.fill(dk, cv::RNG::NORMAL, 0, 1);
|
||||
dk *= 1e-9*cv::norm(k);
|
||||
cv::Mat k2 = k + dk;
|
||||
cv::fisheye::projectPoints(X, x2, om, T, K, k2, alpha, cv::noArray());
|
||||
xpred = x1 + cv::Mat(jacobians.colRange(4,8) * dk).reshape(2, 1);
|
||||
CV_Assert (cv::norm(x2 - xpred) < 1e-10);
|
||||
|
||||
//test on alpha:
|
||||
cv::Mat dalpha(1, 1, CV_64FC1);
|
||||
r.fill(dalpha, cv::RNG::NORMAL, 0, 1);
|
||||
dalpha *= 1e-9*cv::norm(f);
|
||||
double alpha2 = alpha + dalpha.at<double>(0);
|
||||
K2 = K + cv::Matx33d(0, f.at<double>(0) * dalpha.at<double>(0), 0, 0, 0, 0, 0, 0, 0);
|
||||
cv::fisheye::projectPoints(X, x2, om, T, K, k, alpha2, cv::noArray());
|
||||
xpred = x1 + cv::Mat(jacobians.col(14) * dalpha).reshape(2, 1);
|
||||
CV_Assert (cv::norm(x2 - xpred) < 1e-10);
|
||||
}
|
||||
|
||||
TEST_F(fisheyeTest, Calibration)
|
||||
{
|
||||
const int n_images = 34;
|
||||
|
||||
std::vector<std::vector<cv::Point2d> > imagePoints(n_images);
|
||||
std::vector<std::vector<cv::Point3d> > objectPoints(n_images);
|
||||
|
||||
const std::string folder =combine(datasets_repository_path, "calib-3_stereo_from_JY");
|
||||
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_left.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_left[cv::format("image_%d", i )] >> imagePoints[i];
|
||||
fs_left.release();
|
||||
|
||||
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_object.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object.release();
|
||||
|
||||
int flag = 0;
|
||||
flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
|
||||
flag |= cv::fisheye::CALIB_CHECK_COND;
|
||||
flag |= cv::fisheye::CALIB_FIX_SKEW;
|
||||
|
||||
cv::Matx33d K;
|
||||
cv::Vec4d D;
|
||||
|
||||
cv::fisheye::calibrate(objectPoints, imagePoints, imageSize, K, D,
|
||||
cv::noArray(), cv::noArray(), flag, cv::TermCriteria(3, 20, 1e-6));
|
||||
|
||||
EXPECT_MAT_NEAR(K, this->K, 1e-10);
|
||||
EXPECT_MAT_NEAR(D, this->D, 1e-10);
|
||||
}
|
||||
|
||||
TEST_F(fisheyeTest, Homography)
|
||||
{
|
||||
const int n_images = 1;
|
||||
|
||||
std::vector<std::vector<cv::Point2d> > imagePoints(n_images);
|
||||
std::vector<std::vector<cv::Point3d> > objectPoints(n_images);
|
||||
|
||||
const std::string folder =combine(datasets_repository_path, "calib-3_stereo_from_JY");
|
||||
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_left.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_left[cv::format("image_%d", i )] >> imagePoints[i];
|
||||
fs_left.release();
|
||||
|
||||
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_object.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object.release();
|
||||
|
||||
cv::internal::IntrinsicParams param;
|
||||
param.Init(cv::Vec2d(cv::max(imageSize.width, imageSize.height) / CV_PI, cv::max(imageSize.width, imageSize.height) / CV_PI),
|
||||
cv::Vec2d(imageSize.width / 2.0 - 0.5, imageSize.height / 2.0 - 0.5));
|
||||
|
||||
cv::Mat _imagePoints (imagePoints[0]);
|
||||
cv::Mat _objectPoints(objectPoints[0]);
|
||||
|
||||
cv::Mat imagePointsNormalized = NormalizePixels(_imagePoints, param).reshape(1).t();
|
||||
_objectPoints = _objectPoints.reshape(1).t();
|
||||
cv::Mat objectPointsMean, covObjectPoints;
|
||||
|
||||
int Np = imagePointsNormalized.cols;
|
||||
cv::calcCovarMatrix(_objectPoints, covObjectPoints, objectPointsMean, CV_COVAR_NORMAL | CV_COVAR_COLS);
|
||||
cv::SVD svd(covObjectPoints);
|
||||
cv::Mat R(svd.vt);
|
||||
|
||||
if (cv::norm(R(cv::Rect(2, 0, 1, 2))) < 1e-6)
|
||||
R = cv::Mat::eye(3,3, CV_64FC1);
|
||||
if (cv::determinant(R) < 0)
|
||||
R = -R;
|
||||
|
||||
cv::Mat T = -R * objectPointsMean;
|
||||
cv::Mat X_new = R * _objectPoints + T * cv::Mat::ones(1, Np, CV_64FC1);
|
||||
cv::Mat H = cv::internal::ComputeHomography(imagePointsNormalized, X_new.rowRange(0, 2));
|
||||
|
||||
cv::Mat M = cv::Mat::ones(3, X_new.cols, CV_64FC1);
|
||||
X_new.rowRange(0, 2).copyTo(M.rowRange(0, 2));
|
||||
cv::Mat mrep = H * M;
|
||||
|
||||
cv::divide(mrep, cv::Mat::ones(3,1, CV_64FC1) * mrep.row(2).clone(), mrep);
|
||||
|
||||
cv::Mat merr = (mrep.rowRange(0, 2) - imagePointsNormalized).t();
|
||||
|
||||
cv::Vec2d std_err;
|
||||
cv::meanStdDev(merr.reshape(2), cv::noArray(), std_err);
|
||||
std_err *= sqrt((double)merr.reshape(2).total() / (merr.reshape(2).total() - 1));
|
||||
|
||||
cv::Vec2d correct_std_err(0.00516740156010384, 0.00644205331553901);
|
||||
EXPECT_MAT_NEAR(std_err, correct_std_err, 1e-12);
|
||||
}
|
||||
|
||||
TEST_F(fisheyeTest, EtimateUncertainties)
|
||||
{
|
||||
const int n_images = 34;
|
||||
|
||||
std::vector<std::vector<cv::Point2d> > imagePoints(n_images);
|
||||
std::vector<std::vector<cv::Point3d> > objectPoints(n_images);
|
||||
|
||||
const std::string folder =combine(datasets_repository_path, "calib-3_stereo_from_JY");
|
||||
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_left.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_left[cv::format("image_%d", i )] >> imagePoints[i];
|
||||
fs_left.release();
|
||||
|
||||
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_object.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object.release();
|
||||
|
||||
int flag = 0;
|
||||
flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
|
||||
flag |= cv::fisheye::CALIB_CHECK_COND;
|
||||
flag |= cv::fisheye::CALIB_FIX_SKEW;
|
||||
|
||||
cv::Matx33d K;
|
||||
cv::Vec4d D;
|
||||
std::vector<cv::Vec3d> rvec;
|
||||
std::vector<cv::Vec3d> tvec;
|
||||
|
||||
cv::fisheye::calibrate(objectPoints, imagePoints, imageSize, K, D,
|
||||
rvec, tvec, flag, cv::TermCriteria(3, 20, 1e-6));
|
||||
|
||||
cv::internal::IntrinsicParams param, errors;
|
||||
cv::Vec2d err_std;
|
||||
double thresh_cond = 1e6;
|
||||
int check_cond = 1;
|
||||
param.Init(cv::Vec2d(K(0,0), K(1,1)), cv::Vec2d(K(0,2), K(1, 2)), D);
|
||||
param.isEstimate = std::vector<int>(9, 1);
|
||||
param.isEstimate[4] = 0;
|
||||
|
||||
errors.isEstimate = param.isEstimate;
|
||||
|
||||
double rms;
|
||||
|
||||
cv::internal::EstimateUncertainties(objectPoints, imagePoints, param, rvec, tvec,
|
||||
errors, err_std, thresh_cond, check_cond, rms);
|
||||
|
||||
EXPECT_MAT_NEAR(errors.f, cv::Vec2d(1.29837104202046, 1.31565641071524), 1e-10);
|
||||
EXPECT_MAT_NEAR(errors.c, cv::Vec2d(0.890439368129246, 0.816096854937896), 1e-10);
|
||||
EXPECT_MAT_NEAR(errors.k, cv::Vec4d(0.00516248605191506, 0.0168181467500934, 0.0213118690274604, 0.00916010877545648), 1e-10);
|
||||
EXPECT_MAT_NEAR(err_std, cv::Vec2d(0.187475975266883, 0.185678953263995), 1e-10);
|
||||
CV_Assert(abs(rms - 0.263782587133546) < 1e-10);
|
||||
CV_Assert(errors.alpha == 0);
|
||||
}
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
TEST_F(fisheyeTest, DISABLED_rectify)
|
||||
#else
|
||||
TEST_F(fisheyeTest, rectify)
|
||||
#endif
|
||||
{
|
||||
const std::string folder =combine(datasets_repository_path, "calib-3_stereo_from_JY");
|
||||
|
||||
cv::Size calibration_size = this->imageSize, requested_size = calibration_size;
|
||||
cv::Matx33d K1 = this->K, K2 = K1;
|
||||
cv::Mat D1 = cv::Mat(this->D), D2 = D1;
|
||||
|
||||
cv::Vec3d T = this->T;
|
||||
cv::Matx33d R = this->R;
|
||||
|
||||
double balance = 0.0, fov_scale = 1.1;
|
||||
cv::Mat R1, R2, P1, P2, Q;
|
||||
cv::fisheye::stereoRectify(K1, D1, K2, D2, calibration_size, R, T, R1, R2, P1, P2, Q,
|
||||
cv::CALIB_ZERO_DISPARITY, requested_size, balance, fov_scale);
|
||||
|
||||
cv::Mat lmapx, lmapy, rmapx, rmapy;
|
||||
//rewrite for fisheye
|
||||
cv::fisheye::initUndistortRectifyMap(K1, D1, R1, P1, requested_size, CV_32F, lmapx, lmapy);
|
||||
cv::fisheye::initUndistortRectifyMap(K2, D2, R2, P2, requested_size, CV_32F, rmapx, rmapy);
|
||||
|
||||
cv::Mat l, r, lundist, rundist;
|
||||
cv::VideoCapture lcap(combine(folder, "left/stereo_pair_%03d.jpg")),
|
||||
rcap(combine(folder, "right/stereo_pair_%03d.jpg"));
|
||||
|
||||
for(int i = 0;; ++i)
|
||||
{
|
||||
lcap >> l; rcap >> r;
|
||||
if (l.empty() || r.empty())
|
||||
break;
|
||||
|
||||
int ndisp = 128;
|
||||
cv::rectangle(l, cv::Rect(255, 0, 829, l.rows-1), CV_RGB(255, 0, 0));
|
||||
cv::rectangle(r, cv::Rect(255, 0, 829, l.rows-1), CV_RGB(255, 0, 0));
|
||||
cv::rectangle(r, cv::Rect(255-ndisp, 0, 829+ndisp ,l.rows-1), CV_RGB(255, 0, 0));
|
||||
cv::remap(l, lundist, lmapx, lmapy, cv::INTER_LINEAR);
|
||||
cv::remap(r, rundist, rmapx, rmapy, cv::INTER_LINEAR);
|
||||
|
||||
cv::Mat rectification = mergeRectification(lundist, rundist);
|
||||
|
||||
cv::Mat correct = cv::imread(combine(datasets_repository_path, cv::format("rectification_AB_%03d.png", i)));
|
||||
|
||||
if (correct.empty())
|
||||
cv::imwrite(combine(datasets_repository_path, cv::format("rectification_AB_%03d.png", i)), rectification);
|
||||
else
|
||||
EXPECT_MAT_NEAR(correct, rectification, 1e-10);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(fisheyeTest, stereoCalibrate)
|
||||
{
|
||||
const int n_images = 34;
|
||||
|
||||
const std::string folder =combine(datasets_repository_path, "calib-3_stereo_from_JY");
|
||||
|
||||
std::vector<std::vector<cv::Point2d> > leftPoints(n_images);
|
||||
std::vector<std::vector<cv::Point2d> > rightPoints(n_images);
|
||||
std::vector<std::vector<cv::Point3d> > objectPoints(n_images);
|
||||
|
||||
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_left.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_left[cv::format("image_%d", i )] >> leftPoints[i];
|
||||
fs_left.release();
|
||||
|
||||
cv::FileStorage fs_right(combine(folder, "right.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_right.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_right[cv::format("image_%d", i )] >> rightPoints[i];
|
||||
fs_right.release();
|
||||
|
||||
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_object.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object.release();
|
||||
|
||||
cv::Matx33d K1, K2, R;
|
||||
cv::Vec3d T;
|
||||
cv::Vec4d D1, D2;
|
||||
|
||||
int flag = 0;
|
||||
flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
|
||||
flag |= cv::fisheye::CALIB_CHECK_COND;
|
||||
flag |= cv::fisheye::CALIB_FIX_SKEW;
|
||||
// flag |= cv::fisheye::CALIB_FIX_INTRINSIC;
|
||||
|
||||
cv::fisheye::stereoCalibrate(objectPoints, leftPoints, rightPoints,
|
||||
K1, D1, K2, D2, imageSize, R, T, flag,
|
||||
cv::TermCriteria(3, 12, 0));
|
||||
|
||||
cv::Matx33d R_correct( 0.9975587205950972, 0.06953016383322372, 0.006492709911733523,
|
||||
-0.06956823121068059, 0.9975601387249519, 0.005833595226966235,
|
||||
-0.006071257768382089, -0.006271040135405457, 0.9999619062167968);
|
||||
cv::Vec3d T_correct(-0.099402724724121, 0.00270812139265413, 0.00129330292472699);
|
||||
cv::Matx33d K1_correct (561.195925927249, 0, 621.282400272412,
|
||||
0, 562.849402029712, 380.555455380889,
|
||||
0, 0, 1);
|
||||
|
||||
cv::Matx33d K2_correct (560.395452535348, 0, 678.971652040359,
|
||||
0, 561.90171021422, 380.401340535339,
|
||||
0, 0, 1);
|
||||
|
||||
cv::Vec4d D1_correct (-7.44253716539556e-05, -0.00702662033932424, 0.00737569823650885, -0.00342230256441771);
|
||||
cv::Vec4d D2_correct (-0.0130785435677431, 0.0284434505383497, -0.0360333869900506, 0.0144724062347222);
|
||||
|
||||
EXPECT_MAT_NEAR(R, R_correct, 1e-10);
|
||||
EXPECT_MAT_NEAR(T, T_correct, 1e-10);
|
||||
|
||||
EXPECT_MAT_NEAR(K1, K1_correct, 1e-10);
|
||||
EXPECT_MAT_NEAR(K2, K2_correct, 1e-10);
|
||||
|
||||
EXPECT_MAT_NEAR(D1, D1_correct, 1e-10);
|
||||
EXPECT_MAT_NEAR(D2, D2_correct, 1e-10);
|
||||
|
||||
}
|
||||
|
||||
TEST_F(fisheyeTest, stereoCalibrateFixIntrinsic)
|
||||
{
|
||||
const int n_images = 34;
|
||||
|
||||
const std::string folder =combine(datasets_repository_path, "calib-3_stereo_from_JY");
|
||||
|
||||
std::vector<std::vector<cv::Point2d> > leftPoints(n_images);
|
||||
std::vector<std::vector<cv::Point2d> > rightPoints(n_images);
|
||||
std::vector<std::vector<cv::Point3d> > objectPoints(n_images);
|
||||
|
||||
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_left.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_left[cv::format("image_%d", i )] >> leftPoints[i];
|
||||
fs_left.release();
|
||||
|
||||
cv::FileStorage fs_right(combine(folder, "right.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_right.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_right[cv::format("image_%d", i )] >> rightPoints[i];
|
||||
fs_right.release();
|
||||
|
||||
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_object.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object.release();
|
||||
|
||||
cv::Matx33d R;
|
||||
cv::Vec3d T;
|
||||
|
||||
int flag = 0;
|
||||
flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
|
||||
flag |= cv::fisheye::CALIB_CHECK_COND;
|
||||
flag |= cv::fisheye::CALIB_FIX_SKEW;
|
||||
flag |= cv::fisheye::CALIB_FIX_INTRINSIC;
|
||||
|
||||
cv::Matx33d K1 (561.195925927249, 0, 621.282400272412,
|
||||
0, 562.849402029712, 380.555455380889,
|
||||
0, 0, 1);
|
||||
|
||||
cv::Matx33d K2 (560.395452535348, 0, 678.971652040359,
|
||||
0, 561.90171021422, 380.401340535339,
|
||||
0, 0, 1);
|
||||
|
||||
cv::Vec4d D1 (-7.44253716539556e-05, -0.00702662033932424, 0.00737569823650885, -0.00342230256441771);
|
||||
cv::Vec4d D2 (-0.0130785435677431, 0.0284434505383497, -0.0360333869900506, 0.0144724062347222);
|
||||
|
||||
cv::fisheye::stereoCalibrate(objectPoints, leftPoints, rightPoints,
|
||||
K1, D1, K2, D2, imageSize, R, T, flag,
|
||||
cv::TermCriteria(3, 12, 0));
|
||||
|
||||
cv::Matx33d R_correct( 0.9975587205950972, 0.06953016383322372, 0.006492709911733523,
|
||||
-0.06956823121068059, 0.9975601387249519, 0.005833595226966235,
|
||||
-0.006071257768382089, -0.006271040135405457, 0.9999619062167968);
|
||||
cv::Vec3d T_correct(-0.099402724724121, 0.00270812139265413, 0.00129330292472699);
|
||||
|
||||
|
||||
EXPECT_MAT_NEAR(R, R_correct, 1e-10);
|
||||
EXPECT_MAT_NEAR(T, T_correct, 1e-10);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// fisheyeTest::
|
||||
|
||||
const cv::Size fisheyeTest::imageSize(1280, 800);
|
||||
|
||||
const cv::Matx33d fisheyeTest::K(558.478087865323, 0, 620.458515360843,
|
||||
0, 560.506767351568, 381.939424848348,
|
||||
0, 0, 1);
|
||||
|
||||
const cv::Vec4d fisheyeTest::D(-0.0014613319981768, -0.00329861110580401, 0.00605760088590183, -0.00374209380722371);
|
||||
|
||||
const cv::Matx33d fisheyeTest::R ( 9.9756700084424932e-01, 6.9698277640183867e-02, 1.4929569991321144e-03,
|
||||
-6.9711825162322980e-02, 9.9748249845531767e-01, 1.2997180766418455e-02,
|
||||
-5.8331736398316541e-04,-1.3069635393884985e-02, 9.9991441852366736e-01);
|
||||
|
||||
const cv::Vec3d fisheyeTest::T(-9.9217369356044638e-02, 3.1741831972356663e-03, 1.8551007952921010e-04);
|
||||
|
||||
std::string fisheyeTest::combine(const std::string& _item1, const std::string& _item2)
|
||||
{
|
||||
std::string item1 = _item1, item2 = _item2;
|
||||
std::replace(item1.begin(), item1.end(), '\\', '/');
|
||||
std::replace(item2.begin(), item2.end(), '\\', '/');
|
||||
|
||||
if (item1.empty())
|
||||
return item2;
|
||||
|
||||
if (item2.empty())
|
||||
return item1;
|
||||
|
||||
char last = item1[item1.size()-1];
|
||||
return item1 + (last != '/' ? "/" : "") + item2;
|
||||
}
|
||||
|
||||
cv::Mat fisheyeTest::mergeRectification(const cv::Mat& l, const cv::Mat& r)
|
||||
{
|
||||
CV_Assert(l.type() == r.type() && l.size() == r.size());
|
||||
cv::Mat merged(l.rows, l.cols * 2, l.type());
|
||||
cv::Mat lpart = merged.colRange(0, l.cols);
|
||||
cv::Mat rpart = merged.colRange(l.cols, merged.cols);
|
||||
l.copyTo(lpart);
|
||||
r.copyTo(rpart);
|
||||
|
||||
for(int i = 0; i < l.rows; i+=20)
|
||||
cv::line(merged, cv::Point(0, i), cv::Point(merged.cols, i), CV_RGB(0, 255, 0));
|
||||
|
||||
return merged;
|
||||
}
|
||||
@@ -46,6 +46,15 @@ a unified access to all face recongition algorithms in OpenCV. ::
|
||||
|
||||
// Deserializes this object from a given cv::FileStorage.
|
||||
virtual void load(const FileStorage& fs) = 0;
|
||||
|
||||
// Sets additional information as pairs label - info.
|
||||
void setLabelsInfo(const std::map<int, string>& labelsInfo);
|
||||
|
||||
// Gets string information by label
|
||||
string getLabelInfo(const int &label);
|
||||
|
||||
// Gets labels by string
|
||||
vector<int> getLabelsByString(const string& str);
|
||||
};
|
||||
|
||||
|
||||
@@ -70,6 +79,8 @@ Moreover every :ocv:class:`FaceRecognizer` supports the:
|
||||
|
||||
* **Loading/Saving** the model state from/to a given XML or YAML.
|
||||
|
||||
* **Setting/Getting labels info**, that is storaged as a string. String labels info is useful for keeping names of the recognized people.
|
||||
|
||||
.. note:: When using the FaceRecognizer interface in combination with Python, please stick to Python 2. Some underlying scripts like create_csv will not work in other versions, like Python 3.
|
||||
|
||||
Setting the Thresholds
|
||||
@@ -293,6 +304,30 @@ to enable loading the model state. ``FaceRecognizer::load(FileStorage& fs)`` in
|
||||
turn gets called by ``FaceRecognizer::load(const string& filename)``, to ease
|
||||
saving a model.
|
||||
|
||||
FaceRecognizer::setLabelsInfo
|
||||
-----------------------------
|
||||
|
||||
Sets string information about labels into the model.
|
||||
.. ocv:function:: void FaceRecognizer::setLabelsInfo(const std::map<int, string>& labelsInfo)
|
||||
|
||||
Information about the label loads as a pair "label id - string info".
|
||||
|
||||
FaceRecognizer::getLabelInfo
|
||||
----------------------------
|
||||
|
||||
Gets string information by label.
|
||||
.. ocv:function:: string FaceRecognizer::getLabelInfo(const int &label)
|
||||
|
||||
If an unknown label id is provided or there is no label information assosiated with the specified label id the method returns an empty string.
|
||||
|
||||
FaceRecognizer::getLabelsByString
|
||||
---------------------------------
|
||||
Gets vector of labels by string.
|
||||
|
||||
.. ocv:function:: vector<int> FaceRecognizer::getLabelsByString(const string& str)
|
||||
|
||||
The function searches for the labels containing the specified substring in the associated string info.
|
||||
|
||||
createEigenFaceRecognizer
|
||||
-------------------------
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ Class for computing stereo correspondence using the variational matching algorit
|
||||
...
|
||||
};
|
||||
|
||||
The class implements the modified S. G. Kosov algorithm [Publication] that differs from the original one as follows:
|
||||
The class implements the modified S. G. Kosov algorithm [KTS09]_ that differs from the original one as follows:
|
||||
|
||||
* The automatic initialization of method's parameters is added.
|
||||
|
||||
@@ -48,6 +48,9 @@ The class implements the modified S. G. Kosov algorithm [Publication] that diffe
|
||||
|
||||
* The method of dynamic adaptation of method's parameters is not included.
|
||||
|
||||
.. [KTS09] Sergey Kosov, Thorsten Thormählen and Hans-Peter Seidel: Accurate real-time disparity estimation with variational methods. In: Advances in Visual Computing. Springer Berlin Heidelberg, 2009. 796-807.
|
||||
|
||||
|
||||
StereoVar::StereoVar
|
||||
--------------------------
|
||||
|
||||
|
||||
@@ -948,6 +948,14 @@ namespace cv
|
||||
// Deserializes this object from a given cv::FileStorage.
|
||||
virtual void load(const FileStorage& fs) = 0;
|
||||
|
||||
// Sets additional information as pairs label - info.
|
||||
void setLabelsInfo(const std::map<int, string>& labelsInfo);
|
||||
|
||||
// Gets string information by label
|
||||
string getLabelInfo(const int &label);
|
||||
|
||||
// Gets labels by string
|
||||
vector<int> getLabelsByString(const string& str);
|
||||
};
|
||||
|
||||
CV_EXPORTS_W Ptr<FaceRecognizer> createEigenFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
|
||||
|
||||
@@ -98,10 +98,84 @@ inline vector<_Tp> remove_dups(const vector<_Tp>& src) {
|
||||
return elems;
|
||||
}
|
||||
|
||||
// The FaceRecognizer2 class is introduced to keep the FaceRecognizer binary backward compatibility in 2.4
|
||||
// In master setLabelInfo/getLabelInfo/getLabelsByString should be virtual and _labelsInfo should be moved
|
||||
// to FaceRecognizer, that allows to avoid FaceRecognizer2 in master
|
||||
class FaceRecognizer2 : public FaceRecognizer
|
||||
{
|
||||
protected:
|
||||
// Stored pairs "label id - string info"
|
||||
std::map<int, string> _labelsInfo;
|
||||
|
||||
public:
|
||||
// Sets additional information as pairs label - info.
|
||||
virtual void setLabelsInfo(const std::map<int, string>& labelsInfo)
|
||||
{
|
||||
_labelsInfo = labelsInfo;
|
||||
}
|
||||
|
||||
// Gets string information by label
|
||||
virtual string getLabelInfo(int label) const
|
||||
{
|
||||
std::map<int, string>::const_iterator iter(_labelsInfo.find(label));
|
||||
return iter != _labelsInfo.end() ? iter->second : "";
|
||||
}
|
||||
|
||||
// Gets labels by string
|
||||
virtual vector<int> getLabelsByString(const string& str)
|
||||
{
|
||||
vector<int> labels;
|
||||
for(std::map<int,string>::const_iterator it = _labelsInfo.begin(); it != _labelsInfo.end(); it++)
|
||||
{
|
||||
size_t found = (it->second).find(str);
|
||||
if(found != string::npos)
|
||||
labels.push_back(it->first);
|
||||
}
|
||||
return labels;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Utility structure to load/save face label info (a pair of int and string) via FileStorage
|
||||
struct LabelInfo
|
||||
{
|
||||
LabelInfo():label(-1), value("") {}
|
||||
LabelInfo(int _label, const std::string &_value): label(_label), value(_value) {}
|
||||
int label;
|
||||
std::string value;
|
||||
void write(cv::FileStorage& fs) const
|
||||
{
|
||||
fs << "{" << "label" << label << "value" << value << "}";
|
||||
}
|
||||
void read(const cv::FileNode& node)
|
||||
{
|
||||
label = (int)node["label"];
|
||||
value = (std::string)node["value"];
|
||||
}
|
||||
std::ostream& operator<<(std::ostream& out)
|
||||
{
|
||||
out << "{ label = " << label << ", " << "value = " << value << "}";
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
static void write(cv::FileStorage& fs, const std::string&, const LabelInfo& x)
|
||||
{
|
||||
x.write(fs);
|
||||
}
|
||||
|
||||
static void read(const cv::FileNode& node, LabelInfo& x, const LabelInfo& default_value = LabelInfo())
|
||||
{
|
||||
if(node.empty())
|
||||
x = default_value;
|
||||
else
|
||||
x.read(node);
|
||||
}
|
||||
|
||||
|
||||
// Turk, M., and Pentland, A. "Eigenfaces for recognition.". Journal of
|
||||
// Cognitive Neuroscience 3 (1991), 71–86.
|
||||
class Eigenfaces : public FaceRecognizer
|
||||
class Eigenfaces : public FaceRecognizer2
|
||||
{
|
||||
private:
|
||||
int _num_components;
|
||||
@@ -154,7 +228,7 @@ public:
|
||||
// faces: Recognition using class specific linear projection.". IEEE
|
||||
// Transactions on Pattern Analysis and Machine Intelligence 19, 7 (1997),
|
||||
// 711–720.
|
||||
class Fisherfaces: public FaceRecognizer
|
||||
class Fisherfaces: public FaceRecognizer2
|
||||
{
|
||||
private:
|
||||
int _num_components;
|
||||
@@ -211,7 +285,7 @@ public:
|
||||
// patterns: Application to face recognition." IEEE Transactions on Pattern
|
||||
// Analysis and Machine Intelligence, 28(12):2037-2041.
|
||||
//
|
||||
class LBPH : public FaceRecognizer
|
||||
class LBPH : public FaceRecognizer2
|
||||
{
|
||||
private:
|
||||
int _grid_x;
|
||||
@@ -228,7 +302,6 @@ private:
|
||||
// old model data.
|
||||
void train(InputArrayOfArrays src, InputArray labels, bool preserveData);
|
||||
|
||||
|
||||
public:
|
||||
using FaceRecognizer::save;
|
||||
using FaceRecognizer::load;
|
||||
@@ -327,6 +400,27 @@ void FaceRecognizer::load(const string& filename) {
|
||||
fs.release();
|
||||
}
|
||||
|
||||
void FaceRecognizer::setLabelsInfo(const std::map<int, string>& labelsInfo)
|
||||
{
|
||||
FaceRecognizer2* base = dynamic_cast<FaceRecognizer2*>(this);
|
||||
CV_Assert(base != 0);
|
||||
base->setLabelsInfo(labelsInfo);
|
||||
}
|
||||
|
||||
string FaceRecognizer::getLabelInfo(const int &label)
|
||||
{
|
||||
FaceRecognizer2* base = dynamic_cast<FaceRecognizer2*>(this);
|
||||
CV_Assert(base != 0);
|
||||
return base->getLabelInfo(label);
|
||||
}
|
||||
|
||||
vector<int> FaceRecognizer::getLabelsByString(const string& str)
|
||||
{
|
||||
FaceRecognizer2* base = dynamic_cast<FaceRecognizer2*>(this);
|
||||
CV_Assert(base != 0);
|
||||
return base->getLabelsByString(str);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Eigenfaces
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -423,6 +517,17 @@ void Eigenfaces::load(const FileStorage& fs) {
|
||||
// read sequences
|
||||
readFileNodeList(fs["projections"], _projections);
|
||||
fs["labels"] >> _labels;
|
||||
const FileNode& fn = fs["labelsInfo"];
|
||||
if (fn.type() == FileNode::SEQ)
|
||||
{
|
||||
_labelsInfo.clear();
|
||||
for (FileNodeIterator it = fn.begin(); it != fn.end();)
|
||||
{
|
||||
LabelInfo item;
|
||||
it >> item;
|
||||
_labelsInfo.insert(std::make_pair(item.label, item.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Eigenfaces::save(FileStorage& fs) const {
|
||||
@@ -434,6 +539,10 @@ void Eigenfaces::save(FileStorage& fs) const {
|
||||
// write sequences
|
||||
writeFileNodeList(fs, "projections", _projections);
|
||||
fs << "labels" << _labels;
|
||||
fs << "labelsInfo" << "[";
|
||||
for (std::map<int, string>::const_iterator it = _labelsInfo.begin(); it != _labelsInfo.end(); it++)
|
||||
fs << LabelInfo(it->first, it->second);
|
||||
fs << "]";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -544,6 +653,17 @@ void Fisherfaces::load(const FileStorage& fs) {
|
||||
// read sequences
|
||||
readFileNodeList(fs["projections"], _projections);
|
||||
fs["labels"] >> _labels;
|
||||
const FileNode& fn = fs["labelsInfo"];
|
||||
if (fn.type() == FileNode::SEQ)
|
||||
{
|
||||
_labelsInfo.clear();
|
||||
for (FileNodeIterator it = fn.begin(); it != fn.end();)
|
||||
{
|
||||
LabelInfo item;
|
||||
it >> item;
|
||||
_labelsInfo.insert(std::make_pair(item.label, item.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See FaceRecognizer::save.
|
||||
@@ -556,6 +676,10 @@ void Fisherfaces::save(FileStorage& fs) const {
|
||||
// write sequences
|
||||
writeFileNodeList(fs, "projections", _projections);
|
||||
fs << "labels" << _labels;
|
||||
fs << "labelsInfo" << "[";
|
||||
for (std::map<int, string>::const_iterator it = _labelsInfo.begin(); it != _labelsInfo.end(); it++)
|
||||
fs << LabelInfo(it->first, it->second);
|
||||
fs << "]";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -743,6 +867,17 @@ void LBPH::load(const FileStorage& fs) {
|
||||
//read matrices
|
||||
readFileNodeList(fs["histograms"], _histograms);
|
||||
fs["labels"] >> _labels;
|
||||
const FileNode& fn = fs["labelsInfo"];
|
||||
if (fn.type() == FileNode::SEQ)
|
||||
{
|
||||
_labelsInfo.clear();
|
||||
for (FileNodeIterator it = fn.begin(); it != fn.end();)
|
||||
{
|
||||
LabelInfo item;
|
||||
it >> item;
|
||||
_labelsInfo.insert(std::make_pair(item.label, item.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See FaceRecognizer::save.
|
||||
@@ -754,6 +889,10 @@ void LBPH::save(FileStorage& fs) const {
|
||||
// write matrices
|
||||
writeFileNodeList(fs, "histograms", _histograms);
|
||||
fs << "labels" << _labels;
|
||||
fs << "labelsInfo" << "[";
|
||||
for (std::map<int, string>::const_iterator it = _labelsInfo.begin(); it != _labelsInfo.end(); it++)
|
||||
fs << LabelInfo(it->first, it->second);
|
||||
fs << "]";
|
||||
}
|
||||
|
||||
void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels) {
|
||||
@@ -849,7 +988,6 @@ int LBPH::predict(InputArray _src) const {
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
Ptr<FaceRecognizer> createEigenFaceRecognizer(int num_components, double threshold)
|
||||
{
|
||||
return new Eigenfaces(num_components, threshold);
|
||||
|
||||
@@ -1209,16 +1209,16 @@ private:
|
||||
|
||||
cv::TickMeter::TickMeter() { reset(); }
|
||||
int64 cv::TickMeter::getTimeTicks() const { return sumTime; }
|
||||
double cv::TickMeter::getTimeMicro() const { return (double)getTimeTicks()/cvGetTickFrequency(); }
|
||||
double cv::TickMeter::getTimeMilli() const { return getTimeMicro()*1e-3; }
|
||||
double cv::TickMeter::getTimeSec() const { return getTimeMilli()*1e-3; }
|
||||
double cv::TickMeter::getTimeSec() const { return (double)getTimeTicks()/getTickFrequency(); }
|
||||
double cv::TickMeter::getTimeMilli() const { return getTimeSec()*1e3; }
|
||||
double cv::TickMeter::getTimeMicro() const { return getTimeMilli()*1e3; }
|
||||
int64 cv::TickMeter::getCounter() const { return counter; }
|
||||
void cv::TickMeter::reset() {startTime = 0; sumTime = 0; counter = 0; }
|
||||
|
||||
void cv::TickMeter::start(){ startTime = cvGetTickCount(); }
|
||||
void cv::TickMeter::start(){ startTime = getTickCount(); }
|
||||
void cv::TickMeter::stop()
|
||||
{
|
||||
int64 time = cvGetTickCount();
|
||||
int64 time = getTickCount();
|
||||
if ( startTime == 0 )
|
||||
return;
|
||||
|
||||
|
||||
@@ -17,7 +17,15 @@ Finds centers of clusters and groups input samples around the clusters.
|
||||
|
||||
:param samples: Floating-point matrix of input samples, one row per sample.
|
||||
|
||||
:param data: Data for clustering.
|
||||
:param data: Data for clustering. An array of N-Dimensional points with float coordinates is needed. Examples of this array can be:
|
||||
|
||||
* ``Mat points(count, 2, CV_32F);``
|
||||
|
||||
* ``Mat points(count, 1, CV_32FC2);``
|
||||
|
||||
* ``Mat points(1, count, CV_32FC2);``
|
||||
|
||||
* ``std::vector<cv::Point2f> points(sampleCount);``
|
||||
|
||||
:param cluster_count: Number of clusters to split the set by.
|
||||
|
||||
|
||||
@@ -371,6 +371,36 @@ Draws a line segment connecting two points.
|
||||
The function ``line`` draws the line segment between ``pt1`` and ``pt2`` points in the image. The line is clipped by the image boundaries. For non-antialiased lines with integer coordinates, the 8-connected or 4-connected Bresenham algorithm is used. Thick lines are drawn with rounding endings.
|
||||
Antialiased lines are drawn using Gaussian filtering. To specify the line color, you may use the macro ``CV_RGB(r, g, b)`` .
|
||||
|
||||
arrowedLine
|
||||
----------------
|
||||
Draws a arrow segment pointing from the first point to the second one.
|
||||
|
||||
.. ocv:function:: void arrowedLine(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0, double tipLength=0.1)
|
||||
|
||||
:param img: Image.
|
||||
|
||||
:param pt1: The point the arrow starts from.
|
||||
|
||||
:param pt2: The point the arrow points to.
|
||||
|
||||
:param color: Line color.
|
||||
|
||||
:param thickness: Line thickness.
|
||||
|
||||
:param lineType: Type of the line:
|
||||
|
||||
* **8** (or omitted) - 8-connected line.
|
||||
|
||||
* **4** - 4-connected line.
|
||||
|
||||
* **CV_AA** - antialiased line.
|
||||
|
||||
:param shift: Number of fractional bits in the point coordinates.
|
||||
|
||||
:param tipLength: The length of the arrow tip in relation to the arrow length
|
||||
|
||||
The function ``arrowedLine`` draws an arrow between ``pt1`` and ``pt2`` points in the image. See also :ocv:func:`line`.
|
||||
|
||||
|
||||
LineIterator
|
||||
------------
|
||||
@@ -514,7 +544,7 @@ Draws a text string.
|
||||
:param font: ``CvFont`` structure initialized using :ocv:cfunc:`InitFont`.
|
||||
|
||||
:param fontFace: Font type. One of ``FONT_HERSHEY_SIMPLEX``, ``FONT_HERSHEY_PLAIN``, ``FONT_HERSHEY_DUPLEX``, ``FONT_HERSHEY_COMPLEX``, ``FONT_HERSHEY_TRIPLEX``, ``FONT_HERSHEY_COMPLEX_SMALL``, ``FONT_HERSHEY_SCRIPT_SIMPLEX``, or ``FONT_HERSHEY_SCRIPT_COMPLEX``,
|
||||
where each of the font ID's can be combined with ``FONT_HERSHEY_ITALIC`` to get the slanted letters.
|
||||
where each of the font ID's can be combined with ``FONT_ITALIC`` to get the slanted letters.
|
||||
|
||||
:param fontScale: Font scale factor that is multiplied by the font-specific base size.
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ Multi-channel (``n``-channel) types can be specified using the following options
|
||||
* ``CV_8UC1`` ... ``CV_64FC4`` constants (for a number of channels from 1 to 4)
|
||||
* ``CV_8UC(n)`` ... ``CV_64FC(n)`` or ``CV_MAKETYPE(CV_8U, n)`` ... ``CV_MAKETYPE(CV_64F, n)`` macros when the number of channels is more than 4 or unknown at the compilation time.
|
||||
|
||||
.. note:: ``CV_32FC1 == CV_32F``, ``CV_32FC2 == CV_32FC(2) == CV_MAKETYPE(CV_32F, 2)``, and ``CV_MAKETYPE(depth, n) == ((x&7)<<3) + (n-1)``. This means that the constant type is formed from the ``depth``, taking the lowest 3 bits, and the number of channels minus 1, taking the next ``log2(CV_CN_MAX)`` bits.
|
||||
.. note:: ``CV_32FC1 == CV_32F``, ``CV_32FC2 == CV_32FC(2) == CV_MAKETYPE(CV_32F, 2)``, and ``CV_MAKETYPE(depth, n) == (depth&7) + ((n-1)<<3)``. This means that the constant type is formed from the ``depth``, taking the lowest 3 bits, and the number of channels minus 1, taking the next ``log2(CV_CN_MAX)`` bits.
|
||||
|
||||
Examples: ::
|
||||
|
||||
|
||||
@@ -1252,11 +1252,12 @@ gemm
|
||||
----
|
||||
Performs generalized matrix multiplication.
|
||||
|
||||
.. ocv:function:: void gemm( InputArray src1, InputArray src2, double alpha, InputArray src3, double gamma, OutputArray dst, int flags=0 )
|
||||
.. ocv:function:: void gemm( InputArray src1, InputArray src2, double alpha, InputArray src3, double beta, OutputArray dst, int flags=0 )
|
||||
|
||||
.. ocv:pyfunction:: cv2.gemm(src1, src2, alpha, src3, gamma[, dst[, flags]]) -> dst
|
||||
.. ocv:pyfunction:: cv2.gemm(src1, src2, alpha, src3, beta[, dst[, flags]]) -> dst
|
||||
|
||||
.. ocv:cfunction:: void cvGEMM( const CvArr* src1, const CvArr* src2, double alpha, const CvArr* src3, double beta, CvArr* dst, int tABC=0)
|
||||
|
||||
.. ocv:pyoldfunction:: cv.GEMM(src1, src2, alpha, src3, beta, dst, tABC=0)-> None
|
||||
|
||||
:param src1: first multiplied input matrix that should have ``CV_32FC1``, ``CV_64FC1``, ``CV_32FC2``, or ``CV_64FC2`` type.
|
||||
|
||||
@@ -317,6 +317,7 @@ Returns true if the specified feature is supported by the host hardware.
|
||||
* ``CV_CPU_SSE4_2`` - SSE 4.2
|
||||
* ``CV_CPU_POPCNT`` - POPCOUNT
|
||||
* ``CV_CPU_AVX`` - AVX
|
||||
* ``CV_CPU_AVX2`` - AVX2
|
||||
|
||||
The function returns true if the host hardware supports the specified feature. When user calls ``setUseOptimized(false)``, the subsequent calls to ``checkHardwareSupport()`` will return false until ``setUseOptimized(true)`` is called. This way user can dynamically switch on and off the optimized code in OpenCV.
|
||||
|
||||
|
||||
@@ -284,6 +284,7 @@ CV_EXPORTS_W int64 getCPUTickCount();
|
||||
- CV_CPU_SSE4_2 - SSE 4.2
|
||||
- CV_CPU_POPCNT - POPCOUNT
|
||||
- CV_CPU_AVX - AVX
|
||||
- CV_CPU_AVX2 - AVX2
|
||||
|
||||
\note {Note that the function output is not static. Once you called cv::useOptimized(false),
|
||||
most of the hardware acceleration is disabled and thus the function will returns false,
|
||||
@@ -495,7 +496,7 @@ public:
|
||||
//! dot product computed in double-precision arithmetics
|
||||
double ddot(const Matx<_Tp, m, n>& v) const;
|
||||
|
||||
//! convertion to another data type
|
||||
//! conversion to another data type
|
||||
template<typename T2> operator Matx<T2, m, n>() const;
|
||||
|
||||
//! change the matrix shape
|
||||
@@ -636,7 +637,7 @@ public:
|
||||
For other dimensionalities the exception is raised
|
||||
*/
|
||||
Vec cross(const Vec& v) const;
|
||||
//! convertion to another data type
|
||||
//! conversion to another data type
|
||||
template<typename T2> operator Vec<T2, cn>() const;
|
||||
//! conversion to 4-element CvScalar.
|
||||
operator CvScalar() const;
|
||||
@@ -2319,7 +2320,7 @@ CV_EXPORTS_W void patchNaNs(InputOutputArray a, double val=0);
|
||||
|
||||
//! implements generalized matrix product algorithm GEMM from BLAS
|
||||
CV_EXPORTS_W void gemm(InputArray src1, InputArray src2, double alpha,
|
||||
InputArray src3, double gamma, OutputArray dst, int flags=0);
|
||||
InputArray src3, double beta, OutputArray dst, int flags=0);
|
||||
//! multiplies matrix by its transposition from the left or from the right
|
||||
CV_EXPORTS_W void mulTransposed( InputArray src, OutputArray dst, bool aTa,
|
||||
InputArray delta=noArray(),
|
||||
@@ -2590,6 +2591,10 @@ CV_EXPORTS_AS(randShuffle) void randShuffle_(InputOutputArray dst, double iterFa
|
||||
CV_EXPORTS_W void line(CV_IN_OUT Mat& img, Point pt1, Point pt2, const Scalar& color,
|
||||
int thickness=1, int lineType=8, int shift=0);
|
||||
|
||||
//! draws an arrow from pt1 to pt2 in the image
|
||||
CV_EXPORTS_W void arrowedLine(CV_IN_OUT Mat& img, Point pt1, Point pt2, const Scalar& color,
|
||||
int thickness=1, int line_type=8, int shift=0, double tipLength=0.1);
|
||||
|
||||
//! draws the rectangle outline or a solid rectangle with the opposite corners pt1 and pt2 in the image
|
||||
CV_EXPORTS_W void rectangle(CV_IN_OUT Mat& img, Point pt1, Point pt2,
|
||||
const Scalar& color, int thickness=1,
|
||||
|
||||
@@ -1107,7 +1107,7 @@ CV_INLINE CvSetElem* cvSetNew( CvSet* set_header )
|
||||
set_header->active_count++;
|
||||
}
|
||||
else
|
||||
cvSetAdd( set_header, NULL, (CvSetElem**)&elem );
|
||||
cvSetAdd( set_header, NULL, &elem );
|
||||
return elem;
|
||||
}
|
||||
|
||||
@@ -1706,6 +1706,7 @@ CVAPI(double) cvGetTickFrequency( void );
|
||||
#define CV_CPU_SSE4_2 7
|
||||
#define CV_CPU_POPCNT 8
|
||||
#define CV_CPU_AVX 10
|
||||
#define CV_CPU_AVX2 11
|
||||
#define CV_HARDWARE_MAX_FEATURE 255
|
||||
|
||||
CVAPI(int) cvCheckHardwareSupport(int feature);
|
||||
|
||||
@@ -97,6 +97,13 @@ CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
IppiSize size = { width, height };
|
||||
return size;
|
||||
}
|
||||
|
||||
CV_INLINE IppiSize ippiSize(const cv::Size & _size)
|
||||
{
|
||||
IppiSize size = { _size.width, _size.height };
|
||||
return size;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef IPPI_CALL
|
||||
@@ -134,6 +141,10 @@ CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
# define __xgetbv() 0
|
||||
# endif
|
||||
# endif
|
||||
# if defined __AVX2__
|
||||
# include <immintrin.h>
|
||||
# define CV_AVX2 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -169,6 +180,9 @@ CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
#ifndef CV_AVX
|
||||
# define CV_AVX 0
|
||||
#endif
|
||||
#ifndef CV_AVX2
|
||||
# define CV_AVX2 0
|
||||
#endif
|
||||
#ifndef CV_NEON
|
||||
# define CV_NEON 0
|
||||
#endif
|
||||
|
||||
@@ -366,7 +366,8 @@ inline void Mat::release()
|
||||
if( refcount && CV_XADD(refcount, -1) == 1 )
|
||||
deallocate();
|
||||
data = datastart = dataend = datalimit = 0;
|
||||
size.p[0] = 0;
|
||||
for(int i = 0; i < dims; i++)
|
||||
size.p[i] = 0;
|
||||
refcount = 0;
|
||||
}
|
||||
|
||||
@@ -683,6 +684,8 @@ template<typename _Tp> inline void Mat::push_back(const _Tp& elem)
|
||||
{
|
||||
if( !data )
|
||||
{
|
||||
CV_Assert((type()==0) || (DataType<_Tp>::type == type()));
|
||||
|
||||
*this = Mat(1, 1, DataType<_Tp>::type, (void*)&elem).clone();
|
||||
return;
|
||||
}
|
||||
@@ -2564,7 +2567,7 @@ SparseMatConstIterator_<_Tp>::operator ++()
|
||||
template<typename _Tp> inline SparseMatConstIterator_<_Tp>
|
||||
SparseMatConstIterator_<_Tp>::operator ++(int)
|
||||
{
|
||||
SparseMatConstIterator it = *this;
|
||||
SparseMatConstIterator_<_Tp> it = *this;
|
||||
SparseMatConstIterator::operator ++();
|
||||
return it;
|
||||
}
|
||||
@@ -2608,7 +2611,7 @@ SparseMatIterator_<_Tp>::operator ++()
|
||||
template<typename _Tp> inline SparseMatIterator_<_Tp>
|
||||
SparseMatIterator_<_Tp>::operator ++(int)
|
||||
{
|
||||
SparseMatIterator it = *this;
|
||||
SparseMatIterator_<_Tp> it = *this;
|
||||
SparseMatConstIterator::operator ++();
|
||||
return it;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
#define CV_XADD(addr,delta) _InterlockedExchangeAdd(const_cast<void*>(reinterpret_cast<volatile void*>(addr)), delta)
|
||||
#elif defined __GNUC__
|
||||
|
||||
#if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__
|
||||
#if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__)
|
||||
#ifdef __ATOMIC_SEQ_CST
|
||||
#define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), (delta), __ATOMIC_SEQ_CST)
|
||||
#else
|
||||
@@ -2625,12 +2625,15 @@ template<typename _Tp> inline Ptr<_Tp>::Ptr(const Ptr<_Tp>& _ptr)
|
||||
|
||||
template<typename _Tp> inline Ptr<_Tp>& Ptr<_Tp>::operator = (const Ptr<_Tp>& _ptr)
|
||||
{
|
||||
int* _refcount = _ptr.refcount;
|
||||
if( _refcount )
|
||||
CV_XADD(_refcount, 1);
|
||||
release();
|
||||
obj = _ptr.obj;
|
||||
refcount = _refcount;
|
||||
if (this != &_ptr)
|
||||
{
|
||||
int* _refcount = _ptr.refcount;
|
||||
if( _refcount )
|
||||
CV_XADD(_refcount, 1);
|
||||
release();
|
||||
obj = _ptr.obj;
|
||||
refcount = _refcount;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -790,7 +790,7 @@ CV_INLINE void cvmSet( CvMat* mat, int row, int col, double value )
|
||||
else
|
||||
{
|
||||
assert( type == CV_64FC1 );
|
||||
((double*)(void*)(mat->data.ptr + (size_t)mat->step*row))[col] = (double)value;
|
||||
((double*)(void*)(mat->data.ptr + (size_t)mat->step*row))[col] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
#define CV_VERSION_EPOCH 2
|
||||
#define CV_VERSION_MAJOR 4
|
||||
#define CV_VERSION_MINOR 9
|
||||
#define CV_VERSION_MINOR 10
|
||||
#define CV_VERSION_REVISION 0
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
|
||||
@@ -533,7 +533,7 @@ static void add8u( const uchar* src1, size_t step1,
|
||||
uchar* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
ippiAdd_8u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)sz, 0),
|
||||
ippiAdd_8u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0),
|
||||
(vBinOp8<uchar, OpAdd<uchar>, IF_SIMD(_VAdd8u)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -549,7 +549,7 @@ static void add16u( const ushort* src1, size_t step1,
|
||||
ushort* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
ippiAdd_16u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)sz, 0),
|
||||
ippiAdd_16u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0),
|
||||
(vBinOp16<ushort, OpAdd<ushort>, IF_SIMD(_VAdd16u)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -558,7 +558,7 @@ static void add16s( const short* src1, size_t step1,
|
||||
short* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
ippiAdd_16s_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)sz, 0),
|
||||
ippiAdd_16s_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0),
|
||||
(vBinOp16<short, OpAdd<short>, IF_SIMD(_VAdd16s)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -574,7 +574,7 @@ static void add32f( const float* src1, size_t step1,
|
||||
float* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
ippiAdd_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)sz),
|
||||
ippiAdd_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)),
|
||||
(vBinOp32f<OpAdd<float>, IF_SIMD(_VAdd32f)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -590,7 +590,7 @@ static void sub8u( const uchar* src1, size_t step1,
|
||||
uchar* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
ippiSub_8u_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, (IppiSize&)sz, 0),
|
||||
ippiSub_8u_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0),
|
||||
(vBinOp8<uchar, OpSub<uchar>, IF_SIMD(_VSub8u)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -606,7 +606,7 @@ static void sub16u( const ushort* src1, size_t step1,
|
||||
ushort* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
ippiSub_16u_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, (IppiSize&)sz, 0),
|
||||
ippiSub_16u_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0),
|
||||
(vBinOp16<ushort, OpSub<ushort>, IF_SIMD(_VSub16u)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ static void sub16s( const short* src1, size_t step1,
|
||||
short* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
ippiSub_16s_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, (IppiSize&)sz, 0),
|
||||
ippiSub_16s_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0),
|
||||
(vBinOp16<short, OpSub<short>, IF_SIMD(_VSub16s)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -631,7 +631,7 @@ static void sub32f( const float* src1, size_t step1,
|
||||
float* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
ippiSub_32f_C1R(src2, (int)step2, src1, (int)step1, dst, (int)step, (IppiSize&)sz),
|
||||
ippiSub_32f_C1R(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz)),
|
||||
(vBinOp32f<OpSub<float>, IF_SIMD(_VSub32f)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -668,7 +668,7 @@ static void max8u( const uchar* src1, size_t step1,
|
||||
#endif
|
||||
|
||||
// IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
// ippiMaxEvery_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (IppiSize&)sz),
|
||||
// ippiMaxEvery_8u_C1R(src1, (int)step1, src2, (int)step2, dst, ippiSize(sz)),
|
||||
// (vBinOp8<uchar, OpMax<uchar>, IF_SIMD(_VMax8u)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -702,7 +702,7 @@ static void max16u( const ushort* src1, size_t step1,
|
||||
#endif
|
||||
|
||||
// IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
// ippiMaxEvery_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (IppiSize&)sz),
|
||||
// ippiMaxEvery_16u_C1R(src1, (int)step1, src2, (int)step2, dst, ippiSize(sz)),
|
||||
// (vBinOp16<ushort, OpMax<ushort>, IF_SIMD(_VMax16u)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -742,7 +742,7 @@ static void max32f( const float* src1, size_t step1,
|
||||
vBinOp32f<OpMax<float>, IF_SIMD(_VMax32f)>(src1, step1, src2, step2, dst, step, sz);
|
||||
#endif
|
||||
// IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
// ippiMaxEvery_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (IppiSize&)sz),
|
||||
// ippiMaxEvery_32f_C1R(src1, (int)step1, src2, (int)step2, dst, ippiSize(sz)),
|
||||
// (vBinOp32f<OpMax<float>, IF_SIMD(_VMax32f)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -776,7 +776,7 @@ static void min8u( const uchar* src1, size_t step1,
|
||||
#endif
|
||||
|
||||
// IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
// ippiMinEvery_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (IppiSize&)sz),
|
||||
// ippiMinEvery_8u_C1R(src1, (int)step1, src2, (int)step2, dst, ippiSize(sz)),
|
||||
// (vBinOp8<uchar, OpMin<uchar>, IF_SIMD(_VMin8u)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -810,7 +810,7 @@ static void min16u( const ushort* src1, size_t step1,
|
||||
#endif
|
||||
|
||||
// IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
// ippiMinEvery_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (IppiSize&)sz),
|
||||
// ippiMinEvery_16u_C1R(src1, (int)step1, src2, (int)step2, dst, ippiSize(sz)),
|
||||
// (vBinOp16<ushort, OpMin<ushort>, IF_SIMD(_VMin16u)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -850,7 +850,7 @@ static void min32f( const float* src1, size_t step1,
|
||||
vBinOp32f<OpMin<float>, IF_SIMD(_VMin32f)>(src1, step1, src2, step2, dst, step, sz);
|
||||
#endif
|
||||
// IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
// ippiMinEvery_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (IppiSize&)sz),
|
||||
// ippiMinEvery_32f_C1R(src1, (int)step1, src2, (int)step2, dst, ippiSize(sz)),
|
||||
// (vBinOp32f<OpMin<float>, IF_SIMD(_VMin32f)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -866,7 +866,7 @@ static void absdiff8u( const uchar* src1, size_t step1,
|
||||
uchar* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
ippiAbsDiff_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)sz),
|
||||
ippiAbsDiff_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)),
|
||||
(vBinOp8<uchar, OpAbsDiff<uchar>, IF_SIMD(_VAbsDiff8u)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -882,7 +882,7 @@ static void absdiff16u( const ushort* src1, size_t step1,
|
||||
ushort* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
ippiAbsDiff_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)sz),
|
||||
ippiAbsDiff_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)),
|
||||
(vBinOp16<ushort, OpAbsDiff<ushort>, IF_SIMD(_VAbsDiff16u)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -905,7 +905,7 @@ static void absdiff32f( const float* src1, size_t step1,
|
||||
float* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
ippiAbsDiff_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)sz),
|
||||
ippiAbsDiff_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)),
|
||||
(vBinOp32f<OpAbsDiff<float>, IF_SIMD(_VAbsDiff32f)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -922,7 +922,7 @@ static void and8u( const uchar* src1, size_t step1,
|
||||
uchar* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
ippiAnd_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)sz),
|
||||
ippiAnd_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)),
|
||||
(vBinOp8<uchar, OpAnd<uchar>, IF_SIMD(_VAnd8u)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -931,7 +931,7 @@ static void or8u( const uchar* src1, size_t step1,
|
||||
uchar* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
ippiOr_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)sz),
|
||||
ippiOr_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)),
|
||||
(vBinOp8<uchar, OpOr<uchar>, IF_SIMD(_VOr8u)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -940,7 +940,7 @@ static void xor8u( const uchar* src1, size_t step1,
|
||||
uchar* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step);
|
||||
ippiXor_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)sz),
|
||||
ippiXor_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)),
|
||||
(vBinOp8<uchar, OpXor<uchar>, IF_SIMD(_VXor8u)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -948,8 +948,8 @@ static void not8u( const uchar* src1, size_t step1,
|
||||
const uchar* src2, size_t step2,
|
||||
uchar* dst, size_t step, Size sz, void* )
|
||||
{
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step); (void *)src2;
|
||||
ippiNot_8u_C1R(src1, (int)step1, dst, (int)step, (IppiSize&)sz),
|
||||
IF_IPP(fixSteps(sz, sizeof(dst[0]), step1, step2, step); (void)src2;
|
||||
ippiNot_8u_C1R(src1, (int)step1, dst, (int)step, ippiSize(sz)),
|
||||
(vBinOp8<uchar, OpNot<uchar>, IF_SIMD(_VNot8u)>(src1, step1, src2, step2, dst, step, sz)));
|
||||
}
|
||||
|
||||
@@ -1553,39 +1553,60 @@ void cv::add( InputArray src1, InputArray src2, OutputArray dst,
|
||||
arithm_op(src1, src2, dst, mask, dtype, getAddTab() );
|
||||
}
|
||||
|
||||
void cv::subtract( InputArray src1, InputArray src2, OutputArray dst,
|
||||
void cv::subtract( InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
InputArray mask, int dtype )
|
||||
{
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
if (mask.empty() && src1.depth() == CV_8U && src2.depth() == CV_8U)
|
||||
{
|
||||
if (dtype == -1 && dst.fixedType())
|
||||
dtype = dst.depth();
|
||||
int kind1 = _src1.kind(), kind2 = _src2.kind();
|
||||
Mat src1 = _src1.getMat(), src2 = _src2.getMat();
|
||||
bool src1Scalar = checkScalar(src1, _src2.type(), kind1, kind2);
|
||||
bool src2Scalar = checkScalar(src2, _src1.type(), kind2, kind1);
|
||||
|
||||
if (!dst.fixedType() || dtype == dst.depth())
|
||||
if (!src1Scalar && !src2Scalar &&
|
||||
src1.depth() == CV_8U && src2.type() == src1.type() &&
|
||||
src1.dims == 2 && src2.size() == src1.size() &&
|
||||
mask.empty())
|
||||
{
|
||||
if (dtype < 0)
|
||||
{
|
||||
if (_dst.fixedType())
|
||||
{
|
||||
dtype = _dst.depth();
|
||||
}
|
||||
else
|
||||
{
|
||||
dtype = src1.depth();
|
||||
}
|
||||
}
|
||||
|
||||
dtype = CV_MAT_DEPTH(dtype);
|
||||
|
||||
if (!_dst.fixedType() || dtype == _dst.depth())
|
||||
{
|
||||
_dst.create(src1.size(), CV_MAKE_TYPE(dtype, src1.channels()));
|
||||
|
||||
if (dtype == CV_16S)
|
||||
{
|
||||
Mat _dst = dst.getMat();
|
||||
if(tegra::subtract_8u8u16s(src1.getMat(), src2.getMat(), _dst))
|
||||
Mat dst = _dst.getMat();
|
||||
if(tegra::subtract_8u8u16s(src1, src2, dst))
|
||||
return;
|
||||
}
|
||||
else if (dtype == CV_32F)
|
||||
{
|
||||
Mat _dst = dst.getMat();
|
||||
if(tegra::subtract_8u8u32f(src1.getMat(), src2.getMat(), _dst))
|
||||
Mat dst = _dst.getMat();
|
||||
if(tegra::subtract_8u8u32f(src1, src2, dst))
|
||||
return;
|
||||
}
|
||||
else if (dtype == CV_8S)
|
||||
{
|
||||
Mat _dst = dst.getMat();
|
||||
if(tegra::subtract_8u8u8s(src1.getMat(), src2.getMat(), _dst))
|
||||
Mat dst = _dst.getMat();
|
||||
if(tegra::subtract_8u8u8s(src1, src2, dst))
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
arithm_op(src1, src2, dst, mask, dtype, getSubTab() );
|
||||
arithm_op(_src1, _src2, _dst, mask, dtype, getSubTab() );
|
||||
}
|
||||
|
||||
void cv::absdiff( InputArray src1, InputArray src2, OutputArray dst )
|
||||
@@ -2184,7 +2205,7 @@ static void cmp8u(const uchar* src1, size_t step1, const uchar* src2, size_t ste
|
||||
if( op >= 0 )
|
||||
{
|
||||
fixSteps(size, sizeof(dst[0]), step1, step2, step);
|
||||
if( ippiCompare_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)size, op) >= 0 )
|
||||
if( ippiCompare_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op) >= 0 )
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -2267,7 +2288,7 @@ static void cmp16u(const ushort* src1, size_t step1, const ushort* src2, size_t
|
||||
if( op >= 0 )
|
||||
{
|
||||
fixSteps(size, sizeof(dst[0]), step1, step2, step);
|
||||
if( ippiCompare_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)size, op) >= 0 )
|
||||
if( ippiCompare_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op) >= 0 )
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -2282,7 +2303,7 @@ static void cmp16s(const short* src1, size_t step1, const short* src2, size_t st
|
||||
if( op > 0 )
|
||||
{
|
||||
fixSteps(size, sizeof(dst[0]), step1, step2, step);
|
||||
if( ippiCompare_16s_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)size, op) >= 0 )
|
||||
if( ippiCompare_16s_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op) >= 0 )
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -2388,7 +2409,7 @@ static void cmp32f(const float* src1, size_t step1, const float* src2, size_t st
|
||||
if( op >= 0 )
|
||||
{
|
||||
fixSteps(size, sizeof(dst[0]), step1, step2, step);
|
||||
if( ippiCompare_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)size, op) >= 0 )
|
||||
if( ippiCompare_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op) >= 0 )
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1580,6 +1580,25 @@ void line( Mat& img, Point pt1, Point pt2, const Scalar& color,
|
||||
ThickLine( img, pt1, pt2, buf, thickness, line_type, 3, shift );
|
||||
}
|
||||
|
||||
void arrowedLine(Mat& img, Point pt1, Point pt2, const Scalar& color,
|
||||
int thickness, int line_type, int shift, double tipLength)
|
||||
{
|
||||
const double tipSize = norm(pt1-pt2)*tipLength;// Factor to normalize the size of the tip depending on the length of the arrow
|
||||
|
||||
line(img, pt1, pt2, color, thickness, line_type, shift);
|
||||
|
||||
const double angle = atan2( (double) pt1.y - pt2.y, (double) pt1.x - pt2.x );
|
||||
|
||||
Point p(cvRound(pt2.x + tipSize * cos(angle + CV_PI / 4)),
|
||||
cvRound(pt2.y + tipSize * sin(angle + CV_PI / 4)));
|
||||
line(img, p, pt2, color, thickness, line_type, shift);
|
||||
|
||||
p.x = cvRound(pt2.x + tipSize * cos(angle - CV_PI / 4));
|
||||
p.y = cvRound(pt2.y + tipSize * sin(angle - CV_PI / 4));
|
||||
line(img, p, pt2, color, thickness, line_type, shift);
|
||||
|
||||
}
|
||||
|
||||
void rectangle( Mat& img, Point pt1, Point pt2,
|
||||
const Scalar& color, int thickness,
|
||||
int lineType, int shift )
|
||||
|
||||
@@ -1013,6 +1013,7 @@ void cv::gemm( InputArray matA, InputArray matB, double alpha,
|
||||
GEMMBlockMulFunc blockMulFunc;
|
||||
GEMMStoreFunc storeFunc;
|
||||
Mat *matD = &D, tmat;
|
||||
int tmat_size = 0;
|
||||
const uchar* Cdata = C.data;
|
||||
size_t Cstep = C.data ? (size_t)C.step : 0;
|
||||
AutoBuffer<uchar> buf;
|
||||
@@ -1045,8 +1046,8 @@ void cv::gemm( InputArray matA, InputArray matB, double alpha,
|
||||
|
||||
if( D.data == A.data || D.data == B.data )
|
||||
{
|
||||
buf.allocate(d_size.width*d_size.height*CV_ELEM_SIZE(type));
|
||||
tmat = Mat(d_size.height, d_size.width, type, (uchar*)buf );
|
||||
tmat_size = d_size.width*d_size.height*CV_ELEM_SIZE(type);
|
||||
// Allocate tmat later, once the size of buf is known
|
||||
matD = &tmat;
|
||||
}
|
||||
|
||||
@@ -1123,6 +1124,10 @@ void cv::gemm( InputArray matA, InputArray matB, double alpha,
|
||||
(d_size.width <= block_lin_size &&
|
||||
d_size.height <= block_lin_size && len <= block_lin_size) )
|
||||
{
|
||||
if( tmat_size > 0 ) {
|
||||
buf.allocate(tmat_size);
|
||||
tmat = Mat(d_size.height, d_size.width, type, (uchar*)buf );
|
||||
}
|
||||
singleMulFunc( A.data, A.step, B.data, b_step, Cdata, Cstep,
|
||||
matD->data, matD->step, a_size, d_size, alpha, beta, flags );
|
||||
}
|
||||
@@ -1182,12 +1187,14 @@ void cv::gemm( InputArray matA, InputArray matB, double alpha,
|
||||
flags &= ~GEMM_1_T;
|
||||
}
|
||||
|
||||
buf.allocate(a_buf_size + b_buf_size + d_buf_size);
|
||||
buf.allocate(d_buf_size + b_buf_size + a_buf_size + tmat_size);
|
||||
d_buf = (uchar*)buf;
|
||||
b_buf = d_buf + d_buf_size;
|
||||
|
||||
if( is_a_t )
|
||||
a_buf = b_buf + b_buf_size;
|
||||
if( tmat_size > 0 )
|
||||
tmat = Mat(d_size.height, d_size.width, type, b_buf + b_buf_size + a_buf_size );
|
||||
|
||||
for( i = 0; i < d_size.height; i += di )
|
||||
{
|
||||
|
||||
@@ -200,9 +200,14 @@ public:
|
||||
void multiply(const MatExpr& e, double s, MatExpr& res) const;
|
||||
|
||||
static void makeExpr(MatExpr& res, int method, Size sz, int type, double alpha=1);
|
||||
static void makeExpr(MatExpr& res, int method, int ndims, const int* sizes, int type, double alpha=1);
|
||||
};
|
||||
|
||||
static MatOp_Initializer g_MatOp_Initializer;
|
||||
static MatOp_Initializer* getGlobalMatOpInitializer()
|
||||
{
|
||||
static MatOp_Initializer initializer;
|
||||
return &initializer;
|
||||
}
|
||||
|
||||
static inline bool isIdentity(const MatExpr& e) { return e.op == &g_MatOp_Identity; }
|
||||
static inline bool isAddEx(const MatExpr& e) { return e.op == &g_MatOp_AddEx; }
|
||||
@@ -215,7 +220,7 @@ static inline bool isInv(const MatExpr& e) { return e.op == &g_MatOp_Invert; }
|
||||
static inline bool isSolve(const MatExpr& e) { return e.op == &g_MatOp_Solve; }
|
||||
static inline bool isGEMM(const MatExpr& e) { return e.op == &g_MatOp_GEMM; }
|
||||
static inline bool isMatProd(const MatExpr& e) { return e.op == &g_MatOp_GEMM && (!e.c.data || e.beta == 0); }
|
||||
static inline bool isInitializer(const MatExpr& e) { return e.op == &g_MatOp_Initializer; }
|
||||
static inline bool isInitializer(const MatExpr& e) { return e.op == getGlobalMatOpInitializer(); }
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1038,14 +1043,14 @@ MatExpr min(const Mat& a, const Mat& b)
|
||||
MatExpr min(const Mat& a, double s)
|
||||
{
|
||||
MatExpr e;
|
||||
MatOp_Bin::makeExpr(e, 'm', a, s);
|
||||
MatOp_Bin::makeExpr(e, 'n', a, s);
|
||||
return e;
|
||||
}
|
||||
|
||||
MatExpr min(double s, const Mat& a)
|
||||
{
|
||||
MatExpr e;
|
||||
MatOp_Bin::makeExpr(e, 'm', a, s);
|
||||
MatOp_Bin::makeExpr(e, 'n', a, s);
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -1059,14 +1064,14 @@ MatExpr max(const Mat& a, const Mat& b)
|
||||
MatExpr max(const Mat& a, double s)
|
||||
{
|
||||
MatExpr e;
|
||||
MatOp_Bin::makeExpr(e, 'M', a, s);
|
||||
MatOp_Bin::makeExpr(e, 'N', a, s);
|
||||
return e;
|
||||
}
|
||||
|
||||
MatExpr max(double s, const Mat& a)
|
||||
{
|
||||
MatExpr e;
|
||||
MatOp_Bin::makeExpr(e, 'M', a, s);
|
||||
MatOp_Bin::makeExpr(e, 'N', a, s);
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -1332,13 +1337,13 @@ void MatOp_Bin::assign(const MatExpr& e, Mat& m, int _type) const
|
||||
bitwise_xor(e.a, e.s, dst);
|
||||
else if( e.flags == '~' && !e.b.data )
|
||||
bitwise_not(e.a, dst);
|
||||
else if( e.flags == 'm' && e.b.data )
|
||||
else if( e.flags == 'm' )
|
||||
cv::min(e.a, e.b, dst);
|
||||
else if( e.flags == 'm' && !e.b.data )
|
||||
else if( e.flags == 'n' )
|
||||
cv::min(e.a, e.s[0], dst);
|
||||
else if( e.flags == 'M' && e.b.data )
|
||||
else if( e.flags == 'M' )
|
||||
cv::max(e.a, e.b, dst);
|
||||
else if( e.flags == 'M' && !e.b.data )
|
||||
else if( e.flags == 'N' )
|
||||
cv::max(e.a, e.s[0], dst);
|
||||
else if( e.flags == 'a' && e.b.data )
|
||||
cv::absdiff(e.a, e.b, dst);
|
||||
@@ -1551,8 +1556,13 @@ void MatOp_Initializer::assign(const MatExpr& e, Mat& m, int _type) const
|
||||
{
|
||||
if( _type == -1 )
|
||||
_type = e.a.type();
|
||||
m.create(e.a.size(), _type);
|
||||
if( e.flags == 'I' )
|
||||
|
||||
if( e.a.dims <= 2 )
|
||||
m.create(e.a.size(), _type);
|
||||
else
|
||||
m.create(e.a.dims, e.a.size, _type);
|
||||
|
||||
if( e.flags == 'I' && e.a.dims <= 2 )
|
||||
setIdentity(m, Scalar(e.alpha));
|
||||
else if( e.flags == '0' )
|
||||
m = Scalar();
|
||||
@@ -1570,9 +1580,15 @@ void MatOp_Initializer::multiply(const MatExpr& e, double s, MatExpr& res) const
|
||||
|
||||
inline void MatOp_Initializer::makeExpr(MatExpr& res, int method, Size sz, int type, double alpha)
|
||||
{
|
||||
res = MatExpr(&g_MatOp_Initializer, method, Mat(sz, type, (void*)0), Mat(), Mat(), alpha, 0);
|
||||
res = MatExpr(getGlobalMatOpInitializer(), method, Mat(sz, type, (void*)0), Mat(), Mat(), alpha, 0);
|
||||
}
|
||||
|
||||
inline void MatOp_Initializer::makeExpr(MatExpr& res, int method, int ndims, const int* sizes, int type, double alpha)
|
||||
{
|
||||
res = MatExpr(getGlobalMatOpInitializer(), method, Mat(ndims, sizes, type, (void*)0), Mat(), Mat(), alpha, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1632,6 +1648,20 @@ MatExpr Mat::ones(Size size, int type)
|
||||
return e;
|
||||
}
|
||||
|
||||
MatExpr Mat::zeros(int ndims, const int* sizes, int type)
|
||||
{
|
||||
MatExpr e;
|
||||
MatOp_Initializer::makeExpr(e, '0', ndims, sizes, type);
|
||||
return e;
|
||||
}
|
||||
|
||||
MatExpr Mat::ones(int ndims, const int* sizes, int type)
|
||||
{
|
||||
MatExpr e;
|
||||
MatOp_Initializer::makeExpr(e, '1', ndims, sizes, type);
|
||||
return e;
|
||||
}
|
||||
|
||||
MatExpr Mat::eye(int rows, int cols, int type)
|
||||
{
|
||||
MatExpr e;
|
||||
|
||||
@@ -2691,16 +2691,18 @@ double cv::kmeans( InputArray _data, int K,
|
||||
int flags, OutputArray _centers )
|
||||
{
|
||||
const int SPP_TRIALS = 3;
|
||||
Mat data = _data.getMat();
|
||||
bool isrow = data.rows == 1 && data.channels() > 1;
|
||||
int N = !isrow ? data.rows : data.cols;
|
||||
int dims = (!isrow ? data.cols : 1)*data.channels();
|
||||
int type = data.depth();
|
||||
Mat data0 = _data.getMat();
|
||||
bool isrow = data0.rows == 1 && data0.channels() > 1;
|
||||
int N = !isrow ? data0.rows : data0.cols;
|
||||
int dims = (!isrow ? data0.cols : 1)*data0.channels();
|
||||
int type = data0.depth();
|
||||
|
||||
attempts = std::max(attempts, 1);
|
||||
CV_Assert( data.dims <= 2 && type == CV_32F && K > 0 );
|
||||
CV_Assert( data0.dims <= 2 && type == CV_32F && K > 0 );
|
||||
CV_Assert( N >= K );
|
||||
|
||||
Mat data(N, dims, CV_32F, data0.data, isrow ? dims * sizeof(float) : static_cast<size_t>(data0.step));
|
||||
|
||||
_bestLabels.create(N, 1, CV_32S, -1, true);
|
||||
|
||||
Mat _labels, best_labels = _bestLabels.getMat();
|
||||
|
||||
@@ -728,10 +728,10 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
|
||||
dcn_stddev = (int)stddev.total();
|
||||
pstddev = (Ipp64f *)stddev.data;
|
||||
}
|
||||
for( int k = cn; k < dcn_mean; k++ )
|
||||
pmean[k] = 0;
|
||||
for( int k = cn; k < dcn_stddev; k++ )
|
||||
pstddev[k] = 0;
|
||||
for( int c = cn; c < dcn_mean; c++ )
|
||||
pmean[c] = 0;
|
||||
for( int c = cn; c < dcn_stddev; c++ )
|
||||
pstddev[c] = 0;
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src.type();
|
||||
if( !mask.empty() )
|
||||
@@ -2463,14 +2463,14 @@ struct BatchDistInvoker : public ParallelLoopBody
|
||||
}
|
||||
|
||||
void cv::batchDistance( InputArray _src1, InputArray _src2,
|
||||
OutputArray _dist, int dtype, OutputArray _nidx,
|
||||
int normType, int K, InputArray _mask,
|
||||
int update, bool crosscheck )
|
||||
OutputArray _dist, int dtype, OutputArray _nidx,
|
||||
int normType, int K, InputArray _mask,
|
||||
int update, bool crosscheck )
|
||||
{
|
||||
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat();
|
||||
int type = src1.type();
|
||||
CV_Assert( type == src2.type() && src1.cols == src2.cols &&
|
||||
(type == CV_32F || type == CV_8U));
|
||||
(type == CV_32F || type == CV_8U));
|
||||
CV_Assert( _nidx.needed() == (K > 0) );
|
||||
|
||||
if( dtype == -1 )
|
||||
|
||||
@@ -253,6 +253,39 @@ struct HWFeatures
|
||||
f.have[CV_CPU_AVX] = (((cpuid_data[2] & (1<<28)) != 0)&&((cpuid_data[2] & (1<<27)) != 0));//OS uses XSAVE_XRSTORE and CPU support AVX
|
||||
}
|
||||
|
||||
#if defined _MSC_VER && (defined _M_IX86 || defined _M_X64)
|
||||
__cpuidex(cpuid_data, 7, 0);
|
||||
#elif defined __GNUC__ && (defined __i386__ || defined __x86_64__)
|
||||
#ifdef __x86_64__
|
||||
asm __volatile__
|
||||
(
|
||||
"movl $7, %%eax\n\t"
|
||||
"movl $0, %%ecx\n\t"
|
||||
"cpuid\n\t"
|
||||
:[eax]"=a"(cpuid_data[0]),[ebx]"=b"(cpuid_data[1]),[ecx]"=c"(cpuid_data[2]),[edx]"=d"(cpuid_data[3])
|
||||
:
|
||||
: "cc"
|
||||
);
|
||||
#else
|
||||
asm volatile
|
||||
(
|
||||
"pushl %%ebx\n\t"
|
||||
"movl $7,%%eax\n\t"
|
||||
"movl $0,%%ecx\n\t"
|
||||
"cpuid\n\t"
|
||||
"popl %%ebx\n\t"
|
||||
: "=a"(cpuid_data[0]), "=b"(cpuid_data[1]), "=c"(cpuid_data[2]), "=d"(cpuid_data[3])
|
||||
:
|
||||
: "cc"
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if( f.x86_family >= 6 )
|
||||
{
|
||||
f.have[CV_CPU_AVX2] = (cpuid_data[1] & (1<<5)) != 0;
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
@@ -423,27 +456,23 @@ string format( const char* fmt, ... )
|
||||
|
||||
string tempfile( const char* suffix )
|
||||
{
|
||||
#ifdef HAVE_WINRT
|
||||
std::wstring temp_dir = L"";
|
||||
const wchar_t* opencv_temp_dir = _wgetenv(L"OPENCV_TEMP_PATH");
|
||||
if (opencv_temp_dir)
|
||||
temp_dir = std::wstring(opencv_temp_dir);
|
||||
#else
|
||||
string fname;
|
||||
#ifndef HAVE_WINRT
|
||||
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
|
||||
#endif
|
||||
string fname;
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
#ifdef HAVE_WINRT
|
||||
RoInitialize(RO_INIT_MULTITHREADED);
|
||||
std::wstring temp_dir2;
|
||||
if (temp_dir.empty())
|
||||
temp_dir = GetTempPathWinRT();
|
||||
std::wstring temp_dir = L"";
|
||||
const wchar_t* opencv_temp_dir = GetTempPathWinRT().c_str();
|
||||
if (opencv_temp_dir)
|
||||
temp_dir = std::wstring(opencv_temp_dir);
|
||||
|
||||
std::wstring temp_file;
|
||||
temp_file = GetTempFileNameWinRT(L"ocv");
|
||||
if (temp_file.empty())
|
||||
return std::string();
|
||||
return string();
|
||||
|
||||
temp_file = temp_dir + std::wstring(L"\\") + temp_file;
|
||||
DeleteFileW(temp_file.c_str());
|
||||
@@ -451,7 +480,7 @@ string tempfile( const char* suffix )
|
||||
char aname[MAX_PATH];
|
||||
size_t copied = wcstombs(aname, temp_file.c_str(), MAX_PATH);
|
||||
CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
|
||||
fname = std::string(aname);
|
||||
fname = string(aname);
|
||||
RoUninitialize();
|
||||
#else
|
||||
char temp_dir2[MAX_PATH] = { 0 };
|
||||
|
||||
@@ -1579,3 +1579,216 @@ TEST_P(Mul1, One)
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Arithm, Mul1, testing::Values(Size(2, 2), Size(1, 1)));
|
||||
|
||||
class SubtractOutputMatNotEmpty : public testing::TestWithParam< std::tr1::tuple<cv::Size, perf::MatType, perf::MatDepth, bool> >
|
||||
{
|
||||
public:
|
||||
cv::Size size;
|
||||
int src_type;
|
||||
int dst_depth;
|
||||
bool fixed;
|
||||
|
||||
void SetUp()
|
||||
{
|
||||
size = std::tr1::get<0>(GetParam());
|
||||
src_type = std::tr1::get<1>(GetParam());
|
||||
dst_depth = std::tr1::get<2>(GetParam());
|
||||
fixed = std::tr1::get<3>(GetParam());
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(SubtractOutputMatNotEmpty, Mat_Mat)
|
||||
{
|
||||
cv::Mat src1(size, src_type, cv::Scalar::all(16));
|
||||
cv::Mat src2(size, src_type, cv::Scalar::all(16));
|
||||
|
||||
cv::Mat dst;
|
||||
|
||||
if (!fixed)
|
||||
{
|
||||
cv::subtract(src1, src2, dst, cv::noArray(), dst_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > 0 ? dst_depth : CV_16S), src1.channels()));
|
||||
cv::subtract(src1, src2, fixed_dst, cv::noArray(), dst_depth);
|
||||
dst = fixed_dst;
|
||||
dst_depth = fixed_dst.depth();
|
||||
}
|
||||
|
||||
ASSERT_FALSE(dst.empty());
|
||||
ASSERT_EQ(src1.size(), dst.size());
|
||||
ASSERT_EQ(dst_depth > 0 ? dst_depth : src1.depth(), dst.depth());
|
||||
ASSERT_EQ(0, cv::countNonZero(dst.reshape(1)));
|
||||
}
|
||||
|
||||
TEST_P(SubtractOutputMatNotEmpty, Mat_Mat_WithMask)
|
||||
{
|
||||
cv::Mat src1(size, src_type, cv::Scalar::all(16));
|
||||
cv::Mat src2(size, src_type, cv::Scalar::all(16));
|
||||
cv::Mat mask(size, CV_8UC1, cv::Scalar::all(255));
|
||||
|
||||
cv::Mat dst;
|
||||
|
||||
if (!fixed)
|
||||
{
|
||||
cv::subtract(src1, src2, dst, mask, dst_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > 0 ? dst_depth : CV_16S), src1.channels()));
|
||||
cv::subtract(src1, src2, fixed_dst, mask, dst_depth);
|
||||
dst = fixed_dst;
|
||||
dst_depth = fixed_dst.depth();
|
||||
}
|
||||
|
||||
ASSERT_FALSE(dst.empty());
|
||||
ASSERT_EQ(src1.size(), dst.size());
|
||||
ASSERT_EQ(dst_depth > 0 ? dst_depth : src1.depth(), dst.depth());
|
||||
ASSERT_EQ(0, cv::countNonZero(dst.reshape(1)));
|
||||
}
|
||||
|
||||
TEST_P(SubtractOutputMatNotEmpty, Mat_Mat_Expr)
|
||||
{
|
||||
cv::Mat src1(size, src_type, cv::Scalar::all(16));
|
||||
cv::Mat src2(size, src_type, cv::Scalar::all(16));
|
||||
|
||||
cv::Mat dst = src1 - src2;
|
||||
|
||||
ASSERT_FALSE(dst.empty());
|
||||
ASSERT_EQ(src1.size(), dst.size());
|
||||
ASSERT_EQ(src1.depth(), dst.depth());
|
||||
ASSERT_EQ(0, cv::countNonZero(dst.reshape(1)));
|
||||
}
|
||||
|
||||
TEST_P(SubtractOutputMatNotEmpty, Mat_Scalar)
|
||||
{
|
||||
cv::Mat src(size, src_type, cv::Scalar::all(16));
|
||||
|
||||
cv::Mat dst;
|
||||
|
||||
if (!fixed)
|
||||
{
|
||||
cv::subtract(src, cv::Scalar::all(16), dst, cv::noArray(), dst_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > 0 ? dst_depth : CV_16S), src.channels()));
|
||||
cv::subtract(src, cv::Scalar::all(16), fixed_dst, cv::noArray(), dst_depth);
|
||||
dst = fixed_dst;
|
||||
dst_depth = fixed_dst.depth();
|
||||
}
|
||||
|
||||
ASSERT_FALSE(dst.empty());
|
||||
ASSERT_EQ(src.size(), dst.size());
|
||||
ASSERT_EQ(dst_depth > 0 ? dst_depth : src.depth(), dst.depth());
|
||||
ASSERT_EQ(0, cv::countNonZero(dst.reshape(1)));
|
||||
}
|
||||
|
||||
TEST_P(SubtractOutputMatNotEmpty, Mat_Scalar_WithMask)
|
||||
{
|
||||
cv::Mat src(size, src_type, cv::Scalar::all(16));
|
||||
cv::Mat mask(size, CV_8UC1, cv::Scalar::all(255));
|
||||
|
||||
cv::Mat dst;
|
||||
|
||||
if (!fixed)
|
||||
{
|
||||
cv::subtract(src, cv::Scalar::all(16), dst, mask, dst_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > 0 ? dst_depth : CV_16S), src.channels()));
|
||||
cv::subtract(src, cv::Scalar::all(16), fixed_dst, mask, dst_depth);
|
||||
dst = fixed_dst;
|
||||
dst_depth = fixed_dst.depth();
|
||||
}
|
||||
|
||||
ASSERT_FALSE(dst.empty());
|
||||
ASSERT_EQ(src.size(), dst.size());
|
||||
ASSERT_EQ(dst_depth > 0 ? dst_depth : src.depth(), dst.depth());
|
||||
ASSERT_EQ(0, cv::countNonZero(dst.reshape(1)));
|
||||
}
|
||||
|
||||
TEST_P(SubtractOutputMatNotEmpty, Scalar_Mat)
|
||||
{
|
||||
cv::Mat src(size, src_type, cv::Scalar::all(16));
|
||||
|
||||
cv::Mat dst;
|
||||
|
||||
if (!fixed)
|
||||
{
|
||||
cv::subtract(cv::Scalar::all(16), src, dst, cv::noArray(), dst_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > 0 ? dst_depth : CV_16S), src.channels()));
|
||||
cv::subtract(cv::Scalar::all(16), src, fixed_dst, cv::noArray(), dst_depth);
|
||||
dst = fixed_dst;
|
||||
dst_depth = fixed_dst.depth();
|
||||
}
|
||||
|
||||
ASSERT_FALSE(dst.empty());
|
||||
ASSERT_EQ(src.size(), dst.size());
|
||||
ASSERT_EQ(dst_depth > 0 ? dst_depth : src.depth(), dst.depth());
|
||||
ASSERT_EQ(0, cv::countNonZero(dst.reshape(1)));
|
||||
}
|
||||
|
||||
TEST_P(SubtractOutputMatNotEmpty, Scalar_Mat_WithMask)
|
||||
{
|
||||
cv::Mat src(size, src_type, cv::Scalar::all(16));
|
||||
cv::Mat mask(size, CV_8UC1, cv::Scalar::all(255));
|
||||
|
||||
cv::Mat dst;
|
||||
|
||||
if (!fixed)
|
||||
{
|
||||
cv::subtract(cv::Scalar::all(16), src, dst, mask, dst_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
const cv::Mat fixed_dst(size, CV_MAKE_TYPE((dst_depth > 0 ? dst_depth : CV_16S), src.channels()));
|
||||
cv::subtract(cv::Scalar::all(16), src, fixed_dst, mask, dst_depth);
|
||||
dst = fixed_dst;
|
||||
dst_depth = fixed_dst.depth();
|
||||
}
|
||||
|
||||
ASSERT_FALSE(dst.empty());
|
||||
ASSERT_EQ(src.size(), dst.size());
|
||||
ASSERT_EQ(dst_depth > 0 ? dst_depth : src.depth(), dst.depth());
|
||||
ASSERT_EQ(0, cv::countNonZero(dst.reshape(1)));
|
||||
}
|
||||
|
||||
TEST_P(SubtractOutputMatNotEmpty, Mat_Mat_3d)
|
||||
{
|
||||
int dims[] = {5, size.height, size.width};
|
||||
|
||||
cv::Mat src1(3, dims, src_type, cv::Scalar::all(16));
|
||||
cv::Mat src2(3, dims, src_type, cv::Scalar::all(16));
|
||||
|
||||
cv::Mat dst;
|
||||
|
||||
if (!fixed)
|
||||
{
|
||||
cv::subtract(src1, src2, dst, cv::noArray(), dst_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
const cv::Mat fixed_dst(3, dims, CV_MAKE_TYPE((dst_depth > 0 ? dst_depth : CV_16S), src1.channels()));
|
||||
cv::subtract(src1, src2, fixed_dst, cv::noArray(), dst_depth);
|
||||
dst = fixed_dst;
|
||||
dst_depth = fixed_dst.depth();
|
||||
}
|
||||
|
||||
ASSERT_FALSE(dst.empty());
|
||||
ASSERT_EQ(src1.dims, dst.dims);
|
||||
ASSERT_EQ(src1.size, dst.size);
|
||||
ASSERT_EQ(dst_depth > 0 ? dst_depth : src1.depth(), dst.depth());
|
||||
ASSERT_EQ(0, cv::countNonZero(dst.reshape(1)));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Arithm, SubtractOutputMatNotEmpty, testing::Combine(
|
||||
testing::Values(cv::Size(16, 16), cv::Size(13, 13), cv::Size(16, 13), cv::Size(13, 16)),
|
||||
testing::Values(perf::MatType(CV_8UC1), CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3),
|
||||
testing::Values(-1, CV_16S, CV_32S, CV_32F),
|
||||
testing::Bool()));
|
||||
|
||||
@@ -918,3 +918,18 @@ TEST(Core_Mat, copyNx1ToVector)
|
||||
|
||||
ASSERT_PRED_FORMAT2(cvtest::MatComparator(0, 0), ref_dst16, cv::Mat_<ushort>(dst16));
|
||||
}
|
||||
|
||||
TEST(Core_Mat, multiDim)
|
||||
{
|
||||
int d[]={3,3,3};
|
||||
Mat m0 = Mat::zeros(3,d,CV_8U);
|
||||
ASSERT_EQ(0,sum(m0)[0]);
|
||||
Mat m = Mat::ones(3,d,CV_8U);
|
||||
ASSERT_EQ(27,sum(m)[0]);
|
||||
m += 2;
|
||||
ASSERT_EQ(81,sum(m)[0]);
|
||||
m *= 3;
|
||||
ASSERT_EQ(243,sum(m)[0]);
|
||||
m += m;
|
||||
ASSERT_EQ(486,sum(m)[0]);
|
||||
}
|
||||
|
||||
@@ -1353,7 +1353,7 @@ void Core_DetTest::get_test_array_types_and_sizes( int test_case_idx, vector<vec
|
||||
{
|
||||
Base::get_test_array_types_and_sizes( test_case_idx, sizes, types );
|
||||
|
||||
sizes[INPUT][0].width = sizes[INPUT][0].height = sizes[INPUT][0].height;
|
||||
sizes[INPUT][0].width = sizes[INPUT][0].height;
|
||||
sizes[TEMP][0] = sizes[INPUT][0];
|
||||
types[TEMP][0] = CV_64FC1;
|
||||
}
|
||||
@@ -2512,6 +2512,15 @@ TEST(Core_SVD, flt)
|
||||
|
||||
// TODO: eigenvv, invsqrt, cbrt, fastarctan, (round, floor, ceil(?)),
|
||||
|
||||
enum
|
||||
{
|
||||
MAT_N_DIM_C1,
|
||||
MAT_N_1_CDIM,
|
||||
MAT_1_N_CDIM,
|
||||
MAT_N_DIM_C1_NONCONT,
|
||||
MAT_N_1_CDIM_NONCONT,
|
||||
VECTOR
|
||||
};
|
||||
|
||||
class CV_KMeansSingularTest : public cvtest::BaseTest
|
||||
{
|
||||
@@ -2519,7 +2528,7 @@ public:
|
||||
CV_KMeansSingularTest() {}
|
||||
~CV_KMeansSingularTest() {}
|
||||
protected:
|
||||
void run(int)
|
||||
void run(int inVariant)
|
||||
{
|
||||
int i, iter = 0, N = 0, N0 = 0, K = 0, dims = 0;
|
||||
Mat labels;
|
||||
@@ -2531,20 +2540,70 @@ protected:
|
||||
for( iter = 0; iter < maxIter; iter++ )
|
||||
{
|
||||
ts->update_context(this, iter, true);
|
||||
dims = rng.uniform(1, MAX_DIM+1);
|
||||
dims = rng.uniform(inVariant == MAT_1_N_CDIM ? 2 : 1, MAX_DIM+1);
|
||||
N = rng.uniform(1, MAX_POINTS+1);
|
||||
N0 = rng.uniform(1, MAX(N/10, 2));
|
||||
K = rng.uniform(1, N+1);
|
||||
|
||||
Mat data0(N0, dims, CV_32F);
|
||||
rng.fill(data0, RNG::UNIFORM, -1, 1);
|
||||
if (inVariant == VECTOR)
|
||||
{
|
||||
dims = 2;
|
||||
|
||||
Mat data(N, dims, CV_32F);
|
||||
for( i = 0; i < N; i++ )
|
||||
data0.row(rng.uniform(0, N0)).copyTo(data.row(i));
|
||||
std::vector<cv::Point2f> data0(N0);
|
||||
rng.fill(data0, RNG::UNIFORM, -1, 1);
|
||||
|
||||
kmeans(data, K, labels, TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 30, 0),
|
||||
5, KMEANS_PP_CENTERS);
|
||||
std::vector<cv::Point2f> data(N);
|
||||
for( i = 0; i < N; i++ )
|
||||
data[i] = data0[rng.uniform(0, N0)];
|
||||
|
||||
kmeans(data, K, labels, TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 30, 0),
|
||||
5, KMEANS_PP_CENTERS);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat data0(N0, dims, CV_32F);
|
||||
rng.fill(data0, RNG::UNIFORM, -1, 1);
|
||||
|
||||
Mat data;
|
||||
|
||||
switch (inVariant)
|
||||
{
|
||||
case MAT_N_DIM_C1:
|
||||
data.create(N, dims, CV_32F);
|
||||
for( i = 0; i < N; i++ )
|
||||
data0.row(rng.uniform(0, N0)).copyTo(data.row(i));
|
||||
break;
|
||||
|
||||
case MAT_N_1_CDIM:
|
||||
data.create(N, 1, CV_32FC(dims));
|
||||
for( i = 0; i < N; i++ )
|
||||
memcpy(data.ptr(i), data0.ptr(rng.uniform(0, N0)), dims * sizeof(float));
|
||||
break;
|
||||
|
||||
case MAT_1_N_CDIM:
|
||||
data.create(1, N, CV_32FC(dims));
|
||||
for( i = 0; i < N; i++ )
|
||||
memcpy(data.data + i * dims * sizeof(float), data0.ptr(rng.uniform(0, N0)), dims * sizeof(float));
|
||||
break;
|
||||
|
||||
case MAT_N_DIM_C1_NONCONT:
|
||||
data.create(N, dims + 5, CV_32F);
|
||||
data = data(Range(0, N), Range(0, dims));
|
||||
for( i = 0; i < N; i++ )
|
||||
data0.row(rng.uniform(0, N0)).copyTo(data.row(i));
|
||||
break;
|
||||
|
||||
case MAT_N_1_CDIM_NONCONT:
|
||||
data.create(N, 3, CV_32FC(dims));
|
||||
data = data.colRange(0, 1);
|
||||
for( i = 0; i < N; i++ )
|
||||
memcpy(data.ptr(i), data0.ptr(rng.uniform(0, N0)), dims * sizeof(float));
|
||||
break;
|
||||
}
|
||||
|
||||
kmeans(data, K, labels, TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 30, 0),
|
||||
5, KMEANS_PP_CENTERS);
|
||||
}
|
||||
|
||||
Mat hist(K, 1, CV_32S, Scalar(0));
|
||||
for( i = 0; i < N; i++ )
|
||||
@@ -2568,7 +2627,19 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Core_KMeans, singular) { CV_KMeansSingularTest test; test.safe_run(); }
|
||||
TEST(Core_KMeans, singular) { CV_KMeansSingularTest test; test.safe_run(MAT_N_DIM_C1); }
|
||||
|
||||
CV_ENUM(KMeansInputVariant, MAT_N_DIM_C1, MAT_N_1_CDIM, MAT_1_N_CDIM, MAT_N_DIM_C1_NONCONT, MAT_N_1_CDIM_NONCONT, VECTOR)
|
||||
|
||||
typedef testing::TestWithParam<KMeansInputVariant> Core_KMeans_InputVariants;
|
||||
|
||||
TEST_P(Core_KMeans_InputVariants, singular)
|
||||
{
|
||||
CV_KMeansSingularTest test;
|
||||
test.safe_run(GetParam());
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(AllVariants, Core_KMeans_InputVariants, KMeansInputVariant::all());
|
||||
|
||||
TEST(CovariationMatrixVectorOfMat, accuracy)
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ Computes the descriptors for a set of keypoints detected in an image (first vari
|
||||
|
||||
:param images: Image set.
|
||||
|
||||
:param keypoints: Input collection of keypoints. Keypoints for which a descriptor cannot be computed are removed. Sometimes new keypoints can be added, for example: ``SIFT`` duplicates keypoint with several dominant orientations (for each orientation).
|
||||
:param keypoints: Input collection of keypoints. Keypoints for which a descriptor cannot be computed are removed and the remaining ones may be reordered. Sometimes new keypoints can be added, for example: ``SIFT`` duplicates a keypoint with several dominant orientations (for each orientation).
|
||||
|
||||
:param descriptors: Computed descriptors. In the second variant of the method ``descriptors[i]`` are descriptors computed for a ``keypoints[i]``. Row ``j`` is the ``keypoints`` (or ``keypoints[i]``) is the descriptor for keypoint ``j``-th keypoint.
|
||||
|
||||
|
||||
@@ -1528,17 +1528,17 @@ CV_EXPORTS void evaluateGenericDescriptorMatcher( const Mat& img1, const Mat& im
|
||||
/*
|
||||
* Abstract base class for training of a 'bag of visual words' vocabulary from a set of descriptors
|
||||
*/
|
||||
class CV_EXPORTS BOWTrainer
|
||||
class CV_EXPORTS_W BOWTrainer
|
||||
{
|
||||
public:
|
||||
BOWTrainer();
|
||||
virtual ~BOWTrainer();
|
||||
|
||||
void add( const Mat& descriptors );
|
||||
const vector<Mat>& getDescriptors() const;
|
||||
int descripotorsCount() const;
|
||||
CV_WRAP void add( const Mat& descriptors );
|
||||
CV_WRAP const vector<Mat>& getDescriptors() const;
|
||||
CV_WRAP int descripotorsCount() const;
|
||||
|
||||
virtual void clear();
|
||||
CV_WRAP virtual void clear();
|
||||
|
||||
/*
|
||||
* Train visual words vocabulary, that is cluster training descriptors and
|
||||
@@ -1547,8 +1547,8 @@ public:
|
||||
*
|
||||
* descriptors Training descriptors computed on images keypoints.
|
||||
*/
|
||||
virtual Mat cluster() const = 0;
|
||||
virtual Mat cluster( const Mat& descriptors ) const = 0;
|
||||
CV_WRAP virtual Mat cluster() const = 0;
|
||||
CV_WRAP virtual Mat cluster( const Mat& descriptors ) const = 0;
|
||||
|
||||
protected:
|
||||
vector<Mat> descriptors;
|
||||
@@ -1558,16 +1558,16 @@ protected:
|
||||
/*
|
||||
* This is BOWTrainer using cv::kmeans to get vocabulary.
|
||||
*/
|
||||
class CV_EXPORTS BOWKMeansTrainer : public BOWTrainer
|
||||
class CV_EXPORTS_W BOWKMeansTrainer : public BOWTrainer
|
||||
{
|
||||
public:
|
||||
BOWKMeansTrainer( int clusterCount, const TermCriteria& termcrit=TermCriteria(),
|
||||
CV_WRAP BOWKMeansTrainer( int clusterCount, const TermCriteria& termcrit=TermCriteria(),
|
||||
int attempts=3, int flags=KMEANS_PP_CENTERS );
|
||||
virtual ~BOWKMeansTrainer();
|
||||
|
||||
// Returns trained vocabulary (i.e. cluster centers).
|
||||
virtual Mat cluster() const;
|
||||
virtual Mat cluster( const Mat& descriptors ) const;
|
||||
CV_WRAP virtual Mat cluster() const;
|
||||
CV_WRAP virtual Mat cluster( const Mat& descriptors ) const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -1580,21 +1580,24 @@ protected:
|
||||
/*
|
||||
* Class to compute image descriptor using bag of visual words.
|
||||
*/
|
||||
class CV_EXPORTS BOWImgDescriptorExtractor
|
||||
class CV_EXPORTS_W BOWImgDescriptorExtractor
|
||||
{
|
||||
public:
|
||||
BOWImgDescriptorExtractor( const Ptr<DescriptorExtractor>& dextractor,
|
||||
CV_WRAP BOWImgDescriptorExtractor( const Ptr<DescriptorExtractor>& dextractor,
|
||||
const Ptr<DescriptorMatcher>& dmatcher );
|
||||
virtual ~BOWImgDescriptorExtractor();
|
||||
|
||||
void setVocabulary( const Mat& vocabulary );
|
||||
const Mat& getVocabulary() const;
|
||||
CV_WRAP void setVocabulary( const Mat& vocabulary );
|
||||
CV_WRAP const Mat& getVocabulary() const;
|
||||
void compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& imgDescriptor,
|
||||
vector<vector<int> >* pointIdxsOfClusters=0, Mat* descriptors=0 );
|
||||
// compute() is not constant because DescriptorMatcher::match is not constant
|
||||
|
||||
int descriptorSize() const;
|
||||
int descriptorType() const;
|
||||
CV_WRAP_AS(compute) void compute2( const Mat& image, vector<KeyPoint>& keypoints, CV_OUT Mat& imgDescriptor )
|
||||
{ compute(image,keypoints,imgDescriptor); }
|
||||
|
||||
CV_WRAP int descriptorSize() const;
|
||||
CV_WRAP int descriptorType() const;
|
||||
|
||||
protected:
|
||||
Mat vocabulary;
|
||||
|
||||
@@ -282,6 +282,9 @@ void SimpleBlobDetector::detectImpl(const cv::Mat& image, std::vector<cv::KeyPoi
|
||||
else
|
||||
grayscaleImage = image;
|
||||
|
||||
if (grayscaleImage.type() != CV_8UC1){
|
||||
CV_Error(CV_StsUnsupportedFormat, "Blob detector only supports 8-bit images!");
|
||||
}
|
||||
vector < vector<Center> > centers;
|
||||
for (double thresh = params.minThreshold; thresh < params.maxThreshold; thresh += params.thresholdStep)
|
||||
{
|
||||
|
||||
@@ -394,7 +394,7 @@ void FREAK::computeImpl( const Mat& image, std::vector<KeyPoint>& keypoints, Mat
|
||||
(*ptr) = result128;
|
||||
++ptr;
|
||||
}
|
||||
ptr -= 8;
|
||||
ptr -= (FREAK_NB_PAIRS/128)*2;
|
||||
#else
|
||||
// extracting descriptor preserving the order of SSE version
|
||||
int cnt = 0;
|
||||
|
||||
@@ -352,18 +352,27 @@ void BFMatcher::knnMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch>
|
||||
|
||||
matches.reserve(queryDescriptors.rows);
|
||||
|
||||
Mat dist, nidx;
|
||||
|
||||
int iIdx, imgCount = (int)trainDescCollection.size(), update = 0;
|
||||
int dtype = normType == NORM_HAMMING || normType == NORM_HAMMING2 ||
|
||||
(normType == NORM_L1 && queryDescriptors.type() == CV_8U) ? CV_32S : CV_32F;
|
||||
int maxRows = 0;
|
||||
|
||||
CV_Assert( (int64)imgCount*IMGIDX_ONE < INT_MAX );
|
||||
|
||||
for( iIdx = 0; iIdx < imgCount; iIdx++ )
|
||||
maxRows = std::max(maxRows, trainDescCollection[iIdx].rows);
|
||||
|
||||
int m = queryDescriptors.rows;
|
||||
Mat dist(m, knn, dtype), nidx(m, knn, CV_32S);
|
||||
dist = Scalar::all(dtype == CV_32S ? (double)INT_MAX : (double)FLT_MAX);
|
||||
nidx = Scalar::all(-1);
|
||||
|
||||
for( iIdx = 0; iIdx < imgCount; iIdx++ )
|
||||
{
|
||||
CV_Assert( trainDescCollection[iIdx].rows < IMGIDX_ONE );
|
||||
batchDistance(queryDescriptors, trainDescCollection[iIdx], dist, dtype, nidx,
|
||||
int n = std::min(knn, trainDescCollection[iIdx].rows);
|
||||
Mat dist_i = dist.colRange(0, n), nidx_i = nidx.colRange(0, n);
|
||||
batchDistance(queryDescriptors, trainDescCollection[iIdx], dist_i, dtype, nidx_i,
|
||||
normType, knn, masks.empty() ? Mat() : masks[iIdx], update, crossCheck);
|
||||
update += IMGIDX_ONE;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,9 @@ public:
|
||||
CV_DescriptorMatcherTest( const string& _name, const Ptr<DescriptorMatcher>& _dmatcher, float _badPart ) :
|
||||
badPart(_badPart), name(_name), dmatcher(_dmatcher)
|
||||
{}
|
||||
|
||||
static void generateData( Mat& query, Mat& train );
|
||||
|
||||
protected:
|
||||
static const int dim = 500;
|
||||
static const int queryDescCount = 300; // must be even number because we split train data in some cases in two
|
||||
@@ -64,7 +67,6 @@ protected:
|
||||
const float badPart;
|
||||
|
||||
virtual void run( int );
|
||||
void generateData( Mat& query, Mat& train );
|
||||
|
||||
void emptyDataTest();
|
||||
void matchTest( const Mat& query, const Mat& train );
|
||||
@@ -526,6 +528,81 @@ void CV_DescriptorMatcherTest::run( int )
|
||||
radiusMatchTest( query, train );
|
||||
}
|
||||
|
||||
// bug #3172: test that knnMatch() can handle images with fewer than knn keypoints
|
||||
class CV_DescriptorMatcherLowKeypointTest : public cvtest::BaseTest
|
||||
{
|
||||
public:
|
||||
CV_DescriptorMatcherLowKeypointTest( const string& _name, const Ptr<DescriptorMatcher>& _dmatcher ) :
|
||||
name(_name), dmatcher(_dmatcher)
|
||||
{}
|
||||
protected:
|
||||
virtual void run(int);
|
||||
|
||||
void knnMatchTest( const Mat& query, const Mat& train );
|
||||
|
||||
private:
|
||||
string name;
|
||||
Ptr<DescriptorMatcher> dmatcher;
|
||||
};
|
||||
|
||||
void CV_DescriptorMatcherLowKeypointTest::knnMatchTest( const Mat& query, const Mat& train )
|
||||
{
|
||||
const int knn = 6;
|
||||
const int queryDescCount = query.rows;
|
||||
vector<vector<DMatch> > matches;
|
||||
|
||||
// three train images, the third one with only one keypoint
|
||||
dmatcher->add( vector<Mat>(1,train.rowRange(0, train.rows/2)) );
|
||||
dmatcher->add( vector<Mat>(1,train.rowRange(train.rows/2, train.rows-1)) );
|
||||
dmatcher->add( vector<Mat>(1,train.rowRange(train.rows-1, train.rows)) );
|
||||
const int trainImgCount = (int)dmatcher->getTrainDescriptors().size();
|
||||
|
||||
dmatcher->knnMatch( query, matches, knn, std::vector<Mat>(), true );
|
||||
|
||||
if( matches.empty() )
|
||||
{
|
||||
ts->printf(cvtest::TS::LOG, "No matches while testing knnMatch() function (3).\n");
|
||||
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );
|
||||
}
|
||||
else
|
||||
{
|
||||
int badImgIdxCount = 0, badQueryIdxCount = 0, badTrainIdxCount = 0;
|
||||
for( size_t i = 0; i < matches.size(); i++ )
|
||||
{
|
||||
for( size_t j = 0; j < matches[i].size(); j++ )
|
||||
{
|
||||
const DMatch& match = matches[i][j];
|
||||
if( match.imgIdx < 0 || match.imgIdx >= trainImgCount )
|
||||
{
|
||||
++badImgIdxCount;
|
||||
}
|
||||
if( match.queryIdx < 0 || match.queryIdx >= queryDescCount )
|
||||
{
|
||||
++badQueryIdxCount;
|
||||
}
|
||||
if( match.trainIdx < 0 )
|
||||
{
|
||||
++badTrainIdxCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( badImgIdxCount > 0 || badQueryIdxCount > 0 || badTrainIdxCount > 0 )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG, "%d/%d/%d - wrong image/query/train indices while testing knnMatch() function (3).\n",
|
||||
badImgIdxCount, badQueryIdxCount, badTrainIdxCount );
|
||||
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CV_DescriptorMatcherLowKeypointTest::run( int )
|
||||
{
|
||||
Mat query, train;
|
||||
CV_DescriptorMatcherTest::generateData( query, train );
|
||||
|
||||
knnMatchTest( query, train );
|
||||
}
|
||||
|
||||
/****************************************************************************************\
|
||||
* Tests registrations *
|
||||
\****************************************************************************************/
|
||||
@@ -541,3 +618,15 @@ TEST( Features2d_DescriptorMatcher_FlannBased, regression )
|
||||
CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based", Algorithm::create<DescriptorMatcher>("DescriptorMatcher.FlannBasedMatcher"), 0.04f );
|
||||
test.safe_run();
|
||||
}
|
||||
|
||||
TEST( Features2d_DescriptorMatcher_LowKeypoint_BruteForce, regression )
|
||||
{
|
||||
CV_DescriptorMatcherLowKeypointTest test( "descriptor-matcher-low-keypoint-brute-force", Algorithm::create<DescriptorMatcher>("DescriptorMatcher.BFMatcher") );
|
||||
test.safe_run();
|
||||
}
|
||||
|
||||
TEST(Features2d_DescriptorMatcher_LowKeypoint_FlannBased, regression)
|
||||
{
|
||||
CV_DescriptorMatcherLowKeypointTest test( "descriptor-matcher-low-keypoint-flann-based", Algorithm::create<DescriptorMatcher>("DescriptorMatcher.FlannBasedMatcher") );
|
||||
test.safe_run();
|
||||
}
|
||||
|
||||
@@ -99,18 +99,22 @@ public:
|
||||
*/
|
||||
virtual void buildIndex()
|
||||
{
|
||||
std::ostringstream stream;
|
||||
bestParams_ = estimateBuildParams();
|
||||
print_params(bestParams_, stream);
|
||||
Logger::info("----------------------------------------------------\n");
|
||||
Logger::info("Autotuned parameters:\n");
|
||||
print_params(bestParams_);
|
||||
Logger::info("%s", stream.str().c_str());
|
||||
Logger::info("----------------------------------------------------\n");
|
||||
|
||||
bestIndex_ = create_index_by_type(dataset_, bestParams_, distance_);
|
||||
bestIndex_->buildIndex();
|
||||
speedup_ = estimateSearchParams(bestSearchParams_);
|
||||
stream.str(std::string());
|
||||
print_params(bestSearchParams_, stream);
|
||||
Logger::info("----------------------------------------------------\n");
|
||||
Logger::info("Search parameters:\n");
|
||||
print_params(bestSearchParams_);
|
||||
Logger::info("%s", stream.str().c_str());
|
||||
Logger::info("----------------------------------------------------\n");
|
||||
}
|
||||
|
||||
|
||||