Compare commits
244 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a984da911b | |||
| df55be3c3d | |||
| 55339de684 | |||
| f08dd510fa | |||
| d308ed3712 | |||
| 6d0f8aa893 | |||
| bea98bd22a | |||
| 4539607ab1 | |||
| b320138dba | |||
| 95ea12588e | |||
| bcd08b5d18 | |||
| 19298ae3cb | |||
| 5e06da3050 | |||
| 17ac18a7b9 | |||
| c259590b26 | |||
| 3f3ca85103 | |||
| 05ddc16eaa | |||
| 2ba77614aa | |||
| ef347aa6a4 | |||
| b1cdb91139 | |||
| a09ad35d98 | |||
| 1b5835cd35 | |||
| 9932bbad3a | |||
| 39ac84ff04 | |||
| fcbefaff86 | |||
| bf2256fb89 | |||
| b0b2fc9e3f | |||
| 1ccd64e102 | |||
| 23bf3e337a | |||
| 3cf265992f | |||
| 67635c6d65 | |||
| a26e496d00 | |||
| d579d3e596 | |||
| 5a77176654 | |||
| 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 | |||
| 939c60bcaa | |||
| 7936faf9a3 | |||
| 5c85f816c9 | |||
| 56683e6d11 | |||
| fbac578c79 | |||
| ade46bd428 | |||
| 6882970248 | |||
| 11a09ef5cc | |||
| 1a1cd9b4e9 | |||
| cd3aa0184a | |||
| 1020a93fa3 | |||
| 8a3b93773d | |||
| bcd63766ce | |||
| ca40d635e4 | |||
| 6fb83f869c | |||
| 0c30b18769 |
@@ -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
|
||||
# ===================================================
|
||||
@@ -599,17 +605,18 @@ if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH AND UNIX)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv_run_all_tests_android.sh.in"
|
||||
"${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh" @ONLY)
|
||||
install(PROGRAMS "${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh"
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT tests)
|
||||
DESTINATION . COMPONENT tests)
|
||||
else()
|
||||
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"
|
||||
DESTINATION /etc/profile.d/ COMPONENT tests)
|
||||
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_run_all_tests_unix.sh.in"
|
||||
"${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()
|
||||
|
||||
@@ -627,11 +634,11 @@ endif()
|
||||
if(ANDROID OR NOT UNIX)
|
||||
install(FILES ${OPENCV_LICENSE_FILE}
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT libs)
|
||||
DESTINATION . COMPONENT libs)
|
||||
if(OPENCV_README_FILE)
|
||||
install(FILES ${OPENCV_README_FILE}
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT libs)
|
||||
DESTINATION . COMPONENT libs)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -745,8 +752,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 +868,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 +914,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()
|
||||
|
||||
@@ -253,6 +253,11 @@ if(MSVC)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSVC12 AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /FS")
|
||||
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} /FS")
|
||||
endif()
|
||||
|
||||
# Extra link libs if the user selects building static libs:
|
||||
if(NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX AND NOT ANDROID)
|
||||
# Android does not need these settings because they are already set by toolchain file
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -140,6 +140,6 @@ if(WIN32)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib" COMPONENT dev)
|
||||
install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev)
|
||||
endif()
|
||||
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT dev)
|
||||
install(FILES "${OpenCV_SOURCE_DIR}/cmake/OpenCVConfig.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/" COMPONENT dev)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" DESTINATION "." COMPONENT dev)
|
||||
install(FILES "${OpenCV_SOURCE_DIR}/cmake/OpenCVConfig.cmake" DESTINATION "." COMPONENT dev)
|
||||
endif()
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -595,9 +617,14 @@ macro(ocv_create_module)
|
||||
|
||||
ocv_install_target(${the_module} EXPORT OpenCVModules
|
||||
RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs
|
||||
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT libs
|
||||
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT libs NAMELINK_SKIP
|
||||
ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT dev
|
||||
)
|
||||
get_target_property(_target_type ${the_module} TYPE)
|
||||
if("${_target_type}" STREQUAL "SHARED_LIBRARY")
|
||||
install(TARGETS ${the_module}
|
||||
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT dev NAMELINK_ONLY)
|
||||
endif()
|
||||
|
||||
# only "public" headers need to be installed
|
||||
if(OPENCV_MODULE_${the_module}_HEADERS AND ";${OPENCV_MODULES_PUBLIC};" MATCHES ";${the_module};")
|
||||
@@ -838,7 +865,7 @@ function(ocv_add_samples)
|
||||
file(GLOB sample_files "${samples_path}/*")
|
||||
install(FILES ${sample_files}
|
||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/${module_id}
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
|
||||
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -11,13 +14,15 @@ machine perception in the commercial products. Being a BSD-licensed product,
|
||||
OpenCV makes it easy for businesses to utilize and modify the code.")
|
||||
set(CPACK_PACKAGE_VENDOR "OpenCV Foundation")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_PACKAGE_CONTACT "admin@opencv.org")
|
||||
set(CPACK_PACKAGE_CONTACT "OpenCV Developers <admin@opencv.org>")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${OPENCV_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${OPENCV_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${OPENCV_VERSION_PATCH}")
|
||||
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")
|
||||
@@ -57,54 +62,107 @@ set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
|
||||
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://opencv.org")
|
||||
|
||||
#display names
|
||||
set(CPACK_COMPONENT_DEV_DISPLAY_NAME "Development files")
|
||||
set(CPACK_COMPONENT_DOCS_DISPLAY_NAME "Documentation")
|
||||
set(CPACK_COMPONENT_JAVA_DISPLAY_NAME "Java bindings")
|
||||
set(CPACK_COMPONENT_LIBS_DISPLAY_NAME "Libraries and data")
|
||||
set(CPACK_COMPONENT_PYTHON_DISPLAY_NAME "Python bindings")
|
||||
set(CPACK_COMPONENT_SAMPLES_DISPLAY_NAME "Samples")
|
||||
set(CPACK_COMPONENT_TESTS_DISPLAY_NAME "Tests")
|
||||
|
||||
#depencencies
|
||||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS TRUE)
|
||||
set(CPACK_COMPONENT_samples_DEPENDS libs)
|
||||
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_COMPONENT_tests_DEPENDS libs)
|
||||
set(CPACK_COMPONENT_LIBS_REQUIRED TRUE)
|
||||
set(CPACK_COMPONENT_SAMPLES_DEPENDS libs dev)
|
||||
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-numpy (>=${PYTHON_NUMPY_VERSION}), python${PYTHON_VERSION_MAJOR_MINOR}")
|
||||
set(CPACK_COMPONENT_TESTS_DEPENDS libs)
|
||||
if (HAVE_opencv_python)
|
||||
set(CPACK_DEB_TESTS_PACKAGE_DEPENDS "python-numpy (>=${PYTHON_NUMPY_VERSION}), 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}")
|
||||
set(CPACK_COMPONENT_dev_DEPENDS libs)
|
||||
set(CPACK_DEB_dev_PACKAGE_DEPENDS "cuda-headers-${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()
|
||||
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_DESCRIPTION "Open Computer Vision Library")
|
||||
set(CPACK_DEBIAN_COMPONENT_LIBS_NAME "libopencv")
|
||||
set(CPACK_DEBIAN_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_DESCRIPTION "Python bindings for Open Source Computer Vision Library")
|
||||
set(CPACK_DEBIAN_COMPONENT_PYTHON_NAME "libopencv-python")
|
||||
set(CPACK_DEBIAN_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_DESCRIPTION "Java bindings for Open Source Computer Vision Library")
|
||||
set(CPACK_DEBIAN_COMPONENT_JAVA_NAME "libopencv-java")
|
||||
set(CPACK_DEBIAN_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_DESCRIPTION "Development files for Open Source Computer Vision Library")
|
||||
set(CPACK_DEBIAN_COMPONENT_DEV_NAME "libopencv-dev")
|
||||
set(CPACK_DEBIAN_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_DESCRIPTION "Documentation for Open Source Computer Vision Library")
|
||||
set(CPACK_DEBIAN_COMPONENT_DOCS_NAME "libopencv-docs")
|
||||
set(CPACK_DEBIAN_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_DESCRIPTION "Samples for Open Source Computer Vision Library")
|
||||
set(CPACK_DEBIAN_COMPONENT_SAMPLES_NAME "libopencv-samples")
|
||||
set(CPACK_DEBIAN_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_DESCRIPTION "Accuracy and performance tests for Open Source Computer Vision Library")
|
||||
set(CPACK_DEBIAN_COMPONENT_TESTS_NAME "libopencv-tests")
|
||||
set(CPACK_DEBIAN_COMPONENT_TESTS_SECTION "misc")
|
||||
endif(NOT OPENCV_CUSTOM_PACKAGE_INFO)
|
||||
|
||||
if(NOT OPENCV_CUSTOM_PACKAGE_LAYOUT)
|
||||
set(CPACK_libs_COMPONENT_INSTALL TRUE)
|
||||
set(CPACK_dev_COMPONENT_INSTALL TRUE)
|
||||
set(CPACK_docs_COMPONENT_INSTALL TRUE)
|
||||
set(CPACK_python_COMPONENT_INSTALL TRUE)
|
||||
set(CPACK_java_COMPONENT_INSTALL TRUE)
|
||||
set(CPACK_samples_COMPONENT_INSTALL TRUE)
|
||||
endif(NOT OPENCV_CUSTOM_PACKAGE_LAYOUT)
|
||||
if(CPACK_GENERATOR STREQUAL "DEB")
|
||||
find_program(GZIP_TOOL NAMES "gzip" PATHS "/bin" "/usr/bin" "/usr/local/bin")
|
||||
if(NOT GZIP_TOOL)
|
||||
message(FATAL_ERROR "Unable to find 'gzip' program")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND "date" "-R"
|
||||
OUTPUT_VARIABLE CHANGELOG_PACKAGE_DATE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
set(CHANGELOG_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
|
||||
set(ALL_COMPONENTS "libs" "dev" "docs" "python" "java" "samples" "tests")
|
||||
foreach (comp ${ALL_COMPONENTS})
|
||||
string(TOUPPER "${comp}" comp_upcase)
|
||||
set(DEBIAN_CHANGELOG_OUT_FILE "${CMAKE_BINARY_DIR}/deb-packages-gen/${comp}/changelog.Debian")
|
||||
set(DEBIAN_CHANGELOG_OUT_FILE_GZ "${CMAKE_BINARY_DIR}/deb-packages-gen/${comp}/changelog.Debian.gz")
|
||||
set(CHANGELOG_PACKAGE_NAME "${CPACK_DEBIAN_COMPONENT_${comp_upcase}_NAME}")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/changelog.Debian.in" "${DEBIAN_CHANGELOG_OUT_FILE}" @ONLY)
|
||||
|
||||
execute_process(COMMAND "${GZIP_TOOL}" "-cf9" "${DEBIAN_CHANGELOG_OUT_FILE}"
|
||||
OUTPUT_FILE "${DEBIAN_CHANGELOG_OUT_FILE_GZ}"
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
|
||||
install(FILES "${DEBIAN_CHANGELOG_OUT_FILE_GZ}"
|
||||
DESTINATION "share/doc/${CPACK_DEBIAN_COMPONENT_${comp_upcase}_NAME}"
|
||||
COMPONENT "${comp}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
include(CPack)
|
||||
|
||||
ENDif(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
ENDif(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
@CHANGELOG_PACKAGE_NAME@ (@CPACK_PACKAGE_VERSION@) unstable; urgency=low
|
||||
* Debian changelog stub. See upstream changelog or release notes in user
|
||||
documentation for more details.
|
||||
-- @CPACK_PACKAGE_CONTACT@ @CHANGELOG_PACKAGE_DATE@
|
||||
@@ -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,2 +0,0 @@
|
||||
# Environment setup for OpenCV testing
|
||||
export OPENCV_TEST_DATA_PATH=@CMAKE_INSTALL_PREFIX@/share/OpenCV/testdata
|
||||
@@ -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>
|
||||
|
||||
|
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:
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 8.1 KiB |
|
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 |
|
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)
|
||||
|
||||
@@ -1588,7 +1588,7 @@ The distorted point coordinates are [x'; y'] where
|
||||
x' = (\theta_d / r) x \\
|
||||
y' = (\theta_d / r) y
|
||||
|
||||
Finally, convertion into pixel coordinates: The final pixel coordinates vector [u; v] where:
|
||||
Finally, conversion into pixel coordinates: The final pixel coordinates vector [u; v] where:
|
||||
|
||||
.. class:: center
|
||||
.. math::
|
||||
|
||||
@@ -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,25 +186,49 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
resultsMutex.lock();
|
||||
if (localInliers.size() > inliers.size())
|
||||
{
|
||||
resultsMutex.lock();
|
||||
|
||||
inliers.clear();
|
||||
inliers.resize(localInliers.size());
|
||||
memcpy(&inliers[0], &localInliers[0], sizeof(int) * localInliers.size());
|
||||
localRvec.copyTo(rvec);
|
||||
localTvec.copyTo(tvec);
|
||||
}
|
||||
resultsMutex.unlock();
|
||||
}
|
||||
|
||||
resultsMutex.unlock();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,10 +307,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 +346,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;
|
||||
|
||||
@@ -385,7 +385,11 @@ TEST_F(fisheyeTest, EtimateUncertainties)
|
||||
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");
|
||||
|
||||
|
||||
@@ -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
|
||||
--------------------------
|
||||
|
||||
|
||||
@@ -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
|
||||
------------
|
||||
|
||||
@@ -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: ::
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -141,6 +141,10 @@ CV_INLINE IppiSize ippiSize(const cv::Size & _size)
|
||||
# define __xgetbv() 0
|
||||
# endif
|
||||
# endif
|
||||
# if defined __AVX2__
|
||||
# include <immintrin.h>
|
||||
# define CV_AVX2 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -176,6 +180,9 @@ CV_INLINE IppiSize ippiSize(const cv::Size & _size)
|
||||
#ifndef CV_AVX
|
||||
# define CV_AVX 0
|
||||
#endif
|
||||
#ifndef CV_AVX2
|
||||
# define CV_AVX2 0
|
||||
#endif
|
||||
#ifndef CV_NEON
|
||||
# define CV_NEON 0
|
||||
#endif
|
||||
|
||||
@@ -684,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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@
|
||||
|
||||
#define CV_VERSION_EPOCH 2
|
||||
#define CV_VERSION_MAJOR 4
|
||||
#define CV_VERSION_MINOR 9
|
||||
#define CV_VERSION_REVISION 0
|
||||
#define CV_VERSION_MINOR 10
|
||||
#define CV_VERSION_REVISION 1
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2683,7 +2683,6 @@ CV_IMPL CvFileStorage*
|
||||
cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, const char* encoding )
|
||||
{
|
||||
CvFileStorage* fs = 0;
|
||||
char* xml_buf = 0;
|
||||
int default_block_size = 1 << 18;
|
||||
bool append = (flags & 3) == CV_STORAGE_APPEND;
|
||||
bool mem = (flags & CV_STORAGE_MEMORY) != 0;
|
||||
@@ -2815,7 +2814,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
|
||||
int last_occurence = -1;
|
||||
xml_buf_size = MIN(xml_buf_size, int(file_size));
|
||||
fseek( fs->file, -xml_buf_size, SEEK_END );
|
||||
xml_buf = (char*)cvAlloc( xml_buf_size+2 );
|
||||
char* xml_buf = (char*)cvAlloc( xml_buf_size+2 );
|
||||
// find the last occurence of </opencv_storage>
|
||||
for(;;)
|
||||
{
|
||||
@@ -2833,6 +2832,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
|
||||
ptr += strlen(substr);
|
||||
}
|
||||
}
|
||||
cvFree( &xml_buf );
|
||||
if( last_occurence < 0 )
|
||||
CV_Error( CV_StsError, "Could not find </opencv_storage> in the end of file.\n" );
|
||||
icvCloseFile( fs );
|
||||
@@ -2936,7 +2936,6 @@ _exit_:
|
||||
}
|
||||
}
|
||||
|
||||
cvFree( &xml_buf );
|
||||
return fs;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "opencv2/gpu/device/transform.hpp"
|
||||
#include "opencv2/gpu/device/functional.hpp"
|
||||
#include "opencv2/gpu/device/type_traits.hpp"
|
||||
#include "opencv2/gpu/device/vec_traits.hpp"
|
||||
|
||||
namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
@@ -105,87 +106,59 @@ namespace cv { namespace gpu { namespace device
|
||||
////////////////////////////////// SetTo //////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
__constant__ uchar scalar_8u[4];
|
||||
__constant__ schar scalar_8s[4];
|
||||
__constant__ ushort scalar_16u[4];
|
||||
__constant__ short scalar_16s[4];
|
||||
__constant__ int scalar_32s[4];
|
||||
__constant__ float scalar_32f[4];
|
||||
__constant__ double scalar_64f[4];
|
||||
|
||||
template <typename T> __device__ __forceinline__ T readScalar(int i);
|
||||
template <> __device__ __forceinline__ uchar readScalar<uchar>(int i) {return scalar_8u[i];}
|
||||
template <> __device__ __forceinline__ schar readScalar<schar>(int i) {return scalar_8s[i];}
|
||||
template <> __device__ __forceinline__ ushort readScalar<ushort>(int i) {return scalar_16u[i];}
|
||||
template <> __device__ __forceinline__ short readScalar<short>(int i) {return scalar_16s[i];}
|
||||
template <> __device__ __forceinline__ int readScalar<int>(int i) {return scalar_32s[i];}
|
||||
template <> __device__ __forceinline__ float readScalar<float>(int i) {return scalar_32f[i];}
|
||||
template <> __device__ __forceinline__ double readScalar<double>(int i) {return scalar_64f[i];}
|
||||
|
||||
void writeScalar(const uchar* vals)
|
||||
{
|
||||
cudaSafeCall( cudaMemcpyToSymbol(scalar_8u, vals, sizeof(uchar) * 4) );
|
||||
}
|
||||
void writeScalar(const schar* vals)
|
||||
{
|
||||
cudaSafeCall( cudaMemcpyToSymbol(scalar_8s, vals, sizeof(schar) * 4) );
|
||||
}
|
||||
void writeScalar(const ushort* vals)
|
||||
{
|
||||
cudaSafeCall( cudaMemcpyToSymbol(scalar_16u, vals, sizeof(ushort) * 4) );
|
||||
}
|
||||
void writeScalar(const short* vals)
|
||||
{
|
||||
cudaSafeCall( cudaMemcpyToSymbol(scalar_16s, vals, sizeof(short) * 4) );
|
||||
}
|
||||
void writeScalar(const int* vals)
|
||||
{
|
||||
cudaSafeCall( cudaMemcpyToSymbol(scalar_32s, vals, sizeof(int) * 4) );
|
||||
}
|
||||
void writeScalar(const float* vals)
|
||||
{
|
||||
cudaSafeCall( cudaMemcpyToSymbol(scalar_32f, vals, sizeof(float) * 4) );
|
||||
}
|
||||
void writeScalar(const double* vals)
|
||||
{
|
||||
cudaSafeCall( cudaMemcpyToSymbol(scalar_64f, vals, sizeof(double) * 4) );
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
__global__ void set_to_without_mask(T* mat, int cols, int rows, size_t step, int channels)
|
||||
__global__ void set_to_without_mask(PtrStepSz<T> mat, typename TypeVec<T, 4>::vec_type val, int channels)
|
||||
{
|
||||
size_t x = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
size_t y = blockIdx.y * blockDim.y + threadIdx.y;
|
||||
const int y = blockIdx.x * blockDim.y + threadIdx.y;
|
||||
|
||||
if ((x < cols * channels ) && (y < rows))
|
||||
if (y < mat.rows)
|
||||
{
|
||||
size_t idx = y * ( step >> shift_and_sizeof<T>::shift ) + x;
|
||||
mat[idx] = readScalar<T>(x % channels);
|
||||
const T vals[] = {
|
||||
val.x, val.y, val.z, val.w
|
||||
};
|
||||
|
||||
T* row = mat.ptr(y);
|
||||
|
||||
for (int x = threadIdx.x; x < mat.cols * channels; x += 32)
|
||||
{
|
||||
row[x] = vals[x % channels];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
__global__ void set_to_with_mask(T* mat, const uchar* mask, int cols, int rows, size_t step, int channels, size_t step_mask)
|
||||
__global__ void set_to_with_mask(PtrStepSz<T> mat, const PtrStepb mask, typename TypeVec<T, 4>::vec_type val, int channels)
|
||||
{
|
||||
size_t x = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
size_t y = blockIdx.y * blockDim.y + threadIdx.y;
|
||||
const int y = blockIdx.x * blockDim.y + threadIdx.y;
|
||||
|
||||
if ((x < cols * channels ) && (y < rows))
|
||||
if (mask[y * step_mask + x / channels] != 0)
|
||||
if (y < mat.rows)
|
||||
{
|
||||
const T vals[] = {
|
||||
val.x, val.y, val.z, val.w
|
||||
};
|
||||
|
||||
T* row = mat.ptr(y);
|
||||
const uchar* mask_row = mask.ptr(y);
|
||||
|
||||
for (int x = threadIdx.x; x < mat.cols * channels; x += 32)
|
||||
{
|
||||
size_t idx = y * ( step >> shift_and_sizeof<T>::shift ) + x;
|
||||
mat[idx] = readScalar<T>(x % channels);
|
||||
if (mask_row[x / channels])
|
||||
{
|
||||
row[x] = vals[x % channels];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void set_to_gpu(PtrStepSzb mat, const T* scalar, PtrStepSzb mask, int channels, cudaStream_t stream)
|
||||
{
|
||||
writeScalar(scalar);
|
||||
typedef typename TypeVec<T, 4>::vec_type vec_type;
|
||||
|
||||
dim3 threadsPerBlock(32, 8, 1);
|
||||
dim3 numBlocks (mat.cols * channels / threadsPerBlock.x + 1, mat.rows / threadsPerBlock.y + 1, 1);
|
||||
dim3 block(32, 8);
|
||||
dim3 grid(divUp(mat.rows, block.y));
|
||||
|
||||
set_to_with_mask<T><<<numBlocks, threadsPerBlock, 0, stream>>>((T*)mat.data, (uchar*)mask.data, mat.cols, mat.rows, mat.step, channels, mask.step);
|
||||
set_to_with_mask<T><<<grid, block, 0, stream>>>(PtrStepSz<T>(mat), mask, VecTraits<vec_type>::make(scalar), channels);
|
||||
cudaSafeCall( cudaGetLastError() );
|
||||
|
||||
if (stream == 0)
|
||||
@@ -203,12 +176,12 @@ namespace cv { namespace gpu { namespace device
|
||||
template <typename T>
|
||||
void set_to_gpu(PtrStepSzb mat, const T* scalar, int channels, cudaStream_t stream)
|
||||
{
|
||||
writeScalar(scalar);
|
||||
typedef typename TypeVec<T, 4>::vec_type vec_type;
|
||||
|
||||
dim3 threadsPerBlock(32, 8, 1);
|
||||
dim3 numBlocks (mat.cols * channels / threadsPerBlock.x + 1, mat.rows / threadsPerBlock.y + 1, 1);
|
||||
dim3 block(32, 8);
|
||||
dim3 grid(divUp(mat.rows, block.y));
|
||||
|
||||
set_to_without_mask<T><<<numBlocks, threadsPerBlock, 0, stream>>>((T*)mat.data, mat.cols, mat.rows, mat.step, channels);
|
||||
set_to_without_mask<T><<<grid, block, 0, stream>>>(PtrStepSz<T>(mat), VecTraits<vec_type>::make(scalar), channels);
|
||||
cudaSafeCall( cudaGetLastError() );
|
||||
|
||||
if (stream == 0)
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -289,8 +289,8 @@ Compares elements of two matrices.
|
||||
:param cmpop: Flag specifying the relation between the elements to be checked:
|
||||
|
||||
* **CMP_EQ:** ``a(.) == b(.)``
|
||||
* **CMP_GT:** ``a(.) < b(.)``
|
||||
* **CMP_GE:** ``a(.) <= b(.)``
|
||||
* **CMP_GT:** ``a(.) > b(.)``
|
||||
* **CMP_GE:** ``a(.) >= b(.)``
|
||||
* **CMP_LT:** ``a(.) < b(.)``
|
||||
* **CMP_LE:** ``a(.) <= b(.)``
|
||||
* **CMP_NE:** ``a(.) != b(.)``
|
||||
|
||||
@@ -302,7 +302,7 @@ gpu::FGDStatModel
|
||||
-----------------
|
||||
.. ocv:class:: gpu::FGDStatModel
|
||||
|
||||
Class used for background/foreground segmentation. ::
|
||||
Class used for background/foreground segmentation. ::
|
||||
|
||||
class FGDStatModel
|
||||
{
|
||||
@@ -400,7 +400,7 @@ gpu::MOG_GPU
|
||||
------------
|
||||
.. ocv:class:: gpu::MOG_GPU
|
||||
|
||||
Gaussian Mixture-based Backbround/Foreground Segmentation Algorithm. ::
|
||||
Gaussian Mixture-based Backbround/Foreground Segmentation Algorithm. ::
|
||||
|
||||
class MOG_GPU
|
||||
{
|
||||
@@ -479,7 +479,7 @@ gpu::MOG2_GPU
|
||||
-------------
|
||||
.. ocv:class:: gpu::MOG2_GPU
|
||||
|
||||
Gaussian Mixture-based Background/Foreground Segmentation Algorithm. ::
|
||||
Gaussian Mixture-based Background/Foreground Segmentation Algorithm. ::
|
||||
|
||||
class MOG2_GPU
|
||||
{
|
||||
@@ -594,7 +594,7 @@ gpu::GMG_GPU
|
||||
|
||||
Class used for background/foreground segmentation. ::
|
||||
|
||||
class GMG_GPU_GPU
|
||||
class GMG_GPU
|
||||
{
|
||||
public:
|
||||
GMG_GPU();
|
||||
|
||||
@@ -626,12 +626,12 @@ namespace cv { namespace gpu { namespace device
|
||||
|
||||
__device__ __forceinline__ int idx_row_low(int y) const
|
||||
{
|
||||
return (y >= 0) * y + (y < 0) * (y - ((y - height + 1) / height) * height);
|
||||
return (y >= 0) ? y : (y - ((y - height + 1) / height) * height);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row_high(int y) const
|
||||
{
|
||||
return (y < height) * y + (y >= height) * (y % height);
|
||||
return (y < height) ? y : (y % height);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_row(int y) const
|
||||
@@ -641,12 +641,12 @@ namespace cv { namespace gpu { namespace device
|
||||
|
||||
__device__ __forceinline__ int idx_col_low(int x) const
|
||||
{
|
||||
return (x >= 0) * x + (x < 0) * (x - ((x - width + 1) / width) * width);
|
||||
return (x >= 0) ? x : (x - ((x - width + 1) / width) * width);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col_high(int x) const
|
||||
{
|
||||
return (x < width) * x + (x >= width) * (x % width);
|
||||
return (x < width) ? x : (x % width);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ int idx_col(int x) const
|
||||
|
||||
@@ -123,7 +123,7 @@ PERF_TEST_P(Image_NFeatures, Features2D_ORB,
|
||||
|
||||
sortKeyPoints(gpu_keypoints, gpu_descriptors);
|
||||
|
||||
SANITY_CHECK_KEYPOINTS(gpu_keypoints);
|
||||
SANITY_CHECK_KEYPOINTS(gpu_keypoints, 1e-10);
|
||||
SANITY_CHECK(gpu_descriptors);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -908,7 +908,7 @@ CV_ENUM(TemplateMethod, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED,
|
||||
|
||||
DEF_PARAM_TEST(Sz_TemplateSz_Cn_Method, cv::Size, cv::Size, MatCn, TemplateMethod);
|
||||
|
||||
PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate8U,
|
||||
PERF_TEST_P(Sz_TemplateSz_Cn_Method, DISABLED_ImgProc_MatchTemplate8U,
|
||||
Combine(GPU_TYPICAL_MAT_SIZES,
|
||||
Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)),
|
||||
GPU_CHANNELS_1_3_4,
|
||||
@@ -948,7 +948,7 @@ PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate8U,
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// MatchTemplate32F
|
||||
|
||||
PERF_TEST_P(Sz_TemplateSz_Cn_Method, ImgProc_MatchTemplate32F,
|
||||
PERF_TEST_P(Sz_TemplateSz_Cn_Method, DISABLED_ImgProc_MatchTemplate32F,
|
||||
Combine(GPU_TYPICAL_MAT_SIZES,
|
||||
Values(cv::Size(5, 5), cv::Size(16, 16), cv::Size(30, 30)),
|
||||
GPU_CHANNELS_1_3_4,
|
||||
@@ -1011,7 +1011,7 @@ PERF_TEST_P(Sz_Flags, ImgProc_MulSpectrums,
|
||||
|
||||
TEST_CYCLE() cv::gpu::mulSpectrums(d_a, d_b, dst, flag);
|
||||
|
||||
GPU_SANITY_CHECK(dst);
|
||||
GPU_SANITY_CHECK(dst, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1045,7 +1045,7 @@ PERF_TEST_P(Sz, ImgProc_MulAndScaleSpectrums,
|
||||
|
||||
TEST_CYCLE() cv::gpu::mulAndScaleSpectrums(d_src1, d_src2, dst, cv::DFT_ROWS, scale, false);
|
||||
|
||||
GPU_SANITY_CHECK(dst);
|
||||
GPU_SANITY_CHECK(dst, 1e-5);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1413,7 +1413,7 @@ PERF_TEST_P(Sz_Depth_Code, ImgProc_CvtColor,
|
||||
|
||||
TEST_CYCLE() cv::gpu::cvtColor(d_src, dst, info.code, info.dcn);
|
||||
|
||||
GPU_SANITY_CHECK(dst, 1e-4);
|
||||
GPU_SANITY_CHECK(dst, 1e-2);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1609,7 +1609,7 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidBuild,
|
||||
cv::gpu::GpuMat dst;
|
||||
d_pyr.getLayer(dst, dstSize);
|
||||
|
||||
GPU_SANITY_CHECK(dst);
|
||||
GPU_SANITY_CHECK(dst, 1e-3);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1646,7 +1646,7 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_ImagePyramidGetLayer,
|
||||
|
||||
TEST_CYCLE() d_pyr.getLayer(dst, dstSize);
|
||||
|
||||
GPU_SANITY_CHECK(dst);
|
||||
GPU_SANITY_CHECK(dst, 1e-3);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -143,7 +143,7 @@ PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap,
|
||||
|
||||
TEST_CYCLE() cv::gpu::createOpticalFlowNeedleMap(u, v, vertex, colors);
|
||||
|
||||
GPU_SANITY_CHECK(vertex, 1e-6);
|
||||
GPU_SANITY_CHECK(vertex, 1e-5);
|
||||
GPU_SANITY_CHECK(colors);
|
||||
}
|
||||
else
|
||||
@@ -340,8 +340,8 @@ PERF_TEST_P(ImagePair_WinSz_Levels_Iters, Video_PyrLKOpticalFlowDense,
|
||||
|
||||
TEST_CYCLE() d_pyrLK.dense(d_frame0, d_frame1, u, v);
|
||||
|
||||
GPU_SANITY_CHECK(u);
|
||||
GPU_SANITY_CHECK(v);
|
||||
GPU_SANITY_CHECK(u, 0.5);
|
||||
GPU_SANITY_CHECK(v, 0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -427,8 +427,8 @@ PERF_TEST_P(ImagePair, Video_OpticalFlowDual_TVL1,
|
||||
|
||||
TEST_CYCLE() d_alg(d_frame0, d_frame1, u, v);
|
||||
|
||||
GPU_SANITY_CHECK(u, 1e-1);
|
||||
GPU_SANITY_CHECK(v, 1e-1);
|
||||
GPU_SANITY_CHECK(u, 0.12);
|
||||
GPU_SANITY_CHECK(v, 0.12);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -317,6 +317,11 @@ void cv::gpu::flip(const GpuMat& src, GpuMat& dst, int flipCode, Stream& stream)
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// LUT
|
||||
|
||||
namespace arithm
|
||||
{
|
||||
void lut(PtrStepSzb src, uchar* lut, int lut_cn, PtrStepSzb dst, bool cc30, cudaStream_t stream);
|
||||
}
|
||||
|
||||
void cv::gpu::LUT(const GpuMat& src, const Mat& lut, GpuMat& dst, Stream& s)
|
||||
{
|
||||
const int cn = src.channels();
|
||||
@@ -328,82 +333,21 @@ void cv::gpu::LUT(const GpuMat& src, const Mat& lut, GpuMat& dst, Stream& s)
|
||||
|
||||
dst.create(src.size(), CV_MAKE_TYPE(lut.depth(), cn));
|
||||
|
||||
NppiSize sz;
|
||||
sz.height = src.rows;
|
||||
sz.width = src.cols;
|
||||
|
||||
Mat nppLut;
|
||||
lut.convertTo(nppLut, CV_32S);
|
||||
|
||||
int nValues3[] = {256, 256, 256};
|
||||
|
||||
Npp32s pLevels[256];
|
||||
for (int i = 0; i < 256; ++i)
|
||||
pLevels[i] = i;
|
||||
|
||||
const Npp32s* pLevels3[3];
|
||||
|
||||
#if (CUDA_VERSION <= 4020)
|
||||
pLevels3[0] = pLevels3[1] = pLevels3[2] = pLevels;
|
||||
#else
|
||||
GpuMat d_pLevels;
|
||||
d_pLevels.upload(Mat(1, 256, CV_32S, pLevels));
|
||||
pLevels3[0] = pLevels3[1] = pLevels3[2] = d_pLevels.ptr<Npp32s>();
|
||||
#endif
|
||||
GpuMat d_lut;
|
||||
d_lut.upload(Mat(1, 256, lut.type(), lut.data));
|
||||
|
||||
int lut_cn = d_lut.channels();
|
||||
bool cc30 = deviceSupports(FEATURE_SET_COMPUTE_30);
|
||||
cudaStream_t stream = StreamAccessor::getStream(s);
|
||||
NppStreamHandler h(stream);
|
||||
|
||||
if (src.type() == CV_8UC1)
|
||||
if (lut_cn == 1)
|
||||
{
|
||||
#if (CUDA_VERSION <= 4020)
|
||||
nppSafeCall( nppiLUT_Linear_8u_C1R(src.ptr<Npp8u>(), static_cast<int>(src.step),
|
||||
dst.ptr<Npp8u>(), static_cast<int>(dst.step), sz, nppLut.ptr<Npp32s>(), pLevels, 256) );
|
||||
#else
|
||||
GpuMat d_nppLut(Mat(1, 256, CV_32S, nppLut.data));
|
||||
nppSafeCall( nppiLUT_Linear_8u_C1R(src.ptr<Npp8u>(), static_cast<int>(src.step),
|
||||
dst.ptr<Npp8u>(), static_cast<int>(dst.step), sz, d_nppLut.ptr<Npp32s>(), d_pLevels.ptr<Npp32s>(), 256) );
|
||||
#endif
|
||||
arithm::lut(src.reshape(1), d_lut.data, lut_cn, dst.reshape(1), cc30, stream);
|
||||
}
|
||||
else
|
||||
else if (lut_cn == 3)
|
||||
{
|
||||
const Npp32s* pValues3[3];
|
||||
|
||||
Mat nppLut3[3];
|
||||
if (nppLut.channels() == 1)
|
||||
{
|
||||
#if (CUDA_VERSION <= 4020)
|
||||
pValues3[0] = pValues3[1] = pValues3[2] = nppLut.ptr<Npp32s>();
|
||||
#else
|
||||
GpuMat d_nppLut(Mat(1, 256, CV_32S, nppLut.data));
|
||||
pValues3[0] = pValues3[1] = pValues3[2] = d_nppLut.ptr<Npp32s>();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::split(nppLut, nppLut3);
|
||||
|
||||
#if (CUDA_VERSION <= 4020)
|
||||
pValues3[0] = nppLut3[0].ptr<Npp32s>();
|
||||
pValues3[1] = nppLut3[1].ptr<Npp32s>();
|
||||
pValues3[2] = nppLut3[2].ptr<Npp32s>();
|
||||
#else
|
||||
GpuMat d_nppLut0(Mat(1, 256, CV_32S, nppLut3[0].data));
|
||||
GpuMat d_nppLut1(Mat(1, 256, CV_32S, nppLut3[1].data));
|
||||
GpuMat d_nppLut2(Mat(1, 256, CV_32S, nppLut3[2].data));
|
||||
|
||||
pValues3[0] = d_nppLut0.ptr<Npp32s>();
|
||||
pValues3[1] = d_nppLut1.ptr<Npp32s>();
|
||||
pValues3[2] = d_nppLut2.ptr<Npp32s>();
|
||||
#endif
|
||||
}
|
||||
|
||||
nppSafeCall( nppiLUT_Linear_8u_C3R(src.ptr<Npp8u>(), static_cast<int>(src.step),
|
||||
dst.ptr<Npp8u>(), static_cast<int>(dst.step), sz, pValues3, pLevels3, nValues3) );
|
||||
arithm::lut(src, d_lut.data, lut_cn, dst, cc30, stream);
|
||||
}
|
||||
|
||||
if (stream == 0)
|
||||
cudaSafeCall( cudaDeviceSynchronize() );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1577,7 +1577,7 @@ namespace
|
||||
|
||||
void rgba_to_mbgra(const GpuMat& src, GpuMat& dst, int, Stream& st)
|
||||
{
|
||||
#if (CUDA_VERSION < 5000)
|
||||
#if (CUDART_VERSION < 5000)
|
||||
(void)src;
|
||||
(void)dst;
|
||||
(void)st;
|
||||
@@ -1947,7 +1947,7 @@ void cv::gpu::swapChannels(GpuMat& image, const int dstOrder[4], Stream& s)
|
||||
|
||||
void cv::gpu::gammaCorrection(const GpuMat& src, GpuMat& dst, bool forward, Stream& stream)
|
||||
{
|
||||
#if (CUDA_VERSION < 5000)
|
||||
#if (CUDART_VERSION < 5000)
|
||||
(void)src;
|
||||
(void)dst;
|
||||
(void)forward;
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
#include "cu_safe_call.h"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
#if defined(HAVE_CUDA) && defined(HAVE_NVCUVID)
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
#if defined(HAVE_CUDA) && defined(HAVE_NVCUVID)
|
||||
|
||||
namespace cv { namespace gpu {
|
||||
namespace detail
|
||||
|
||||
@@ -374,6 +374,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
|
||||
template <int BLOCK_SIZE, int MAX_DESC_LEN, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void matchUnrolledCached(const PtrStepSz<T> query, const PtrStepSz<T> train, const Mask mask, int2* bestTrainIdx, float2* bestDistance)
|
||||
{
|
||||
extern __shared__ int smem[];
|
||||
@@ -424,6 +425,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
|
||||
template <int BLOCK_SIZE, int MAX_DESC_LEN, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void matchUnrolledCached(const PtrStepSz<T> query, const PtrStepSz<T>* trains, int n, const Mask mask, int2* bestTrainIdx, int2* bestImgIdx, float2* bestDistance)
|
||||
{
|
||||
extern __shared__ int smem[];
|
||||
@@ -553,6 +555,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
|
||||
template <int BLOCK_SIZE, int MAX_DESC_LEN, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void matchUnrolled(const PtrStepSz<T> query, const PtrStepSz<T> train, const Mask mask, int2* bestTrainIdx, float2* bestDistance)
|
||||
{
|
||||
extern __shared__ int smem[];
|
||||
@@ -601,6 +604,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
|
||||
template <int BLOCK_SIZE, int MAX_DESC_LEN, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void matchUnrolled(const PtrStepSz<T> query, const PtrStepSz<T>* trains, int n, const Mask mask, int2* bestTrainIdx, int2* bestImgIdx, float2* bestDistance)
|
||||
{
|
||||
extern __shared__ int smem[];
|
||||
@@ -727,6 +731,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
|
||||
template <int BLOCK_SIZE, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void match(const PtrStepSz<T> query, const PtrStepSz<T> train, const Mask mask, int2* bestTrainIdx, float2* bestDistance)
|
||||
{
|
||||
extern __shared__ int smem[];
|
||||
@@ -775,6 +780,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
|
||||
template <int BLOCK_SIZE, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void match(const PtrStepSz<T> query, const PtrStepSz<T>* trains, int n, const Mask mask, int2* bestTrainIdx, int2* bestImgIdx, float2* bestDistance)
|
||||
{
|
||||
extern __shared__ int smem[];
|
||||
@@ -902,6 +908,7 @@ namespace cv { namespace gpu { namespace device
|
||||
// Calc distance kernel
|
||||
|
||||
template <int BLOCK_SIZE, int MAX_DESC_LEN, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void calcDistanceUnrolled(const PtrStepSz<T> query, const PtrStepSz<T> train, const Mask mask, PtrStepf allDist)
|
||||
{
|
||||
extern __shared__ int smem[];
|
||||
@@ -966,6 +973,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
|
||||
template <int BLOCK_SIZE, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void calcDistance(const PtrStepSz<T> query, const PtrStepSz<T> train, const Mask mask, PtrStepf allDist)
|
||||
{
|
||||
extern __shared__ int smem[];
|
||||
@@ -1066,6 +1074,7 @@ namespace cv { namespace gpu { namespace device
|
||||
// find knn match kernel
|
||||
|
||||
template <int BLOCK_SIZE>
|
||||
__launch_bounds__(BLOCK_SIZE)
|
||||
__global__ void findBestMatch(PtrStepSzf allDist, int i, PtrStepi trainIdx, PtrStepf distance)
|
||||
{
|
||||
const int SMEM_SIZE = BLOCK_SIZE > 64 ? BLOCK_SIZE : 64;
|
||||
|
||||
@@ -136,6 +136,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
|
||||
template <int BLOCK_SIZE, int MAX_DESC_LEN, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void matchUnrolledCached(const PtrStepSz<T> query, const PtrStepSz<T> train, const Mask mask, int* bestTrainIdx, float* bestDistance)
|
||||
{
|
||||
extern __shared__ int smem[];
|
||||
@@ -184,6 +185,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
|
||||
template <int BLOCK_SIZE, int MAX_DESC_LEN, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void matchUnrolledCached(const PtrStepSz<T> query, const PtrStepSz<T>* trains, int n, const Mask mask,
|
||||
int* bestTrainIdx, int* bestImgIdx, float* bestDistance)
|
||||
{
|
||||
@@ -296,6 +298,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
|
||||
template <int BLOCK_SIZE, int MAX_DESC_LEN, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void matchUnrolled(const PtrStepSz<T> query, const PtrStepSz<T> train, const Mask mask, int* bestTrainIdx, float* bestDistance)
|
||||
{
|
||||
extern __shared__ int smem[];
|
||||
@@ -342,6 +345,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
|
||||
template <int BLOCK_SIZE, int MAX_DESC_LEN, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void matchUnrolled(const PtrStepSz<T> query, const PtrStepSz<T>* trains, int n, const Mask mask,
|
||||
int* bestTrainIdx, int* bestImgIdx, float* bestDistance)
|
||||
{
|
||||
@@ -451,6 +455,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
|
||||
template <int BLOCK_SIZE, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void match(const PtrStepSz<T> query, const PtrStepSz<T> train, const Mask mask, int* bestTrainIdx, float* bestDistance)
|
||||
{
|
||||
extern __shared__ int smem[];
|
||||
@@ -497,6 +502,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
|
||||
template <int BLOCK_SIZE, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void match(const PtrStepSz<T> query, const PtrStepSz<T>* trains, int n, const Mask mask,
|
||||
int* bestTrainIdx, int* bestImgIdx, float* bestDistance)
|
||||
{
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace cv { namespace gpu { namespace device
|
||||
// Match Unrolled
|
||||
|
||||
template <int BLOCK_SIZE, int MAX_DESC_LEN, bool SAVE_IMG_IDX, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void matchUnrolled(const PtrStepSz<T> query, int imgIdx, const PtrStepSz<T> train, float maxDistance, const Mask mask,
|
||||
PtrStepi bestTrainIdx, PtrStepi bestImgIdx, PtrStepf bestDistance, unsigned int* nMatches, int maxCount)
|
||||
{
|
||||
@@ -164,6 +165,7 @@ namespace cv { namespace gpu { namespace device
|
||||
// Match
|
||||
|
||||
template <int BLOCK_SIZE, bool SAVE_IMG_IDX, typename Dist, typename T, typename Mask>
|
||||
__launch_bounds__(BLOCK_SIZE * BLOCK_SIZE)
|
||||
__global__ void match(const PtrStepSz<T> query, int imgIdx, const PtrStepSz<T> train, float maxDistance, const Mask mask,
|
||||
PtrStepi bestTrainIdx, PtrStepi bestImgIdx, PtrStepf bestDistance, unsigned int* nMatches, int maxCount)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#if !defined CUDA_DISABLER
|
||||
|
||||
#include <cstring>
|
||||
#include "opencv2/gpu/device/common.hpp"
|
||||
#include "opencv2/gpu/device/transform.hpp"
|
||||
#include "opencv2/gpu/device/functional.hpp"
|
||||
|
||||
using namespace cv::gpu;
|
||||
using namespace cv::gpu::device;
|
||||
|
||||
namespace
|
||||
{
|
||||
texture<uchar, cudaTextureType1D, cudaReadModeElementType> texLutTable;
|
||||
|
||||
struct LutC1 : public unary_function<uchar, uchar>
|
||||
{
|
||||
typedef uchar value_type;
|
||||
typedef uchar index_type;
|
||||
|
||||
cudaTextureObject_t texLutTableObj;
|
||||
|
||||
__device__ __forceinline__ uchar operator ()(uchar x) const
|
||||
{
|
||||
#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ < 300)
|
||||
// Use the texture reference
|
||||
return tex1Dfetch(texLutTable, x);
|
||||
#else
|
||||
// Use the texture object
|
||||
return tex1Dfetch<uchar>(texLutTableObj, x);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
struct LutC3 : public unary_function<uchar3, uchar3>
|
||||
{
|
||||
typedef uchar3 value_type;
|
||||
typedef uchar3 index_type;
|
||||
|
||||
cudaTextureObject_t texLutTableObj;
|
||||
|
||||
__device__ __forceinline__ uchar3 operator ()(const uchar3& x) const
|
||||
{
|
||||
#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ < 300)
|
||||
// Use the texture reference
|
||||
return make_uchar3(tex1Dfetch(texLutTable, x.x * 3), tex1Dfetch(texLutTable, x.y * 3 + 1), tex1Dfetch(texLutTable, x.z * 3 + 2));
|
||||
#else
|
||||
// Use the texture object
|
||||
return make_uchar3(tex1Dfetch<uchar>(texLutTableObj, x.x * 3), tex1Dfetch<uchar>(texLutTableObj, x.y * 3 + 1), tex1Dfetch<uchar>(texLutTableObj, x.z * 3 + 2));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace arithm
|
||||
{
|
||||
void lut(PtrStepSzb src, uchar* lut, int lut_cn, PtrStepSzb dst, bool cc30, cudaStream_t stream)
|
||||
{
|
||||
cudaTextureObject_t texLutTableObj;
|
||||
|
||||
if (cc30)
|
||||
{
|
||||
// Use the texture object
|
||||
cudaResourceDesc texRes;
|
||||
std::memset(&texRes, 0, sizeof(texRes));
|
||||
texRes.resType = cudaResourceTypeLinear;
|
||||
texRes.res.linear.devPtr = lut;
|
||||
texRes.res.linear.desc = cudaCreateChannelDesc<uchar>();
|
||||
texRes.res.linear.sizeInBytes = 256 * lut_cn * sizeof(uchar);
|
||||
|
||||
cudaTextureDesc texDescr;
|
||||
std::memset(&texDescr, 0, sizeof(texDescr));
|
||||
|
||||
cudaSafeCall( cudaCreateTextureObject(&texLutTableObj, &texRes, &texDescr, 0) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use the texture reference
|
||||
cudaChannelFormatDesc desc = cudaCreateChannelDesc<uchar>();
|
||||
cudaSafeCall( cudaBindTexture(0, &texLutTable, lut, &desc) );
|
||||
}
|
||||
|
||||
if (lut_cn == 1)
|
||||
{
|
||||
LutC1 op;
|
||||
op.texLutTableObj = texLutTableObj;
|
||||
|
||||
transform((PtrStepSz<uchar>) src, (PtrStepSz<uchar>) dst, op, WithOutMask(), stream);
|
||||
}
|
||||
else if (lut_cn == 3)
|
||||
{
|
||||
LutC3 op;
|
||||
op.texLutTableObj = texLutTableObj;
|
||||
|
||||
transform((PtrStepSz<uchar3>) src, (PtrStepSz<uchar3>) dst, op, WithOutMask(), stream);
|
||||
}
|
||||
|
||||
if (cc30)
|
||||
{
|
||||
// Use the texture object
|
||||
cudaSafeCall( cudaDestroyTextureObject(texLutTableObj) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use the texture reference
|
||||
cudaSafeCall( cudaUnbindTexture(texLutTable) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -77,8 +77,8 @@ namespace cv { namespace gpu { namespace device
|
||||
|
||||
if (dst_x < dst.cols && dst_y < dst.rows)
|
||||
{
|
||||
const float src_x = dst_x * fx;
|
||||
const float src_y = dst_y * fy;
|
||||
const float src_x = (dst_x + 0.5f) * fx - 0.5f;
|
||||
const float src_y = (dst_y + 0.5f) * fy - 0.5f;
|
||||
|
||||
work_type out = VecTraits<work_type>::all(0);
|
||||
|
||||
@@ -86,16 +86,18 @@ namespace cv { namespace gpu { namespace device
|
||||
const int y1 = __float2int_rd(src_y);
|
||||
const int x2 = x1 + 1;
|
||||
const int y2 = y1 + 1;
|
||||
const int x2_read = ::min(x2, src.cols - 1);
|
||||
const int y2_read = ::min(y2, src.rows - 1);
|
||||
const int x1_read = ::max(::min(x1, src.cols - 1), 0);
|
||||
const int y1_read = ::max(::min(y1, src.rows - 1), 0);
|
||||
const int x2_read = ::max(::min(x2, src.cols - 1), 0);
|
||||
const int y2_read = ::max(::min(y2, src.rows - 1), 0);
|
||||
|
||||
T src_reg = src(y1, x1);
|
||||
T src_reg = src(y1_read, x1_read);
|
||||
out = out + src_reg * ((x2 - src_x) * (y2 - src_y));
|
||||
|
||||
src_reg = src(y1, x2_read);
|
||||
src_reg = src(y1_read, x2_read);
|
||||
out = out + src_reg * ((src_x - x1) * (y2 - src_y));
|
||||
|
||||
src_reg = src(y2_read, x1);
|
||||
src_reg = src(y2_read, x1_read);
|
||||
out = out + src_reg * ((x2 - src_x) * (src_y - y1));
|
||||
|
||||
src_reg = src(y2_read, x2_read);
|
||||
@@ -119,6 +121,20 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
}
|
||||
|
||||
template <class Ptr2D, typename T> __global__ void resize_linear(const Ptr2D src, PtrStepSz<T> dst, const float fy, const float fx)
|
||||
{
|
||||
const int dst_x = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
const int dst_y = blockDim.y * blockIdx.y + threadIdx.y;
|
||||
|
||||
if (dst_x < dst.cols && dst_y < dst.rows)
|
||||
{
|
||||
const float src_x = (dst_x + 0.5f) * fx - 0.5f;
|
||||
const float src_y = (dst_y + 0.5f) * fy - 0.5f;
|
||||
|
||||
dst(dst_y, dst_x) = src(src_y, src_x);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Ptr2D, typename T> __global__ void resize_area(const Ptr2D src, PtrStepSz<T> dst)
|
||||
{
|
||||
const int x = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
@@ -231,7 +247,7 @@ namespace cv { namespace gpu { namespace device
|
||||
TextureAccessor<T> texSrc = texAccessor(src, 0, 0);
|
||||
LinearFilter< TextureAccessor<T> > filteredSrc(texSrc);
|
||||
|
||||
resize<<<grid, block>>>(filteredSrc, dst, fy, fx);
|
||||
resize_linear<<<grid, block>>>(filteredSrc, dst, fy, fx);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -241,7 +257,7 @@ namespace cv { namespace gpu { namespace device
|
||||
BorderReader<TextureAccessor<T>, BrdReplicate<T> > brdSrc(texSrc, brd);
|
||||
LinearFilter< BorderReader<TextureAccessor<T>, BrdReplicate<T> > > filteredSrc(brdSrc);
|
||||
|
||||
resize<<<grid, block>>>(filteredSrc, dst, fy, fx);
|
||||
resize_linear<<<grid, block>>>(filteredSrc, dst, fy, fx);
|
||||
}
|
||||
|
||||
cudaSafeCall( cudaGetLastError() );
|
||||
|
||||
@@ -103,16 +103,22 @@ namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
static __device__ __forceinline__ float compute(const uchar* left, const uchar* right)
|
||||
{
|
||||
return fmin(cdata_weight * ::abs((int)*left - *right), cdata_weight * cmax_data_term);
|
||||
int l = *(left);
|
||||
int r = *(right);
|
||||
|
||||
return fmin(cdata_weight * ::abs(l - r), cdata_weight * cmax_data_term);
|
||||
}
|
||||
};
|
||||
template <> struct DataCostPerPixel<3>
|
||||
{
|
||||
static __device__ __forceinline__ float compute(const uchar* left, const uchar* right)
|
||||
{
|
||||
float tb = 0.114f * ::abs((int)left[0] - right[0]);
|
||||
float tg = 0.587f * ::abs((int)left[1] - right[1]);
|
||||
float tr = 0.299f * ::abs((int)left[2] - right[2]);
|
||||
uchar3 l = *((const uchar3*)left);
|
||||
uchar3 r = *((const uchar3*)right);
|
||||
|
||||
float tb = 0.114f * ::abs((int)l.x - r.x);
|
||||
float tg = 0.587f * ::abs((int)l.y - r.y);
|
||||
float tr = 0.299f * ::abs((int)l.z - r.z);
|
||||
|
||||
return fmin(cdata_weight * (tr + tg + tb), cdata_weight * cmax_data_term);
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ void cv::gpu::Stream::enqueueConvert(const GpuMat& src, GpuMat& dst, int dtype,
|
||||
convertTo(src, dst, alpha, beta, stream);
|
||||
}
|
||||
|
||||
#if CUDA_VERSION >= 5000
|
||||
#if CUDART_VERSION >= 5000
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -293,7 +293,7 @@ namespace
|
||||
|
||||
void cv::gpu::Stream::enqueueHostCallback(StreamCallback callback, void* userData)
|
||||
{
|
||||
#if CUDA_VERSION >= 5000
|
||||
#if CUDART_VERSION >= 5000
|
||||
CallbackData* data = new CallbackData;
|
||||
data->callback = callback;
|
||||
data->userData = userData;
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace
|
||||
|
||||
void cv::gpu::graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& bottom, GpuMat& labels, GpuMat& buf, Stream& s)
|
||||
{
|
||||
#if (CUDA_VERSION < 5000)
|
||||
#if (CUDART_VERSION < 5000)
|
||||
CV_Assert(terminals.type() == CV_32S);
|
||||
#else
|
||||
CV_Assert(terminals.type() == CV_32S || terminals.type() == CV_32F);
|
||||
@@ -181,7 +181,7 @@ void cv::gpu::graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTrans
|
||||
|
||||
NppiGraphcutStateHandler state(sznpp, buf.ptr<Npp8u>(), nppiGraphcutInitAlloc);
|
||||
|
||||
#if (CUDA_VERSION < 5000)
|
||||
#if (CUDART_VERSION < 5000)
|
||||
nppSafeCall( nppiGraphcut_32s8u(terminals.ptr<Npp32s>(), leftTransp.ptr<Npp32s>(), rightTransp.ptr<Npp32s>(), top.ptr<Npp32s>(), bottom.ptr<Npp32s>(),
|
||||
static_cast<int>(terminals.step), static_cast<int>(leftTransp.step), sznpp, labels.ptr<Npp8u>(), static_cast<int>(labels.step), state) );
|
||||
#else
|
||||
@@ -204,7 +204,7 @@ void cv::gpu::graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTrans
|
||||
void cv::gpu::graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& topLeft, GpuMat& topRight,
|
||||
GpuMat& bottom, GpuMat& bottomLeft, GpuMat& bottomRight, GpuMat& labels, GpuMat& buf, Stream& s)
|
||||
{
|
||||
#if (CUDA_VERSION < 5000)
|
||||
#if (CUDART_VERSION < 5000)
|
||||
CV_Assert(terminals.type() == CV_32S);
|
||||
#else
|
||||
CV_Assert(terminals.type() == CV_32S || terminals.type() == CV_32F);
|
||||
@@ -253,7 +253,7 @@ void cv::gpu::graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTrans
|
||||
|
||||
NppiGraphcutStateHandler state(sznpp, buf.ptr<Npp8u>(), nppiGraphcut8InitAlloc);
|
||||
|
||||
#if (CUDA_VERSION < 5000)
|
||||
#if (CUDART_VERSION < 5000)
|
||||
nppSafeCall( nppiGraphcut8_32s8u(terminals.ptr<Npp32s>(), leftTransp.ptr<Npp32s>(), rightTransp.ptr<Npp32s>(),
|
||||
top.ptr<Npp32s>(), topLeft.ptr<Npp32s>(), topRight.ptr<Npp32s>(),
|
||||
bottom.ptr<Npp32s>(), bottomLeft.ptr<Npp32s>(), bottomRight.ptr<Npp32s>(),
|
||||
|
||||
@@ -127,9 +127,6 @@ cv::gpu::HOGDescriptor::HOGDescriptor(Size win_size_, Size block_size_, Size blo
|
||||
|
||||
Size cells_per_block = Size(block_size.width / cell_size.width, block_size.height / cell_size.height);
|
||||
CV_Assert(cells_per_block == Size(2, 2));
|
||||
|
||||
cv::Size blocks_per_win = numPartsWithin(win_size, block_size, block_stride);
|
||||
hog::set_up_constants(nbins, block_stride.width, block_stride.height, blocks_per_win.width, blocks_per_win.height);
|
||||
}
|
||||
|
||||
size_t cv::gpu::HOGDescriptor::getDescriptorSize() const
|
||||
@@ -221,6 +218,9 @@ void cv::gpu::HOGDescriptor::computeGradient(const GpuMat& img, GpuMat& _grad, G
|
||||
|
||||
void cv::gpu::HOGDescriptor::computeBlockHistograms(const GpuMat& img)
|
||||
{
|
||||
cv::Size blocks_per_win = numPartsWithin(win_size, block_size, block_stride);
|
||||
hog::set_up_constants(nbins, block_stride.width, block_stride.height, blocks_per_win.width, blocks_per_win.height);
|
||||
|
||||
computeGradient(img, grad, qangle);
|
||||
|
||||
size_t block_hist_size = getBlockHistogramSize();
|
||||
|
||||
@@ -132,7 +132,7 @@ void cv::gpu::meanStdDev(const GpuMat& src, Scalar& mean, Scalar& stddev, GpuMat
|
||||
DeviceBuffer dbuf(2);
|
||||
|
||||
int bufSize;
|
||||
#if (CUDA_VERSION <= 4020)
|
||||
#if (CUDART_VERSION <= 4020)
|
||||
nppSafeCall( nppiMeanStdDev8uC1RGetBufferHostSize(sz, &bufSize) );
|
||||
#else
|
||||
nppSafeCall( nppiMeanStdDevGetBufferHostSize_8u_C1R(sz, &bufSize) );
|
||||
@@ -187,7 +187,7 @@ double cv::gpu::norm(const GpuMat& src1, const GpuMat& src2, int normType)
|
||||
CV_Assert(src1.size() == src2.size() && src1.type() == src2.type());
|
||||
CV_Assert(normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2);
|
||||
|
||||
#if CUDA_VERSION < 5050
|
||||
#if CUDART_VERSION < 5050
|
||||
typedef NppStatus (*func_t)(const Npp8u* pSrc1, int nSrcStep1, const Npp8u* pSrc2, int nSrcStep2, NppiSize oSizeROI, Npp64f* pRetVal);
|
||||
|
||||
static const func_t funcs[] = {nppiNormDiff_Inf_8u_C1R, nppiNormDiff_L1_8u_C1R, nppiNormDiff_L2_8u_C1R};
|
||||
@@ -212,7 +212,7 @@ double cv::gpu::norm(const GpuMat& src1, const GpuMat& src2, int normType)
|
||||
|
||||
DeviceBuffer dbuf;
|
||||
|
||||
#if CUDA_VERSION < 5050
|
||||
#if CUDART_VERSION < 5050
|
||||
nppSafeCall( funcs[funcIdx](src1.ptr<Npp8u>(), static_cast<int>(src1.step), src2.ptr<Npp8u>(), static_cast<int>(src2.step), sz, dbuf) );
|
||||
#else
|
||||
int bufSize;
|
||||
|
||||
@@ -288,7 +288,7 @@ __global__ void scanRows(T_in *d_src, Ncv32u texOffs, Ncv32u srcWidth, Ncv32u sr
|
||||
Ncv32u curElemOffs = offsetX + threadIdx.x;
|
||||
T_out curScanElem;
|
||||
|
||||
T_in curElem;
|
||||
T_in curElem = 0;
|
||||
T_out curElemMod;
|
||||
|
||||
if (curElemOffs < srcWidth)
|
||||
|
||||