Merge pull request #4081 from vpisarev:30_small_fixes
This commit is contained in:
commit
a28c8d002d
@ -252,7 +252,14 @@ pthread_mutex_t ThreadManager::m_manager_access_mutex = PTHREAD_RECURSIVE_MUTEX_
|
||||
|
||||
ThreadManager::ptr_holder ThreadManager::m_instance;
|
||||
const char ThreadManager::m_env_name[] = "OPENCV_FOR_THREADS_NUM";
|
||||
|
||||
#ifdef ANDROID
|
||||
// many modern phones/tables have 4-core CPUs. Let's use no more
|
||||
// than 2 threads by default not to overheat the devices
|
||||
const unsigned int ThreadManager::m_default_number_of_threads = 2;
|
||||
#else
|
||||
const unsigned int ThreadManager::m_default_number_of_threads = 8;
|
||||
#endif
|
||||
|
||||
ForThread::~ForThread()
|
||||
{
|
||||
@ -399,11 +406,10 @@ ThreadManager::~ThreadManager()
|
||||
|
||||
void ThreadManager::run(const cv::Range& range, const cv::ParallelLoopBody& body, double nstripes)
|
||||
{
|
||||
bool is_work_thread;
|
||||
bool is_work_thread = m_is_work_thread.get()->value;
|
||||
|
||||
is_work_thread = m_is_work_thread.get()->value;
|
||||
|
||||
if( (getNumOfThreads() > 1) && !is_work_thread && (range.end - range.start > 1) )
|
||||
if( (getNumOfThreads() > 1) && !is_work_thread &&
|
||||
(range.end - range.start > 1) && (nstripes <= 0 || nstripes >= 1.5) )
|
||||
{
|
||||
int res = pthread_mutex_trylock(&m_manager_access_mutex);
|
||||
|
||||
|
@ -402,16 +402,19 @@ double cv::findTransformECC(InputArray templateImage,
|
||||
|
||||
Mat inputMaskMat = inputMask.getMat();
|
||||
//to use it for mask warping
|
||||
Mat preMask =
|
||||
inputMaskMat.empty() ? Mat::ones(hd, wd, CV_8U) : inputMaskMat;
|
||||
Mat preMask;
|
||||
if(inputMask.empty())
|
||||
preMask = Mat::ones(hd, wd, CV_8U);
|
||||
else
|
||||
threshold(inputMask, preMask, 0, 1, THRESH_BINARY);
|
||||
|
||||
//gaussian filtering is optional
|
||||
src.convertTo(templateFloat, templateFloat.type());
|
||||
GaussianBlur(templateFloat, templateFloat, Size(5, 5), 0, 0);//is in-place filtering slower?
|
||||
GaussianBlur(templateFloat, templateFloat, Size(5, 5), 0, 0);
|
||||
|
||||
Mat preMaskFloat = Mat(hd, wd, CV_32F);
|
||||
preMask.convertTo(preMaskFloat, preMaskFloat.type());
|
||||
GaussianBlur(preMaskFloat, preMaskFloat, Size(5, 5), 0, 0);//is in-place filtering slower?
|
||||
Mat preMaskFloat;
|
||||
preMask.convertTo(preMaskFloat, CV_32F);
|
||||
GaussianBlur(preMaskFloat, preMaskFloat, Size(5, 5), 0, 0);
|
||||
// Change threshold.
|
||||
preMaskFloat *= (0.5/0.95);
|
||||
// Rounding conversion.
|
||||
@ -512,7 +515,7 @@ double cv::findTransformECC(InputArray templateImage,
|
||||
// calculate enhanced correlation coefficiont (ECC)->rho
|
||||
last_rho = rho;
|
||||
rho = correlation/(imgNorm*tmpNorm);
|
||||
if (isnan(rho)) {
|
||||
if (cvIsNaN(rho)) {
|
||||
CV_Error(Error::StsNoConv, "NaN encountered.");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user