Compare commits
210 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7018f94959 | |||
| 533fde66e3 | |||
| 5bd18155be | |||
| aa6b5ac124 | |||
| ca40a749b6 | |||
| d54d580f79 | |||
| 774d6c1d0a | |||
| 302d80d744 | |||
| 286c6b496d | |||
| 44da1f795f | |||
| 71c4e96e17 | |||
| 60fd5c2a3a | |||
| 8271c4e9c4 | |||
| 1f4fe3bb27 | |||
| a0431acb37 | |||
| e3f1d722e7 | |||
| 1c3c94fd2c | |||
| 45a1063c4a | |||
| 1cc80f10ba | |||
| a160158cb3 | |||
| 6a53cb9307 | |||
| 1920232268 | |||
| 7f4eb4f6c6 | |||
| e88a36621e | |||
| 467f5fc90f | |||
| ad018da224 | |||
| 90a1c6b1f0 | |||
| 93d1ceae43 | |||
| 073a7ff95a | |||
| 5bf1a4c08c | |||
| 562ff9d111 | |||
| 32f6e1a554 | |||
| 10bbcca11e | |||
| 19b3aab23f | |||
| df28bb5ccd | |||
| d4ec359f11 | |||
| 3603102c89 | |||
| a615102947 | |||
| 9c91d0103f | |||
| 37a1767286 | |||
| 03662c0589 | |||
| 7c354c14f7 | |||
| d2ba09e6ff | |||
| 934394c5e2 | |||
| 6c3cadbd73 | |||
| 4dda2002f6 | |||
| 539f8032dc | |||
| f8c5128729 | |||
| 150487feda | |||
| b767613d20 | |||
| 197b2e75e1 | |||
| 3516e14e05 | |||
| d82b918a7b | |||
| f60726b090 | |||
| 1675b23a64 | |||
| aa9da6e433 | |||
| 772f6208db | |||
| 0cf1de8eea | |||
| 5947519ff4 | |||
| 084835ec30 | |||
| a67484668e | |||
| 26fd37b27d | |||
| ccaedaedc8 | |||
| c5de129c36 | |||
| 533dd85299 | |||
| 48dc18ed59 | |||
| bac492fff6 | |||
| 1d2d579bd6 | |||
| 80687c8a56 | |||
| 8a1d3929cc | |||
| 281ce7a054 | |||
| 343f4b3026 | |||
| 882426a9b2 | |||
| cf15b9e8ad | |||
| f4f7522fe7 | |||
| 1b4e3ec35a | |||
| b9d5f3f6e9 | |||
| 587402859e | |||
| 0421da78b3 | |||
| b027a84fa1 | |||
| fbbf4e380f | |||
| faed8f43d6 | |||
| 9a15c7a899 | |||
| 35768ed638 | |||
| 161f50962d | |||
| e638b9e805 | |||
| d7737528d1 | |||
| 18c0511d3c | |||
| 06a1c90679 | |||
| bdb82d181f | |||
| 89833853fa | |||
| 25d125fba1 | |||
| d1229efeec | |||
| fd7a2defae | |||
| fcc481e751 | |||
| 1984aacb27 | |||
| eaaa2d27d5 | |||
| 74d8527f8a | |||
| 57cf3d1766 | |||
| f81b3101e8 | |||
| 81aefed13a | |||
| 41040e589f | |||
| 6eb26c1519 | |||
| ad7a871708 | |||
| 634ffed488 | |||
| ebe36d6e7c | |||
| d68e62c968 | |||
| b027eac173 | |||
| 2ed24876af | |||
| b08a6ccd9d | |||
| d558260a8e | |||
| 023a42ba55 | |||
| 7409f21e9f | |||
| 62f27b28ed | |||
| 599f5ef51b | |||
| 86e12b6074 | |||
| 5dff283b39 | |||
| 341c3d5933 | |||
| 988555a5d9 | |||
| e11333dd83 | |||
| af2434c547 | |||
| a4c883c098 | |||
| 0a531815c5 | |||
| a15db2d9cf | |||
| efc1c39315 | |||
| 3334b1437b | |||
| 34103ef1cb | |||
| e7f348e720 | |||
| da9be8231f | |||
| ed2cdb71e5 | |||
| bbe48eaac6 | |||
| bab826a381 | |||
| 77294855d7 | |||
| d8187f7518 | |||
| 9e83463128 | |||
| e98c9a7ce3 | |||
| 204651e0e2 | |||
| 042892f0d7 | |||
| 7cefaa49dd | |||
| fc41e8850b | |||
| 38b3698b97 | |||
| c2746b5d2a | |||
| daff2a0674 | |||
| ad5c2de97c | |||
| 9c285da329 | |||
| de37cfc224 | |||
| 946c09f58c | |||
| 4e168ffdf3 | |||
| d7bbafd683 | |||
| e90c233551 | |||
| 06897dbdb5 | |||
| 39020fc9cf | |||
| d5489f3a68 | |||
| 5a5a487612 | |||
| 46775ad186 | |||
| 901d9b70b0 | |||
| 0b4e043442 | |||
| d0c3c4c373 | |||
| 6c5dc17a1e | |||
| cf3757448d | |||
| 8578f9c565 | |||
| c9c09262f7 | |||
| faac7f18c7 | |||
| 8d58b238ca | |||
| 51bd56f19d | |||
| b111fb94b7 | |||
| 544dd8b130 | |||
| 246a793d82 | |||
| d31a0eab9e | |||
| ccbc764c02 | |||
| 60a5ada454 | |||
| d3c2b15f82 | |||
| b030d7e6a1 | |||
| 64d8cf1e2e | |||
| d262b04d99 | |||
| cce2d9927e | |||
| 79878a57a9 | |||
| 03fe86f0a3 | |||
| 13a0c14e6c | |||
| 6e022dcb06 | |||
| c38023f4e7 | |||
| cbb5fc0acc | |||
| 2df3abe16b | |||
| ecec53f509 | |||
| 023102c804 | |||
| 52c05e75cc | |||
| 3d48994a72 | |||
| 7b160fa3cb | |||
| 71d3654832 | |||
| 2c29ee9e00 | |||
| aafda43df1 | |||
| 39127d942e | |||
| b068e63618 | |||
| 4b8fb6c246 | |||
| 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
|
||||
# ===================================================
|
||||
@@ -601,6 +607,12 @@ if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH AND UNIX)
|
||||
install(PROGRAMS "${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh"
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT tests)
|
||||
else()
|
||||
set(OPENCV_PYTHON_TESTS_LIST "")
|
||||
if(BUILD_opencv_python)
|
||||
file(GLOB py_tests modules/python/test/*.py)
|
||||
install(PROGRAMS ${py_tests} DESTINATION ${OPENCV_TEST_INSTALL_PATH} COMPONENT tests)
|
||||
set(OPENCV_PYTHON_TESTS_LIST "test2.py")
|
||||
endif()
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv_testing.sh.in"
|
||||
"${CMAKE_BINARY_DIR}/unix-install/opencv_testing.sh" @ONLY)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/unix-install/opencv_testing.sh"
|
||||
@@ -609,7 +621,6 @@ if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH AND UNIX)
|
||||
"${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh" @ONLY)
|
||||
install(PROGRAMS "${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh"
|
||||
DESTINATION ${OPENCV_TEST_INSTALL_PATH} COMPONENT tests)
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -745,8 +756,8 @@ if(WIN32)
|
||||
status("")
|
||||
status(" Windows RT support:" HAVE_WINRT THEN YES ELSE NO)
|
||||
if (ENABLE_WINRT_MODE OR ENABLE_WINRT_MODE_NATIVE)
|
||||
status(" Windows SDK v8.0:" ${WINDOWS_SDK_PATH})
|
||||
status(" Visual Studio 2012:" ${VISUAL_STUDIO_PATH})
|
||||
status(" Windows (Phone) SDK v8.0/v8.1:" ${WINDOWS_SDK_PATH})
|
||||
status(" Visual Studio 2012/2013:" ${VISUAL_STUDIO_PATH})
|
||||
endif()
|
||||
endif(WIN32)
|
||||
|
||||
@@ -861,10 +872,12 @@ endif(DEFINED WITH_FFMPEG)
|
||||
if(DEFINED WITH_GSTREAMER)
|
||||
status(" GStreamer:" HAVE_GSTREAMER THEN "" ELSE NO)
|
||||
if(HAVE_GSTREAMER)
|
||||
status(" base:" "YES (ver ${ALIASOF_gstreamer-base-0.10_VERSION})")
|
||||
status(" app:" "YES (ver ${ALIASOF_gstreamer-app-0.10_VERSION})")
|
||||
status(" video:" "YES (ver ${ALIASOF_gstreamer-video-0.10_VERSION})")
|
||||
endif()
|
||||
status(" base:" "YES (ver ${GSTREAMER_BASE_VERSION})")
|
||||
status(" video:" "YES (ver ${GSTREAMER_VIDEO_VERSION})")
|
||||
status(" app:" "YES (ver ${GSTREAMER_APP_VERSION})")
|
||||
status(" riff:" "YES (ver ${GSTREAMER_RIFF_VERSION})")
|
||||
status(" pbutils:" "YES (ver ${GSTREAMER_PBUTILS_VERSION})")
|
||||
endif(HAVE_GSTREAMER)
|
||||
endif(DEFINED WITH_GSTREAMER)
|
||||
|
||||
if(DEFINED WITH_OPENNI)
|
||||
@@ -905,8 +918,9 @@ if(DEFINED WITH_V4L)
|
||||
else()
|
||||
set(HAVE_CAMV4L2_STR "NO")
|
||||
endif()
|
||||
status(" V4L/V4L2:" HAVE_LIBV4L THEN "Using libv4l (ver ${ALIASOF_libv4l1_VERSION})"
|
||||
ELSE "${HAVE_CAMV4L_STR}/${HAVE_CAMV4L2_STR}")
|
||||
status(" V4L/V4L2:" HAVE_LIBV4L
|
||||
THEN "Using libv4l1 (ver ${ALIASOF_libv4l1_VERSION}) / libv4l2 (ver ${ALIASOF_libv4l2_VERSION})"
|
||||
ELSE "${HAVE_CAMV4L_STR}/${HAVE_CAMV4L2_STR}")
|
||||
endif(DEFINED WITH_V4L)
|
||||
|
||||
if(DEFINED WITH_DSHOW)
|
||||
|
||||
@@ -29,6 +29,9 @@ set(cvhaartraining_lib_src
|
||||
cvhaarclassifier.cpp
|
||||
cvhaartraining.cpp
|
||||
cvsamples.cpp
|
||||
cvsamplesoutput.cpp
|
||||
cvsamplesoutput.h
|
||||
ioutput.h
|
||||
)
|
||||
|
||||
add_library(opencv_haartraining_engine STATIC ${cvhaartraining_lib_src})
|
||||
|
||||
@@ -50,10 +50,12 @@
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include <ctime>
|
||||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "cvhaartraining.h"
|
||||
#include "ioutput.h"
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
@@ -71,11 +73,12 @@ int main( int argc, char* argv[] )
|
||||
double maxxangle = 1.1;
|
||||
double maxyangle = 1.1;
|
||||
double maxzangle = 0.5;
|
||||
int showsamples = 0;
|
||||
bool showsamples = false;
|
||||
/* the samples are adjusted to this scale in the sample preview window */
|
||||
double scale = 4.0;
|
||||
int width = 24;
|
||||
int height = 24;
|
||||
bool pngoutput = false; /* whether to make the samples in png or in jpg*/
|
||||
|
||||
srand((unsigned int)time(0));
|
||||
|
||||
@@ -92,7 +95,8 @@ int main( int argc, char* argv[] )
|
||||
" [-maxyangle <max_y_rotation_angle = %f>]\n"
|
||||
" [-maxzangle <max_z_rotation_angle = %f>]\n"
|
||||
" [-show [<scale = %f>]]\n"
|
||||
" [-w <sample_width = %d>]\n [-h <sample_height = %d>]\n",
|
||||
" [-w <sample_width = %d>]\n [-h <sample_height = %d>]\n"
|
||||
" [-pngoutput]",
|
||||
argv[0], num, bgcolor, bgthreshold, maxintensitydev,
|
||||
maxxangle, maxyangle, maxzangle, scale, width, height );
|
||||
|
||||
@@ -155,7 +159,7 @@ int main( int argc, char* argv[] )
|
||||
}
|
||||
else if( !strcmp( argv[i], "-show" ) )
|
||||
{
|
||||
showsamples = 1;
|
||||
showsamples = true;
|
||||
if( i+1 < argc && strlen( argv[i+1] ) > 0 && argv[i+1][0] != '-' )
|
||||
{
|
||||
double d;
|
||||
@@ -172,6 +176,10 @@ int main( int argc, char* argv[] )
|
||||
{
|
||||
height = atoi( argv[++i] );
|
||||
}
|
||||
else if( !strcmp( argv[i], "-pngoutput" ) )
|
||||
{
|
||||
pngoutput = true;
|
||||
}
|
||||
}
|
||||
|
||||
printf( "Info file name: %s\n", ((infoname == NULL) ? nullname : infoname ) );
|
||||
@@ -190,10 +198,14 @@ int main( int argc, char* argv[] )
|
||||
printf( "Show samples: %s\n", (showsamples) ? "TRUE" : "FALSE" );
|
||||
if( showsamples )
|
||||
{
|
||||
printf( "Scale: %g\n", scale );
|
||||
printf( "Scale applied to display : %g\n", scale );
|
||||
}
|
||||
if( !pngoutput)
|
||||
{
|
||||
printf( "Original image will be scaled to:\n");
|
||||
printf( "\tWidth: $backgroundWidth / %d\n", width );
|
||||
printf( "\tHeight: $backgroundHeight / %d\n", height );
|
||||
}
|
||||
printf( "Width: %d\n", width );
|
||||
printf( "Height: %d\n", height );
|
||||
|
||||
/* determine action */
|
||||
if( imagename && vecname )
|
||||
@@ -207,13 +219,24 @@ int main( int argc, char* argv[] )
|
||||
|
||||
printf( "Done\n" );
|
||||
}
|
||||
else if( imagename && bgfilename && infoname )
|
||||
else if( imagename && bgfilename && infoname)
|
||||
{
|
||||
printf( "Create test samples from single image applying distortions...\n" );
|
||||
printf( "Create data set from single image applying distortions...\n"
|
||||
"Output format: %s\n",
|
||||
(( pngoutput ) ? "PNG" : "JPG") );
|
||||
|
||||
cvCreateTestSamples( infoname, imagename, bgcolor, bgthreshold, bgfilename, num,
|
||||
invert, maxintensitydev,
|
||||
maxxangle, maxyangle, maxzangle, showsamples, width, height );
|
||||
std::auto_ptr<DatasetGenerator> creator;
|
||||
if( pngoutput )
|
||||
{
|
||||
creator = std::auto_ptr<DatasetGenerator>( new PngDatasetGenerator( infoname ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
creator = std::auto_ptr<DatasetGenerator>( new JpgDatasetGenerator( infoname ) );
|
||||
}
|
||||
creator->create( imagename, bgcolor, bgthreshold, bgfilename, num,
|
||||
invert, maxintensitydev, maxxangle, maxyangle, maxzangle,
|
||||
showsamples, width, height );
|
||||
|
||||
printf( "Done\n" );
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
#include "cvhaartraining.h"
|
||||
#include "_cvhaartraining.h"
|
||||
|
||||
#include "ioutput.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
@@ -2841,14 +2843,12 @@ void cvCreateTreeCascadeClassifier( const char* dirname,
|
||||
cvReleaseMat( &features_idx );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void cvCreateTrainingSamples( const char* filename,
|
||||
const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
int showsamples,
|
||||
bool showsamples,
|
||||
int winwidth, int winheight )
|
||||
{
|
||||
CvSampleDistortionData data;
|
||||
@@ -2915,7 +2915,7 @@ void cvCreateTrainingSamples( const char* filename,
|
||||
cvShowImage( "Sample", &sample );
|
||||
if( cvWaitKey( 0 ) == 27 )
|
||||
{
|
||||
showsamples = 0;
|
||||
showsamples = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2942,45 +2942,43 @@ void cvCreateTrainingSamples( const char* filename,
|
||||
|
||||
}
|
||||
|
||||
#define CV_INFO_FILENAME "info.dat"
|
||||
DatasetGenerator::DatasetGenerator( IOutput* _writer )
|
||||
:writer(_writer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void cvCreateTestSamples( const char* infoname,
|
||||
const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
int showsamples,
|
||||
int winwidth, int winheight )
|
||||
void DatasetGenerator::showSamples(bool* show, CvMat *img) const
|
||||
{
|
||||
if( *show )
|
||||
{
|
||||
cvShowImage( "Image", img);
|
||||
if( cvWaitKey( 0 ) == 27 )
|
||||
{
|
||||
*show = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DatasetGenerator::create(const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
bool showsamples,
|
||||
int winwidth, int winheight )
|
||||
{
|
||||
CvSampleDistortionData data;
|
||||
|
||||
assert( infoname != NULL );
|
||||
assert( imgfilename != NULL );
|
||||
assert( bgfilename != NULL );
|
||||
|
||||
if( !icvMkDir( infoname ) )
|
||||
{
|
||||
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Unable to create directory hierarchy: %s\n", infoname );
|
||||
#endif /* CV_VERBOSE */
|
||||
|
||||
return;
|
||||
}
|
||||
if( icvStartSampleDistortion( imgfilename, bgcolor, bgthreshold, &data ) )
|
||||
{
|
||||
char fullname[PATH_MAX];
|
||||
char* filename;
|
||||
CvMat win;
|
||||
FILE* info;
|
||||
|
||||
if( icvInitBackgroundReaders( bgfilename, cvSize( 10, 10 ) ) )
|
||||
{
|
||||
int i;
|
||||
int x, y, width, height;
|
||||
float scale;
|
||||
float maxscale;
|
||||
int inverse;
|
||||
|
||||
if( showsamples )
|
||||
@@ -2988,73 +2986,112 @@ void cvCreateTestSamples( const char* infoname,
|
||||
cvNamedWindow( "Image", CV_WINDOW_AUTOSIZE );
|
||||
}
|
||||
|
||||
info = fopen( infoname, "w" );
|
||||
strcpy( fullname, infoname );
|
||||
filename = strrchr( fullname, '\\' );
|
||||
if( filename == NULL )
|
||||
{
|
||||
filename = strrchr( fullname, '/' );
|
||||
}
|
||||
if( filename == NULL )
|
||||
{
|
||||
filename = fullname;
|
||||
}
|
||||
else
|
||||
{
|
||||
filename++;
|
||||
}
|
||||
|
||||
count = MIN( count, cvbgdata->count );
|
||||
inverse = invert;
|
||||
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
icvGetNextFromBackgroundData( cvbgdata, cvbgreader );
|
||||
|
||||
maxscale = MIN( 0.7F * cvbgreader->src.cols / winwidth,
|
||||
0.7F * cvbgreader->src.rows / winheight );
|
||||
if( maxscale < 1.0F ) continue;
|
||||
CvRect boundingBox = getObjectPosition( cvSize( cvbgreader->src.cols,
|
||||
cvbgreader->src.rows ),
|
||||
cvGetSize(data.img),
|
||||
cvSize( winwidth, winheight ) );
|
||||
if(boundingBox.width <= 0 || boundingBox.height <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
scale = (maxscale - 1.0F) * rand() / RAND_MAX + 1.0F;
|
||||
width = (int) (scale * winwidth);
|
||||
height = (int) (scale * winheight);
|
||||
x = (int) ((0.1+0.8 * rand()/RAND_MAX) * (cvbgreader->src.cols - width));
|
||||
y = (int) ((0.1+0.8 * rand()/RAND_MAX) * (cvbgreader->src.rows - height));
|
||||
cvGetSubArr( &cvbgreader->src, &win, boundingBox );
|
||||
|
||||
cvGetSubArr( &cvbgreader->src, &win, cvRect( x, y ,width, height ) );
|
||||
if( invert == CV_RANDOM_INVERT )
|
||||
{
|
||||
inverse = (rand() > (RAND_MAX/2));
|
||||
}
|
||||
|
||||
icvPlaceDistortedSample( &win, inverse, maxintensitydev,
|
||||
maxxangle, maxyangle, maxzangle,
|
||||
1, 0.0, 0.0, &data );
|
||||
|
||||
writer->write( cvbgreader->src, boundingBox );
|
||||
|
||||
sprintf( filename, "%04d_%04d_%04d_%04d_%04d.jpg",
|
||||
(i + 1), x, y, width, height );
|
||||
|
||||
if( info )
|
||||
{
|
||||
fprintf( info, "%s %d %d %d %d %d\n",
|
||||
filename, 1, x, y, width, height );
|
||||
}
|
||||
|
||||
cvSaveImage( fullname, &cvbgreader->src );
|
||||
if( showsamples )
|
||||
{
|
||||
cvShowImage( "Image", &cvbgreader->src );
|
||||
if( cvWaitKey( 0 ) == 27 )
|
||||
{
|
||||
showsamples = 0;
|
||||
}
|
||||
}
|
||||
showSamples(&showsamples, &cvbgreader->src);
|
||||
}
|
||||
if( info ) fclose( info );
|
||||
icvDestroyBackgroundReaders();
|
||||
}
|
||||
icvEndSampleDistortion( &data );
|
||||
}
|
||||
}
|
||||
|
||||
DatasetGenerator::~DatasetGenerator()
|
||||
{
|
||||
delete writer;
|
||||
}
|
||||
|
||||
|
||||
JpgDatasetGenerator::JpgDatasetGenerator( const char* filename )
|
||||
:DatasetGenerator( IOutput::createOutput( filename, IOutput::JPG_DATASET ) )
|
||||
{
|
||||
}
|
||||
|
||||
CvSize JpgDatasetGenerator::scaleObjectSize( const CvSize& bgImgSize,
|
||||
const CvSize& ,
|
||||
const CvSize& sampleSize) const
|
||||
{
|
||||
float scale;
|
||||
float maxscale;
|
||||
|
||||
maxscale = MIN( 0.7F * bgImgSize.width / sampleSize.width,
|
||||
0.7F * bgImgSize.height / sampleSize.height );
|
||||
if( maxscale < 1.0F )
|
||||
{
|
||||
scale = -1.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale = (maxscale - 1.0F) * rand() / RAND_MAX + 1.0F;
|
||||
}
|
||||
|
||||
int width = (int) (scale * sampleSize.width);
|
||||
int height = (int) (scale * sampleSize.height);
|
||||
|
||||
return cvSize( width, height );
|
||||
}
|
||||
|
||||
CvRect DatasetGenerator::getObjectPosition(const CvSize& bgImgSize,
|
||||
const CvSize& imgSize,
|
||||
const CvSize& sampleSize) const
|
||||
{
|
||||
CvSize size = scaleObjectSize( bgImgSize, imgSize, sampleSize );
|
||||
|
||||
int width = size.width;
|
||||
int height = size.height;
|
||||
int x = (int) ((0.1 + 0.8 * rand() / RAND_MAX) * (bgImgSize.width - width));
|
||||
int y = (int) ((0.1 + 0.8 * rand() / RAND_MAX) * (bgImgSize.height - height));
|
||||
|
||||
return cvRect( x, y, width, height );
|
||||
}
|
||||
|
||||
|
||||
PngDatasetGenerator::PngDatasetGenerator(const char* filename)
|
||||
:DatasetGenerator( IOutput::createOutput( filename, IOutput::PNG_DATASET ) )
|
||||
{
|
||||
}
|
||||
|
||||
CvSize PngDatasetGenerator::scaleObjectSize( const CvSize& bgImgSize,
|
||||
const CvSize& imgSize,
|
||||
const CvSize& ) const
|
||||
{
|
||||
float scale;
|
||||
|
||||
scale = MIN( 0.3F * bgImgSize.width / imgSize.width,
|
||||
0.3F * bgImgSize.height / imgSize.height );
|
||||
|
||||
|
||||
int width = (int) (scale * imgSize.width);
|
||||
int height = (int) (scale * imgSize.height);
|
||||
|
||||
return cvSize( width, height );
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
|
||||
@@ -48,6 +48,11 @@
|
||||
#ifndef _CVHAARTRAINING_H_
|
||||
#define _CVHAARTRAINING_H_
|
||||
|
||||
class IOutput;
|
||||
struct CvRect;
|
||||
struct CvSize;
|
||||
struct CvMat;
|
||||
|
||||
/*
|
||||
* cvCreateTrainingSamples
|
||||
*
|
||||
@@ -74,23 +79,30 @@
|
||||
*/
|
||||
#define CV_RANDOM_INVERT 0x7FFFFFFF
|
||||
|
||||
void cvCreateTrainingSamples( const char* filename,
|
||||
void cvCreateTrainingSamples(const char* filename,
|
||||
const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert = 0, int maxintensitydev = 40,
|
||||
double maxxangle = 1.1,
|
||||
double maxyangle = 1.1,
|
||||
double maxzangle = 0.5,
|
||||
int showsamples = 0,
|
||||
bool showsamples = false,
|
||||
int winwidth = 24, int winheight = 24 );
|
||||
|
||||
void cvCreateTestSamples( const char* infoname,
|
||||
const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
void cvCreatePngTrainingSet(const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
int winwidth, int winheight,
|
||||
IOutput *writer );
|
||||
|
||||
void cvCreateTestSamples(const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
int showsamples,
|
||||
int winwidth, int winheight );
|
||||
int winwidth, int winheight,
|
||||
IOutput* writer);
|
||||
|
||||
/*
|
||||
* cvCreateTrainingSamplesFromInfo
|
||||
@@ -189,4 +201,50 @@ void cvCreateTreeCascadeClassifier( const char* dirname,
|
||||
int boosttype, int stumperror,
|
||||
int maxtreesplits, int minpos, bool bg_vecfile = false );
|
||||
|
||||
|
||||
class DatasetGenerator
|
||||
{
|
||||
public:
|
||||
DatasetGenerator( IOutput* _writer );
|
||||
void create( const char* imgfilename, int bgcolor, int bgthreshold,
|
||||
const char* bgfilename, int count,
|
||||
int invert, int maxintensitydev,
|
||||
double maxxangle, double maxyangle, double maxzangle,
|
||||
bool showsamples,
|
||||
int winwidth, int winheight);
|
||||
virtual ~DatasetGenerator();
|
||||
private:
|
||||
virtual void showSamples( bool* showSamples, CvMat* img ) const;
|
||||
|
||||
CvRect getObjectPosition( const CvSize& bgImgSize,
|
||||
const CvSize& imgSize,
|
||||
const CvSize& sampleSize ) const;
|
||||
virtual CvSize scaleObjectSize(const CvSize& bgImgSize,
|
||||
const CvSize& imgSize ,
|
||||
const CvSize& sampleSize) const =0 ;
|
||||
private:
|
||||
IOutput* writer;
|
||||
};
|
||||
|
||||
/* Provides the functionality of test set generating */
|
||||
class JpgDatasetGenerator: public DatasetGenerator
|
||||
{
|
||||
public:
|
||||
JpgDatasetGenerator(const char* filename);
|
||||
private:
|
||||
CvSize scaleObjectSize(const CvSize& bgImgSize,
|
||||
const CvSize& ,
|
||||
const CvSize& sampleSize) const;
|
||||
};
|
||||
|
||||
class PngDatasetGenerator: public DatasetGenerator
|
||||
{
|
||||
public:
|
||||
PngDatasetGenerator(const char *filename);
|
||||
private:
|
||||
CvSize scaleObjectSize(const CvSize& bgImgSize,
|
||||
const CvSize& imgSize ,
|
||||
const CvSize& ) const;
|
||||
};
|
||||
|
||||
#endif /* _CVHAARTRAINING_H_ */
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
#include "cvsamplesoutput.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "_cvcommon.h"
|
||||
#include "highgui.h"
|
||||
|
||||
/* print statistic info */
|
||||
#define CV_VERBOSE 1
|
||||
|
||||
IOutput::IOutput()
|
||||
: currentIdx(0)
|
||||
{}
|
||||
|
||||
void IOutput::findFilePathPart(char **partOfPath, char *fullPath)
|
||||
{
|
||||
*partOfPath = strrchr( fullPath, '\\' );
|
||||
if( *partOfPath == NULL )
|
||||
{
|
||||
*partOfPath = strrchr( fullPath, '/' );
|
||||
}
|
||||
if( *partOfPath == NULL )
|
||||
{
|
||||
*partOfPath = fullPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
*partOfPath += 1;
|
||||
}
|
||||
}
|
||||
|
||||
IOutput* IOutput::createOutput(const char *filename,
|
||||
IOutput::OutputType type)
|
||||
{
|
||||
IOutput* output = 0;
|
||||
switch (type) {
|
||||
case IOutput::PNG_DATASET:
|
||||
output = new PngDatasetOutput();
|
||||
break;
|
||||
case IOutput::JPG_DATASET:
|
||||
output = new JpgDatasetOutput();
|
||||
break;
|
||||
default:
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Invalid output type, valid types are: PNG_TRAINING_SET, JPG_TEST_SET");
|
||||
#endif /* CV_VERBOSE */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( output->init( filename ) )
|
||||
return output;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool PngDatasetOutput::init( const char* annotationsListFileName )
|
||||
{
|
||||
IOutput::init( annotationsListFileName );
|
||||
|
||||
if(imgFileName == imgFullPath)
|
||||
{
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Invalid path to annotations file: %s\n"
|
||||
"It should contain a parent directory name\n", imgFullPath );
|
||||
#endif /* CV_VERBOSE */
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const char* annotationsdirname = "/annotations/";
|
||||
const char* positivesdirname = "/pos/";
|
||||
|
||||
imgFileName[-1] = '\0'; //erase slash at the end of the path
|
||||
imgFileName -= 1;
|
||||
|
||||
//copy path to dataset top-level dir
|
||||
strcpy(annotationFullPath, imgFullPath);
|
||||
//find the name of annotation starting from the top-level dataset dir
|
||||
findFilePathPart(&annotationRelativePath, annotationFullPath);
|
||||
if( !strcmp( annotationRelativePath, ".." ) || !strcmp( annotationRelativePath, "." ) )
|
||||
{
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Invalid path to annotations file: %s\n"
|
||||
"It should contain a parent directory name\n", annotationsListFileName );
|
||||
#endif /* CV_VERBOSE */
|
||||
return false;
|
||||
}
|
||||
//find the name of output image starting from the top-level dataset dir
|
||||
findFilePathPart(&imgRelativePath, imgFullPath);
|
||||
annotationFileName = annotationFullPath + strlen(annotationFullPath);
|
||||
|
||||
sprintf(annotationFileName, "%s", annotationsdirname);
|
||||
annotationFileName += strlen(annotationFileName);
|
||||
sprintf(imgFileName, "%s", positivesdirname);
|
||||
imgFileName += strlen(imgFileName);
|
||||
|
||||
if( !icvMkDir( annotationFullPath ) )
|
||||
{
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Unable to create directory hierarchy: %s\n", annotationFullPath );
|
||||
#endif /* CV_VERBOSE */
|
||||
return false;
|
||||
}
|
||||
if( !icvMkDir( imgFullPath ) )
|
||||
{
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Unable to create directory hierarchy: %s\n", imgFullPath );
|
||||
#endif /* CV_VERBOSE */
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PngDatasetOutput::write( const CvMat& img,
|
||||
const CvRect& boundingBox )
|
||||
{
|
||||
CvRect bbox = addBoundingboxBorder(boundingBox);
|
||||
|
||||
sprintf( imgFileName,
|
||||
"%04d_%04d_%04d_%04d_%04d",
|
||||
++currentIdx,
|
||||
bbox.x,
|
||||
bbox.y,
|
||||
bbox.width,
|
||||
bbox.height );
|
||||
|
||||
sprintf( annotationFileName, "%s.txt", imgFileName );
|
||||
fprintf( annotationsList, "%s\n", annotationRelativePath );
|
||||
|
||||
FILE* annotationFile = fopen( annotationFullPath, "w" );
|
||||
if(annotationFile == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
sprintf( imgFileName + strlen(imgFileName), ".%s", extension );
|
||||
|
||||
|
||||
|
||||
fprintf( annotationFile,
|
||||
"Image filename : \"%s\"\n"
|
||||
"Bounding box for object 1 \"PASperson\" (Xmin, Ymin) - (Xmax, Ymax) : (%d, %d) - (%d, %d)",
|
||||
imgRelativePath,
|
||||
bbox.x,
|
||||
bbox.y,
|
||||
bbox.x + bbox.width,
|
||||
bbox.y + bbox.height );
|
||||
fclose( annotationFile );
|
||||
|
||||
cvSaveImage( imgFullPath, &img);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CvRect PngDatasetOutput::addBoundingboxBorder(const CvRect& bbox) const
|
||||
{
|
||||
CvRect boundingBox = bbox;
|
||||
int border = 5;
|
||||
|
||||
boundingBox.x -= border;
|
||||
boundingBox.y -= border;
|
||||
boundingBox.width += 2*border;
|
||||
boundingBox.height += 2*border;
|
||||
|
||||
return boundingBox;
|
||||
}
|
||||
|
||||
IOutput::~IOutput()
|
||||
{
|
||||
if(annotationsList)
|
||||
{
|
||||
fclose(annotationsList);
|
||||
}
|
||||
}
|
||||
|
||||
bool IOutput::init(const char *filename)
|
||||
{
|
||||
assert( filename != NULL );
|
||||
|
||||
if( !icvMkDir( filename ) )
|
||||
{
|
||||
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Unable to create directory hierarchy: %s\n", filename );
|
||||
#endif /* CV_VERBOSE */
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
annotationsList = fopen( filename, "w" );
|
||||
if( annotationsList == NULL )
|
||||
{
|
||||
#if CV_VERBOSE
|
||||
fprintf( stderr, "Unable to create info file: %s\n", filename );
|
||||
#endif /* CV_VERBOSE */
|
||||
return false;
|
||||
}
|
||||
strcpy( imgFullPath, filename );
|
||||
|
||||
findFilePathPart( &imgFileName, imgFullPath );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JpgDatasetOutput::write( const CvMat& img,
|
||||
const CvRect& boundingBox )
|
||||
{
|
||||
sprintf( imgFileName, "%04d_%04d_%04d_%04d_%04d.jpg",
|
||||
++currentIdx,
|
||||
boundingBox.x,
|
||||
boundingBox.y,
|
||||
boundingBox.width,
|
||||
boundingBox.height );
|
||||
|
||||
fprintf( annotationsList, "%s %d %d %d %d %d\n",
|
||||
imgFileName,
|
||||
1,
|
||||
boundingBox.x,
|
||||
boundingBox.y,
|
||||
boundingBox.width,
|
||||
boundingBox.height );
|
||||
|
||||
cvSaveImage( imgFullPath, &img);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef CVSAMPLESOUTPUT_H
|
||||
#define CVSAMPLESOUTPUT_H
|
||||
|
||||
#include "ioutput.h"
|
||||
|
||||
class PngDatasetOutput: public IOutput
|
||||
{
|
||||
friend IOutput* IOutput::createOutput(const char *filename, OutputType type);
|
||||
public:
|
||||
virtual bool write( const CvMat& img,
|
||||
const CvRect& boundingBox);
|
||||
|
||||
virtual ~PngDatasetOutput(){}
|
||||
private:
|
||||
PngDatasetOutput()
|
||||
: extension("png")
|
||||
, destImgWidth(640)
|
||||
, destImgHeight(480)
|
||||
{}
|
||||
|
||||
virtual bool init(const char* annotationsListFileName );
|
||||
|
||||
CvRect addBoundingboxBorder(const CvRect& bbox) const;
|
||||
private:
|
||||
|
||||
char annotationFullPath[PATH_MAX];
|
||||
char* annotationFileName;
|
||||
char* annotationRelativePath;
|
||||
char* imgRelativePath;
|
||||
const char* extension;
|
||||
|
||||
int destImgWidth;
|
||||
int destImgHeight ;
|
||||
};
|
||||
|
||||
class JpgDatasetOutput: public IOutput
|
||||
{
|
||||
friend IOutput* IOutput::createOutput(const char *filename, OutputType type);
|
||||
public:
|
||||
virtual bool write( const CvMat& img,
|
||||
const CvRect& boundingBox );
|
||||
virtual ~JpgDatasetOutput(){}
|
||||
private:
|
||||
JpgDatasetOutput(){}
|
||||
};
|
||||
#endif // CVSAMPLESOUTPUT_H
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef IOUTPUT_H
|
||||
#define IOUTPUT_H
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "_cvcommon.h"
|
||||
|
||||
struct CvMat;
|
||||
struct CvRect;
|
||||
|
||||
class IOutput
|
||||
{
|
||||
public:
|
||||
enum OutputType {PNG_DATASET, JPG_DATASET};
|
||||
public:
|
||||
virtual bool write( const CvMat& img,
|
||||
const CvRect& boundingBox ) =0;
|
||||
|
||||
virtual ~IOutput();
|
||||
|
||||
static IOutput* createOutput( const char *filename, OutputType type );
|
||||
protected:
|
||||
IOutput();
|
||||
/* finds the beginning of the last token in the path */
|
||||
void findFilePathPart( char **partOfPath, char *fullPath );
|
||||
virtual bool init( const char* filename );
|
||||
protected:
|
||||
int currentIdx;
|
||||
char imgFullPath[PATH_MAX];
|
||||
char* imgFileName;
|
||||
FILE* annotationsList;
|
||||
};
|
||||
|
||||
#endif // IOUTPUT_H
|
||||
@@ -198,7 +198,7 @@ bool CvCascadeClassifier::train( const string _cascadeDirName,
|
||||
cout << endl << "===== TRAINING " << i << "-stage =====" << endl;
|
||||
cout << "<BEGIN" << endl;
|
||||
|
||||
if ( !updateTrainingSet( tempLeafFARate ) )
|
||||
if ( !updateTrainingSet( requiredLeafFARate, tempLeafFARate ) )
|
||||
{
|
||||
cout << "Train dataset for temp stage can not be filled. "
|
||||
"Branch training terminated." << endl;
|
||||
@@ -284,17 +284,17 @@ int CvCascadeClassifier::predict( int sampleIdx )
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool CvCascadeClassifier::updateTrainingSet( double& acceptanceRatio)
|
||||
bool CvCascadeClassifier::updateTrainingSet( double minimumAcceptanceRatio, double& acceptanceRatio)
|
||||
{
|
||||
int64 posConsumed = 0, negConsumed = 0;
|
||||
imgReader.restart();
|
||||
int posCount = fillPassedSamples( 0, numPos, true, posConsumed );
|
||||
int posCount = fillPassedSamples( 0, numPos, true, 0, posConsumed );
|
||||
if( !posCount )
|
||||
return false;
|
||||
cout << "POS count : consumed " << posCount << " : " << (int)posConsumed << endl;
|
||||
|
||||
int proNumNeg = cvRound( ( ((double)numNeg) * ((double)posCount) ) / numPos ); // apply only a fraction of negative samples. double is required since overflow is possible
|
||||
int negCount = fillPassedSamples( posCount, proNumNeg, false, negConsumed );
|
||||
int negCount = fillPassedSamples( posCount, proNumNeg, false, minimumAcceptanceRatio, negConsumed );
|
||||
if ( !negCount )
|
||||
return false;
|
||||
|
||||
@@ -304,7 +304,7 @@ bool CvCascadeClassifier::updateTrainingSet( double& acceptanceRatio)
|
||||
return true;
|
||||
}
|
||||
|
||||
int CvCascadeClassifier::fillPassedSamples( int first, int count, bool isPositive, int64& consumed )
|
||||
int CvCascadeClassifier::fillPassedSamples( int first, int count, bool isPositive, double minimumAcceptanceRatio, int64& consumed )
|
||||
{
|
||||
int getcount = 0;
|
||||
Mat img(cascadeParams.winSize, CV_8UC1);
|
||||
@@ -312,6 +312,9 @@ int CvCascadeClassifier::fillPassedSamples( int first, int count, bool isPositiv
|
||||
{
|
||||
for( ; ; )
|
||||
{
|
||||
if( consumed != 0 && ((double)getcount+1)/(double)(int64)consumed <= minimumAcceptanceRatio )
|
||||
return getcount;
|
||||
|
||||
bool isGetImg = isPositive ? imgReader.getPos( img ) :
|
||||
imgReader.getNeg( img );
|
||||
if( !isGetImg )
|
||||
@@ -506,6 +509,8 @@ void CvCascadeClassifier::save( const string filename, bool baseFormat )
|
||||
|
||||
bool CvCascadeClassifier::load( const string cascadeDirName )
|
||||
{
|
||||
cout << "Training parameters are loaded from the parameter file in data folder!" << endl;
|
||||
cout << "Please empty the data folder if you want to use your own set of parameters." << endl;
|
||||
FileStorage fs( cascadeDirName + CC_PARAMS_FILENAME, FileStorage::READ );
|
||||
if ( !fs.isOpened() )
|
||||
return false;
|
||||
|
||||
@@ -101,8 +101,8 @@ private:
|
||||
int predict( int sampleIdx );
|
||||
void save( const std::string cascadeDirName, bool baseFormat = false );
|
||||
bool load( const std::string cascadeDirName );
|
||||
bool updateTrainingSet( double& acceptanceRatio );
|
||||
int fillPassedSamples( int first, int count, bool isPositive, int64& consumed );
|
||||
bool updateTrainingSet( double minimumAcceptanceRatio, double& acceptanceRatio );
|
||||
int fillPassedSamples( int first, int count, bool isPositive, double requiredAcceptanceRatio, int64& consumed );
|
||||
|
||||
void writeParams( cv::FileStorage &fs ) const;
|
||||
void writeStages( cv::FileStorage &fs, const cv::Mat& featureMap ) const;
|
||||
|
||||
@@ -6,34 +6,62 @@ endif()
|
||||
|
||||
set(HAVE_WINRT FALSE)
|
||||
|
||||
# search Windows Platform SDK
|
||||
message(STATUS "Checking for Windows Platform SDK")
|
||||
GET_FILENAME_COMPONENT(WINDOWS_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]" ABSOLUTE CACHE)
|
||||
if(WINDOWS_SDK_PATH STREQUAL "")
|
||||
set(HAVE_MSPDK FALSE)
|
||||
message(STATUS "Windows Platform SDK 8.0 was not found")
|
||||
# search Windows (Phone) Platform SDK
|
||||
message(STATUS "Checking for Windows (Phone) Platform SDK 8.0/8.1")
|
||||
unset(WINDOWS_SDK_PATH CACHE)
|
||||
GET_FILENAME_COMPONENT(WINDOWS_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhoneApp\\v8.1;InstallationFolder]" ABSOLUTE CACHE)
|
||||
if((NOT ENABLE_WINPHONESDK81) OR (NOT (MSVC_VERSION EQUAL 1800)) OR (WINDOWS_SDK_PATH STREQUAL ""))
|
||||
unset(WINDOWS_SDK_PATH CACHE)
|
||||
GET_FILENAME_COMPONENT(WINDOWS_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.0;InstallationFolder]" ABSOLUTE CACHE)
|
||||
if((NOT ENABLE_WINPHONESDK80) OR (MSVC_VERSION LESS 1700) OR (WINDOWS_SDK_PATH STREQUAL ""))
|
||||
unset(WINDOWS_SDK_PATH CACHE)
|
||||
GET_FILENAME_COMPONENT(WINDOWS_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]" ABSOLUTE CACHE)
|
||||
if((NOT ENABLE_WINSDK81) OR (NOT (MSVC_VERSION EQUAL 1800)) OR (WINDOWS_SDK_PATH STREQUAL ""))
|
||||
set(HAVE_MSPDK FALSE)
|
||||
unset(WINDOWS_SDK_PATH CACHE)
|
||||
GET_FILENAME_COMPONENT(WINDOWS_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]" ABSOLUTE CACHE)
|
||||
if(WINDOWS_SDK_PATH STREQUAL "")
|
||||
set(HAVE_MSPDK FALSE)
|
||||
message(STATUS "Windows (Phone) Platform SDK 8.0/8.1 was not found")
|
||||
else()
|
||||
set(HAVE_MSPDK TRUE)
|
||||
endif()
|
||||
else()
|
||||
set(HAVE_MSPDK TRUE)
|
||||
endif()
|
||||
else()
|
||||
set(HAVE_MSPDK TRUE)
|
||||
endif()
|
||||
else()
|
||||
set(HAVE_MSPDK TRUE)
|
||||
endif()
|
||||
|
||||
#search for Visual Studio 11.0 install directory
|
||||
message(STATUS "Checking for Visual Studio 2012")
|
||||
GET_FILENAME_COMPONENT(VISUAL_STUDIO_PATH [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VS;ProductDir] REALPATH CACHE)
|
||||
if(VISUAL_STUDIO_PATH STREQUAL "")
|
||||
set(HAVE_MSVC2012 FALSE)
|
||||
message(STATUS "Visual Studio 2012 was not found")
|
||||
#search for Visual Studio 11.0/12.0 install directory
|
||||
message(STATUS "Checking for Visual Studio 2012/2013")
|
||||
unset(VISUAL_STUDIO_PATH CACHE)
|
||||
GET_FILENAME_COMPONENT(VISUAL_STUDIO_PATH [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0\\Setup\\VS;ProductDir] REALPATH CACHE)
|
||||
if((NOT ENABLE_LIBVS2013) OR (NOT (MSVC_VERSION EQUAL 1800)) OR (VISUAL_STUDIO_PATH STREQUAL ""))
|
||||
set(HAVE_MSVC2013 FALSE)
|
||||
unset(VISUAL_STUDIO_PATH CACHE)
|
||||
GET_FILENAME_COMPONENT(VISUAL_STUDIO_PATH [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VS;ProductDir] REALPATH CACHE)
|
||||
if(VISUAL_STUDIO_PATH STREQUAL "")
|
||||
set(HAVE_MSVC2012 FALSE)
|
||||
message(STATUS "Visual Studio 2012/2013 not found")
|
||||
else()
|
||||
set(HAVE_MSVC2012 TRUE)
|
||||
endif()
|
||||
else()
|
||||
set(HAVE_MSVC2012 TRUE)
|
||||
set(HAVE_MSVC2013 TRUE)
|
||||
endif()
|
||||
|
||||
try_compile(HAVE_WINRT_SDK
|
||||
"${OpenCV_BINARY_DIR}"
|
||||
"${OpenCV_SOURCE_DIR}/cmake/checks/winrttest.cpp")
|
||||
|
||||
if(ENABLE_WINRT_MODE AND HAVE_WINRT_SDK AND HAVE_MSVC2012 AND HAVE_MSPDK)
|
||||
if(ENABLE_WINRT_MODE AND HAVE_WINRT_SDK AND (HAVE_MSVC2012 OR HAVE_MSVC2013) AND HAVE_MSPDK)
|
||||
set(HAVE_WINRT TRUE)
|
||||
set(HAVE_WINRT_CX TRUE)
|
||||
elseif(ENABLE_WINRT_MODE_NATIVE AND HAVE_WINRT_SDK AND HAVE_MSVC2012 AND HAVE_MSPDK)
|
||||
elseif(ENABLE_WINRT_MODE_NATIVE AND HAVE_WINRT_SDK AND (HAVE_MSVC2012 OR HAVE_MSVC2013) AND HAVE_MSPDK)
|
||||
set(HAVE_WINRT TRUE)
|
||||
set(HAVE_WINRT_CX FALSE)
|
||||
endif()
|
||||
|
||||
@@ -140,7 +140,11 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
# SSE3 and further should be disabled under MingW because it generates compiler errors
|
||||
if(NOT MINGW)
|
||||
if(ENABLE_AVX)
|
||||
add_extra_compiler_option(-mavx)
|
||||
ocv_check_flag_support(CXX "-mavx" _varname)
|
||||
endif()
|
||||
|
||||
if(ENABLE_AVX2)
|
||||
ocv_check_flag_support(CXX "-mavx2" _varname)
|
||||
endif()
|
||||
|
||||
# GCC depresses SSEx instructions when -mavx is used. Instead, it generates new AVX instructions or AVX equivalence for all SSEx instructions when needed.
|
||||
@@ -216,10 +220,6 @@ if(MSVC)
|
||||
set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} /Zi")
|
||||
endif()
|
||||
|
||||
if(ENABLE_AVX AND NOT MSVC_VERSION LESS 1600)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:AVX")
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSE4_1 AND CV_ICC AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE4.1")
|
||||
endif()
|
||||
@@ -238,7 +238,7 @@ if(MSVC)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSE OR ENABLE_SSE2 OR ENABLE_SSE3 OR ENABLE_SSE4_1 OR ENABLE_AVX)
|
||||
if(ENABLE_SSE OR ENABLE_SSE2 OR ENABLE_SSE3 OR ENABLE_SSE4_1 OR ENABLE_AVX OR ENABLE_AVX2)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /Oi")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -38,7 +38,9 @@ if(PYTHON_EXECUTABLE)
|
||||
|
||||
if(NOT ANDROID AND NOT IOS)
|
||||
ocv_check_environment_variables(PYTHON_LIBRARY PYTHON_INCLUDE_DIR)
|
||||
if(CMAKE_VERSION VERSION_GREATER 2.8.8 AND PYTHON_VERSION_FULL)
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
find_host_package(PythonLibs ${PYTHON_VERSION_MAJOR_MINOR})
|
||||
elseif(CMAKE_VERSION VERSION_GREATER 2.8.8 AND PYTHON_VERSION_FULL)
|
||||
find_host_package(PythonLibs ${PYTHON_VERSION_FULL} EXACT)
|
||||
else()
|
||||
find_host_package(PythonLibs ${PYTHON_VERSION_FULL})
|
||||
|
||||
@@ -12,15 +12,42 @@ endif(WITH_VFW)
|
||||
|
||||
# --- GStreamer ---
|
||||
ocv_clear_vars(HAVE_GSTREAMER)
|
||||
if(WITH_GSTREAMER)
|
||||
CHECK_MODULE(gstreamer-base-0.10 HAVE_GSTREAMER)
|
||||
if(HAVE_GSTREAMER)
|
||||
CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER)
|
||||
# try to find gstreamer 1.x first
|
||||
if(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
|
||||
CHECK_MODULE(gstreamer-base-1.0 HAVE_GSTREAMER_BASE)
|
||||
CHECK_MODULE(gstreamer-video-1.0 HAVE_GSTREAMER_VIDEO)
|
||||
CHECK_MODULE(gstreamer-app-1.0 HAVE_GSTREAMER_APP)
|
||||
CHECK_MODULE(gstreamer-riff-1.0 HAVE_GSTREAMER_RIFF)
|
||||
CHECK_MODULE(gstreamer-pbutils-1.0 HAVE_GSTREAMER_PBUTILS)
|
||||
|
||||
if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS)
|
||||
set(HAVE_GSTREAMER TRUE)
|
||||
set(GSTREAMER_BASE_VERSION ${ALIASOF_gstreamer-base-1.0_VERSION})
|
||||
set(GSTREAMER_VIDEO_VERSION ${ALIASOF_gstreamer-video-1.0_VERSION})
|
||||
set(GSTREAMER_APP_VERSION ${ALIASOF_gstreamer-app-1.0_VERSION})
|
||||
set(GSTREAMER_RIFF_VERSION ${ALIASOF_gstreamer-riff-1.0_VERSION})
|
||||
set(GSTREAMER_PBUTILS_VERSION ${ALIASOF_gstreamer-pbutils-1.0_VERSION})
|
||||
endif()
|
||||
if(HAVE_GSTREAMER)
|
||||
CHECK_MODULE(gstreamer-video-0.10 HAVE_GSTREAMER)
|
||||
|
||||
endif(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
|
||||
|
||||
# if gstreamer 1.x was not found, or we specified we wanted 0.10, try to find it
|
||||
if(WITH_GSTREAMER_0_10 OR NOT HAVE_GSTREAMER)
|
||||
CHECK_MODULE(gstreamer-base-0.10 HAVE_GSTREAMER_BASE)
|
||||
CHECK_MODULE(gstreamer-video-0.10 HAVE_GSTREAMER_VIDEO)
|
||||
CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER_APP)
|
||||
CHECK_MODULE(gstreamer-riff-0.10 HAVE_GSTREAMER_RIFF)
|
||||
CHECK_MODULE(gstreamer-pbutils-0.10 HAVE_GSTREAMER_PBUTILS)
|
||||
|
||||
if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS)
|
||||
set(HAVE_GSTREAMER TRUE)
|
||||
set(GSTREAMER_BASE_VERSION ${ALIASOF_gstreamer-base-0.10_VERSION})
|
||||
set(GSTREAMER_VIDEO_VERSION ${ALIASOF_gstreamer-video-0.10_VERSION})
|
||||
set(GSTREAMER_APP_VERSION ${ALIASOF_gstreamer-app-0.10_VERSION})
|
||||
set(GSTREAMER_RIFF_VERSION ${ALIASOF_gstreamer-riff-0.10_VERSION})
|
||||
set(GSTREAMER_PBUTILS_VERSION ${ALIASOF_gstreamer-pbutils-0.10_VERSION})
|
||||
endif()
|
||||
endif(WITH_GSTREAMER)
|
||||
endif(WITH_GSTREAMER_0_10 OR NOT HAVE_GSTREAMER)
|
||||
|
||||
# --- unicap ---
|
||||
ocv_clear_vars(HAVE_UNICAP)
|
||||
@@ -126,7 +153,13 @@ endif(WITH_XINE)
|
||||
ocv_clear_vars(HAVE_LIBV4L HAVE_CAMV4L HAVE_CAMV4L2 HAVE_VIDEOIO)
|
||||
if(WITH_V4L)
|
||||
if(WITH_LIBV4L)
|
||||
CHECK_MODULE(libv4l1 HAVE_LIBV4L)
|
||||
CHECK_MODULE(libv4l1 HAVE_LIBV4L1)
|
||||
CHECK_MODULE(libv4l2 HAVE_LIBV4L2)
|
||||
if(HAVE_LIBV4L1 AND HAVE_LIBV4L2)
|
||||
set(HAVE_LIBV4L YES)
|
||||
else()
|
||||
set(HAVE_LIBV4L NO)
|
||||
endif()
|
||||
endif()
|
||||
CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L)
|
||||
CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2)
|
||||
@@ -222,6 +255,7 @@ if(WITH_DSHOW)
|
||||
endif(WITH_DSHOW)
|
||||
|
||||
# --- VideoInput/Microsoft Media Foundation ---
|
||||
ocv_clear_vars(HAVE_MSMF)
|
||||
if(WITH_MSMF)
|
||||
check_include_file(Mfapi.h HAVE_MSMF)
|
||||
endif(WITH_MSMF)
|
||||
|
||||
@@ -31,6 +31,12 @@ if(WIN32)
|
||||
else()
|
||||
set(XIMEA_FOUND 0)
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
if(EXISTS /Library/Frameworks/m3api.framework)
|
||||
set(XIMEA_FOUND 1)
|
||||
else()
|
||||
set(XIMEA_FOUND 0)
|
||||
endif()
|
||||
else()
|
||||
if(EXISTS /opt/XIMEA)
|
||||
set(XIMEA_FOUND 1)
|
||||
|
||||
@@ -526,6 +526,28 @@ macro(ocv_glob_module_sources)
|
||||
list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp")
|
||||
endif()
|
||||
|
||||
if(ENABLE_AVX)
|
||||
file(GLOB avx_srcs "src/avx/*.cpp")
|
||||
foreach(src ${avx_srcs})
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS -mavx)
|
||||
elseif(MSVC AND NOT MSVC_VERSION LESS 1600)
|
||||
set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS /arch:AVX)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(ENABLE_AVX2)
|
||||
file(GLOB avx2_srcs "src/avx2/*.cpp")
|
||||
foreach(src ${avx2_srcs})
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS -mavx2)
|
||||
elseif(MSVC AND NOT MSVC_VERSION LESS 1800)
|
||||
set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS /arch:AVX2)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
source_group("Include" FILES ${lib_hdrs})
|
||||
source_group("Include\\detail" FILES ${lib_hdrs_detail})
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
# Use patched version of CPACK to build accurate set of Debian packages
|
||||
# https://github.com/asmorkalov/CMake/tree/deb_generator_improvement
|
||||
|
||||
if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
set(CPACK_set_DESTDIR "on")
|
||||
|
||||
@@ -18,6 +21,8 @@ OpenCV makes it easy for businesses to utilize and modify the code.")
|
||||
set(CPACK_PACKAGE_VERSION "${OPENCV_VCSVERSION}")
|
||||
endif(NOT OPENCV_CUSTOM_PACKAGE_INFO)
|
||||
|
||||
set(CPACK_STRIP_FILES 1)
|
||||
|
||||
#arch
|
||||
if(X86)
|
||||
set(CPACK_DEBIAN_ARCHITECTURE "i386")
|
||||
@@ -64,36 +69,61 @@ set(CPACK_COMPONENT_dev_DEPENDS libs)
|
||||
set(CPACK_COMPONENT_docs_DEPENDS libs)
|
||||
set(CPACK_COMPONENT_java_DEPENDS libs)
|
||||
set(CPACK_COMPONENT_python_DEPENDS libs)
|
||||
set(CPACK_DEB_python_PACKAGE_DEPENDS "python${PYTHON_VERSION_MAJOR_MINOR}")
|
||||
set(CPACK_COMPONENT_tests_DEPENDS libs)
|
||||
if (HAVE_opencv_python)
|
||||
set(CPACK_DEB_tests_PACKAGE_DEPENDS "python${PYTHON_VERSION_MAJOR_MINOR}, python-py | python-pytest")
|
||||
endif()
|
||||
|
||||
if(HAVE_CUDA)
|
||||
string(REPLACE "." "-" cuda_version_suffix ${CUDA_VERSION})
|
||||
set(CPACK_DEB_libs_PACKAGE_DEPENDS "cuda-core-libs-${cuda_version_suffix}, cuda-extra-libs-${cuda_version_suffix}")
|
||||
if(CUDA_VERSION VERSION_LESS "6.5")
|
||||
set(CPACK_DEB_libs_PACKAGE_DEPENDS "cuda-core-libs-${cuda_version_suffix}, cuda-extra-libs-${cuda_version_suffix}")
|
||||
set(CPACK_DEB_dev_PACKAGE_DEPENDS "cuda-headers-${cuda_version_suffix}")
|
||||
else()
|
||||
set(CPACK_DEB_libs_PACKAGE_DEPENDS "cuda-cudart-${cuda_version_suffix}, cuda-npp-${cuda_version_suffix}")
|
||||
set(CPACK_DEB_dev_PACKAGE_DEPENDS "cuda-cudart-dev-${cuda_version_suffix}, cuda-npp-dev-${cuda_version_suffix}")
|
||||
if(HAVE_CUFFT)
|
||||
set(CPACK_DEB_libs_PACKAGE_DEPENDS "${CPACK_DEB_libs_PACKAGE_DEPENDS}, cuda-cufft-${cuda_version_suffix}")
|
||||
set(CPACK_DEB_dev_PACKAGE_DEPENDS "${CPACK_DEB_dev_PACKAGE_DEPENDS}, cuda-cufft-dev-${cuda_version_suffix}")
|
||||
endif()
|
||||
if(HAVE_HAVE_CUBLAS)
|
||||
set(CPACK_DEB_libs_PACKAGE_DEPENDS "${CPACK_DEB_libs_PACKAGE_DEPENDS}, cuda-cublas-${cuda_version_suffix}")
|
||||
set(CPACK_DEB_dev_PACKAGE_DEPENDS "${CPACK_DEB_dev_PACKAGE_DEPENDS}, cuda-cublas-dev-${cuda_version_suffix}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CPACK_COMPONENT_dev_DEPENDS libs)
|
||||
set(CPACK_DEB_dev_PACKAGE_DEPENDS "cuda-headers-${cuda_version_suffix}")
|
||||
endif()
|
||||
|
||||
if(NOT OPENCV_CUSTOM_PACKAGE_INFO)
|
||||
set(CPACK_COMPONENT_libs_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}")
|
||||
set(CPACK_COMPONENT_libs_DESCRIPTION "Open Computer Vision Library")
|
||||
set(CPACK_COMPONENT_libs_SECTION "libs")
|
||||
|
||||
set(CPACK_COMPONENT_python_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-python")
|
||||
set(CPACK_COMPONENT_python_DESCRIPTION "Python bindings for Open Source Computer Vision Library")
|
||||
set(CPACK_COMPONENT_python_SECTION "python")
|
||||
|
||||
set(CPACK_COMPONENT_java_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-java")
|
||||
set(CPACK_COMPONENT_java_DESCRIPTION "Java bindings for Open Source Computer Vision Library")
|
||||
set(CPACK_COMPONENT_java_SECTION "java")
|
||||
|
||||
set(CPACK_COMPONENT_dev_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-dev")
|
||||
set(CPACK_COMPONENT_dev_DESCRIPTION "Development files for Open Source Computer Vision Library")
|
||||
set(CPACK_COMPONENT_dev_SECTION "libdevel")
|
||||
|
||||
set(CPACK_COMPONENT_docs_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-docs")
|
||||
set(CPACK_COMPONENT_docs_DESCRIPTION "Documentation for Open Source Computer Vision Library")
|
||||
set(CPACK_COMPONENT_docs_SECTION "doc")
|
||||
|
||||
set(CPACK_COMPONENT_samples_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-samples")
|
||||
set(CPACK_COMPONENT_samples_DESCRIPTION "Samples for Open Source Computer Vision Library")
|
||||
set(CPACK_COMPONENT_samples_SECTION "devel")
|
||||
|
||||
set(CPACK_COMPONENT_tests_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-tests")
|
||||
set(CPACK_COMPONENT_tests_DESCRIPTION "Accuracy and performance tests for Open Source Computer Vision Library")
|
||||
set(CPACK_COMPONENT_tests_SECTION "misc")
|
||||
endif(NOT OPENCV_CUSTOM_PACKAGE_INFO)
|
||||
|
||||
if(NOT OPENCV_CUSTOM_PACKAGE_LAYOUT)
|
||||
|
||||
@@ -18,11 +18,14 @@ if [ -z `which adb` ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
accuracy=`find "$OPENCV_TEST_PATH/$TARGET_ARCH" -maxdepth 1 -executable -name "opencv_test_*" -not -name opencv_test_ocl`
|
||||
performance=`find "$OPENCV_TEST_PATH/$TARGET_ARCH" -maxdepth 1 -executable -name "opencv_perf_*" -not -name opencv_perf_ocl`
|
||||
|
||||
adb push $OPENCV_TEST_DATA_PATH /sdcard/opencv_testdata
|
||||
|
||||
adb shell "mkdir -p /data/local/tmp/opencv_test"
|
||||
SUMMARY_STATUS=0
|
||||
for t in "$OPENCV_TEST_PATH/$TARGET_ARCH/"opencv_test_* "$OPENCV_TEST_PATH/$TARGET_ARCH/"opencv_perf_*;
|
||||
for t in $accuracy $performance;
|
||||
do
|
||||
test_name=`basename "$t"`
|
||||
report="$test_name-`date --rfc-3339=date`.xml"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
OPENCV_TEST_PATH=@CMAKE_INSTALL_PREFIX@/@OPENCV_TEST_INSTALL_PATH@
|
||||
OPENCV_PYTHON_TESTS=@OPENCV_PYTHON_TESTS_LIST@
|
||||
export OPENCV_TEST_DATA_PATH=@CMAKE_INSTALL_PREFIX@/share/OpenCV/testdata
|
||||
|
||||
SUMMARY_STATUS=0
|
||||
@@ -14,6 +15,16 @@ do
|
||||
fi
|
||||
done
|
||||
|
||||
for t in $OPENCV_PYTHON_TESTS;
|
||||
do
|
||||
report="`basename "$t"`-`date --rfc-3339=date`.xml"
|
||||
py.test --junitxml $report "$OPENCV_TEST_PATH"/$t
|
||||
TEST_STATUS=$?
|
||||
if [ $TEST_STATUS -ne 0 ]; then
|
||||
SUMMARY_STATUS=$TEST_STATUS
|
||||
fi
|
||||
done
|
||||
|
||||
rm -f /tmp/__opencv_temp.*
|
||||
|
||||
if [ $SUMMARY_STATUS -eq 0 ]; then
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<!--
|
||||
This is 20x34 detector of profile faces using LBP features.
|
||||
It was created by Attila Novak during GSoC 2012.
|
||||
Note that the detector only detects faces rotated to the right,
|
||||
so you may want to run it on the original and on
|
||||
the flipped image to detect different profile faces.
|
||||
-->
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
This is 20x34 detector of profile faces using LBP features.
|
||||
It was created by Attila Novak during GSoC 2012.
|
||||
Note that the detector only detects faces rotated to the right,
|
||||
so you may want to run it on the original and on
|
||||
the flipped image to detect different profile faces.
|
||||
-->
|
||||
<opencv_storage>
|
||||
<cascade>
|
||||
<stageType>BOOST</stageType>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
This is 12x80 detector of the silverware (forks, spoons, knives) using LBP features.
|
||||
It was created by Attila Novak during GSoC 2012.
|
||||
@@ -6,7 +7,6 @@
|
||||
(probably should run detector several times).
|
||||
It also assumes the "top view" when the camera optical axis is orthogonal to the table plane.
|
||||
-->
|
||||
<?xml version="1.0"?>
|
||||
<opencv_storage>
|
||||
<cascade>
|
||||
<stageType>BOOST</stageType>
|
||||
|
||||
|
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,9 +186,11 @@ namespace cv
|
||||
vector<int> localInliers;
|
||||
for (int i = 0; i < objectPoints.cols; i++)
|
||||
{
|
||||
Point2f p(imagePoints.at<Vec2f>(0, i)[0], imagePoints.at<Vec2f>(0, i)[1]);
|
||||
//Although p is a 2D point it needs the same type as the object points to enable the norm calculation
|
||||
Point_<OpointType> p((OpointType)imagePoints.at<Vec<IpointType,2> >(0, i)[0],
|
||||
(OpointType)imagePoints.at<Vec<IpointType,2> >(0, i)[1]);
|
||||
if ((norm(p - projected_points[i]) < params.reprojectionError)
|
||||
&& (rotatedPoints.at<Vec3f>(0, i)[2] > 0)) //hack
|
||||
&& (rotatedPoints.at<Vec<OpointType,3> >(0, i)[2] > 0)) //hack
|
||||
{
|
||||
localInliers.push_back(i);
|
||||
}
|
||||
@@ -206,6 +210,30 @@ namespace cv
|
||||
}
|
||||
}
|
||||
|
||||
static void pnpTask(const vector<char>& pointsMask, const Mat& objectPoints, const Mat& imagePoints,
|
||||
const Parameters& params, vector<int>& inliers, Mat& rvec, Mat& tvec,
|
||||
const Mat& rvecInit, const Mat& tvecInit, Mutex& resultsMutex)
|
||||
{
|
||||
CV_Assert(objectPoints.depth() == CV_64F || objectPoints.depth() == CV_32F);
|
||||
CV_Assert(imagePoints.depth() == CV_64F || imagePoints.depth() == CV_32F);
|
||||
const bool objectDoublePrecision = objectPoints.depth() == CV_64F;
|
||||
const bool imageDoublePrecision = imagePoints.depth() == CV_64F;
|
||||
if(objectDoublePrecision)
|
||||
{
|
||||
if(imageDoublePrecision)
|
||||
pnpTask<double, double>(pointsMask, objectPoints, imagePoints, params, inliers, rvec, tvec, rvecInit, tvecInit, resultsMutex);
|
||||
else
|
||||
pnpTask<double, float>(pointsMask, objectPoints, imagePoints, params, inliers, rvec, tvec, rvecInit, tvecInit, resultsMutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(imageDoublePrecision)
|
||||
pnpTask<float, double>(pointsMask, objectPoints, imagePoints, params, inliers, rvec, tvec, rvecInit, tvecInit, resultsMutex);
|
||||
else
|
||||
pnpTask<float, float>(pointsMask, objectPoints, imagePoints, params, inliers, rvec, tvec, rvecInit, tvecInit, resultsMutex);
|
||||
}
|
||||
}
|
||||
|
||||
class PnPSolver
|
||||
{
|
||||
public:
|
||||
@@ -281,10 +309,10 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints,
|
||||
Mat cameraMatrix = _cameraMatrix.getMat(), distCoeffs = _distCoeffs.getMat();
|
||||
|
||||
CV_Assert(opoints.isContinuous());
|
||||
CV_Assert(opoints.depth() == CV_32F);
|
||||
CV_Assert(opoints.depth() == CV_32F || opoints.depth() == CV_64F);
|
||||
CV_Assert((opoints.rows == 1 && opoints.channels() == 3) || opoints.cols*opoints.channels() == 3);
|
||||
CV_Assert(ipoints.isContinuous());
|
||||
CV_Assert(ipoints.depth() == CV_32F);
|
||||
CV_Assert(ipoints.depth() == CV_32F || ipoints.depth() == CV_64F);
|
||||
CV_Assert((ipoints.rows == 1 && ipoints.channels() == 2) || ipoints.cols*ipoints.channels() == 2);
|
||||
|
||||
_rvec.create(3, 1, CV_64FC1);
|
||||
@@ -320,7 +348,7 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints,
|
||||
if (flags != CV_P3P)
|
||||
{
|
||||
int i, pointsCount = (int)localInliers.size();
|
||||
Mat inlierObjectPoints(1, pointsCount, CV_32FC3), inlierImagePoints(1, pointsCount, CV_32FC2);
|
||||
Mat inlierObjectPoints(1, pointsCount, CV_MAKE_TYPE(opoints.depth(), 3)), inlierImagePoints(1, pointsCount, CV_MAKE_TYPE(ipoints.depth(), 2));
|
||||
for (i = 0; i < pointsCount; i++)
|
||||
{
|
||||
int index = localInliers[i];
|
||||
|
||||
@@ -224,6 +224,42 @@ prefilterXSobel( const Mat& src, Mat& dst, int ftzero )
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if CV_NEON
|
||||
int16x8_t ftz = vdupq_n_s16 ((short) ftzero);
|
||||
uint8x8_t ftz2 = vdup_n_u8 (cv::saturate_cast<uchar>(ftzero*2));
|
||||
|
||||
for(; x <=size.width-9; x += 8 )
|
||||
{
|
||||
uint8x8_t c0 = vld1_u8 (srow0 + x - 1);
|
||||
uint8x8_t c1 = vld1_u8 (srow1 + x - 1);
|
||||
uint8x8_t d0 = vld1_u8 (srow0 + x + 1);
|
||||
uint8x8_t d1 = vld1_u8 (srow1 + x + 1);
|
||||
|
||||
int16x8_t t0 = vreinterpretq_s16_u16 (vsubl_u8 (d0, c0));
|
||||
int16x8_t t1 = vreinterpretq_s16_u16 (vsubl_u8 (d1, c1));
|
||||
|
||||
uint8x8_t c2 = vld1_u8 (srow2 + x - 1);
|
||||
uint8x8_t c3 = vld1_u8 (srow3 + x - 1);
|
||||
uint8x8_t d2 = vld1_u8 (srow2 + x + 1);
|
||||
uint8x8_t d3 = vld1_u8 (srow3 + x + 1);
|
||||
|
||||
int16x8_t t2 = vreinterpretq_s16_u16 (vsubl_u8 (d2, c2));
|
||||
int16x8_t t3 = vreinterpretq_s16_u16 (vsubl_u8 (d3, c3));
|
||||
|
||||
int16x8_t v0 = vaddq_s16 (vaddq_s16 (t2, t0), vaddq_s16 (t1, t1));
|
||||
int16x8_t v1 = vaddq_s16 (vaddq_s16 (t3, t1), vaddq_s16 (t2, t2));
|
||||
|
||||
|
||||
uint8x8_t v0_u8 = vqmovun_s16 (vaddq_s16 (v0, ftz));
|
||||
uint8x8_t v1_u8 = vqmovun_s16 (vaddq_s16 (v1, ftz));
|
||||
v0_u8 = vmin_u8 (v0_u8, ftz2);
|
||||
v1_u8 = vmin_u8 (v1_u8, ftz2);
|
||||
vqmovun_s16 (vaddq_s16 (v1, ftz));
|
||||
|
||||
vst1_u8 (dptr0 + x, v0_u8);
|
||||
vst1_u8 (dptr1 + x, v1_u8);
|
||||
}
|
||||
#endif
|
||||
|
||||
for( ; x < size.width-1; x++ )
|
||||
{
|
||||
@@ -236,10 +272,19 @@ prefilterXSobel( const Mat& src, Mat& dst, int ftzero )
|
||||
}
|
||||
}
|
||||
|
||||
#if CV_NEON
|
||||
uint8x16_t val0_16 = vdupq_n_u8 (val0);
|
||||
#endif
|
||||
|
||||
for( ; y < size.height; y++ )
|
||||
{
|
||||
uchar* dptr = dst.ptr<uchar>(y);
|
||||
for( x = 0; x < size.width; x++ )
|
||||
x = 0;
|
||||
#if CV_NEON
|
||||
for(; x <= size.width-16; x+=16 )
|
||||
vst1q_u8 (dptr + x, val0_16);
|
||||
#endif
|
||||
for(; x < size.width; x++ )
|
||||
dptr[x] = val0;
|
||||
}
|
||||
}
|
||||
@@ -510,6 +555,7 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
Mat& disp, Mat& cost, const CvStereoBMState& state,
|
||||
uchar* buf, int _dy0, int _dy1 )
|
||||
{
|
||||
|
||||
const int ALIGN = 16;
|
||||
int x, y, d;
|
||||
int wsz = state.SADWindowSize, wsz2 = wsz/2;
|
||||
@@ -525,6 +571,15 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
int uniquenessRatio = state.uniquenessRatio;
|
||||
short FILTERED = (short)((mindisp - 1) << DISPARITY_SHIFT);
|
||||
|
||||
#if CV_NEON
|
||||
CV_Assert (ndisp % 8 == 0);
|
||||
int32_t d0_4_temp [4];
|
||||
for (int i = 0; i < 4; i ++)
|
||||
d0_4_temp[i] = i;
|
||||
int32x4_t d0_4 = vld1q_s32 (d0_4_temp);
|
||||
int32x4_t dd_4 = vdupq_n_s32 (4);
|
||||
#endif
|
||||
|
||||
int *sad, *hsad0, *hsad, *hsad_sub, *htext;
|
||||
uchar *cbuf0, *cbuf;
|
||||
const uchar* lptr0 = left.data + lofs;
|
||||
@@ -560,12 +615,29 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
for( y = -dy0; y < height + dy1; y++, hsad += ndisp, cbuf += ndisp, lptr += sstep, rptr += sstep )
|
||||
{
|
||||
int lval = lptr[0];
|
||||
#if CV_NEON
|
||||
int16x8_t lv = vdupq_n_s16 ((int16_t)lval);
|
||||
|
||||
for( d = 0; d < ndisp; d += 8 )
|
||||
{
|
||||
int16x8_t rv = vreinterpretq_s16_u16 (vmovl_u8 (vld1_u8 (rptr + d)));
|
||||
int32x4_t hsad_l = vld1q_s32 (hsad + d);
|
||||
int32x4_t hsad_h = vld1q_s32 (hsad + d + 4);
|
||||
int16x8_t diff = vabdq_s16 (lv, rv);
|
||||
vst1_u8 (cbuf + d, vmovn_u16(vreinterpretq_u16_s16(diff)));
|
||||
hsad_l = vaddq_s32 (hsad_l, vmovl_s16(vget_low_s16 (diff)));
|
||||
hsad_h = vaddq_s32 (hsad_h, vmovl_s16(vget_high_s16 (diff)));
|
||||
vst1q_s32 ((hsad + d), hsad_l);
|
||||
vst1q_s32 ((hsad + d + 4), hsad_h);
|
||||
}
|
||||
#else
|
||||
for( d = 0; d < ndisp; d++ )
|
||||
{
|
||||
int diff = std::abs(lval - rptr[d]);
|
||||
cbuf[d] = (uchar)diff;
|
||||
hsad[d] = (int)(hsad[d] + diff);
|
||||
}
|
||||
#endif
|
||||
htext[y] += tab[lval];
|
||||
}
|
||||
}
|
||||
@@ -595,12 +667,31 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
hsad += ndisp, lptr += sstep, lptr_sub += sstep, rptr += sstep )
|
||||
{
|
||||
int lval = lptr[0];
|
||||
#if CV_NEON
|
||||
int16x8_t lv = vdupq_n_s16 ((int16_t)lval);
|
||||
for( d = 0; d < ndisp; d += 8 )
|
||||
{
|
||||
int16x8_t rv = vreinterpretq_s16_u16 (vmovl_u8 (vld1_u8 (rptr + d)));
|
||||
int32x4_t hsad_l = vld1q_s32 (hsad + d);
|
||||
int32x4_t hsad_h = vld1q_s32 (hsad + d + 4);
|
||||
int16x8_t cbs = vreinterpretq_s16_u16 (vmovl_u8 (vld1_u8 (cbuf_sub + d)));
|
||||
int16x8_t diff = vabdq_s16 (lv, rv);
|
||||
int32x4_t diff_h = vsubl_s16 (vget_high_s16 (diff), vget_high_s16 (cbs));
|
||||
int32x4_t diff_l = vsubl_s16 (vget_low_s16 (diff), vget_low_s16 (cbs));
|
||||
vst1_u8 (cbuf + d, vmovn_u16(vreinterpretq_u16_s16(diff)));
|
||||
hsad_h = vaddq_s32 (hsad_h, diff_h);
|
||||
hsad_l = vaddq_s32 (hsad_l, diff_l);
|
||||
vst1q_s32 ((hsad + d), hsad_l);
|
||||
vst1q_s32 ((hsad + d + 4), hsad_h);
|
||||
}
|
||||
#else
|
||||
for( d = 0; d < ndisp; d++ )
|
||||
{
|
||||
int diff = std::abs(lval - rptr[d]);
|
||||
cbuf[d] = (uchar)diff;
|
||||
hsad[d] = hsad[d] + diff - cbuf_sub[d];
|
||||
}
|
||||
#endif
|
||||
htext[y] += tab[lval] - tab[lptr_sub[0]];
|
||||
}
|
||||
|
||||
@@ -616,8 +707,24 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
|
||||
hsad = hsad0 + (1 - dy0)*ndisp;
|
||||
for( y = 1 - dy0; y < wsz2; y++, hsad += ndisp )
|
||||
{
|
||||
#if CV_NEON
|
||||
for( d = 0; d <= ndisp-8; d += 8 )
|
||||
{
|
||||
int32x4_t s0 = vld1q_s32 (sad + d);
|
||||
int32x4_t s1 = vld1q_s32 (sad + d + 4);
|
||||
int32x4_t t0 = vld1q_s32 (hsad + d);
|
||||
int32x4_t t1 = vld1q_s32 (hsad + d + 4);
|
||||
s0 = vaddq_s32 (s0, t0);
|
||||
s1 = vaddq_s32 (s1, t1);
|
||||
vst1q_s32 (sad + d, s0);
|
||||
vst1q_s32 (sad + d + 4, s1);
|
||||
}
|
||||
#else
|
||||
for( d = 0; d < ndisp; d++ )
|
||||
sad[d] = (int)(sad[d] + hsad[d]);
|
||||
#endif
|
||||
}
|
||||
int tsum = 0;
|
||||
for( y = -wsz2-1; y < wsz2; y++ )
|
||||
tsum += htext[y];
|
||||
@@ -628,7 +735,61 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
int minsad = INT_MAX, mind = -1;
|
||||
hsad = hsad0 + MIN(y + wsz2, height+dy1-1)*ndisp;
|
||||
hsad_sub = hsad0 + MAX(y - wsz2 - 1, -dy0)*ndisp;
|
||||
#if CV_NEON
|
||||
int32x4_t minsad4 = vdupq_n_s32 (INT_MAX);
|
||||
int32x4_t mind4 = vdupq_n_s32(0), d4 = d0_4;
|
||||
|
||||
for( d = 0; d <= ndisp-8; d += 8 )
|
||||
{
|
||||
int32x4_t u0 = vld1q_s32 (hsad_sub + d);
|
||||
int32x4_t u1 = vld1q_s32 (hsad + d);
|
||||
|
||||
int32x4_t v0 = vld1q_s32 (hsad_sub + d + 4);
|
||||
int32x4_t v1 = vld1q_s32 (hsad + d + 4);
|
||||
|
||||
int32x4_t usad4 = vld1q_s32(sad + d);
|
||||
int32x4_t vsad4 = vld1q_s32(sad + d + 4);
|
||||
|
||||
u1 = vsubq_s32 (u1, u0);
|
||||
v1 = vsubq_s32 (v1, v0);
|
||||
usad4 = vaddq_s32 (usad4, u1);
|
||||
vsad4 = vaddq_s32 (vsad4, v1);
|
||||
|
||||
uint32x4_t mask = vcgtq_s32 (minsad4, usad4);
|
||||
minsad4 = vminq_s32 (minsad4, usad4);
|
||||
mind4 = vbslq_s32(mask, d4, mind4);
|
||||
|
||||
vst1q_s32 (sad + d, usad4);
|
||||
vst1q_s32 (sad + d + 4, vsad4);
|
||||
d4 = vaddq_s32 (d4, dd_4);
|
||||
|
||||
mask = vcgtq_s32 (minsad4, vsad4);
|
||||
minsad4 = vminq_s32 (minsad4, vsad4);
|
||||
mind4 = vbslq_s32(mask, d4, mind4);
|
||||
|
||||
d4 = vaddq_s32 (d4, dd_4);
|
||||
|
||||
}
|
||||
int32x2_t mind4_h = vget_high_s32 (mind4);
|
||||
int32x2_t mind4_l = vget_low_s32 (mind4);
|
||||
int32x2_t minsad4_h = vget_high_s32 (minsad4);
|
||||
int32x2_t minsad4_l = vget_low_s32 (minsad4);
|
||||
|
||||
uint32x2_t mask = vorr_u32 (vclt_s32 (minsad4_h, minsad4_l), vand_u32 (vceq_s32 (minsad4_h, minsad4_l), vclt_s32 (mind4_h, mind4_l)));
|
||||
mind4_h = vbsl_s32 (mask, mind4_h, mind4_l);
|
||||
minsad4_h = vbsl_s32 (mask, minsad4_h, minsad4_l);
|
||||
|
||||
mind4_l = vext_s32 (mind4_h,mind4_h,1);
|
||||
minsad4_l = vext_s32 (minsad4_h,minsad4_h,1);
|
||||
|
||||
mask = vorr_u32 (vclt_s32 (minsad4_h, minsad4_l), vand_u32 (vceq_s32 (minsad4_h, minsad4_l), vclt_s32 (mind4_h, mind4_l)));
|
||||
mind4_h = vbsl_s32 (mask, mind4_h, mind4_l);
|
||||
minsad4_h = vbsl_s32 (mask, minsad4_h, minsad4_l);
|
||||
|
||||
mind = (int) vget_lane_s32 (mind4_h, 0);
|
||||
minsad = sad[mind];
|
||||
|
||||
#else
|
||||
for( d = 0; d < ndisp; d++ )
|
||||
{
|
||||
int currsad = sad[d] + hsad[d] - hsad_sub[d];
|
||||
@@ -639,6 +800,7 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
|
||||
mind = d;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
tsum += htext[y + wsz2] - htext[y - wsz2 - 1];
|
||||
if( tsum < textureThreshold )
|
||||
{
|
||||
|
||||
@@ -913,18 +913,6 @@ namespace
|
||||
T dp = *dpp;
|
||||
int* lpp = labels + width*p.y + p.x;
|
||||
|
||||
if( p.x < width-1 && !lpp[+1] && dpp[+1] != newVal && std::abs(dp - dpp[+1]) <= maxDiff )
|
||||
{
|
||||
lpp[+1] = curlabel;
|
||||
*ws++ = Point2s(p.x+1, p.y);
|
||||
}
|
||||
|
||||
if( p.x > 0 && !lpp[-1] && dpp[-1] != newVal && std::abs(dp - dpp[-1]) <= maxDiff )
|
||||
{
|
||||
lpp[-1] = curlabel;
|
||||
*ws++ = Point2s(p.x-1, p.y);
|
||||
}
|
||||
|
||||
if( p.y < height-1 && !lpp[+width] && dpp[+dstep] != newVal && std::abs(dp - dpp[+dstep]) <= maxDiff )
|
||||
{
|
||||
lpp[+width] = curlabel;
|
||||
@@ -937,6 +925,18 @@ namespace
|
||||
*ws++ = Point2s(p.x, p.y-1);
|
||||
}
|
||||
|
||||
if( p.x < width-1 && !lpp[+1] && dpp[+1] != newVal && std::abs(dp - dpp[+1]) <= maxDiff )
|
||||
{
|
||||
lpp[+1] = curlabel;
|
||||
*ws++ = Point2s(p.x+1, p.y);
|
||||
}
|
||||
|
||||
if( p.x > 0 && !lpp[-1] && dpp[-1] != newVal && std::abs(dp - dpp[-1]) <= maxDiff )
|
||||
{
|
||||
lpp[-1] = curlabel;
|
||||
*ws++ = Point2s(p.x-1, p.y);
|
||||
}
|
||||
|
||||
// pop most recent and propagate
|
||||
// NB: could try least recent, maybe better convergence
|
||||
p = *--ws;
|
||||
|
||||
@@ -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,7 +49,7 @@
|
||||
|
||||
#define CV_VERSION_EPOCH 2
|
||||
#define CV_VERSION_MAJOR 4
|
||||
#define CV_VERSION_MINOR 9
|
||||
#define CV_VERSION_MINOR 10
|
||||
#define CV_VERSION_REVISION 0
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -160,16 +160,12 @@ namespace cv { namespace gpu { namespace device
|
||||
template <int green_bits, int bidx> struct RGB2RGB5x5Converter;
|
||||
template<int bidx> struct RGB2RGB5x5Converter<6, bidx>
|
||||
{
|
||||
static __device__ __forceinline__ ushort cvt(const uchar3& src)
|
||||
template <typename T>
|
||||
static __device__ __forceinline__ ushort cvt(const T& src)
|
||||
{
|
||||
return (ushort)(((&src.x)[bidx] >> 3) | ((src.y & ~3) << 3) | (((&src.x)[bidx^2] & ~7) << 8));
|
||||
}
|
||||
|
||||
static __device__ __forceinline__ ushort cvt(uint src)
|
||||
{
|
||||
uint b = 0xffu & (src >> (bidx * 8));
|
||||
uint g = 0xffu & (src >> 8);
|
||||
uint r = 0xffu & (src >> ((bidx ^ 2) * 8));
|
||||
uint b = bidx == 0 ? src.x : src.z;
|
||||
uint g = src.y;
|
||||
uint r = bidx == 0 ? src.z : src.x;
|
||||
return (ushort)((b >> 3) | ((g & ~3) << 3) | ((r & ~7) << 8));
|
||||
}
|
||||
};
|
||||
@@ -178,22 +174,25 @@ namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
static __device__ __forceinline__ ushort cvt(const uchar3& src)
|
||||
{
|
||||
return (ushort)(((&src.x)[bidx] >> 3) | ((src.y & ~7) << 2) | (((&src.x)[bidx^2] & ~7) << 7));
|
||||
uint b = bidx == 0 ? src.x : src.z;
|
||||
uint g = src.y;
|
||||
uint r = bidx == 0 ? src.z : src.x;
|
||||
return (ushort)((b >> 3) | ((g & ~7) << 2) | ((r & ~7) << 7));
|
||||
}
|
||||
|
||||
static __device__ __forceinline__ ushort cvt(uint src)
|
||||
static __device__ __forceinline__ ushort cvt(const uchar4& src)
|
||||
{
|
||||
uint b = 0xffu & (src >> (bidx * 8));
|
||||
uint g = 0xffu & (src >> 8);
|
||||
uint r = 0xffu & (src >> ((bidx ^ 2) * 8));
|
||||
uint a = 0xffu & (src >> 24);
|
||||
uint b = bidx == 0 ? src.x : src.z;
|
||||
uint g = src.y;
|
||||
uint r = bidx == 0 ? src.z : src.x;
|
||||
uint a = src.w;
|
||||
return (ushort)((b >> 3) | ((g & ~7) << 2) | ((r & ~7) << 7) | (a * 0x8000));
|
||||
}
|
||||
};
|
||||
|
||||
template<int scn, int bidx, int green_bits> struct RGB2RGB5x5;
|
||||
|
||||
template<int bidx, int green_bits> struct RGB2RGB5x5<3, bidx,green_bits> : unary_function<uchar3, ushort>
|
||||
template<int bidx, int green_bits> struct RGB2RGB5x5<3, bidx, green_bits> : unary_function<uchar3, ushort>
|
||||
{
|
||||
__device__ __forceinline__ ushort operator()(const uchar3& src) const
|
||||
{
|
||||
@@ -204,9 +203,9 @@ namespace cv { namespace gpu { namespace device
|
||||
__host__ __device__ __forceinline__ RGB2RGB5x5(const RGB2RGB5x5&) {}
|
||||
};
|
||||
|
||||
template<int bidx, int green_bits> struct RGB2RGB5x5<4, bidx,green_bits> : unary_function<uint, ushort>
|
||||
template<int bidx, int green_bits> struct RGB2RGB5x5<4, bidx, green_bits> : unary_function<uchar4, ushort>
|
||||
{
|
||||
__device__ __forceinline__ ushort operator()(uint src) const
|
||||
__device__ __forceinline__ ushort operator()(const uchar4& src) const
|
||||
{
|
||||
return RGB2RGB5x5Converter<green_bits, bidx>::cvt(src);
|
||||
}
|
||||
@@ -1822,7 +1821,7 @@ namespace cv { namespace gpu { namespace device
|
||||
|
||||
dst.x = saturate_cast<uchar>(dstf.x * 2.55f);
|
||||
dst.y = saturate_cast<uchar>(dstf.y * 0.72033898305084743f + 96.525423728813564f);
|
||||
dst.z = saturate_cast<uchar>(dstf.z * 0.99609375f + 139.453125f);
|
||||
dst.z = saturate_cast<uchar>(dstf.z * 0.9732824427480916f + 136.259541984732824f);
|
||||
}
|
||||
|
||||
template <typename T, int scn, int dcn, bool srgb, int blueIdx> struct RGB2Luv;
|
||||
@@ -1916,7 +1915,7 @@ namespace cv { namespace gpu { namespace device
|
||||
|
||||
srcf.x = src.x * (100.f / 255.f);
|
||||
srcf.y = src.y * 1.388235294117647f - 134.f;
|
||||
srcf.z = src.z * 1.003921568627451f - 140.f;
|
||||
srcf.z = src.z * 1.027450980392157f - 140.f;
|
||||
|
||||
Luv2RGBConvert_f<srgb, blueIdx>(srcf, dstf);
|
||||
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -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() );
|
||||
|
||||
@@ -48,24 +48,24 @@
|
||||
#include "NCV.hpp"
|
||||
|
||||
template<typename TBase> inline __host__ __device__ TBase _pixMaxVal();
|
||||
template<> static inline __host__ __device__ Ncv8u _pixMaxVal<Ncv8u>() {return UCHAR_MAX;}
|
||||
template<> static inline __host__ __device__ Ncv16u _pixMaxVal<Ncv16u>() {return USHRT_MAX;}
|
||||
template<> static inline __host__ __device__ Ncv32u _pixMaxVal<Ncv32u>() {return UINT_MAX;}
|
||||
template<> static inline __host__ __device__ Ncv8s _pixMaxVal<Ncv8s>() {return SCHAR_MAX;}
|
||||
template<> static inline __host__ __device__ Ncv16s _pixMaxVal<Ncv16s>() {return SHRT_MAX;}
|
||||
template<> static inline __host__ __device__ Ncv32s _pixMaxVal<Ncv32s>() {return INT_MAX;}
|
||||
template<> static inline __host__ __device__ Ncv32f _pixMaxVal<Ncv32f>() {return FLT_MAX;}
|
||||
template<> static inline __host__ __device__ Ncv64f _pixMaxVal<Ncv64f>() {return DBL_MAX;}
|
||||
template<> inline __host__ __device__ Ncv8u _pixMaxVal<Ncv8u>() {return UCHAR_MAX;}
|
||||
template<> inline __host__ __device__ Ncv16u _pixMaxVal<Ncv16u>() {return USHRT_MAX;}
|
||||
template<> inline __host__ __device__ Ncv32u _pixMaxVal<Ncv32u>() {return UINT_MAX;}
|
||||
template<> inline __host__ __device__ Ncv8s _pixMaxVal<Ncv8s>() {return SCHAR_MAX;}
|
||||
template<> inline __host__ __device__ Ncv16s _pixMaxVal<Ncv16s>() {return SHRT_MAX;}
|
||||
template<> inline __host__ __device__ Ncv32s _pixMaxVal<Ncv32s>() {return INT_MAX;}
|
||||
template<> inline __host__ __device__ Ncv32f _pixMaxVal<Ncv32f>() {return FLT_MAX;}
|
||||
template<> inline __host__ __device__ Ncv64f _pixMaxVal<Ncv64f>() {return DBL_MAX;}
|
||||
|
||||
template<typename TBase> inline __host__ __device__ TBase _pixMinVal();
|
||||
template<> static inline __host__ __device__ Ncv8u _pixMinVal<Ncv8u>() {return 0;}
|
||||
template<> static inline __host__ __device__ Ncv16u _pixMinVal<Ncv16u>() {return 0;}
|
||||
template<> static inline __host__ __device__ Ncv32u _pixMinVal<Ncv32u>() {return 0;}
|
||||
template<> static inline __host__ __device__ Ncv8s _pixMinVal<Ncv8s>() {return SCHAR_MIN;}
|
||||
template<> static inline __host__ __device__ Ncv16s _pixMinVal<Ncv16s>() {return SHRT_MIN;}
|
||||
template<> static inline __host__ __device__ Ncv32s _pixMinVal<Ncv32s>() {return INT_MIN;}
|
||||
template<> static inline __host__ __device__ Ncv32f _pixMinVal<Ncv32f>() {return FLT_MIN;}
|
||||
template<> static inline __host__ __device__ Ncv64f _pixMinVal<Ncv64f>() {return DBL_MIN;}
|
||||
template<> inline __host__ __device__ Ncv8u _pixMinVal<Ncv8u>() {return 0;}
|
||||
template<> inline __host__ __device__ Ncv16u _pixMinVal<Ncv16u>() {return 0;}
|
||||
template<> inline __host__ __device__ Ncv32u _pixMinVal<Ncv32u>() {return 0;}
|
||||
template<> inline __host__ __device__ Ncv8s _pixMinVal<Ncv8s>() {return SCHAR_MIN;}
|
||||
template<> inline __host__ __device__ Ncv16s _pixMinVal<Ncv16s>() {return SHRT_MIN;}
|
||||
template<> inline __host__ __device__ Ncv32s _pixMinVal<Ncv32s>() {return INT_MIN;}
|
||||
template<> inline __host__ __device__ Ncv32f _pixMinVal<Ncv32f>() {return FLT_MIN;}
|
||||
template<> inline __host__ __device__ Ncv64f _pixMinVal<Ncv64f>() {return DBL_MIN;}
|
||||
|
||||
template<typename Tvec> struct TConvVec2Base;
|
||||
template<> struct TConvVec2Base<uchar1> {typedef Ncv8u TBase;};
|
||||
@@ -116,21 +116,21 @@ template<typename Tin> static inline __host__ __device__ void _TDemoteClampNN(Ti
|
||||
template<typename Tin> static inline __host__ __device__ void _TDemoteClampNN(Tin &a, Ncv32f &out) {out = (Ncv32f)a;}
|
||||
|
||||
template<typename Tout> inline Tout _pixMakeZero();
|
||||
template<> static inline __host__ __device__ uchar1 _pixMakeZero<uchar1>() {return make_uchar1(0);}
|
||||
template<> static inline __host__ __device__ uchar3 _pixMakeZero<uchar3>() {return make_uchar3(0,0,0);}
|
||||
template<> static inline __host__ __device__ uchar4 _pixMakeZero<uchar4>() {return make_uchar4(0,0,0,0);}
|
||||
template<> static inline __host__ __device__ ushort1 _pixMakeZero<ushort1>() {return make_ushort1(0);}
|
||||
template<> static inline __host__ __device__ ushort3 _pixMakeZero<ushort3>() {return make_ushort3(0,0,0);}
|
||||
template<> static inline __host__ __device__ ushort4 _pixMakeZero<ushort4>() {return make_ushort4(0,0,0,0);}
|
||||
template<> static inline __host__ __device__ uint1 _pixMakeZero<uint1>() {return make_uint1(0);}
|
||||
template<> static inline __host__ __device__ uint3 _pixMakeZero<uint3>() {return make_uint3(0,0,0);}
|
||||
template<> static inline __host__ __device__ uint4 _pixMakeZero<uint4>() {return make_uint4(0,0,0,0);}
|
||||
template<> static inline __host__ __device__ float1 _pixMakeZero<float1>() {return make_float1(0.f);}
|
||||
template<> static inline __host__ __device__ float3 _pixMakeZero<float3>() {return make_float3(0.f,0.f,0.f);}
|
||||
template<> static inline __host__ __device__ float4 _pixMakeZero<float4>() {return make_float4(0.f,0.f,0.f,0.f);}
|
||||
template<> static inline __host__ __device__ double1 _pixMakeZero<double1>() {return make_double1(0.);}
|
||||
template<> static inline __host__ __device__ double3 _pixMakeZero<double3>() {return make_double3(0.,0.,0.);}
|
||||
template<> static inline __host__ __device__ double4 _pixMakeZero<double4>() {return make_double4(0.,0.,0.,0.);}
|
||||
template<> inline __host__ __device__ uchar1 _pixMakeZero<uchar1>() {return make_uchar1(0);}
|
||||
template<> inline __host__ __device__ uchar3 _pixMakeZero<uchar3>() {return make_uchar3(0,0,0);}
|
||||
template<> inline __host__ __device__ uchar4 _pixMakeZero<uchar4>() {return make_uchar4(0,0,0,0);}
|
||||
template<> inline __host__ __device__ ushort1 _pixMakeZero<ushort1>() {return make_ushort1(0);}
|
||||
template<> inline __host__ __device__ ushort3 _pixMakeZero<ushort3>() {return make_ushort3(0,0,0);}
|
||||
template<> inline __host__ __device__ ushort4 _pixMakeZero<ushort4>() {return make_ushort4(0,0,0,0);}
|
||||
template<> inline __host__ __device__ uint1 _pixMakeZero<uint1>() {return make_uint1(0);}
|
||||
template<> inline __host__ __device__ uint3 _pixMakeZero<uint3>() {return make_uint3(0,0,0);}
|
||||
template<> inline __host__ __device__ uint4 _pixMakeZero<uint4>() {return make_uint4(0,0,0,0);}
|
||||
template<> inline __host__ __device__ float1 _pixMakeZero<float1>() {return make_float1(0.f);}
|
||||
template<> inline __host__ __device__ float3 _pixMakeZero<float3>() {return make_float3(0.f,0.f,0.f);}
|
||||
template<> inline __host__ __device__ float4 _pixMakeZero<float4>() {return make_float4(0.f,0.f,0.f,0.f);}
|
||||
template<> inline __host__ __device__ double1 _pixMakeZero<double1>() {return make_double1(0.);}
|
||||
template<> inline __host__ __device__ double3 _pixMakeZero<double3>() {return make_double3(0.,0.,0.);}
|
||||
template<> inline __host__ __device__ double4 _pixMakeZero<double4>() {return make_double4(0.,0.,0.,0.);}
|
||||
|
||||
static inline __host__ __device__ uchar1 _pixMake(Ncv8u x) {return make_uchar1(x);}
|
||||
static inline __host__ __device__ uchar3 _pixMake(Ncv8u x, Ncv8u y, Ncv8u z) {return make_uchar3(x,y,z);}
|
||||
|
||||
@@ -98,10 +98,13 @@ GPU_TEST_P(FGDStatModel, Update)
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
|
||||
IplImage ipl_frame = frame;
|
||||
cv::Mat frameSmall;
|
||||
cv::resize(frame, frameSmall, cv::Size(), 0.5, 0.5);
|
||||
|
||||
IplImage ipl_frame = frameSmall;
|
||||
cv::Ptr<CvBGStatModel> model(cvCreateFGDStatModel(&ipl_frame));
|
||||
|
||||
cv::gpu::GpuMat d_frame(frame);
|
||||
cv::gpu::GpuMat d_frame(frameSmall);
|
||||
cv::gpu::FGDStatModel d_model(out_cn);
|
||||
d_model.create(d_frame);
|
||||
|
||||
@@ -109,18 +112,17 @@ GPU_TEST_P(FGDStatModel, Update)
|
||||
cv::Mat h_foreground;
|
||||
cv::Mat h_background3;
|
||||
|
||||
cv::Mat backgroundDiff;
|
||||
cv::Mat foregroundDiff;
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
|
||||
ipl_frame = frame;
|
||||
cv::resize(frame, frameSmall, cv::Size(), 0.5, 0.5);
|
||||
|
||||
ipl_frame = frameSmall;
|
||||
int gold_count = cvUpdateBGStatModel(&ipl_frame, model);
|
||||
|
||||
d_frame.upload(frame);
|
||||
d_frame.upload(frameSmall);
|
||||
|
||||
int count = d_model.update(d_frame);
|
||||
|
||||
|
||||
@@ -73,6 +73,28 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, template <typename> class Interpolator>
|
||||
void resizeLinearImpl(const cv::Mat& src, cv::Mat& dst, double fx, double fy)
|
||||
{
|
||||
const int cn = src.channels();
|
||||
|
||||
cv::Size dsize(cv::saturate_cast<int>(src.cols * fx), cv::saturate_cast<int>(src.rows * fy));
|
||||
|
||||
dst.create(dsize, src.type());
|
||||
|
||||
float ifx = static_cast<float>(1.0 / fx);
|
||||
float ify = static_cast<float>(1.0 / fy);
|
||||
|
||||
for (int y = 0; y < dsize.height; ++y)
|
||||
{
|
||||
for (int x = 0; x < dsize.width; ++x)
|
||||
{
|
||||
for (int c = 0; c < cn; ++c)
|
||||
dst.at<T>(y, x * cn + c) = Interpolator<T>::getValue(src, (y + 0.5f) * ify - 0.5f, (x + 0.5f) * ifx - 0.5f, c, cv::BORDER_REPLICATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void resizeGold(const cv::Mat& src, cv::Mat& dst, double fx, double fy, int interpolation)
|
||||
{
|
||||
typedef void (*func_t)(const cv::Mat& src, cv::Mat& dst, double fx, double fy);
|
||||
@@ -90,12 +112,12 @@ namespace
|
||||
|
||||
static const func_t linear_funcs[] =
|
||||
{
|
||||
resizeImpl<unsigned char, LinearInterpolator>,
|
||||
resizeImpl<signed char, LinearInterpolator>,
|
||||
resizeImpl<unsigned short, LinearInterpolator>,
|
||||
resizeImpl<short, LinearInterpolator>,
|
||||
resizeImpl<int, LinearInterpolator>,
|
||||
resizeImpl<float, LinearInterpolator>
|
||||
resizeLinearImpl<unsigned char, LinearInterpolator>,
|
||||
resizeLinearImpl<signed char, LinearInterpolator>,
|
||||
resizeLinearImpl<unsigned short, LinearInterpolator>,
|
||||
resizeLinearImpl<short, LinearInterpolator>,
|
||||
resizeLinearImpl<int, LinearInterpolator>,
|
||||
resizeLinearImpl<float, LinearInterpolator>
|
||||
};
|
||||
|
||||
static const func_t cubic_funcs[] =
|
||||
@@ -195,7 +217,8 @@ GPU_TEST_P(ResizeSameAsHost, Accuracy)
|
||||
cv::Mat dst_gold;
|
||||
cv::resize(src, dst_gold, cv::Size(), coeff, coeff, interpolation);
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-2 : 1.0);
|
||||
// CPU test for cv::resize uses 16 as error threshold for CV_8U, we uses 4 as error threshold for CV_8U
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-2 : src.depth() == CV_8U ? 4.0 : 1.0);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, ResizeSameAsHost, testing::Combine(
|
||||
@@ -203,7 +226,15 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, ResizeSameAsHost, testing::Combine(
|
||||
DIFFERENT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
|
||||
testing::Values(0.3, 0.5),
|
||||
testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_AREA)),
|
||||
testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_AREA)),
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc2, ResizeSameAsHost, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
|
||||
testing::Values(0.3, 0.5, 1.5, 2.0),
|
||||
testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR)),
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
#endif // HAVE_CUDA
|
||||
|
||||
@@ -9,6 +9,10 @@ ocv_add_module(highgui opencv_imgproc OPTIONAL opencv_androidcamera)
|
||||
|
||||
ocv_clear_vars(GRFMT_LIBS)
|
||||
|
||||
if(HAVE_WINRT_CX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
|
||||
endif()
|
||||
|
||||
if(HAVE_PNG OR HAVE_TIFF OR HAVE_OPENEXR)
|
||||
ocv_include_directories(${ZLIB_INCLUDE_DIR})
|
||||
list(APPEND GRFMT_LIBS ${ZLIB_LIBRARIES})
|
||||
@@ -50,13 +54,11 @@ source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs})
|
||||
set(highgui_hdrs
|
||||
src/precomp.hpp
|
||||
src/utils.hpp
|
||||
src/cap_ffmpeg_impl.hpp
|
||||
)
|
||||
|
||||
set(highgui_srcs
|
||||
src/cap.cpp
|
||||
src/cap_images.cpp
|
||||
src/cap_ffmpeg.cpp
|
||||
src/loadsave.cpp
|
||||
src/utils.cpp
|
||||
src/window.cpp
|
||||
@@ -119,6 +121,7 @@ if (WIN32 AND HAVE_DSHOW)
|
||||
endif()
|
||||
|
||||
if (WIN32 AND HAVE_MSMF)
|
||||
list(APPEND highgui_srcs src/cap_msmf.hpp)
|
||||
list(APPEND highgui_srcs src/cap_msmf.cpp)
|
||||
endif()
|
||||
|
||||
@@ -165,18 +168,24 @@ endif(HAVE_opencv_androidcamera)
|
||||
|
||||
if(HAVE_XIMEA)
|
||||
list(APPEND highgui_srcs src/cap_ximea.cpp)
|
||||
ocv_include_directories(${XIMEA_PATH})
|
||||
if(XIMEA_PATH)
|
||||
ocv_include_directories(${XIMEA_PATH})
|
||||
endif()
|
||||
if(XIMEA_LIBRARY_DIR)
|
||||
link_directories("${XIMEA_LIBRARY_DIR}")
|
||||
endif()
|
||||
if(X86_64)
|
||||
if(WIN32 AND X86_64)
|
||||
list(APPEND HIGHGUI_LIBRARIES m3apiX64)
|
||||
elseif(APPLE)
|
||||
list(APPEND HIGHGUI_LIBRARIES "-framework m3api")
|
||||
else()
|
||||
list(APPEND HIGHGUI_LIBRARIES m3api)
|
||||
endif()
|
||||
endif(HAVE_XIMEA)
|
||||
|
||||
if(HAVE_FFMPEG)
|
||||
list(APPEND highgui_hdrs src/cap_ffmpeg_impl.hpp)
|
||||
list(APPEND highgui_srcs src/cap_ffmpeg.cpp)
|
||||
if(UNIX AND BZIP2_LIBRARIES)
|
||||
list(APPEND HIGHGUI_LIBRARIES ${BZIP2_LIBRARIES})
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,568 @@
|
||||
//
|
||||
// Copyright (C) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// Modified for native C++ WRL support by Gregory Morse
|
||||
//
|
||||
// Code in Details namespace is for internal usage within the library code
|
||||
//
|
||||
|
||||
#ifndef _PLATFORM_AGILE_H_
|
||||
#define _PLATFORM_AGILE_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif // _MSC_VER
|
||||
|
||||
#include <algorithm>
|
||||
#include <wrl\client.h>
|
||||
|
||||
template <typename T, bool TIsNotAgile> class Agile;
|
||||
|
||||
template <typename T>
|
||||
struct UnwrapAgile
|
||||
{
|
||||
static const bool _IsAgile = false;
|
||||
};
|
||||
template <typename T>
|
||||
struct UnwrapAgile<Agile<T, false>>
|
||||
{
|
||||
static const bool _IsAgile = true;
|
||||
};
|
||||
template <typename T>
|
||||
struct UnwrapAgile<Agile<T, true>>
|
||||
{
|
||||
static const bool _IsAgile = true;
|
||||
};
|
||||
|
||||
#define IS_AGILE(T) UnwrapAgile<T>::_IsAgile
|
||||
|
||||
#define __is_winrt_agile(T) (std::is_same<T, HSTRING__>::value || std::is_base_of<Microsoft::WRL::FtmBase, T>::value || std::is_base_of<IAgileObject, T>::value) //derived from Microsoft::WRL::FtmBase or IAgileObject
|
||||
|
||||
#define __is_win_interface(T) (std::is_base_of<IUnknown, T>::value || std::is_base_of<IInspectable, T>::value) //derived from IUnknown or IInspectable
|
||||
|
||||
#define __is_win_class(T) (std::is_same<T, HSTRING__>::value || std::is_base_of<Microsoft::WRL::Details::RuntimeClassBase, T>::value) //derived from Microsoft::WRL::RuntimeClass or HSTRING
|
||||
|
||||
namespace Details
|
||||
{
|
||||
IUnknown* __stdcall GetObjectContext();
|
||||
HRESULT __stdcall GetProxyImpl(IUnknown*, REFIID, IUnknown*, IUnknown**);
|
||||
HRESULT __stdcall ReleaseInContextImpl(IUnknown*, IUnknown*);
|
||||
|
||||
template <typename T>
|
||||
#if _MSC_VER >= 1800
|
||||
__declspec(no_refcount) inline HRESULT GetProxy(T *ObjectIn, IUnknown *ContextCallBack, T **Proxy)
|
||||
#else
|
||||
inline HRESULT GetProxy(T *ObjectIn, IUnknown *ContextCallBack, T **Proxy)
|
||||
#endif
|
||||
{
|
||||
#if _MSC_VER >= 1800
|
||||
return GetProxyImpl(*reinterpret_cast<IUnknown**>(&ObjectIn), __uuidof(T*), ContextCallBack, reinterpret_cast<IUnknown**>(Proxy));
|
||||
#else
|
||||
return GetProxyImpl(*reinterpret_cast<IUnknown**>(&const_cast<T*>(ObjectIn)), __uuidof(T*), ContextCallBack, reinterpret_cast<IUnknown**>(Proxy));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline HRESULT ReleaseInContext(T *ObjectIn, IUnknown *ContextCallBack)
|
||||
{
|
||||
return ReleaseInContextImpl(ObjectIn, ContextCallBack);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
class AgileHelper
|
||||
{
|
||||
__abi_IUnknown* _p;
|
||||
bool _release;
|
||||
public:
|
||||
AgileHelper(__abi_IUnknown* p, bool release = true) : _p(p), _release(release)
|
||||
{
|
||||
}
|
||||
AgileHelper(AgileHelper&& other) : _p(other._p), _release(other._release)
|
||||
{
|
||||
_other._p = nullptr;
|
||||
_other._release = true;
|
||||
}
|
||||
AgileHelper operator=(AgileHelper&& other)
|
||||
{
|
||||
_p = other._p;
|
||||
_release = other._release;
|
||||
_other._p = nullptr;
|
||||
_other._release = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~AgileHelper()
|
||||
{
|
||||
if (_release && _p)
|
||||
{
|
||||
_p->__abi_Release();
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(no_refcount) __declspec(no_release_return)
|
||||
T* operator->()
|
||||
{
|
||||
return reinterpret_cast<T*>(_p);
|
||||
}
|
||||
|
||||
__declspec(no_refcount) __declspec(no_release_return)
|
||||
operator T * ()
|
||||
{
|
||||
return reinterpret_cast<T*>(_p);
|
||||
}
|
||||
private:
|
||||
AgileHelper(const AgileHelper&);
|
||||
AgileHelper operator=(const AgileHelper&);
|
||||
};
|
||||
template <typename T>
|
||||
struct __remove_hat
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
template <typename T>
|
||||
struct __remove_hat<T*>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
template <typename T>
|
||||
struct AgileTypeHelper
|
||||
{
|
||||
typename typedef __remove_hat<T>::type type;
|
||||
typename typedef __remove_hat<T>::type* agileMemberType;
|
||||
};
|
||||
} // namespace Details
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4451) // Usage of ref class inside this context can lead to invalid marshaling of object across contexts
|
||||
|
||||
template <
|
||||
typename T,
|
||||
bool TIsNotAgile = (__is_win_class(typename Details::AgileTypeHelper<T>::type) && !__is_winrt_agile(typename Details::AgileTypeHelper<T>::type)) ||
|
||||
__is_win_interface(typename Details::AgileTypeHelper<T>::type)
|
||||
>
|
||||
class Agile
|
||||
{
|
||||
static_assert(__is_win_class(typename Details::AgileTypeHelper<T>::type) || __is_win_interface(typename Details::AgileTypeHelper<T>::type), "Agile can only be used with ref class or interface class types");
|
||||
typename typedef Details::AgileTypeHelper<T>::agileMemberType TypeT;
|
||||
TypeT _object;
|
||||
::Microsoft::WRL::ComPtr<IUnknown> _contextCallback;
|
||||
ULONG_PTR _contextToken;
|
||||
|
||||
#if _MSC_VER >= 1800
|
||||
enum class AgileState
|
||||
{
|
||||
NonAgilePointer = 0,
|
||||
AgilePointer = 1,
|
||||
Unknown = 2
|
||||
};
|
||||
AgileState _agileState;
|
||||
#endif
|
||||
|
||||
void CaptureContext()
|
||||
{
|
||||
_contextCallback = Details::GetObjectContext();
|
||||
__abi_ThrowIfFailed(CoGetContextToken(&_contextToken));
|
||||
}
|
||||
|
||||
void SetObject(TypeT object)
|
||||
{
|
||||
// Capture context before setting the pointer
|
||||
// If context capture fails then nothing to cleanup
|
||||
Release();
|
||||
if (object != nullptr)
|
||||
{
|
||||
::Microsoft::WRL::ComPtr<IAgileObject> checkIfAgile;
|
||||
HRESULT hr = reinterpret_cast<IUnknown*>(object)->QueryInterface(__uuidof(IAgileObject), &checkIfAgile);
|
||||
// Don't Capture context if object is agile
|
||||
if (hr != S_OK)
|
||||
{
|
||||
#if _MSC_VER >= 1800
|
||||
_agileState = AgileState::NonAgilePointer;
|
||||
#endif
|
||||
CaptureContext();
|
||||
}
|
||||
#if _MSC_VER >= 1800
|
||||
else
|
||||
{
|
||||
_agileState = AgileState::AgilePointer;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
_object = object;
|
||||
}
|
||||
|
||||
public:
|
||||
Agile() throw() : _object(nullptr), _contextToken(0)
|
||||
#if _MSC_VER >= 1800
|
||||
, _agileState(AgileState::Unknown)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
Agile(nullptr_t) throw() : _object(nullptr), _contextToken(0)
|
||||
#if _MSC_VER >= 1800
|
||||
, _agileState(AgileState::Unknown)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
explicit Agile(TypeT object) throw() : _object(nullptr), _contextToken(0)
|
||||
#if _MSC_VER >= 1800
|
||||
, _agileState(AgileState::Unknown)
|
||||
#endif
|
||||
{
|
||||
// Assumes that the source object is from the current context
|
||||
SetObject(object);
|
||||
}
|
||||
|
||||
Agile(const Agile& object) throw() : _object(nullptr), _contextToken(0)
|
||||
#if _MSC_VER >= 1800
|
||||
, _agileState(AgileState::Unknown)
|
||||
#endif
|
||||
{
|
||||
// Get returns pointer valid for current context
|
||||
SetObject(object.Get());
|
||||
}
|
||||
|
||||
Agile(Agile&& object) throw() : _object(nullptr), _contextToken(0)
|
||||
#if _MSC_VER >= 1800
|
||||
, _agileState(AgileState::Unknown)
|
||||
#endif
|
||||
{
|
||||
// Assumes that the source object is from the current context
|
||||
Swap(object);
|
||||
}
|
||||
|
||||
~Agile() throw()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
TypeT Get() const
|
||||
{
|
||||
// Agile object, no proxy required
|
||||
#if _MSC_VER >= 1800
|
||||
if (_agileState == AgileState::AgilePointer || _object == nullptr)
|
||||
#else
|
||||
if (_contextToken == 0 || _contextCallback == nullptr || _object == nullptr)
|
||||
#endif
|
||||
{
|
||||
return _object;
|
||||
}
|
||||
|
||||
// Do the check for same context
|
||||
ULONG_PTR currentContextToken;
|
||||
__abi_ThrowIfFailed(CoGetContextToken(¤tContextToken));
|
||||
if (currentContextToken == _contextToken)
|
||||
{
|
||||
return _object;
|
||||
}
|
||||
|
||||
#if _MSC_VER >= 1800
|
||||
// Different context and holding on to a non agile object
|
||||
// Do the costly work of getting a proxy
|
||||
TypeT localObject;
|
||||
__abi_ThrowIfFailed(Details::GetProxy(_object, _contextCallback.Get(), &localObject));
|
||||
|
||||
if (_agileState == AgileState::Unknown)
|
||||
#else
|
||||
// Object is agile if it implements IAgileObject
|
||||
// GetAddressOf captures the context with out knowing the type of object that it will hold
|
||||
if (_object != nullptr)
|
||||
#endif
|
||||
{
|
||||
#if _MSC_VER >= 1800
|
||||
// Object is agile if it implements IAgileObject
|
||||
// GetAddressOf captures the context with out knowing the type of object that it will hold
|
||||
::Microsoft::WRL::ComPtr<IAgileObject> checkIfAgile;
|
||||
HRESULT hr = reinterpret_cast<IUnknown*>(localObject)->QueryInterface(__uuidof(IAgileObject), &checkIfAgile);
|
||||
#else
|
||||
::Microsoft::WRL::ComPtr<IAgileObject> checkIfAgile;
|
||||
HRESULT hr = reinterpret_cast<IUnknown*>(_object)->QueryInterface(__uuidof(IAgileObject), &checkIfAgile);
|
||||
#endif
|
||||
if (hr == S_OK)
|
||||
{
|
||||
auto pThis = const_cast<Agile*>(this);
|
||||
#if _MSC_VER >= 1800
|
||||
pThis->_agileState = AgileState::AgilePointer;
|
||||
#endif
|
||||
pThis->_contextToken = 0;
|
||||
pThis->_contextCallback = nullptr;
|
||||
return _object;
|
||||
}
|
||||
#if _MSC_VER >= 1800
|
||||
else
|
||||
{
|
||||
auto pThis = const_cast<Agile*>(this);
|
||||
pThis->_agileState = AgileState::NonAgilePointer;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if _MSC_VER < 1800
|
||||
// Different context and holding on to a non agile object
|
||||
// Do the costly work of getting a proxy
|
||||
TypeT localObject;
|
||||
__abi_ThrowIfFailed(Details::GetProxy(_object, _contextCallback.Get(), &localObject));
|
||||
#endif
|
||||
return localObject;
|
||||
}
|
||||
|
||||
TypeT* GetAddressOf() throw()
|
||||
{
|
||||
Release();
|
||||
CaptureContext();
|
||||
return &_object;
|
||||
}
|
||||
|
||||
TypeT* GetAddressOfForInOut() throw()
|
||||
{
|
||||
CaptureContext();
|
||||
return &_object;
|
||||
}
|
||||
|
||||
TypeT operator->() const throw()
|
||||
{
|
||||
return Get();
|
||||
}
|
||||
|
||||
Agile& operator=(nullptr_t) throw()
|
||||
{
|
||||
Release();
|
||||
return *this;
|
||||
}
|
||||
|
||||
Agile& operator=(TypeT object) throw()
|
||||
{
|
||||
Agile(object).Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Agile& operator=(Agile object) throw()
|
||||
{
|
||||
// parameter is by copy which gets pointer valid for current context
|
||||
object.Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if _MSC_VER < 1800
|
||||
Agile& operator=(IUnknown* lp) throw()
|
||||
{
|
||||
// bump ref count
|
||||
::Microsoft::WRL::ComPtr<IUnknown> spObject(lp);
|
||||
|
||||
// put it into Platform Object
|
||||
Platform::Object object;
|
||||
*(IUnknown**)(&object) = spObject.Detach();
|
||||
|
||||
SetObject(object);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Swap(Agile& object)
|
||||
{
|
||||
std::swap(_object, object._object);
|
||||
std::swap(_contextCallback, object._contextCallback);
|
||||
std::swap(_contextToken, object._contextToken);
|
||||
#if _MSC_VER >= 1800
|
||||
std::swap(_agileState, object._agileState);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Release the interface and set to NULL
|
||||
void Release() throw()
|
||||
{
|
||||
if (_object)
|
||||
{
|
||||
// Cast to IInspectable (no QI)
|
||||
IUnknown* pObject = *(IUnknown**)(&_object);
|
||||
// Set * to null without release
|
||||
*(IUnknown**)(&_object) = nullptr;
|
||||
|
||||
ULONG_PTR currentContextToken;
|
||||
__abi_ThrowIfFailed(CoGetContextToken(¤tContextToken));
|
||||
if (_contextToken == 0 || _contextCallback == nullptr || _contextToken == currentContextToken)
|
||||
{
|
||||
pObject->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
Details::ReleaseInContext(pObject, _contextCallback.Get());
|
||||
}
|
||||
_contextCallback = nullptr;
|
||||
_contextToken = 0;
|
||||
#if _MSC_VER >= 1800
|
||||
_agileState = AgileState::Unknown;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(nullptr_t) const throw()
|
||||
{
|
||||
return _object == nullptr;
|
||||
}
|
||||
|
||||
bool operator==(const Agile& other) const throw()
|
||||
{
|
||||
return _object == other._object && _contextToken == other._contextToken;
|
||||
}
|
||||
|
||||
bool operator<(const Agile& other) const throw()
|
||||
{
|
||||
if (reinterpret_cast<void*>(_object) < reinterpret_cast<void*>(other._object))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return _object == other._object && _contextToken < other._contextToken;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class Agile<T, false>
|
||||
{
|
||||
static_assert(__is_win_class(typename Details::AgileTypeHelper<T>::type) || __is_win_interface(typename Details::AgileTypeHelper<T>::type), "Agile can only be used with ref class or interface class types");
|
||||
typename typedef Details::AgileTypeHelper<T>::agileMemberType TypeT;
|
||||
TypeT _object;
|
||||
|
||||
public:
|
||||
Agile() throw() : _object(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Agile(nullptr_t) throw() : _object(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
explicit Agile(TypeT object) throw() : _object(object)
|
||||
{
|
||||
}
|
||||
|
||||
Agile(const Agile& object) throw() : _object(object._object)
|
||||
{
|
||||
}
|
||||
|
||||
Agile(Agile&& object) throw() : _object(nullptr)
|
||||
{
|
||||
Swap(object);
|
||||
}
|
||||
|
||||
~Agile() throw()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
TypeT Get() const
|
||||
{
|
||||
return _object;
|
||||
}
|
||||
|
||||
TypeT* GetAddressOf() throw()
|
||||
{
|
||||
Release();
|
||||
return &_object;
|
||||
}
|
||||
|
||||
TypeT* GetAddressOfForInOut() throw()
|
||||
{
|
||||
return &_object;
|
||||
}
|
||||
|
||||
TypeT operator->() const throw()
|
||||
{
|
||||
return Get();
|
||||
}
|
||||
|
||||
Agile& operator=(nullptr_t) throw()
|
||||
{
|
||||
Release();
|
||||
return *this;
|
||||
}
|
||||
|
||||
Agile& operator=(TypeT object) throw()
|
||||
{
|
||||
if (_object != object)
|
||||
{
|
||||
_object = object;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Agile& operator=(Agile object) throw()
|
||||
{
|
||||
object.Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if _MSC_VER < 1800
|
||||
Agile& operator=(IUnknown* lp) throw()
|
||||
{
|
||||
Release();
|
||||
// bump ref count
|
||||
::Microsoft::WRL::ComPtr<IUnknown> spObject(lp);
|
||||
|
||||
// put it into Platform Object
|
||||
Platform::Object object;
|
||||
*(IUnknown**)(&object) = spObject.Detach();
|
||||
|
||||
_object = object;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Release the interface and set to NULL
|
||||
void Release() throw()
|
||||
{
|
||||
_object = nullptr;
|
||||
}
|
||||
|
||||
void Swap(Agile& object)
|
||||
{
|
||||
std::swap(_object, object._object);
|
||||
}
|
||||
|
||||
bool operator==(nullptr_t) const throw()
|
||||
{
|
||||
return _object == nullptr;
|
||||
}
|
||||
|
||||
bool operator==(const Agile& other) const throw()
|
||||
{
|
||||
return _object == other._object;
|
||||
}
|
||||
|
||||
bool operator<(const Agile& other) const throw()
|
||||
{
|
||||
return reinterpret_cast<void*>(_object) < reinterpret_cast<void*>(other._object);
|
||||
}
|
||||
};
|
||||
|
||||
#pragma warning(pop)
|
||||
|
||||
template<class U>
|
||||
bool operator==(nullptr_t, const Agile<U>& a) throw()
|
||||
{
|
||||
return a == nullptr;
|
||||
}
|
||||
|
||||
template<class U>
|
||||
bool operator!=(const Agile<U>& a, nullptr_t) throw()
|
||||
{
|
||||
return !(a == nullptr);
|
||||
}
|
||||
|
||||
template<class U>
|
||||
bool operator!=(nullptr_t, const Agile<U>& a) throw()
|
||||
{
|
||||
return !(a == nullptr);
|
||||
}
|
||||
|
||||
template<class U>
|
||||
bool operator!=(const Agile<U>& a, const Agile<U>& b) throw()
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
|
||||
#endif // _PLATFORM_AGILE_H_
|
||||
@@ -368,8 +368,10 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
|
||||
{
|
||||
CvCapture * result = 0;
|
||||
|
||||
#ifdef HAVE_FFMPEG
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_FFMPEG_proxy (filename);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_VFW
|
||||
if (! result)
|
||||
@@ -426,8 +428,10 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
|
||||
if(!fourcc || !fps)
|
||||
result = cvCreateVideoWriter_Images(filename);
|
||||
|
||||
#ifdef HAVE_FFMPEG
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_FFMPEG_proxy (filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_VFW
|
||||
if(!result)
|
||||
@@ -459,6 +463,19 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
|
||||
result = cvCreateVideoWriter_GStreamer(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_FFMPEG) && \
|
||||
!defined(HAVE_VFW) && \
|
||||
!defined(HAVE_MSMF) && \
|
||||
!defined(HAVE_AVFOUNDATION) && \
|
||||
!defined(HAVE_QUICKTIME) && \
|
||||
!defined(HAVE_QTKIT) && \
|
||||
!defined(HAVE_GSTREAMER)
|
||||
// If none of the writers is used
|
||||
// these statements suppress 'unused parameter' warnings.
|
||||
(void)frameSize;
|
||||
(void)is_color;
|
||||
#endif
|
||||
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_Images(filename);
|
||||
|
||||
|
||||
@@ -1825,6 +1825,8 @@ bool videoInput::setVideoSettingCamera(int deviceID, long Property, long lValue,
|
||||
hr = VDList[deviceID]->pVideoInputFilter->QueryInterface(IID_IAMCameraControl, (void**)&pIAMCameraControl);
|
||||
if (FAILED(hr)) {
|
||||
printf("Error\n");
|
||||
if(VDList[deviceID]->pVideoInputFilter)VDList[deviceID]->pVideoInputFilter->Release();
|
||||
if(VDList[deviceID]->pVideoInputFilter)VDList[deviceID]->pVideoInputFilter = NULL;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -1843,6 +1845,8 @@ bool videoInput::setVideoSettingCamera(int deviceID, long Property, long lValue,
|
||||
pIAMCameraControl->Set(Property, lValue, Flags);
|
||||
}
|
||||
pIAMCameraControl->Release();
|
||||
if(VDList[deviceID]->pVideoInputFilter)VDList[deviceID]->pVideoInputFilter->Release();
|
||||
if(VDList[deviceID]->pVideoInputFilter)VDList[deviceID]->pVideoInputFilter = NULL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,6 +485,7 @@ static int LockCallBack(void **mutex, AVLockOp op)
|
||||
localMutex->destroy();
|
||||
free(localMutex);
|
||||
localMutex = NULL;
|
||||
*mutex = NULL;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@@ -630,7 +631,7 @@ bool CvCapture_FFMPEG::grabFrame()
|
||||
int got_picture;
|
||||
|
||||
int count_errs = 0;
|
||||
const int max_number_of_attempts = 1 << 16;
|
||||
const int max_number_of_attempts = 1 << 9;
|
||||
|
||||
if( !ic || !video_st ) return false;
|
||||
|
||||
|
||||
@@ -193,6 +193,14 @@
|
||||
// Release any retained subviews of the main view.
|
||||
// e.g. self.myOutlet = nil;
|
||||
|
||||
for (AVCaptureInput *input in self.captureSession.inputs) {
|
||||
[self.captureSession removeInput:input];
|
||||
}
|
||||
|
||||
for (AVCaptureOutput *output in self.captureSession.outputs) {
|
||||
[self.captureSession removeOutput:output];
|
||||
}
|
||||
|
||||
[self.captureSession stopRunning];
|
||||
self.captureSession = nil;
|
||||
self.captureVideoPreviewLayer = nil;
|
||||
|
||||
@@ -102,7 +102,7 @@ I modified the following:
|
||||
autosetup_capture_mode_v4l2 -> autodetect capture modes for v4l2
|
||||
- Modifications are according with Video4Linux old codes
|
||||
- Video4Linux handling is automatically if it does not recognize a Video4Linux2 device
|
||||
- Tested succesful with Logitech Quickcam Express (V4L), Creative Vista (V4L) and Genius VideoCam Notebook (V4L2)
|
||||
- Tested successfully with Logitech Quickcam Express (V4L), Creative Vista (V4L) and Genius VideoCam Notebook (V4L2)
|
||||
- Correct source lines with compiler warning messages
|
||||
- Information message from v4l/v4l2 detection
|
||||
|
||||
@@ -113,7 +113,7 @@ I modified the following:
|
||||
- SN9C10x chip based webcams support
|
||||
- New methods are internal:
|
||||
bayer2rgb24, sonix_decompress -> decoder routines for SN9C10x decoding from Takafumi Mizuno <taka-qce@ls-a.jp> with his pleasure :)
|
||||
- Tested succesful with Genius VideoCam Notebook (V4L2)
|
||||
- Tested successfully with Genius VideoCam Notebook (V4L2)
|
||||
|
||||
Sixth Patch: Sept 10, 2005 Csaba Kertesz sign@freemail.hu
|
||||
For Release: OpenCV-Linux Beta5 OpenCV-0.9.7
|
||||
@@ -123,7 +123,7 @@ I added the following:
|
||||
- Get and change V4L capture controls (hue, saturation, brightness, contrast)
|
||||
- New method is internal:
|
||||
icvSetControl -> set capture controls
|
||||
- Tested succesful with Creative Vista (V4L)
|
||||
- Tested successfully with Creative Vista (V4L)
|
||||
|
||||
Seventh Patch: Sept 10, 2005 Csaba Kertesz sign@freemail.hu
|
||||
For Release: OpenCV-Linux Beta5 OpenCV-0.9.7
|
||||
@@ -132,7 +132,7 @@ I added the following:
|
||||
- Detect, get and change V4L2 capture controls (hue, saturation, brightness, contrast, gain)
|
||||
- New methods are internal:
|
||||
v4l2_scan_controls_enumerate_menu, v4l2_scan_controls -> detect capture control intervals
|
||||
- Tested succesful with Genius VideoCam Notebook (V4L2)
|
||||
- Tested successfully with Genius VideoCam Notebook (V4L2)
|
||||
|
||||
8th patch: Jan 5, 2006, Olivier.Bornet@idiap.ch
|
||||
Add support of V4L2_PIX_FMT_YUYV and V4L2_PIX_FMT_MJPEG.
|
||||
|
||||
@@ -102,7 +102,7 @@ I modified the following:
|
||||
autosetup_capture_mode_v4l2 -> autodetect capture modes for v4l2
|
||||
- Modifications are according with Video4Linux old codes
|
||||
- Video4Linux handling is automatically if it does not recognize a Video4Linux2 device
|
||||
- Tested succesful with Logitech Quickcam Express (V4L), Creative Vista (V4L) and Genius VideoCam Notebook (V4L2)
|
||||
- Tested successfully with Logitech Quickcam Express (V4L), Creative Vista (V4L) and Genius VideoCam Notebook (V4L2)
|
||||
- Correct source lines with compiler warning messages
|
||||
- Information message from v4l/v4l2 detection
|
||||
|
||||
@@ -113,7 +113,7 @@ I modified the following:
|
||||
- SN9C10x chip based webcams support
|
||||
- New methods are internal:
|
||||
bayer2rgb24, sonix_decompress -> decoder routines for SN9C10x decoding from Takafumi Mizuno <taka-qce@ls-a.jp> with his pleasure :)
|
||||
- Tested succesful with Genius VideoCam Notebook (V4L2)
|
||||
- Tested successfully with Genius VideoCam Notebook (V4L2)
|
||||
|
||||
Sixth Patch: Sept 10, 2005 Csaba Kertesz sign@freemail.hu
|
||||
For Release: OpenCV-Linux Beta5 OpenCV-0.9.7
|
||||
@@ -123,7 +123,7 @@ I added the following:
|
||||
- Get and change V4L capture controls (hue, saturation, brightness, contrast)
|
||||
- New method is internal:
|
||||
icvSetControl -> set capture controls
|
||||
- Tested succesful with Creative Vista (V4L)
|
||||
- Tested successfully with Creative Vista (V4L)
|
||||
|
||||
Seventh Patch: Sept 10, 2005 Csaba Kertesz sign@freemail.hu
|
||||
For Release: OpenCV-Linux Beta5 OpenCV-0.9.7
|
||||
@@ -132,7 +132,7 @@ I added the following:
|
||||
- Detect, get and change V4L2 capture controls (hue, saturation, brightness, contrast, gain)
|
||||
- New methods are internal:
|
||||
v4l2_scan_controls_enumerate_menu, v4l2_scan_controls -> detect capture control intervals
|
||||
- Tested succesful with Genius VideoCam Notebook (V4L2)
|
||||
- Tested successfully with Genius VideoCam Notebook (V4L2)
|
||||
|
||||
8th patch: Jan 5, 2006, Olivier.Bornet@idiap.ch
|
||||
Add support of V4L2_PIX_FMT_YUYV and V4L2_PIX_FMT_MJPEG.
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef WIN32
|
||||
#include "xiApi.h"
|
||||
#include "xiExt.h"
|
||||
#include "m3Api.h"
|
||||
#else
|
||||
#include <m3api/xiApi.h>
|
||||
#endif
|
||||
|
||||
/**********************************************************************************/
|
||||
|
||||
@@ -156,7 +158,7 @@ bool CvCaptureCAM_XIMEA::grabFrame()
|
||||
image.size = sizeof(XI_IMG);
|
||||
int mvret = xiGetImage( hmv, timeout, &image);
|
||||
|
||||
if(mvret == MM40_ACQUISITION_STOPED)
|
||||
if(mvret == XI_ACQUISITION_STOPED)
|
||||
{
|
||||
xiStartAcquisition(hmv);
|
||||
mvret = xiGetImage(hmv, timeout, &image);
|
||||
|
||||
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 1.8 KiB |