Skip to content

Commit

Permalink
Merge 2.4 into master
Browse files Browse the repository at this point in the history
PR opencv#2968: cce2d99 8578f9c
Fixed bug which caused crash of GPU version of feature matcher in stitcher

The bug caused crash of GPU version of feature matcher in stitcher when
we use ORB features.

PR opencv#3236: 5947519
Check sure that we're not already below required leaf false alarm rate before continuing to get negative samples.

PR opencv#3190
fix blobdetector

PR opencv#3562 (part): 82bd82e
TBB updated to 4.3u2. Fix for aarch64 support.

PR opencv#3604 (part): 091c7a3
OpenGL interop sample reworked not ot use cvconfig.h

PR opencv#3792: afdf319
Add -L for CUDA libs path to pkg-config

Add all dirs from CUDA_LIBS_PATH as -L linker options to
OPENCV_LINKER_LIBS. These will end up in opencv.pc.

PR opencv#3893: 122b9f8
Turn ocv_convert_to_lib_name into a function

PR opencv#5490: ec5244a
fixed memory leak in findHomography tests

PR opencv#5491: 0d5b739
delete video readers

PR opencv#5574

PR opencv#5202
  • Loading branch information
alalek committed Dec 8, 2015
2 parents 4448cbf + 681df84 commit d86d8ed
Show file tree
Hide file tree
Showing 15 changed files with 209 additions and 115 deletions.
38 changes: 22 additions & 16 deletions 3rdparty/tbb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@ if (WIN32 AND NOT ARM)
message(FATAL_ERROR "BUILD_TBB option supports Windows on ARM only!\nUse regular official TBB build instead of the BUILD_TBB option!")
endif()

if (WIN32 AND ARM)
# 4.1 update 4 - The first release that supports Windows RT. Hangs on some Android devices
set(tbb_ver "tbb41_20130613oss")
set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130613oss_src.tgz")
set(tbb_md5 "108c8c1e481b0aaea61878289eb28b6a")
set(tbb_version_file "version_string.ver")
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702)
else()
# 4.1 update 2 - works fine
set(tbb_ver "tbb41_20130116oss")
set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130116oss_src.tgz")
set(tbb_md5 "3809790e1001a1b32d59c9fee590ee85")
set(tbb_version_file "version_string.ver")
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
endif()
set(tbb_ver "tbb43_20141204oss")
set(tbb_url "http://www.threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb43_20141204oss_src.tgz")
set(tbb_md5 "e903dd92d9433701f097fa7ca29a3c1f")
set(tbb_version_file "version_string.ver")
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)

# 4.1 update 4 - The first release that supports Windows RT. Hangs on some Android devices
#set(tbb_ver "tbb41_20130613oss")
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130613oss_src.tgz")
#set(tbb_md5 "108c8c1e481b0aaea61878289eb28b6a")
#set(tbb_version_file "version_string.ver")
#ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702)

# 4.1 update 2 - works fine
#set(tbb_ver "tbb41_20130116oss")
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130116oss_src.tgz")
#set(tbb_md5 "3809790e1001a1b32d59c9fee590ee85")
#set(tbb_version_file "version_string.ver")
#ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)

# 4.1 update 3 dev - Hangs on some Android devices
#set(tbb_ver "tbb41_20130401oss")
Expand Down Expand Up @@ -97,7 +102,7 @@ if(NOT EXISTS "${tbb_tarball}")
message(STATUS "Downloading ${tbb_ver}_src.tgz")
file(DOWNLOAD "${tbb_url}" "${tbb_tarball}" TIMEOUT 600 STATUS __statvar)
if(NOT __statvar EQUAL 0)
message(FATAL_ERROR "Failed to download TBB sources: ${tbb_url}")
message(FATAL_ERROR "Failed to download TBB sources (${__statvar}): ${tbb_url}")
endif()
file(MD5 "${tbb_tarball}" tbb_local_md5)
if(NOT tbb_local_md5 STREQUAL tbb_md5)
Expand Down Expand Up @@ -153,6 +158,7 @@ if (WIN32)
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} /APPCONTAINER")
else()
add_definitions(-D__TBB_DYNAMIC_LOAD_ENABLED=0 #required
-D__TBB_WEAK_SYMBOLS_PRESENT=0 #required for 4.3
-D__TBB_BUILD=1 #required
-D__TBB_SURVIVE_THREAD_SWITCH=0 #no cilk support
-DTBB_USE_DEBUG=0 #just to be sure
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,9 @@ if(HAVE_CUDA)
if(HAVE_CUFFT)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cufft_LIBRARY})
endif()
foreach(p ${CUDA_LIBS_PATH})
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} -L${p})
endforeach()
endif()
# ----------------------------------------------------------------------------
# Solution folders:
Expand Down
13 changes: 8 additions & 5 deletions apps/traincascade/cascadeclassifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,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;
Expand Down Expand Up @@ -297,17 +297,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;

Expand All @@ -317,14 +317,17 @@ 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);
for( int i = first; i < first + count; i++ )
{
for( ; ; )
{
if( consumed != 0 && ((double)getcount+1)/(double)(int64)consumed <= minimumAcceptanceRatio )
return getcount;

bool isGetImg = isPositive ? imgReader.getPos( img ) :
imgReader.getNeg( img );
if( !isGetImg )
Expand Down
4 changes: 2 additions & 2 deletions apps/traincascade/cascadeclassifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ class CvCascadeClassifier
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;
Expand Down
4 changes: 2 additions & 2 deletions cmake/OpenCVFindLibsVideo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ endif(WITH_VFW)

# --- GStreamer ---
ocv_clear_vars(HAVE_GSTREAMER)
# try to find gstreamer 1.x first
# try to find gstreamer 1.x first if 0.10 was not requested
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)
Expand All @@ -29,7 +29,7 @@ if(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
set(GSTREAMER_PBUTILS_VERSION ${ALIASOF_gstreamer-pbutils-1.0_VERSION})
endif()

endif(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
endif()

# if gstreamer 1.x was not found, or we specified we wanted 0.10, try to find it
if(WITH_GSTREAMER AND NOT HAVE_GSTREAMER OR WITH_GSTREAMER_0_10)
Expand Down
16 changes: 7 additions & 9 deletions cmake/OpenCVUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -503,17 +503,15 @@ endmacro()


# convert list of paths to libraries names without lib prefix
macro(ocv_convert_to_lib_name var)
set(__tmp "")
function(ocv_convert_to_lib_name var)
set(tmp "")
foreach(path ${ARGN})
get_filename_component(__tmp_name "${path}" NAME_WE)
string(REGEX REPLACE "^lib" "" __tmp_name ${__tmp_name})
list(APPEND __tmp "${__tmp_name}")
get_filename_component(tmp_name "${path}" NAME_WE)
string(REGEX REPLACE "^lib" "" tmp_name "${tmp_name}")
list(APPEND tmp "${tmp_name}")
endforeach()
set(${var} ${__tmp})
unset(__tmp)
unset(__tmp_name)
endmacro()
set(${var} ${tmp} PARENT_SCOPE)
endfunction()


# add install command
Expand Down
4 changes: 4 additions & 0 deletions modules/calib3d/test/test_homography.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2015, Itseez Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -564,6 +565,9 @@ void CV_HomographyTest::run(int)
default: continue;
}
}

delete[]src_data;
src_data = NULL;
}
}

Expand Down
4 changes: 4 additions & 0 deletions modules/features2d/src/blobdetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ void SimpleBlobDetectorImpl::detect(InputArray image, std::vector<cv::KeyPoint>&
else
grayscaleImage = image.getMat();

if (grayscaleImage.type() != CV_8UC1) {
CV_Error(Error::StsUnsupportedFormat, "Blob detector only supports 8-bit images!");
}

std::vector < std::vector<Center> > centers;
for (double thresh = params.minThreshold; thresh < params.maxThreshold; thresh += params.thresholdStep)
{
Expand Down
6 changes: 5 additions & 1 deletion modules/stitching/src/matchers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ void GpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &feat
descriptors1_.upload(features1.descriptors);
descriptors2_.upload(features2.descriptors);

Ptr<cuda::DescriptorMatcher> matcher = cuda::DescriptorMatcher::createBFMatcher(NORM_L2);
//TODO: NORM_L1 allows to avoid matcher crashes for ORB features, but is not absolutely correct for them.
// The best choice for ORB features is NORM_HAMMING, but it is incorrect for SURF features.
// More accurate fix in this place should be done in the future -- the type of the norm
// should be either a parameter of this method, or a field of the class.
Ptr<cuda::DescriptorMatcher> matcher = cuda::DescriptorMatcher::createBFMatcher(NORM_L1);

MatchesSet matches;

Expand Down
6 changes: 4 additions & 2 deletions modules/videoio/src/cap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,12 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)

#ifdef HAVE_GSTREAMER
if (!capture)
capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, 0);
capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2,
reinterpret_cast<char *>(index));

if (!capture)
capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L, 0);
capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L,
reinterpret_cast<char *>(index));
#endif
if (pref) break; // CV_CAP_VFW

Expand Down
Loading

0 comments on commit d86d8ed

Please sign in to comment.