Set stricter warning rules for gcc
This commit is contained in:
parent
0395f7c63f
commit
49a1ba6038
@ -42,6 +42,9 @@
|
||||
#ifndef __CVCOMMON_H_
|
||||
#define __CVCOMMON_H_
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/internal.hpp"
|
||||
|
||||
#include "cxcore.h"
|
||||
#include "cv.h"
|
||||
#include "cxmisc.h"
|
||||
|
@ -80,11 +80,11 @@ typedef struct CvValArray
|
||||
( *( (float*) (aux->data + ((int) (idx1)) * aux->step ) ) < \
|
||||
*( (float*) (aux->data + ((int) (idx2)) * aux->step ) ) )
|
||||
|
||||
CV_IMPLEMENT_QSORT_EX( icvSortIndexedValArray_16s, short, CMP_VALUES, CvValArray* )
|
||||
static CV_IMPLEMENT_QSORT_EX( icvSortIndexedValArray_16s, short, CMP_VALUES, CvValArray* )
|
||||
|
||||
CV_IMPLEMENT_QSORT_EX( icvSortIndexedValArray_32s, int, CMP_VALUES, CvValArray* )
|
||||
static CV_IMPLEMENT_QSORT_EX( icvSortIndexedValArray_32s, int, CMP_VALUES, CvValArray* )
|
||||
|
||||
CV_IMPLEMENT_QSORT_EX( icvSortIndexedValArray_32f, float, CMP_VALUES, CvValArray* )
|
||||
static CV_IMPLEMENT_QSORT_EX( icvSortIndexedValArray_32f, float, CMP_VALUES, CvValArray* )
|
||||
|
||||
CV_BOOST_IMPL
|
||||
void cvGetSortedIndices( CvMat* val, CvMat* idx, int sortcols )
|
||||
@ -190,7 +190,7 @@ float cvEvalStumpClassifier( CvClassifier* classifier, CvMat* sample )
|
||||
}
|
||||
|
||||
#define ICV_DEF_FIND_STUMP_THRESHOLD( suffix, type, error ) \
|
||||
CV_BOOST_IMPL int icvFindStumpThreshold_##suffix( \
|
||||
static int icvFindStumpThreshold_##suffix( \
|
||||
uchar* data, size_t datastep, \
|
||||
uchar* wdata, size_t wstep, \
|
||||
uchar* ydata, size_t ystep, \
|
||||
@ -1149,7 +1149,7 @@ float cvEvalCARTClassifier( CvClassifier* classifier, CvMat* sample )
|
||||
return ((CvCARTClassifier*) classifier)->val[-idx];
|
||||
}
|
||||
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
float cvEvalCARTClassifierIdx( CvClassifier* classifier, CvMat* sample )
|
||||
{
|
||||
CV_FUNCNAME( "cvEvalCARTClassifierIdx" );
|
||||
@ -1209,7 +1209,7 @@ void cvReleaseCARTClassifier( CvClassifier** classifier )
|
||||
*classifier = NULL;
|
||||
}
|
||||
|
||||
void CV_CDECL icvDefaultSplitIdx_R( int compidx, float threshold,
|
||||
static void CV_CDECL icvDefaultSplitIdx_R( int compidx, float threshold,
|
||||
CvMat* idx, CvMat** left, CvMat** right,
|
||||
void* userdata )
|
||||
{
|
||||
@ -1258,7 +1258,7 @@ void CV_CDECL icvDefaultSplitIdx_R( int compidx, float threshold,
|
||||
}
|
||||
}
|
||||
|
||||
void CV_CDECL icvDefaultSplitIdx_C( int compidx, float threshold,
|
||||
static void CV_CDECL icvDefaultSplitIdx_C( int compidx, float threshold,
|
||||
CvMat* idx, CvMat** left, CvMat** right,
|
||||
void* userdata )
|
||||
{
|
||||
@ -1529,7 +1529,7 @@ typedef struct CvBoostTrainer
|
||||
* using ANY appropriate weak classifier
|
||||
*/
|
||||
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
CvBoostTrainer* icvBoostStartTraining( CvMat* trainClasses,
|
||||
CvMat* weakTrainVals,
|
||||
CvMat* /*weights*/,
|
||||
@ -1607,7 +1607,7 @@ CvBoostTrainer* icvBoostStartTraining( CvMat* trainClasses,
|
||||
* Discrete AdaBoost functions
|
||||
*
|
||||
*/
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
float icvBoostNextWeakClassifierDAB( CvMat* weakEvalVals,
|
||||
CvMat* trainClasses,
|
||||
CvMat* /*weakTrainVals*/,
|
||||
@ -1681,7 +1681,7 @@ float icvBoostNextWeakClassifierDAB( CvMat* weakEvalVals,
|
||||
* Real AdaBoost functions
|
||||
*
|
||||
*/
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
float icvBoostNextWeakClassifierRAB( CvMat* weakEvalVals,
|
||||
CvMat* trainClasses,
|
||||
CvMat* /*weakTrainVals*/,
|
||||
@ -1743,7 +1743,7 @@ float icvBoostNextWeakClassifierRAB( CvMat* weakEvalVals,
|
||||
#define CV_LB_PROB_THRESH 0.01F
|
||||
#define CV_LB_WEIGHT_THRESHOLD 0.0001F
|
||||
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
void icvResponsesAndWeightsLB( int num, uchar* wdata, int wstep,
|
||||
uchar* ydata, int ystep,
|
||||
uchar* fdata, int fstep,
|
||||
@ -1772,7 +1772,7 @@ void icvResponsesAndWeightsLB( int num, uchar* wdata, int wstep,
|
||||
}
|
||||
}
|
||||
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
CvBoostTrainer* icvBoostStartTrainingLB( CvMat* trainClasses,
|
||||
CvMat* weakTrainVals,
|
||||
CvMat* weights,
|
||||
@ -1854,7 +1854,7 @@ CvBoostTrainer* icvBoostStartTrainingLB( CvMat* trainClasses,
|
||||
return ptr;
|
||||
}
|
||||
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
float icvBoostNextWeakClassifierLB( CvMat* weakEvalVals,
|
||||
CvMat* trainClasses,
|
||||
CvMat* weakTrainVals,
|
||||
@ -1913,7 +1913,7 @@ float icvBoostNextWeakClassifierLB( CvMat* weakEvalVals,
|
||||
* Gentle AdaBoost
|
||||
*
|
||||
*/
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
float icvBoostNextWeakClassifierGAB( CvMat* weakEvalVals,
|
||||
CvMat* trainClasses,
|
||||
CvMat* /*weakTrainVals*/,
|
||||
@ -2071,7 +2071,7 @@ typedef struct CvBtTrainer
|
||||
typedef void (*CvZeroApproxFunc)( float* approx, CvBtTrainer* trainer );
|
||||
|
||||
/* Mean zero approximation */
|
||||
void icvZeroApproxMean( float* approx, CvBtTrainer* trainer )
|
||||
static void icvZeroApproxMean( float* approx, CvBtTrainer* trainer )
|
||||
{
|
||||
int i;
|
||||
int idx;
|
||||
@ -2088,7 +2088,7 @@ void icvZeroApproxMean( float* approx, CvBtTrainer* trainer )
|
||||
/*
|
||||
* Median zero approximation
|
||||
*/
|
||||
void icvZeroApproxMed( float* approx, CvBtTrainer* trainer )
|
||||
static void icvZeroApproxMed( float* approx, CvBtTrainer* trainer )
|
||||
{
|
||||
int i;
|
||||
int idx;
|
||||
@ -2106,7 +2106,7 @@ void icvZeroApproxMed( float* approx, CvBtTrainer* trainer )
|
||||
/*
|
||||
* 0.5 * log( mean(y) / (1 - mean(y)) ) where y in {0, 1}
|
||||
*/
|
||||
void icvZeroApproxLog( float* approx, CvBtTrainer* trainer )
|
||||
static void icvZeroApproxLog( float* approx, CvBtTrainer* trainer )
|
||||
{
|
||||
float y_mean;
|
||||
|
||||
@ -2117,7 +2117,7 @@ void icvZeroApproxLog( float* approx, CvBtTrainer* trainer )
|
||||
/*
|
||||
* 0 zero approximation
|
||||
*/
|
||||
void icvZeroApprox0( float* approx, CvBtTrainer* trainer )
|
||||
static void icvZeroApprox0( float* approx, CvBtTrainer* trainer )
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -2143,7 +2143,7 @@ static CvZeroApproxFunc icvZeroApproxFunc[] =
|
||||
CV_BOOST_IMPL
|
||||
void cvBtNext( CvCARTClassifier** trees, CvBtTrainer* trainer );
|
||||
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
CvBtTrainer* cvBtStart( CvCARTClassifier** trees,
|
||||
CvMat* trainData,
|
||||
int flags,
|
||||
@ -2270,7 +2270,7 @@ CvBtTrainer* cvBtStart( CvCARTClassifier** trees,
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void icvBtNext_LSREG( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
static void icvBtNext_LSREG( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -2288,7 +2288,7 @@ void icvBtNext_LSREG( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
}
|
||||
|
||||
|
||||
void icvBtNext_LADREG( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
static void icvBtNext_LADREG( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
{
|
||||
CvCARTClassifier* ptr;
|
||||
int i, j;
|
||||
@ -2361,7 +2361,7 @@ void icvBtNext_LADREG( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
}
|
||||
|
||||
|
||||
void icvBtNext_MREG( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
static void icvBtNext_MREG( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
{
|
||||
CvCARTClassifier* ptr;
|
||||
int i, j;
|
||||
@ -2476,7 +2476,7 @@ void icvBtNext_MREG( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
|
||||
#define CV_LOG_VAL_MAX 18.0
|
||||
|
||||
void icvBtNext_L2CLASS( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
static void icvBtNext_L2CLASS( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
{
|
||||
CvCARTClassifier* ptr;
|
||||
int i, j;
|
||||
@ -2617,7 +2617,7 @@ void icvBtNext_L2CLASS( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
trees[0] = ptr;
|
||||
}
|
||||
|
||||
void icvBtNext_LKCLASS( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
static void icvBtNext_LKCLASS( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
{
|
||||
int i, j, k, kk, num;
|
||||
CvMat sample;
|
||||
@ -2781,7 +2781,7 @@ void icvBtNext_LKCLASS( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
}
|
||||
|
||||
|
||||
void icvBtNext_XXBCLASS( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
static void icvBtNext_XXBCLASS( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
{
|
||||
float alpha;
|
||||
int i;
|
||||
@ -2898,7 +2898,7 @@ void cvBtNext( CvCARTClassifier** trees, CvBtTrainer* trainer )
|
||||
}
|
||||
}
|
||||
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
void cvBtEnd( CvBtTrainer** trainer )
|
||||
{
|
||||
CV_FUNCNAME( "cvBtEnd" );
|
||||
@ -2931,7 +2931,7 @@ void cvBtEnd( CvBtTrainer** trainer )
|
||||
* Boosted tree model as a classifier *
|
||||
\****************************************************************************************/
|
||||
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
float cvEvalBtClassifier( CvClassifier* classifier, CvMat* sample )
|
||||
{
|
||||
float val;
|
||||
@ -2972,7 +2972,7 @@ float cvEvalBtClassifier( CvClassifier* classifier, CvMat* sample )
|
||||
return val;
|
||||
}
|
||||
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
float cvEvalBtClassifier2( CvClassifier* classifier, CvMat* sample )
|
||||
{
|
||||
float val;
|
||||
@ -2988,7 +2988,7 @@ float cvEvalBtClassifier2( CvClassifier* classifier, CvMat* sample )
|
||||
return (float) (val >= 0.0F);
|
||||
}
|
||||
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
float cvEvalBtClassifierK( CvClassifier* classifier, CvMat* sample )
|
||||
{
|
||||
int cls = 0;
|
||||
@ -3072,7 +3072,7 @@ static CvEvalBtClassifier icvEvalBtClassifier[] =
|
||||
cvEvalBtClassifier
|
||||
};
|
||||
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
int cvSaveBtClassifier( CvClassifier* classifier, const char* filename )
|
||||
{
|
||||
CV_FUNCNAME( "cvSaveBtClassifier" );
|
||||
@ -3137,7 +3137,7 @@ int cvSaveBtClassifier( CvClassifier* classifier, const char* filename )
|
||||
}
|
||||
|
||||
|
||||
CV_BOOST_IMPL
|
||||
static
|
||||
void cvReleaseBtClassifier( CvClassifier** ptr )
|
||||
{
|
||||
CV_FUNCNAME( "cvReleaseBtClassifier" );
|
||||
@ -3183,7 +3183,7 @@ void cvReleaseBtClassifier( CvClassifier** ptr )
|
||||
__END__;
|
||||
}
|
||||
|
||||
void cvTuneBtClassifier( CvClassifier* classifier, CvMat*, int flags,
|
||||
static void cvTuneBtClassifier( CvClassifier* classifier, CvMat*, int flags,
|
||||
CvMat*, CvMat* , CvMat*, CvMat*, CvMat* )
|
||||
{
|
||||
CV_FUNCNAME( "cvTuneBtClassifier" );
|
||||
@ -3244,7 +3244,7 @@ void cvTuneBtClassifier( CvClassifier* classifier, CvMat*, int flags,
|
||||
__END__;
|
||||
}
|
||||
|
||||
CvBtClassifier* icvAllocBtClassifier( CvBoostType type, int flags, int numclasses,
|
||||
static CvBtClassifier* icvAllocBtClassifier( CvBoostType type, int flags, int numclasses,
|
||||
int numiter )
|
||||
{
|
||||
CvBtClassifier* ptr;
|
||||
@ -3720,7 +3720,7 @@ void cvWriteTrainData( const char* filename, int flags,
|
||||
|
||||
|
||||
#define ICV_RAND_SHUFFLE( suffix, type ) \
|
||||
void icvRandShuffle_##suffix( uchar* data, size_t step, int num ) \
|
||||
static void icvRandShuffle_##suffix( uchar* data, size_t step, int num ) \
|
||||
{ \
|
||||
time_t seed; \
|
||||
type tmp; \
|
||||
|
@ -394,7 +394,7 @@ void icvSaveStageHaarClassifier( CvIntHaarClassifier* classifier, FILE* file )
|
||||
|
||||
|
||||
|
||||
CvIntHaarClassifier* icvLoadCARTStageHaarClassifierF( FILE* file, int step )
|
||||
static CvIntHaarClassifier* icvLoadCARTStageHaarClassifierF( FILE* file, int step )
|
||||
{
|
||||
CvStageHaarClassifier* ptr = NULL;
|
||||
|
||||
|
@ -1257,11 +1257,11 @@ CvBackgroundData* icvCreateBackgroundData( const char* filename, CvSize winsize
|
||||
while( !feof( input ) )
|
||||
{
|
||||
*imgfilename = '\0';
|
||||
if( !fgets( imgfilename, PATH_MAX - (int)(imgfilename - full) - 1, input ))
|
||||
if( !fgets( imgfilename, PATH_MAX - (int)(imgfilename - full) - 1, input ))
|
||||
break;
|
||||
len = (int)strlen( imgfilename );
|
||||
if( len > 0 && imgfilename[len-1] == '\n' )
|
||||
imgfilename[len-1] = 0, len--;
|
||||
if( len > 0 && imgfilename[len-1] == '\n' )
|
||||
imgfilename[len-1] = 0, len--;
|
||||
if( len > 0 )
|
||||
{
|
||||
if( (*imgfilename) == '#' ) continue; /* comment */
|
||||
@ -1878,7 +1878,7 @@ int icvGetHaarTraininDataFromVecCallback( CvMat* img, void* userdata )
|
||||
return 1;
|
||||
}
|
||||
|
||||
int icvGetHaarTrainingDataFromBGCallback ( CvMat* img, void* /*userdata*/ )
|
||||
static int icvGetHaarTrainingDataFromBGCallback ( CvMat* img, void* /*userdata*/ )
|
||||
{
|
||||
if (! cvbgdata)
|
||||
return 0;
|
||||
@ -2215,7 +2215,7 @@ void cvCreateCascadeClassifier( const char* dirname,
|
||||
|
||||
/* tree cascade classifier */
|
||||
|
||||
int icvNumSplits( CvStageHaarClassifier* stage )
|
||||
static int icvNumSplits( CvStageHaarClassifier* stage )
|
||||
{
|
||||
int i;
|
||||
int num;
|
||||
@ -2229,7 +2229,7 @@ int icvNumSplits( CvStageHaarClassifier* stage )
|
||||
return num;
|
||||
}
|
||||
|
||||
void icvSetNumSamples( CvHaarTrainingData* training_data, int num )
|
||||
static void icvSetNumSamples( CvHaarTrainingData* training_data, int num )
|
||||
{
|
||||
assert( num <= training_data->maxnum );
|
||||
|
||||
@ -2238,7 +2238,7 @@ void icvSetNumSamples( CvHaarTrainingData* training_data, int num )
|
||||
training_data->cls.cols = training_data->weights.cols = num;
|
||||
}
|
||||
|
||||
void icvSetWeightsAndClasses( CvHaarTrainingData* training_data,
|
||||
static void icvSetWeightsAndClasses( CvHaarTrainingData* training_data,
|
||||
int num1, float weight1, float cls1,
|
||||
int num2, float weight2, float cls2 )
|
||||
{
|
||||
@ -2258,7 +2258,7 @@ void icvSetWeightsAndClasses( CvHaarTrainingData* training_data,
|
||||
}
|
||||
}
|
||||
|
||||
CvMat* icvGetUsedValues( CvHaarTrainingData* training_data,
|
||||
static CvMat* icvGetUsedValues( CvHaarTrainingData* training_data,
|
||||
int start, int num,
|
||||
CvIntHaarFeatures* haar_features,
|
||||
CvStageHaarClassifier* stage )
|
||||
|
@ -83,7 +83,7 @@
|
||||
* cij - coeffs[i][j], coeffs[2][2] = 1
|
||||
* (ui, vi) - rectangle vertices
|
||||
*/
|
||||
void cvGetPerspectiveTransform( CvSize src_size, double quad[4][2],
|
||||
static void cvGetPerspectiveTransform( CvSize src_size, double quad[4][2],
|
||||
double coeffs[3][3] )
|
||||
{
|
||||
//CV_FUNCNAME( "cvWarpPerspective" );
|
||||
@ -130,7 +130,7 @@ void cvGetPerspectiveTransform( CvSize src_size, double quad[4][2],
|
||||
}
|
||||
|
||||
/* Warps source into destination by a perspective transform */
|
||||
void cvWarpPerspective( CvArr* src, CvArr* dst, double quad[4][2] )
|
||||
static void cvWarpPerspective( CvArr* src, CvArr* dst, double quad[4][2] )
|
||||
{
|
||||
CV_FUNCNAME( "cvWarpPerspective" );
|
||||
|
||||
|
@ -44,6 +44,9 @@
|
||||
*
|
||||
* Measure performance of classifier
|
||||
*/
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/internal.hpp"
|
||||
|
||||
#include "cv.h"
|
||||
#include "highgui.h"
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/internal.hpp"
|
||||
|
||||
#include "HOGfeatures.h"
|
||||
#include "cascadeclassifier.h"
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/internal.hpp"
|
||||
|
||||
#include "boost.h"
|
||||
#include "cascadeclassifier.h"
|
||||
#include <queue>
|
||||
@ -481,7 +484,7 @@ CvCascadeBoostTrainData::CvCascadeBoostTrainData( const CvFeatureEvaluator* _fea
|
||||
void CvCascadeBoostTrainData::setData( const CvFeatureEvaluator* _featureEvaluator,
|
||||
int _numSamples,
|
||||
int _precalcValBufSize, int _precalcIdxBufSize,
|
||||
const CvDTreeParams& _params )
|
||||
const CvDTreeParams& _params )
|
||||
{
|
||||
int* idst = 0;
|
||||
unsigned short* udst = 0;
|
||||
@ -504,10 +507,10 @@ void CvCascadeBoostTrainData::setData( const CvFeatureEvaluator* _featureEvaluat
|
||||
responses = &_resp;
|
||||
// TODO: check responses: elements must be 0 or 1
|
||||
|
||||
if( _precalcValBufSize < 0 || _precalcIdxBufSize < 0)
|
||||
if( _precalcValBufSize < 0 || _precalcIdxBufSize < 0)
|
||||
CV_Error( CV_StsOutOfRange, "_numPrecalcVal and _numPrecalcIdx must be positive or 0" );
|
||||
|
||||
var_count = var_all = featureEvaluator->getNumFeatures() * featureEvaluator->getFeatureSize();
|
||||
var_count = var_all = featureEvaluator->getNumFeatures() * featureEvaluator->getFeatureSize();
|
||||
sample_count = _numSamples;
|
||||
|
||||
is_buf_16u = false;
|
||||
@ -556,7 +559,7 @@ void CvCascadeBoostTrainData::setData( const CvFeatureEvaluator* _featureEvaluat
|
||||
cat_count = cvCreateMat( 1, cat_var_count + 1, CV_32SC1 );
|
||||
|
||||
// precalculate valCache and set indices in buf
|
||||
precalculate();
|
||||
precalculate();
|
||||
|
||||
// now calculate the maximum size of split,
|
||||
// create memory storage that will keep nodes and splits of the decision tree
|
||||
@ -739,8 +742,8 @@ const int* CvCascadeBoostTrainData::get_cat_var_data( CvDTreeNode* n, int vi, in
|
||||
float CvCascadeBoostTrainData::getVarValue( int vi, int si )
|
||||
{
|
||||
if ( vi < numPrecalcVal && !valCache.empty() )
|
||||
return valCache.at<float>( vi, si );
|
||||
return (*featureEvaluator)( vi, si );
|
||||
return valCache.at<float>( vi, si );
|
||||
return (*featureEvaluator)( vi, si );
|
||||
}
|
||||
|
||||
|
||||
@ -1232,7 +1235,7 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
|
||||
data->free_node_data(node);
|
||||
}
|
||||
|
||||
void auxMarkFeaturesInMap( const CvDTreeNode* node, Mat& featureMap)
|
||||
static void auxMarkFeaturesInMap( const CvDTreeNode* node, Mat& featureMap)
|
||||
{
|
||||
if ( node && node->split )
|
||||
{
|
||||
|
@ -1,3 +1,6 @@
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/internal.hpp"
|
||||
|
||||
#include "cascadeclassifier.h"
|
||||
#include <queue>
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/internal.hpp"
|
||||
|
||||
#include "traincascade_features.h"
|
||||
#include "cascadeclassifier.h"
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/internal.hpp"
|
||||
|
||||
#include "haarfeatures.h"
|
||||
#include "cascadeclassifier.h"
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/internal.hpp"
|
||||
|
||||
#include "cv.h"
|
||||
#include "imagestorage.h"
|
||||
#include <stdio.h>
|
||||
|
@ -1,3 +1,6 @@
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/internal.hpp"
|
||||
|
||||
#include "lbpfeatures.h"
|
||||
#include "cascadeclassifier.h"
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/internal.hpp"
|
||||
|
||||
#include "cv.h"
|
||||
#include "cascadeclassifier.h"
|
||||
|
||||
|
@ -47,6 +47,9 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
# High level of warnings.
|
||||
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -Wall")
|
||||
|
||||
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Werror=format-security")
|
||||
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -Wmissing-declarations -Wcast-align -Wundef -Winit-self -Wpointer-arith") #-Wstrict-aliasing=2
|
||||
|
||||
# The -Wno-long-long is required in 64bit systems when including sytem headers.
|
||||
if(X86_64)
|
||||
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -Wno-long-long")
|
||||
@ -217,6 +220,10 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCV_EXTRA_EXE_LINKER_
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}")
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-prototypes -Wstrict-prototypes")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# avoid warnings from MSVC about overriding the /W* option
|
||||
# we replace /W3 with /W4 only for C++ files,
|
||||
|
@ -72,6 +72,7 @@ MACRO(_PCH_WRITE_PCHDEP_CXX _targetName _include_file _dephelp)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT "${${_dephelp}}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "#include \\\"${_include_file}\\\"" > "${${_dephelp}}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "int testfunction();" >> "${${_dephelp}}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "int testfunction()" >> "${${_dephelp}}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "{" >> "${${_dephelp}}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo " return 0;" >> "${${_dephelp}}"
|
||||
@ -82,6 +83,7 @@ MACRO(_PCH_WRITE_PCHDEP_CXX _targetName _include_file _dephelp)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT "${${_dephelp}}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "\\#include \\\"${_include_file}\\\"" > "${${_dephelp}}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "int testfunction\\(\\)\\;" >> "${${_dephelp}}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "int testfunction\\(\\)" >> "${${_dephelp}}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "{" >> "${${_dephelp}}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo " \\return 0\\;" >> "${${_dephelp}}"
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
|
||||
#if GTEST_CREATE_SHARED_LIBRARY
|
||||
#ifdef GTEST_CREATE_SHARED_LIBRARY
|
||||
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
|
||||
#endif
|
||||
|
||||
|
@ -55,7 +55,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
void icvGetQuadrangleHypotheses(CvSeq* contours, std::vector<std::pair<float, int> >& quads, int class_id)
|
||||
static void icvGetQuadrangleHypotheses(CvSeq* contours, std::vector<std::pair<float, int> >& quads, int class_id)
|
||||
{
|
||||
const float min_aspect_ratio = 0.3f;
|
||||
const float max_aspect_ratio = 3.0f;
|
||||
@ -80,7 +80,7 @@ void icvGetQuadrangleHypotheses(CvSeq* contours, std::vector<std::pair<float, in
|
||||
}
|
||||
}
|
||||
|
||||
void countClasses(const std::vector<std::pair<float, int> >& pairs, size_t idx1, size_t idx2, std::vector<int>& counts)
|
||||
static void countClasses(const std::vector<std::pair<float, int> >& pairs, size_t idx1, size_t idx2, std::vector<int>& counts)
|
||||
{
|
||||
counts.assign(2, 0);
|
||||
for(size_t i = idx1; i != idx2; i++)
|
||||
@ -89,7 +89,7 @@ void countClasses(const std::vector<std::pair<float, int> >& pairs, size_t idx1,
|
||||
}
|
||||
}
|
||||
|
||||
bool less_pred(const std::pair<float, int>& p1, const std::pair<float, int>& p2)
|
||||
inline bool less_pred(const std::pair<float, int>& p1, const std::pair<float, int>& p2)
|
||||
{
|
||||
return p1.first < p2.first;
|
||||
}
|
||||
|
@ -1223,7 +1223,7 @@ void computePredecessorMatrix(const Mat &dm, int verticesCount, Mat &predecessor
|
||||
}
|
||||
}
|
||||
|
||||
void computeShortestPath(Mat &predecessorMatrix, size_t v1, size_t v2, vector<size_t> &path)
|
||||
static void computeShortestPath(Mat &predecessorMatrix, size_t v1, size_t v2, vector<size_t> &path)
|
||||
{
|
||||
if (predecessorMatrix.at<int> ((int)v1, (int)v2) < 0)
|
||||
{
|
||||
@ -1403,7 +1403,7 @@ void CirclesGridFinder::getHoles(vector<Point2f> &outHoles) const
|
||||
}
|
||||
}
|
||||
|
||||
bool areIndicesCorrect(Point pos, vector<vector<size_t> > *points)
|
||||
static bool areIndicesCorrect(Point pos, vector<vector<size_t> > *points)
|
||||
{
|
||||
if (pos.y < 0 || pos.x < 0)
|
||||
return false;
|
||||
|
@ -42,7 +42,7 @@
|
||||
#ifndef __OPENCV_PRECOMP_H__
|
||||
#define __OPENCV_PRECOMP_H__
|
||||
|
||||
#if _MSC_VER >= 1200
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning( disable: 4251 4710 4711 4514 4996 )
|
||||
#endif
|
||||
|
||||
|
@ -54,39 +54,39 @@
|
||||
namespace cv {
|
||||
|
||||
|
||||
void drawCircles(Mat& img, const vector<Point2f>& corners, const vector<float>& radius)
|
||||
{
|
||||
for(size_t i = 0; i < corners.size(); i++)
|
||||
{
|
||||
circle(img, corners[i], cvRound(radius[i]), CV_RGB(255, 0, 0));
|
||||
}
|
||||
}
|
||||
// static void drawCircles(Mat& img, const vector<Point2f>& corners, const vector<float>& radius)
|
||||
// {
|
||||
// for(size_t i = 0; i < corners.size(); i++)
|
||||
// {
|
||||
// circle(img, corners[i], cvRound(radius[i]), CV_RGB(255, 0, 0));
|
||||
// }
|
||||
// }
|
||||
|
||||
int histQuantile(const Mat& hist, float quantile)
|
||||
{
|
||||
if(hist.dims > 1) return -1; // works for 1D histograms only
|
||||
// static int histQuantile(const Mat& hist, float quantile)
|
||||
// {
|
||||
// if(hist.dims > 1) return -1; // works for 1D histograms only
|
||||
|
||||
float cur_sum = 0;
|
||||
float total_sum = (float)sum(hist).val[0];
|
||||
float quantile_sum = total_sum*quantile;
|
||||
for(int j = 0; j < hist.size[0]; j++)
|
||||
{
|
||||
cur_sum += (float)hist.at<float>(j);
|
||||
if(cur_sum > quantile_sum)
|
||||
{
|
||||
return j;
|
||||
}
|
||||
}
|
||||
// float cur_sum = 0;
|
||||
// float total_sum = (float)sum(hist).val[0];
|
||||
// float quantile_sum = total_sum*quantile;
|
||||
// for(int j = 0; j < hist.size[0]; j++)
|
||||
// {
|
||||
// cur_sum += (float)hist.at<float>(j);
|
||||
// if(cur_sum > quantile_sum)
|
||||
// {
|
||||
// return j;
|
||||
// }
|
||||
// }
|
||||
|
||||
return hist.size[0] - 1;
|
||||
}
|
||||
// return hist.size[0] - 1;
|
||||
// }
|
||||
|
||||
bool is_smaller(const std::pair<int, float>& p1, const std::pair<int, float>& p2)
|
||||
inline bool is_smaller(const std::pair<int, float>& p1, const std::pair<int, float>& p2)
|
||||
{
|
||||
return p1.second < p2.second;
|
||||
}
|
||||
|
||||
void orderContours(const vector<vector<Point> >& contours, Point2f point, vector<std::pair<int, float> >& order)
|
||||
static void orderContours(const vector<vector<Point> >& contours, Point2f point, vector<std::pair<int, float> >& order)
|
||||
{
|
||||
order.clear();
|
||||
size_t i, j, n = contours.size();
|
||||
@ -106,16 +106,16 @@ void orderContours(const vector<vector<Point> >& contours, Point2f point, vector
|
||||
}
|
||||
|
||||
// fit second order curve to a set of 2D points
|
||||
void fitCurve2Order(const vector<Point2f>& /*points*/, vector<float>& /*curve*/)
|
||||
inline void fitCurve2Order(const vector<Point2f>& /*points*/, vector<float>& /*curve*/)
|
||||
{
|
||||
// TBD
|
||||
}
|
||||
|
||||
void findCurvesCross(const vector<float>& /*curve1*/, const vector<float>& /*curve2*/, Point2f& /*cross_point*/)
|
||||
inline void findCurvesCross(const vector<float>& /*curve1*/, const vector<float>& /*curve2*/, Point2f& /*cross_point*/)
|
||||
{
|
||||
}
|
||||
|
||||
void findLinesCrossPoint(Point2f origin1, Point2f dir1, Point2f origin2, Point2f dir2, Point2f& cross_point)
|
||||
static void findLinesCrossPoint(Point2f origin1, Point2f dir1, Point2f origin2, Point2f dir2, Point2f& cross_point)
|
||||
{
|
||||
float det = dir2.x*dir1.y - dir2.y*dir1.x;
|
||||
Point2f offset = origin2 - origin1;
|
||||
@ -124,30 +124,30 @@ void findLinesCrossPoint(Point2f origin1, Point2f dir1, Point2f origin2, Point2f
|
||||
cross_point = origin1 + dir1*alpha;
|
||||
}
|
||||
|
||||
void findCorner(const vector<Point>& contour, Point2f point, Point2f& corner)
|
||||
{
|
||||
// find the nearest point
|
||||
double min_dist = std::numeric_limits<double>::max();
|
||||
int min_idx = -1;
|
||||
// static void findCorner(const vector<Point>& contour, Point2f point, Point2f& corner)
|
||||
// {
|
||||
// // find the nearest point
|
||||
// double min_dist = std::numeric_limits<double>::max();
|
||||
// int min_idx = -1;
|
||||
|
||||
// find corner idx
|
||||
for(size_t i = 0; i < contour.size(); i++)
|
||||
{
|
||||
double dist = norm(Point2f((float)contour[i].x, (float)contour[i].y) - point);
|
||||
if(dist < min_dist)
|
||||
{
|
||||
min_dist = dist;
|
||||
min_idx = (int)i;
|
||||
}
|
||||
}
|
||||
assert(min_idx >= 0);
|
||||
// // find corner idx
|
||||
// for(size_t i = 0; i < contour.size(); i++)
|
||||
// {
|
||||
// double dist = norm(Point2f((float)contour[i].x, (float)contour[i].y) - point);
|
||||
// if(dist < min_dist)
|
||||
// {
|
||||
// min_dist = dist;
|
||||
// min_idx = (int)i;
|
||||
// }
|
||||
// }
|
||||
// assert(min_idx >= 0);
|
||||
|
||||
// temporary solution, have to make something more precise
|
||||
corner = contour[min_idx];
|
||||
return;
|
||||
}
|
||||
// // temporary solution, have to make something more precise
|
||||
// corner = contour[min_idx];
|
||||
// return;
|
||||
// }
|
||||
|
||||
void findCorner(const vector<Point2f>& contour, Point2f point, Point2f& corner)
|
||||
static void findCorner(const vector<Point2f>& contour, Point2f point, Point2f& corner)
|
||||
{
|
||||
// find the nearest point
|
||||
double min_dist = std::numeric_limits<double>::max();
|
||||
@ -170,7 +170,7 @@ void findCorner(const vector<Point2f>& contour, Point2f point, Point2f& corner)
|
||||
return;
|
||||
}
|
||||
|
||||
int segment_hist_max(const Mat& hist, int& low_thresh, int& high_thresh)
|
||||
static int segment_hist_max(const Mat& hist, int& low_thresh, int& high_thresh)
|
||||
{
|
||||
Mat bw;
|
||||
//const double max_bell_width = 20; // we expect two bells with width bounded above
|
||||
|
@ -59,41 +59,41 @@ bool cv::solvePnP( InputArray _opoints, InputArray _ipoints,
|
||||
|
||||
if (flags == CV_EPNP)
|
||||
{
|
||||
cv::Mat undistortedPoints;
|
||||
cv::undistortPoints(ipoints, undistortedPoints, cameraMatrix, distCoeffs);
|
||||
epnp PnP(cameraMatrix, opoints, undistortedPoints);
|
||||
cv::Mat undistortedPoints;
|
||||
cv::undistortPoints(ipoints, undistortedPoints, cameraMatrix, distCoeffs);
|
||||
epnp PnP(cameraMatrix, opoints, undistortedPoints);
|
||||
|
||||
cv::Mat R, rvec = _rvec.getMat(), tvec = _tvec.getMat();
|
||||
PnP.compute_pose(R, tvec);
|
||||
cv::Rodrigues(R, rvec);
|
||||
return true;
|
||||
}
|
||||
else if (flags == CV_P3P)
|
||||
{
|
||||
CV_Assert( npoints == 4);
|
||||
cv::Mat undistortedPoints;
|
||||
cv::undistortPoints(ipoints, undistortedPoints, cameraMatrix, distCoeffs);
|
||||
p3p P3Psolver(cameraMatrix);
|
||||
return true;
|
||||
}
|
||||
else if (flags == CV_P3P)
|
||||
{
|
||||
CV_Assert( npoints == 4);
|
||||
cv::Mat undistortedPoints;
|
||||
cv::undistortPoints(ipoints, undistortedPoints, cameraMatrix, distCoeffs);
|
||||
p3p P3Psolver(cameraMatrix);
|
||||
|
||||
cv::Mat R, rvec = _rvec.getMat(), tvec = _tvec.getMat();
|
||||
bool result = P3Psolver.solve(R, tvec, opoints, undistortedPoints);
|
||||
if (result)
|
||||
cv::Rodrigues(R, rvec);
|
||||
return result;
|
||||
}
|
||||
else if (flags == CV_ITERATIVE)
|
||||
{
|
||||
CvMat c_objectPoints = opoints, c_imagePoints = ipoints;
|
||||
CvMat c_cameraMatrix = cameraMatrix, c_distCoeffs = distCoeffs;
|
||||
CvMat c_rvec = _rvec.getMat(), c_tvec = _tvec.getMat();
|
||||
cvFindExtrinsicCameraParams2(&c_objectPoints, &c_imagePoints, &c_cameraMatrix,
|
||||
c_distCoeffs.rows*c_distCoeffs.cols ? &c_distCoeffs : 0,
|
||||
&c_rvec, &c_tvec, useExtrinsicGuess );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
cv::Rodrigues(R, rvec);
|
||||
return result;
|
||||
}
|
||||
else if (flags == CV_ITERATIVE)
|
||||
{
|
||||
CvMat c_objectPoints = opoints, c_imagePoints = ipoints;
|
||||
CvMat c_cameraMatrix = cameraMatrix, c_distCoeffs = distCoeffs;
|
||||
CvMat c_rvec = _rvec.getMat(), c_tvec = _tvec.getMat();
|
||||
cvFindExtrinsicCameraParams2(&c_objectPoints, &c_imagePoints, &c_cameraMatrix,
|
||||
c_distCoeffs.rows*c_distCoeffs.cols ? &c_distCoeffs : 0,
|
||||
&c_rvec, &c_tvec, useExtrinsicGuess );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
CV_Error(CV_StsBadArg, "The flags argument must be one of CV_ITERATIVE or CV_EPNP");
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
namespace cv
|
||||
@ -102,7 +102,7 @@ namespace cv
|
||||
{
|
||||
const int MIN_POINTS_COUNT = 4;
|
||||
|
||||
void project3dPoints(const Mat& points, const Mat& rvec, const Mat& tvec, Mat& modif_points)
|
||||
static void project3dPoints(const Mat& points, const Mat& rvec, const Mat& tvec, Mat& modif_points)
|
||||
{
|
||||
modif_points.create(1, points.cols, CV_32FC3);
|
||||
Mat R(3, 3, CV_64FC1);
|
||||
@ -119,11 +119,11 @@ namespace cv
|
||||
{
|
||||
public:
|
||||
Mutex() {
|
||||
}
|
||||
}
|
||||
void lock()
|
||||
{
|
||||
#ifdef HAVE_TBB
|
||||
resultsMutex.lock();
|
||||
resultsMutex.lock();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -158,11 +158,11 @@ namespace cv
|
||||
float reprojectionError;
|
||||
int minInliersCount;
|
||||
bool useExtrinsicGuess;
|
||||
int flags;
|
||||
int flags;
|
||||
CameraParameters camera;
|
||||
};
|
||||
|
||||
void pnpTask(const vector<char>& pointsMask, const Mat& objectPoints, const Mat& imagePoints,
|
||||
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)
|
||||
{
|
||||
@ -195,8 +195,8 @@ namespace cv
|
||||
rvecInit.copyTo(localRvec);
|
||||
tvecInit.copyTo(localTvec);
|
||||
|
||||
solvePnP(modelObjectPoints, modelImagePoints, params.camera.intrinsics, params.camera.distortion, localRvec, localTvec,
|
||||
params.useExtrinsicGuess, params.flags);
|
||||
solvePnP(modelObjectPoints, modelImagePoints, params.camera.intrinsics, params.camera.distortion, localRvec, localTvec,
|
||||
params.useExtrinsicGuess, params.flags);
|
||||
|
||||
|
||||
vector<Point2f> projected_points;
|
||||
@ -262,7 +262,7 @@ namespace cv
|
||||
tvec.copyTo(initTvec);
|
||||
}
|
||||
private:
|
||||
PnPSolver& operator=(const PnPSolver&);
|
||||
PnPSolver& operator=(const PnPSolver&);
|
||||
|
||||
const Mat& objectPoints;
|
||||
const Mat& imagePoints;
|
||||
@ -325,7 +325,7 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints,
|
||||
params.reprojectionError = reprojectionError;
|
||||
params.useExtrinsicGuess = useExtrinsicGuess;
|
||||
params.camera.init(cameraMatrix, distCoeffs);
|
||||
params.flags = flags;
|
||||
params.flags = flags;
|
||||
|
||||
vector<int> localInliers;
|
||||
Mat localRvec, localTvec;
|
||||
@ -340,21 +340,21 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints,
|
||||
|
||||
if (localInliers.size() >= (size_t)pnpransac::MIN_POINTS_COUNT)
|
||||
{
|
||||
if (flags != CV_P3P)
|
||||
{
|
||||
int i, pointsCount = (int)localInliers.size();
|
||||
Mat inlierObjectPoints(1, pointsCount, CV_32FC3), inlierImagePoints(1, pointsCount, CV_32FC2);
|
||||
for (i = 0; i < pointsCount; i++)
|
||||
{
|
||||
int index = localInliers[i];
|
||||
Mat colInlierImagePoints = inlierImagePoints(Rect(i, 0, 1, 1));
|
||||
imagePoints.col(index).copyTo(colInlierImagePoints);
|
||||
Mat colInlierObjectPoints = inlierObjectPoints(Rect(i, 0, 1, 1));
|
||||
objectPoints.col(index).copyTo(colInlierObjectPoints);
|
||||
}
|
||||
solvePnP(inlierObjectPoints, inlierImagePoints, params.camera.intrinsics, params.camera.distortion, localRvec, localTvec, true, flags);
|
||||
}
|
||||
localRvec.copyTo(rvec);
|
||||
if (flags != CV_P3P)
|
||||
{
|
||||
int i, pointsCount = (int)localInliers.size();
|
||||
Mat inlierObjectPoints(1, pointsCount, CV_32FC3), inlierImagePoints(1, pointsCount, CV_32FC2);
|
||||
for (i = 0; i < pointsCount; i++)
|
||||
{
|
||||
int index = localInliers[i];
|
||||
Mat colInlierImagePoints = inlierImagePoints(Rect(i, 0, 1, 1));
|
||||
imagePoints.col(index).copyTo(colInlierImagePoints);
|
||||
Mat colInlierObjectPoints = inlierObjectPoints(Rect(i, 0, 1, 1));
|
||||
objectPoints.col(index).copyTo(colInlierObjectPoints);
|
||||
}
|
||||
solvePnP(inlierObjectPoints, inlierImagePoints, params.camera.intrinsics, params.camera.distortion, localRvec, localTvec, true, flags);
|
||||
}
|
||||
localRvec.copyTo(rvec);
|
||||
localTvec.copyTo(tvec);
|
||||
if (_inliers.needed())
|
||||
Mat(localInliers).copyTo(_inliers);
|
||||
|
@ -58,26 +58,26 @@ LevMarqSparse::~LevMarqSparse() {
|
||||
}
|
||||
|
||||
LevMarqSparse::LevMarqSparse(int npoints, // number of points
|
||||
int ncameras, // number of cameras
|
||||
int nPointParams, // number of params per one point (3 in case of 3D points)
|
||||
int nCameraParams, // number of parameters per one camera
|
||||
int nErrParams, // number of parameters in measurement vector
|
||||
// for 1 point at one camera (2 in case of 2D projections)
|
||||
Mat& visibility, // visibility matrix. rows correspond to points, columns correspond to cameras
|
||||
// 1 - point is visible for the camera, 0 - invisible
|
||||
Mat& P0, // starting vector of parameters, first cameras then points
|
||||
Mat& X_, // measurements, in order of visibility. non visible cases are skipped
|
||||
TermCriteria criteria, // termination criteria
|
||||
int ncameras, // number of cameras
|
||||
int nPointParams, // number of params per one point (3 in case of 3D points)
|
||||
int nCameraParams, // number of parameters per one camera
|
||||
int nErrParams, // number of parameters in measurement vector
|
||||
// for 1 point at one camera (2 in case of 2D projections)
|
||||
Mat& visibility, // visibility matrix. rows correspond to points, columns correspond to cameras
|
||||
// 1 - point is visible for the camera, 0 - invisible
|
||||
Mat& P0, // starting vector of parameters, first cameras then points
|
||||
Mat& X_, // measurements, in order of visibility. non visible cases are skipped
|
||||
TermCriteria criteria, // termination criteria
|
||||
|
||||
// callback for estimation of Jacobian matrices
|
||||
void (CV_CDECL * fjac)(int i, int j, Mat& point_params,
|
||||
Mat& cam_params, Mat& A, Mat& B, void* data),
|
||||
// callback for estimation of backprojection errors
|
||||
void (CV_CDECL * func)(int i, int j, Mat& point_params,
|
||||
Mat& cam_params, Mat& estim, void* data),
|
||||
void* data, // user-specific data passed to the callbacks
|
||||
BundleAdjustCallback _cb, void* _user_data
|
||||
) {
|
||||
// callback for estimation of Jacobian matrices
|
||||
void (CV_CDECL * fjac)(int i, int j, Mat& point_params,
|
||||
Mat& cam_params, Mat& A, Mat& B, void* data),
|
||||
// callback for estimation of backprojection errors
|
||||
void (CV_CDECL * func)(int i, int j, Mat& point_params,
|
||||
Mat& cam_params, Mat& estim, void* data),
|
||||
void* data, // user-specific data passed to the callbacks
|
||||
BundleAdjustCallback _cb, void* _user_data
|
||||
) {
|
||||
Vis_index = X = prevP = P = deltaP = err = JtJ_diag = S = hX = NULL;
|
||||
U = ea = V = inv_V_star = eb = Yj = NULL;
|
||||
A = B = W = NULL;
|
||||
@ -95,17 +95,17 @@ void LevMarqSparse::clear() {
|
||||
//CvMat* tmp = ((CvMat**)(A->data.ptr + i * A->step))[j];
|
||||
CvMat* tmp = A[j+i*num_cams];
|
||||
if (tmp)
|
||||
cvReleaseMat( &tmp );
|
||||
cvReleaseMat( &tmp );
|
||||
|
||||
//tmp = ((CvMat**)(B->data.ptr + i * B->step))[j];
|
||||
tmp = B[j+i*num_cams];
|
||||
if (tmp)
|
||||
cvReleaseMat( &tmp );
|
||||
cvReleaseMat( &tmp );
|
||||
|
||||
//tmp = ((CvMat**)(W->data.ptr + j * W->step))[i];
|
||||
tmp = W[j+i*num_cams];
|
||||
if (tmp)
|
||||
cvReleaseMat( &tmp );
|
||||
cvReleaseMat( &tmp );
|
||||
}
|
||||
}
|
||||
delete A; //cvReleaseMat(&A);
|
||||
@ -165,19 +165,19 @@ void LevMarqSparse::clear() {
|
||||
//num_errors - number of measurements.
|
||||
|
||||
void LevMarqSparse::run( int num_points_, //number of points
|
||||
int num_cams_, //number of cameras
|
||||
int num_point_param_, //number of params per one point (3 in case of 3D points)
|
||||
int num_cam_param_, //number of parameters per one camera
|
||||
int num_err_param_, //number of parameters in measurement vector for 1 point at one camera (2 in case of 2D projections)
|
||||
Mat& visibility, //visibility matrix . rows correspond to points, columns correspond to cameras
|
||||
// 0 - point is visible for the camera, 0 - invisible
|
||||
Mat& P0, //starting vector of parameters, first cameras then points
|
||||
Mat& X_init, //measurements, in order of visibility. non visible cases are skipped
|
||||
TermCriteria criteria_init,
|
||||
void (*fjac_)(int i, int j, Mat& point_params, Mat& cam_params, Mat& A, Mat& B, void* data),
|
||||
void (*func_)(int i, int j, Mat& point_params, Mat& cam_params, Mat& estim, void* data),
|
||||
void* data_
|
||||
) { //termination criteria
|
||||
int num_cams_, //number of cameras
|
||||
int num_point_param_, //number of params per one point (3 in case of 3D points)
|
||||
int num_cam_param_, //number of parameters per one camera
|
||||
int num_err_param_, //number of parameters in measurement vector for 1 point at one camera (2 in case of 2D projections)
|
||||
Mat& visibility, //visibility matrix . rows correspond to points, columns correspond to cameras
|
||||
// 0 - point is visible for the camera, 0 - invisible
|
||||
Mat& P0, //starting vector of parameters, first cameras then points
|
||||
Mat& X_init, //measurements, in order of visibility. non visible cases are skipped
|
||||
TermCriteria criteria_init,
|
||||
void (*fjac_)(int i, int j, Mat& point_params, Mat& cam_params, Mat& A, Mat& B, void* data),
|
||||
void (*func_)(int i, int j, Mat& point_params, Mat& cam_params, Mat& estim, void* data),
|
||||
void* data_
|
||||
) { //termination criteria
|
||||
//clear();
|
||||
|
||||
func = func_; //assign evaluation function
|
||||
@ -228,28 +228,28 @@ void LevMarqSparse::run( int num_points_, //number of points
|
||||
for (int i = 0; i < num_points; i++ ) {
|
||||
for (int j = 0; j < num_cams; j++ ) {
|
||||
if (((int*)(_vis.data.ptr+ i * _vis.step))[j] ) {
|
||||
((int*)(Vis_index->data.ptr + i * Vis_index->step))[j] = index;
|
||||
index += num_err_param;
|
||||
((int*)(Vis_index->data.ptr + i * Vis_index->step))[j] = index;
|
||||
index += num_err_param;
|
||||
|
||||
//create matrices Aij, Bij
|
||||
CvMat* tmp = cvCreateMat(Aij_height, Aij_width, CV_64F );
|
||||
//((CvMat**)(A->data.ptr + i * A->step))[j] = tmp;
|
||||
cvSet(tmp,cvScalar(1.0,1.0,1.0,1.0));
|
||||
A[j+i*num_cams] = tmp;
|
||||
//create matrices Aij, Bij
|
||||
CvMat* tmp = cvCreateMat(Aij_height, Aij_width, CV_64F );
|
||||
//((CvMat**)(A->data.ptr + i * A->step))[j] = tmp;
|
||||
cvSet(tmp,cvScalar(1.0,1.0,1.0,1.0));
|
||||
A[j+i*num_cams] = tmp;
|
||||
|
||||
tmp = cvCreateMat( Bij_height, Bij_width, CV_64F );
|
||||
//((CvMat**)(B->data.ptr + i * B->step))[j] = tmp;
|
||||
cvSet(tmp,cvScalar(1.0,1.0,1.0,1.0));
|
||||
B[j+i*num_cams] = tmp;
|
||||
tmp = cvCreateMat( Bij_height, Bij_width, CV_64F );
|
||||
//((CvMat**)(B->data.ptr + i * B->step))[j] = tmp;
|
||||
cvSet(tmp,cvScalar(1.0,1.0,1.0,1.0));
|
||||
B[j+i*num_cams] = tmp;
|
||||
|
||||
tmp = cvCreateMat( Wij_height, Wij_width, CV_64F );
|
||||
//((CvMat**)(W->data.ptr + j * W->step))[i] = tmp; //note indices i and j swapped
|
||||
cvSet(tmp,cvScalar(1.0,1.0,1.0,1.0));
|
||||
W[j+i*num_cams] = tmp;
|
||||
tmp = cvCreateMat( Wij_height, Wij_width, CV_64F );
|
||||
//((CvMat**)(W->data.ptr + j * W->step))[i] = tmp; //note indices i and j swapped
|
||||
cvSet(tmp,cvScalar(1.0,1.0,1.0,1.0));
|
||||
W[j+i*num_cams] = tmp;
|
||||
} else{
|
||||
A[j+i*num_cams] = NULL;
|
||||
B[j+i*num_cams] = NULL;
|
||||
W[j+i*num_cams] = NULL;
|
||||
A[j+i*num_cams] = NULL;
|
||||
B[j+i*num_cams] = NULL;
|
||||
W[j+i*num_cams] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -423,22 +423,22 @@ void LevMarqSparse::optimize(CvMat &_vis) { //main function that runs minimizati
|
||||
cvSetZero(ea[j]);
|
||||
//summ by i (number of points)
|
||||
for (int i = 0; i < num_points; i++ ) {
|
||||
//get Aij
|
||||
//CvMat* Aij = ((CvMat**)(A->data.ptr + A->step * i))[j];
|
||||
CvMat* Aij = A[j+i*num_cams];
|
||||
if (Aij ) {
|
||||
//Uj+= AijT*Aij
|
||||
cvGEMM( Aij, Aij, 1, U[j], 1, U[j], CV_GEMM_A_T );
|
||||
//ea_j += AijT * e_ij
|
||||
CvMat eij;
|
||||
//get Aij
|
||||
//CvMat* Aij = ((CvMat**)(A->data.ptr + A->step * i))[j];
|
||||
CvMat* Aij = A[j+i*num_cams];
|
||||
if (Aij ) {
|
||||
//Uj+= AijT*Aij
|
||||
cvGEMM( Aij, Aij, 1, U[j], 1, U[j], CV_GEMM_A_T );
|
||||
//ea_j += AijT * e_ij
|
||||
CvMat eij;
|
||||
|
||||
int index = ((int*)(Vis_index->data.ptr + i * Vis_index->step))[j];
|
||||
int index = ((int*)(Vis_index->data.ptr + i * Vis_index->step))[j];
|
||||
|
||||
cvGetSubRect( err, &eij, cvRect( 0, index, 1, Aij->height ) ); //width of transposed Aij
|
||||
cvGEMM( Aij, &eij, 1, ea[j], 1, ea[j], CV_GEMM_A_T );
|
||||
}
|
||||
else
|
||||
invisible_count++;
|
||||
cvGetSubRect( err, &eij, cvRect( 0, index, 1, Aij->height ) ); //width of transposed Aij
|
||||
cvGEMM( Aij, &eij, 1, ea[j], 1, ea[j], CV_GEMM_A_T );
|
||||
}
|
||||
else
|
||||
invisible_count++;
|
||||
}
|
||||
} //U_j and ea_j computed for all j
|
||||
|
||||
@ -455,37 +455,37 @@ void LevMarqSparse::optimize(CvMat &_vis) { //main function that runs minimizati
|
||||
|
||||
//summ by i (number of points)
|
||||
for( int j = 0; j < num_cams; j++ ) {
|
||||
//get Bij
|
||||
//CvMat* Bij = ((CvMat**)(B->data.ptr + B->step * i))[j];
|
||||
CvMat* Bij = B[j+i*num_cams];
|
||||
if (Bij ) {
|
||||
//Vi+= BijT*Bij
|
||||
cvGEMM( Bij, Bij, 1, V[i], 1, V[i], CV_GEMM_A_T );
|
||||
//get Bij
|
||||
//CvMat* Bij = ((CvMat**)(B->data.ptr + B->step * i))[j];
|
||||
CvMat* Bij = B[j+i*num_cams];
|
||||
if (Bij ) {
|
||||
//Vi+= BijT*Bij
|
||||
cvGEMM( Bij, Bij, 1, V[i], 1, V[i], CV_GEMM_A_T );
|
||||
|
||||
//eb_i += BijT * e_ij
|
||||
int index = ((int*)(Vis_index->data.ptr + i * Vis_index->step))[j];
|
||||
//eb_i += BijT * e_ij
|
||||
int index = ((int*)(Vis_index->data.ptr + i * Vis_index->step))[j];
|
||||
|
||||
CvMat eij;
|
||||
cvGetSubRect( err, &eij, cvRect( 0, index, 1, Bij->height ) ); //width of transposed Bij
|
||||
cvGEMM( Bij, &eij, 1, eb[i], 1, eb[i], CV_GEMM_A_T );
|
||||
}
|
||||
CvMat eij;
|
||||
cvGetSubRect( err, &eij, cvRect( 0, index, 1, Bij->height ) ); //width of transposed Bij
|
||||
cvGEMM( Bij, &eij, 1, eb[i], 1, eb[i], CV_GEMM_A_T );
|
||||
}
|
||||
}
|
||||
} //V_i and eb_i computed for all i
|
||||
|
||||
//compute W_ij
|
||||
for( int i = 0; i < num_points; i++ ) {
|
||||
for( int j = 0; j < num_cams; j++ ) {
|
||||
//CvMat* Aij = ((CvMat**)(A->data.ptr + A->step * i))[j];
|
||||
CvMat* Aij = A[j+i*num_cams];
|
||||
if( Aij ) { //visible
|
||||
//CvMat* Bij = ((CvMat**)(B->data.ptr + B->step * i))[j];
|
||||
CvMat* Bij = B[j+i*num_cams];
|
||||
//CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
|
||||
CvMat* Wij = W[j+i*num_cams];
|
||||
//CvMat* Aij = ((CvMat**)(A->data.ptr + A->step * i))[j];
|
||||
CvMat* Aij = A[j+i*num_cams];
|
||||
if( Aij ) { //visible
|
||||
//CvMat* Bij = ((CvMat**)(B->data.ptr + B->step * i))[j];
|
||||
CvMat* Bij = B[j+i*num_cams];
|
||||
//CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
|
||||
CvMat* Wij = W[j+i*num_cams];
|
||||
|
||||
//multiply
|
||||
cvGEMM( Aij, Bij, 1, NULL, 0, Wij, CV_GEMM_A_T );
|
||||
}
|
||||
//multiply
|
||||
cvGEMM( Aij, Bij, 1, NULL, 0, Wij, CV_GEMM_A_T );
|
||||
}
|
||||
}
|
||||
} //Wij computed
|
||||
|
||||
@ -494,16 +494,16 @@ void LevMarqSparse::optimize(CvMat &_vis) { //main function that runs minimizati
|
||||
CvMat dia;
|
||||
CvMat subr;
|
||||
for( int j = 0; j < num_cams; j++ ) {
|
||||
cvGetDiag(U[j], &dia);
|
||||
cvGetSubRect(JtJ_diag, &subr,
|
||||
cvRect(0, j*num_cam_param, 1, num_cam_param ));
|
||||
cvCopy( &dia, &subr );
|
||||
cvGetDiag(U[j], &dia);
|
||||
cvGetSubRect(JtJ_diag, &subr,
|
||||
cvRect(0, j*num_cam_param, 1, num_cam_param ));
|
||||
cvCopy( &dia, &subr );
|
||||
}
|
||||
for( int i = 0; i < num_points; i++ ) {
|
||||
cvGetDiag(V[i], &dia);
|
||||
cvGetSubRect(JtJ_diag, &subr,
|
||||
cvRect(0, num_cams*num_cam_param + i * num_point_param, 1, num_point_param ));
|
||||
cvCopy( &dia, &subr );
|
||||
cvGetDiag(V[i], &dia);
|
||||
cvGetSubRect(JtJ_diag, &subr,
|
||||
cvRect(0, num_cams*num_cam_param + i * num_point_param, 1, num_point_param ));
|
||||
cvCopy( &dia, &subr );
|
||||
}
|
||||
}
|
||||
|
||||
@ -511,10 +511,10 @@ void LevMarqSparse::optimize(CvMat &_vis) { //main function that runs minimizati
|
||||
//initialize lambda. It is set to 1e-3 * average diagonal element in JtJ
|
||||
double average_diag = 0;
|
||||
for( int j = 0; j < num_cams; j++ ) {
|
||||
average_diag += cvTrace( U[j] ).val[0];
|
||||
average_diag += cvTrace( U[j] ).val[0];
|
||||
}
|
||||
for( int i = 0; i < num_points; i++ ) {
|
||||
average_diag += cvTrace( V[i] ).val[0];
|
||||
average_diag += cvTrace( V[i] ).val[0];
|
||||
}
|
||||
average_diag /= (num_cams*num_cam_param + num_points * num_point_param );
|
||||
|
||||
@ -527,187 +527,187 @@ void LevMarqSparse::optimize(CvMat &_vis) { //main function that runs minimizati
|
||||
for(;;) {
|
||||
//augmentation of diagonal
|
||||
for(int j = 0; j < num_cams; j++ ) {
|
||||
CvMat diag;
|
||||
cvGetDiag( U[j], &diag );
|
||||
CvMat diag;
|
||||
cvGetDiag( U[j], &diag );
|
||||
#if 1
|
||||
cvAddS( &diag, cvScalar( lambda ), &diag );
|
||||
cvAddS( &diag, cvScalar( lambda ), &diag );
|
||||
#else
|
||||
cvScale( &diag, &diag, 1 + lambda );
|
||||
cvScale( &diag, &diag, 1 + lambda );
|
||||
#endif
|
||||
}
|
||||
for(int i = 0; i < num_points; i++ ) {
|
||||
CvMat diag;
|
||||
cvGetDiag( V[i], &diag );
|
||||
CvMat diag;
|
||||
cvGetDiag( V[i], &diag );
|
||||
#if 1
|
||||
cvAddS( &diag, cvScalar( lambda ), &diag );
|
||||
cvAddS( &diag, cvScalar( lambda ), &diag );
|
||||
#else
|
||||
cvScale( &diag, &diag, 1 + lambda );
|
||||
cvScale( &diag, &diag, 1 + lambda );
|
||||
#endif
|
||||
}
|
||||
bool error = false;
|
||||
//compute inv(V*)
|
||||
bool inverted_ok = true;
|
||||
for(int i = 0; i < num_points; i++ ) {
|
||||
double det = cvInvert( V[i], inv_V_star[i] );
|
||||
double det = cvInvert( V[i], inv_V_star[i] );
|
||||
|
||||
if( fabs(det) <= FLT_EPSILON ) {
|
||||
inverted_ok = false;
|
||||
std::cerr<<"V["<<i<<"] failed"<<std::endl;
|
||||
break;
|
||||
} //means we did wrong augmentation, try to choose different lambda
|
||||
if( fabs(det) <= FLT_EPSILON ) {
|
||||
inverted_ok = false;
|
||||
std::cerr<<"V["<<i<<"] failed"<<std::endl;
|
||||
break;
|
||||
} //means we did wrong augmentation, try to choose different lambda
|
||||
}
|
||||
|
||||
if( inverted_ok ) {
|
||||
cvSetZero( E );
|
||||
//loop through cameras, compute upper diagonal blocks of matrix S
|
||||
for( int j = 0; j < num_cams; j++ ) {
|
||||
//compute Yij = Wij (V*_i)^-1 for all i (if Wij exists/nonzero)
|
||||
for( int i = 0; i < num_points; i++ ) {
|
||||
//
|
||||
//CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
|
||||
CvMat* Wij = W[j+i*num_cams];
|
||||
if( Wij ) {
|
||||
cvMatMul( Wij, inv_V_star[i], Yj[i] );
|
||||
}
|
||||
}
|
||||
cvSetZero( E );
|
||||
//loop through cameras, compute upper diagonal blocks of matrix S
|
||||
for( int j = 0; j < num_cams; j++ ) {
|
||||
//compute Yij = Wij (V*_i)^-1 for all i (if Wij exists/nonzero)
|
||||
for( int i = 0; i < num_points; i++ ) {
|
||||
//
|
||||
//CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
|
||||
CvMat* Wij = W[j+i*num_cams];
|
||||
if( Wij ) {
|
||||
cvMatMul( Wij, inv_V_star[i], Yj[i] );
|
||||
}
|
||||
}
|
||||
|
||||
//compute Sjk for k>=j (because Sjk = Skj)
|
||||
for( int k = j; k < num_cams; k++ ) {
|
||||
cvSetZero( YWt );
|
||||
for( int i = 0; i < num_points; i++ ) {
|
||||
//check that both Wij and Wik exist
|
||||
// CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
|
||||
CvMat* Wij = W[j+i*num_cams];
|
||||
//CvMat* Wik = ((CvMat**)(W->data.ptr + W->step * k))[i];
|
||||
CvMat* Wik = W[k+i*num_cams];
|
||||
//compute Sjk for k>=j (because Sjk = Skj)
|
||||
for( int k = j; k < num_cams; k++ ) {
|
||||
cvSetZero( YWt );
|
||||
for( int i = 0; i < num_points; i++ ) {
|
||||
//check that both Wij and Wik exist
|
||||
// CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
|
||||
CvMat* Wij = W[j+i*num_cams];
|
||||
//CvMat* Wik = ((CvMat**)(W->data.ptr + W->step * k))[i];
|
||||
CvMat* Wik = W[k+i*num_cams];
|
||||
|
||||
if( Wij && Wik ) {
|
||||
//multiply YWt += Yj[i]*Wik'
|
||||
cvGEMM( Yj[i], Wik, 1, YWt, 1, YWt, CV_GEMM_B_T ); ///*transpose Wik
|
||||
}
|
||||
}
|
||||
if( Wij && Wik ) {
|
||||
//multiply YWt += Yj[i]*Wik'
|
||||
cvGEMM( Yj[i], Wik, 1, YWt, 1, YWt, CV_GEMM_B_T ); ///*transpose Wik
|
||||
}
|
||||
}
|
||||
|
||||
//copy result to matrix S
|
||||
//copy result to matrix S
|
||||
|
||||
CvMat Sjk;
|
||||
//extract submat
|
||||
cvGetSubRect( S, &Sjk, cvRect( k * num_cam_param, j * num_cam_param, num_cam_param, num_cam_param ));
|
||||
CvMat Sjk;
|
||||
//extract submat
|
||||
cvGetSubRect( S, &Sjk, cvRect( k * num_cam_param, j * num_cam_param, num_cam_param, num_cam_param ));
|
||||
|
||||
|
||||
//if j==k, add diagonal
|
||||
if( j != k ) {
|
||||
//just copy with minus
|
||||
cvScale( YWt, &Sjk, -1 ); //if we set initial S to zero then we can use cvSub( Sjk, YWt, Sjk);
|
||||
} else {
|
||||
//add diagonal value
|
||||
|
||||
//subtract YWt from augmented Uj
|
||||
cvSub( U[j], YWt, &Sjk );
|
||||
}
|
||||
}
|
||||
|
||||
//compute right part of equation involving matrix S
|
||||
// e_j=ea_j - \sum_i Y_ij eb_i
|
||||
{
|
||||
CvMat e_j;
|
||||
|
||||
//select submat
|
||||
cvGetSubRect( E, &e_j, cvRect( 0, j * num_cam_param, 1, num_cam_param ) );
|
||||
|
||||
for( int i = 0; i < num_points; i++ ) {
|
||||
//CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
|
||||
CvMat* Wij = W[j+i*num_cams];
|
||||
if( Wij )
|
||||
cvMatMulAdd( Yj[i], eb[i], &e_j, &e_j );
|
||||
}
|
||||
|
||||
cvSub( ea[j], &e_j, &e_j );
|
||||
}
|
||||
|
||||
}
|
||||
//fill below diagonal elements of matrix S
|
||||
cvCompleteSymm( S, 0 ); ///*from upper to low //operation may be done by nonzero blocks or during upper diagonal computation
|
||||
|
||||
//Solve linear system S * deltaP_a = E
|
||||
CvMat dpa;
|
||||
cvGetSubRect( deltaP, &dpa, cvRect(0, 0, 1, S->width ) );
|
||||
int res = cvSolve( S, E, &dpa, CV_CHOLESKY );
|
||||
|
||||
if( res ) { //system solved ok
|
||||
//compute db_i
|
||||
for( int i = 0; i < num_points; i++ ) {
|
||||
CvMat dbi;
|
||||
cvGetSubRect( deltaP, &dbi, cvRect( 0, dpa.height + i * num_point_param, 1, num_point_param ) );
|
||||
|
||||
// compute \sum_j W_ij^T da_j
|
||||
for( int j = 0; j < num_cams; j++ ) {
|
||||
//get Wij
|
||||
//CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
|
||||
CvMat* Wij = W[j+i*num_cams];
|
||||
if( Wij ) {
|
||||
//get da_j
|
||||
CvMat daj;
|
||||
cvGetSubRect( &dpa, &daj, cvRect( 0, j * num_cam_param, 1, num_cam_param ));
|
||||
cvGEMM( Wij, &daj, 1, &dbi, 1, &dbi, CV_GEMM_A_T ); ///* transpose Wij
|
||||
}
|
||||
}
|
||||
//finalize dbi
|
||||
cvSub( eb[i], &dbi, &dbi );
|
||||
cvMatMul(inv_V_star[i], &dbi, &dbi ); //here we get final dbi
|
||||
} //now we computed whole deltaP
|
||||
|
||||
//add deltaP to delta
|
||||
cvAdd( prevP, deltaP, P );
|
||||
|
||||
//evaluate function with new parameters
|
||||
ask_for_proj(_vis); // func( P, hX );
|
||||
|
||||
//compute error
|
||||
errNorm = cvNorm( X, hX, CV_L2 );
|
||||
|
||||
} else {
|
||||
error = true;
|
||||
}
|
||||
//if j==k, add diagonal
|
||||
if( j != k ) {
|
||||
//just copy with minus
|
||||
cvScale( YWt, &Sjk, -1 ); //if we set initial S to zero then we can use cvSub( Sjk, YWt, Sjk);
|
||||
} else {
|
||||
error = true;
|
||||
//add diagonal value
|
||||
|
||||
//subtract YWt from augmented Uj
|
||||
cvSub( U[j], YWt, &Sjk );
|
||||
}
|
||||
}
|
||||
|
||||
//compute right part of equation involving matrix S
|
||||
// e_j=ea_j - \sum_i Y_ij eb_i
|
||||
{
|
||||
CvMat e_j;
|
||||
|
||||
//select submat
|
||||
cvGetSubRect( E, &e_j, cvRect( 0, j * num_cam_param, 1, num_cam_param ) );
|
||||
|
||||
for( int i = 0; i < num_points; i++ ) {
|
||||
//CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
|
||||
CvMat* Wij = W[j+i*num_cams];
|
||||
if( Wij )
|
||||
cvMatMulAdd( Yj[i], eb[i], &e_j, &e_j );
|
||||
}
|
||||
|
||||
cvSub( ea[j], &e_j, &e_j );
|
||||
}
|
||||
|
||||
}
|
||||
//fill below diagonal elements of matrix S
|
||||
cvCompleteSymm( S, 0 ); ///*from upper to low //operation may be done by nonzero blocks or during upper diagonal computation
|
||||
|
||||
//Solve linear system S * deltaP_a = E
|
||||
CvMat dpa;
|
||||
cvGetSubRect( deltaP, &dpa, cvRect(0, 0, 1, S->width ) );
|
||||
int res = cvSolve( S, E, &dpa, CV_CHOLESKY );
|
||||
|
||||
if( res ) { //system solved ok
|
||||
//compute db_i
|
||||
for( int i = 0; i < num_points; i++ ) {
|
||||
CvMat dbi;
|
||||
cvGetSubRect( deltaP, &dbi, cvRect( 0, dpa.height + i * num_point_param, 1, num_point_param ) );
|
||||
|
||||
// compute \sum_j W_ij^T da_j
|
||||
for( int j = 0; j < num_cams; j++ ) {
|
||||
//get Wij
|
||||
//CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
|
||||
CvMat* Wij = W[j+i*num_cams];
|
||||
if( Wij ) {
|
||||
//get da_j
|
||||
CvMat daj;
|
||||
cvGetSubRect( &dpa, &daj, cvRect( 0, j * num_cam_param, 1, num_cam_param ));
|
||||
cvGEMM( Wij, &daj, 1, &dbi, 1, &dbi, CV_GEMM_A_T ); ///* transpose Wij
|
||||
}
|
||||
}
|
||||
//finalize dbi
|
||||
cvSub( eb[i], &dbi, &dbi );
|
||||
cvMatMul(inv_V_star[i], &dbi, &dbi ); //here we get final dbi
|
||||
} //now we computed whole deltaP
|
||||
|
||||
//add deltaP to delta
|
||||
cvAdd( prevP, deltaP, P );
|
||||
|
||||
//evaluate function with new parameters
|
||||
ask_for_proj(_vis); // func( P, hX );
|
||||
|
||||
//compute error
|
||||
errNorm = cvNorm( X, hX, CV_L2 );
|
||||
|
||||
} else {
|
||||
error = true;
|
||||
}
|
||||
} else {
|
||||
error = true;
|
||||
}
|
||||
//check solution
|
||||
if( error || ///* singularities somewhere
|
||||
errNorm > prevErrNorm ) { //step was not accepted
|
||||
//increase lambda and reject change
|
||||
lambda *= 10;
|
||||
int nviz = X->rows / num_err_param;
|
||||
double e2 = errNorm*errNorm, e2_prev = prevErrNorm*prevErrNorm;
|
||||
double e2n = e2/nviz, e2n_prev = e2_prev/nviz;
|
||||
std::cerr<<"move failed: lambda = "<<lambda<<", e2 = "<<e2<<" ("<<e2n<<") > "<<e2_prev<<" ("<<e2n_prev<<")"<<std::endl;
|
||||
errNorm > prevErrNorm ) { //step was not accepted
|
||||
//increase lambda and reject change
|
||||
lambda *= 10;
|
||||
int nviz = X->rows / num_err_param;
|
||||
double e2 = errNorm*errNorm, e2_prev = prevErrNorm*prevErrNorm;
|
||||
double e2n = e2/nviz, e2n_prev = e2_prev/nviz;
|
||||
std::cerr<<"move failed: lambda = "<<lambda<<", e2 = "<<e2<<" ("<<e2n<<") > "<<e2_prev<<" ("<<e2n_prev<<")"<<std::endl;
|
||||
|
||||
//restore diagonal from backup
|
||||
{
|
||||
CvMat dia;
|
||||
CvMat subr;
|
||||
for( int j = 0; j < num_cams; j++ ) {
|
||||
cvGetDiag(U[j], &dia);
|
||||
cvGetSubRect(JtJ_diag, &subr,
|
||||
cvRect(0, j*num_cam_param, 1, num_cam_param ));
|
||||
cvCopy( &subr, &dia );
|
||||
}
|
||||
for( int i = 0; i < num_points; i++ ) {
|
||||
cvGetDiag(V[i], &dia);
|
||||
cvGetSubRect(JtJ_diag, &subr,
|
||||
cvRect(0, num_cams*num_cam_param + i * num_point_param, 1, num_point_param ));
|
||||
cvCopy( &subr, &dia );
|
||||
}
|
||||
}
|
||||
//restore diagonal from backup
|
||||
{
|
||||
CvMat dia;
|
||||
CvMat subr;
|
||||
for( int j = 0; j < num_cams; j++ ) {
|
||||
cvGetDiag(U[j], &dia);
|
||||
cvGetSubRect(JtJ_diag, &subr,
|
||||
cvRect(0, j*num_cam_param, 1, num_cam_param ));
|
||||
cvCopy( &subr, &dia );
|
||||
}
|
||||
for( int i = 0; i < num_points; i++ ) {
|
||||
cvGetDiag(V[i], &dia);
|
||||
cvGetSubRect(JtJ_diag, &subr,
|
||||
cvRect(0, num_cams*num_cam_param + i * num_point_param, 1, num_point_param ));
|
||||
cvCopy( &subr, &dia );
|
||||
}
|
||||
}
|
||||
} else { //all is ok
|
||||
//accept change and decrease lambda
|
||||
lambda /= 10;
|
||||
lambda = MAX(lambda, 1e-16);
|
||||
std::cerr<<"decreasing lambda to "<<lambda<<std::endl;
|
||||
prevErrNorm = errNorm;
|
||||
//accept change and decrease lambda
|
||||
lambda /= 10;
|
||||
lambda = MAX(lambda, 1e-16);
|
||||
std::cerr<<"decreasing lambda to "<<lambda<<std::endl;
|
||||
prevErrNorm = errNorm;
|
||||
|
||||
//compute new projection error vector
|
||||
cvSub( X, hX, err );
|
||||
break;
|
||||
//compute new projection error vector
|
||||
cvSub( X, hX, err );
|
||||
break;
|
||||
}
|
||||
}
|
||||
iters++;
|
||||
@ -715,7 +715,7 @@ void LevMarqSparse::optimize(CvMat &_vis) { //main function that runs minimizati
|
||||
double param_change_norm = cvNorm(P, prevP, CV_RELATIVE_L2);
|
||||
//check termination criteria
|
||||
if( (criteria.type&CV_TERMCRIT_ITER && iters > criteria.max_iter ) ||
|
||||
(criteria.type&CV_TERMCRIT_EPS && param_change_norm < criteria.epsilon) ) {
|
||||
(criteria.type&CV_TERMCRIT_EPS && param_change_norm < criteria.epsilon) ) {
|
||||
// std::cerr<<"relative norm change "<<param_change_norm<<" lower than eps "<<criteria.epsilon<<", stopping"<<std::endl;
|
||||
done = true;
|
||||
break;
|
||||
@ -730,7 +730,7 @@ void LevMarqSparse::optimize(CvMat &_vis) { //main function that runs minimizati
|
||||
|
||||
//Utilities
|
||||
|
||||
void fjac(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, CvMat* A, CvMat* B, void* /*data*/) {
|
||||
static void fjac(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, CvMat* A, CvMat* B, void* /*data*/) {
|
||||
//compute jacobian per camera parameters (i.e. Aij)
|
||||
//take i-th point 3D current coordinates
|
||||
|
||||
@ -766,7 +766,7 @@ void fjac(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, CvMat* A
|
||||
cvGetCols( A, &_dpdk, 10, A->width );
|
||||
}
|
||||
cvProjectPoints2(&_Mi, &_ri, &_ti, &_A, have_dk ? &_k : NULL, _mp, &_dpdr, &_dpdt,
|
||||
&_dpdf, &_dpdc, have_dk ? &_dpdk : NULL, 0);
|
||||
&_dpdf, &_dpdc, have_dk ? &_dpdk : NULL, 0);
|
||||
|
||||
cvReleaseMat( &_mp );
|
||||
|
||||
@ -843,7 +843,7 @@ void fjac(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, CvMat* A
|
||||
// dy'/dX dy'/dY dy'/dZ
|
||||
|
||||
double coeff[6] = { z, 0, -x,
|
||||
0, z, -y };
|
||||
0, z, -y };
|
||||
CvMat coeffmat = cvMat( 2, 3, CV_64F, coeff );
|
||||
|
||||
CvMat* dstrike_dbig = cvCreateMat(2,3,CV_64F);
|
||||
@ -884,7 +884,7 @@ void fjac(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, CvMat* A
|
||||
CvMat* dstrike2_dbig = cvCreateMat( 2, 3, CV_64F );
|
||||
|
||||
double c[4] = { g+2*p1*y_strike+4*p2*x_strike, 2*p1*x_strike,
|
||||
2*p2*y_strike, g+2*p2*x_strike + 4*p1*y_strike };
|
||||
2*p2*y_strike, g+2*p2*x_strike + 4*p1*y_strike };
|
||||
|
||||
CvMat coeffmat = cvMat(2,2,CV_64F, c );
|
||||
|
||||
@ -935,7 +935,7 @@ void fjac(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, CvMat* A
|
||||
#endif
|
||||
|
||||
};
|
||||
void func(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, CvMat* estim, void* /*data*/) {
|
||||
static void func(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, CvMat* estim, void* /*data*/) {
|
||||
//just do projections
|
||||
CvMat _Mi;
|
||||
cvReshape( point_params, &_Mi, 3, 1 );
|
||||
@ -965,7 +965,7 @@ void func(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, CvMat* e
|
||||
cvGetRows( cam_params, &_k, 10, cam_params->height );
|
||||
}
|
||||
cvProjectPoints2( &_Mi, &_ri, &_ti, &_A, have_dk ? &_k : NULL, _mp, NULL, NULL,
|
||||
NULL, NULL, NULL, 0);
|
||||
NULL, NULL, NULL, 0);
|
||||
// std::cerr<<"_mp = "<<_mp->data.db[0]<<","<<_mp->data.db[1]<<std::endl;
|
||||
//
|
||||
_mp2->data.db[0] = _mp->data.db[0];
|
||||
@ -975,34 +975,34 @@ void func(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, CvMat* e
|
||||
cvReleaseMat( &_mp2 );
|
||||
};
|
||||
|
||||
void fjac_new(int i, int j, Mat& point_params, Mat& cam_params, Mat& A, Mat& B, void* data) {
|
||||
static void fjac_new(int i, int j, Mat& point_params, Mat& cam_params, Mat& A, Mat& B, void* data) {
|
||||
CvMat _point_params = point_params, _cam_params = cam_params, _Al = A, _Bl = B;
|
||||
fjac(i,j, &_point_params, &_cam_params, &_Al, &_Bl, data);
|
||||
};
|
||||
|
||||
void func_new(int i, int j, Mat& point_params, Mat& cam_params, Mat& estim, void* data) {
|
||||
static void func_new(int i, int j, Mat& point_params, Mat& cam_params, Mat& estim, void* data) {
|
||||
CvMat _point_params = point_params, _cam_params = cam_params, _estim = estim;
|
||||
func(i,j,&_point_params,&_cam_params,&_estim,data);
|
||||
};
|
||||
|
||||
void LevMarqSparse::bundleAdjust( vector<Point3d>& points, //positions of points in global coordinate system (input and output)
|
||||
const vector<vector<Point2d> >& imagePoints, //projections of 3d points for every camera
|
||||
const vector<vector<int> >& visibility, //visibility of 3d points for every camera
|
||||
vector<Mat>& cameraMatrix, //intrinsic matrices of all cameras (input and output)
|
||||
vector<Mat>& R, //rotation matrices of all cameras (input and output)
|
||||
vector<Mat>& T, //translation vector of all cameras (input and output)
|
||||
vector<Mat>& distCoeffs, //distortion coefficients of all cameras (input and output)
|
||||
const TermCriteria& criteria,
|
||||
BundleAdjustCallback cb, void* user_data) {
|
||||
const vector<vector<Point2d> >& imagePoints, //projections of 3d points for every camera
|
||||
const vector<vector<int> >& visibility, //visibility of 3d points for every camera
|
||||
vector<Mat>& cameraMatrix, //intrinsic matrices of all cameras (input and output)
|
||||
vector<Mat>& R, //rotation matrices of all cameras (input and output)
|
||||
vector<Mat>& T, //translation vector of all cameras (input and output)
|
||||
vector<Mat>& distCoeffs, //distortion coefficients of all cameras (input and output)
|
||||
const TermCriteria& criteria,
|
||||
BundleAdjustCallback cb, void* user_data) {
|
||||
//,enum{MOTION_AND_STRUCTURE,MOTION,STRUCTURE})
|
||||
int num_points = (int)points.size();
|
||||
int num_cameras = (int)cameraMatrix.size();
|
||||
|
||||
CV_Assert( imagePoints.size() == (size_t)num_cameras &&
|
||||
visibility.size() == (size_t)num_cameras &&
|
||||
R.size() == (size_t)num_cameras &&
|
||||
T.size() == (size_t)num_cameras &&
|
||||
(distCoeffs.size() == (size_t)num_cameras || distCoeffs.size() == 0) );
|
||||
visibility.size() == (size_t)num_cameras &&
|
||||
R.size() == (size_t)num_cameras &&
|
||||
T.size() == (size_t)num_cameras &&
|
||||
(distCoeffs.size() == (size_t)num_cameras || distCoeffs.size() == 0) );
|
||||
|
||||
int numdist = distCoeffs.size() ? (distCoeffs[0].rows * distCoeffs[0].cols) : 0;
|
||||
|
||||
@ -1066,19 +1066,19 @@ void LevMarqSparse::bundleAdjust( vector<Point3d>& points, //positions of points
|
||||
for(int j = 0; j < num_cameras; j++ ) {
|
||||
//check visibility
|
||||
if( visibility[j][i] ) {
|
||||
//extract point and put tu vector
|
||||
Point2d p = imagePoints[j][i];
|
||||
((double*)(X.data))[counter] = p.x;
|
||||
((double*)(X.data))[counter+1] = p.y;
|
||||
assert(p.x != -1 || p.y != -1);
|
||||
counter+=2;
|
||||
//extract point and put tu vector
|
||||
Point2d p = imagePoints[j][i];
|
||||
((double*)(X.data))[counter] = p.x;
|
||||
((double*)(X.data))[counter+1] = p.y;
|
||||
assert(p.x != -1 || p.y != -1);
|
||||
counter+=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LevMarqSparse levmar( num_points, num_cameras, num_point_param, num_cam_param, 2, vismat, params, X,
|
||||
TermCriteria(criteria), fjac_new, func_new, NULL,
|
||||
cb, user_data);
|
||||
TermCriteria(criteria), fjac_new, func_new, NULL,
|
||||
cb, user_data);
|
||||
//extract results
|
||||
//fill point params
|
||||
/*Mat final_points(num_points, 1, CV_64FC3,
|
||||
|
@ -81,6 +81,7 @@ private:
|
||||
{
|
||||
public:
|
||||
virtual ImageIterator* iterator() const = 0;
|
||||
virtual ~ImageRange() {}
|
||||
};
|
||||
|
||||
// Sliding window
|
||||
|
@ -60,7 +60,7 @@ static Mat sortMatrixRowsByIndices(InputArray src, InputArray indices)
|
||||
}
|
||||
|
||||
|
||||
Mat argsort(InputArray _src, bool ascending=true)
|
||||
static Mat argsort(InputArray _src, bool ascending=true)
|
||||
{
|
||||
Mat src = _src.getMat();
|
||||
if (src.rows != 1 && src.cols != 1)
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#define DEBUGLOGS 1
|
||||
|
||||
#if ANDROID
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#define LOG_TAG "OBJECT_DETECTOR"
|
||||
#define LOGD0(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
|
||||
|
@ -46,7 +46,7 @@
|
||||
|
||||
using namespace cv;
|
||||
|
||||
void downsamplePoints( const Mat& src, Mat& dst, size_t count )
|
||||
static void downsamplePoints( const Mat& src, Mat& dst, size_t count )
|
||||
{
|
||||
CV_Assert( count >= 2 );
|
||||
CV_Assert( src.cols == 1 || src.rows == 1 );
|
||||
|
@ -73,7 +73,7 @@ static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double
|
||||
return data;
|
||||
}
|
||||
|
||||
void sortMatrixColumnsByIndices(InputArray _src, InputArray _indices, OutputArray _dst) {
|
||||
static void sortMatrixColumnsByIndices(InputArray _src, InputArray _indices, OutputArray _dst) {
|
||||
if(_indices.getMat().type() != CV_32SC1)
|
||||
CV_Error(CV_StsUnsupportedFormat, "cv::sortColumnsByIndices only works on integer indices!");
|
||||
Mat src = _src.getMat();
|
||||
@ -87,7 +87,7 @@ void sortMatrixColumnsByIndices(InputArray _src, InputArray _indices, OutputArra
|
||||
}
|
||||
}
|
||||
|
||||
Mat sortMatrixColumnsByIndices(InputArray src, InputArray indices) {
|
||||
static Mat sortMatrixColumnsByIndices(InputArray src, InputArray indices) {
|
||||
Mat dst;
|
||||
sortMatrixColumnsByIndices(src, indices, dst);
|
||||
return dst;
|
||||
|
@ -43,8 +43,9 @@
|
||||
#include "precomp.hpp"
|
||||
#include <limits>
|
||||
|
||||
namespace cv
|
||||
namespace
|
||||
{
|
||||
using namespace cv;
|
||||
const size_t MAX_STACK_SIZE = 255;
|
||||
const size_t MAX_LEAFS = 8;
|
||||
|
||||
@ -159,10 +160,13 @@ namespace cv
|
||||
child.x_min = parent.x_min;
|
||||
}
|
||||
|
||||
}//namespace
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////// Octree //////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace cv
|
||||
{
|
||||
Octree::Octree()
|
||||
{
|
||||
}
|
||||
|
@ -43,7 +43,7 @@
|
||||
#ifndef __OPENCV_PRECOMP_H__
|
||||
#define __OPENCV_PRECOMP_H__
|
||||
|
||||
#if _MSC_VER >= 1200
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning( disable: 4251 4710 4711 4514 4996 )
|
||||
#endif
|
||||
|
||||
|
@ -1299,6 +1299,7 @@ public:
|
||||
GPU_MAT = 9 << KIND_SHIFT
|
||||
};
|
||||
_InputArray();
|
||||
|
||||
_InputArray(const Mat& m);
|
||||
_InputArray(const MatExpr& expr);
|
||||
template<typename _Tp> _InputArray(const _Tp* vec, int n);
|
||||
@ -1328,6 +1329,8 @@ public:
|
||||
virtual int channels(int i=-1) const;
|
||||
virtual bool empty() const;
|
||||
|
||||
virtual ~_InputArray();
|
||||
|
||||
int flags;
|
||||
void* obj;
|
||||
Size sz;
|
||||
@ -1384,6 +1387,8 @@ public:
|
||||
virtual void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
|
||||
virtual void release() const;
|
||||
virtual void clear() const;
|
||||
|
||||
virtual ~_OutputArray();
|
||||
};
|
||||
|
||||
typedef const _InputArray& InputArray;
|
||||
|
@ -60,34 +60,34 @@
|
||||
#endif
|
||||
|
||||
#if defined WIN32 || defined WINCE
|
||||
#ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?)
|
||||
#define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#undef small
|
||||
#undef min
|
||||
#undef max
|
||||
# ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?)
|
||||
# define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# undef small
|
||||
# undef min
|
||||
# undef max
|
||||
#else
|
||||
#include <pthread.h>
|
||||
# include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#ifndef WIN32
|
||||
#define WIN32
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
#define _WIN32
|
||||
#endif
|
||||
#define CV_DLL
|
||||
#undef _CV_ALWAYS_PROFILE_
|
||||
#define _CV_ALWAYS_NO_PROFILE_
|
||||
# ifndef WIN32
|
||||
# define WIN32
|
||||
# endif
|
||||
# ifndef _WIN32
|
||||
# define _WIN32
|
||||
# endif
|
||||
# define CV_DLL
|
||||
# undef _CV_ALWAYS_PROFILE_
|
||||
# define _CV_ALWAYS_NO_PROFILE_
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
# define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
# define TRUE 1
|
||||
#endif
|
||||
|
||||
#define __BEGIN__ __CV_BEGIN__
|
||||
@ -95,7 +95,7 @@
|
||||
#define EXIT __CV_EXIT__
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
#include "ipp.h"
|
||||
# include "ipp.h"
|
||||
|
||||
CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
{
|
||||
@ -104,137 +104,132 @@ CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined __SSE2__ || _MSC_VER >= 1300
|
||||
#include "emmintrin.h"
|
||||
#define CV_SSE 1
|
||||
#define CV_SSE2 1
|
||||
#if defined __SSE3__ || _MSC_VER >= 1500
|
||||
#include "pmmintrin.h"
|
||||
#define CV_SSE3 1
|
||||
#endif
|
||||
#if defined __SSSE3__
|
||||
#include "tmmintrin.h"
|
||||
#define CV_SSSE3 1
|
||||
#endif
|
||||
#if defined __SSE2__ || (defined _MSC_VER && _MSC_VER >= 1300)
|
||||
# include "emmintrin.h"
|
||||
# define CV_SSE 1
|
||||
# define CV_SSE2 1
|
||||
# if defined __SSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include "pmmintrin.h"
|
||||
# define CV_SSE3 1
|
||||
# else
|
||||
# define CV_SSE3 0
|
||||
# endif
|
||||
# if defined __SSSE3__
|
||||
# include "tmmintrin.h"
|
||||
# define CV_SSSE3 1
|
||||
# else
|
||||
# define CV_SSSE3 0
|
||||
# endif
|
||||
#else
|
||||
#define CV_SSE 0
|
||||
#define CV_SSE2 0
|
||||
#define CV_SSE3 0
|
||||
#define CV_SSSE3 0
|
||||
# define CV_SSE 0
|
||||
# define CV_SSE2 0
|
||||
# define CV_SSE3 0
|
||||
# define CV_SSSE3 0
|
||||
#endif
|
||||
|
||||
#if defined ANDROID && defined __ARM_NEON__ && defined __GNUC__
|
||||
#include "arm_neon.h"
|
||||
#define CV_NEON 1
|
||||
#if defined ANDROID && defined __ARM_NEON__
|
||||
# include "arm_neon.h"
|
||||
# define CV_NEON 1
|
||||
|
||||
#define CPU_HAS_NEON_FEATURE (true)
|
||||
# define CPU_HAS_NEON_FEATURE (true)
|
||||
//TODO: make real check using stuff from "cpu-features.h"
|
||||
//((bool)android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON)
|
||||
#else
|
||||
#define CV_NEON 0
|
||||
#define CPU_HAS_NEON_FEATURE (false)
|
||||
#endif
|
||||
|
||||
#ifdef CV_ICC
|
||||
#define CV_ENABLE_UNROLLED 0
|
||||
#else
|
||||
#define CV_ENABLE_UNROLLED 1
|
||||
# define CV_NEON 0
|
||||
# define CPU_HAS_NEON_FEATURE (false)
|
||||
#endif
|
||||
|
||||
#ifndef IPPI_CALL
|
||||
#define IPPI_CALL(func) CV_Assert((func) >= 0)
|
||||
# define IPPI_CALL(func) CV_Assert((func) >= 0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TBB
|
||||
#include "tbb/tbb_stddef.h"
|
||||
#if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
|
||||
#include "tbb/tbb.h"
|
||||
#include "tbb/task.h"
|
||||
#undef min
|
||||
#undef max
|
||||
#else
|
||||
#undef HAVE_TBB
|
||||
#endif
|
||||
# include "tbb/tbb_stddef.h"
|
||||
# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
|
||||
# include "tbb/tbb.h"
|
||||
# include "tbb/task.h"
|
||||
# undef min
|
||||
# undef max
|
||||
# else
|
||||
# undef HAVE_TBB
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_EIGEN
|
||||
#include <Eigen/Core>
|
||||
#include "opencv2/core/eigen.hpp"
|
||||
# include <Eigen/Core>
|
||||
# include "opencv2/core/eigen.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace cv
|
||||
{
|
||||
#ifdef HAVE_TBB
|
||||
namespace cv
|
||||
|
||||
typedef tbb::blocked_range<int> BlockedRange;
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_for( const BlockedRange& range, const Body& body )
|
||||
{
|
||||
typedef tbb::blocked_range<int> BlockedRange;
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_for( const BlockedRange& range, const Body& body )
|
||||
{
|
||||
tbb::parallel_for(range, body);
|
||||
}
|
||||
|
||||
template<typename Iterator, typename Body> static inline
|
||||
void parallel_do( Iterator first, Iterator last, const Body& body )
|
||||
{
|
||||
tbb::parallel_do(first, last, body);
|
||||
}
|
||||
|
||||
typedef tbb::split Split;
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_reduce( const BlockedRange& range, Body& body )
|
||||
{
|
||||
tbb::parallel_reduce(range, body);
|
||||
}
|
||||
|
||||
typedef tbb::concurrent_vector<Rect> ConcurrentRectVector;
|
||||
typedef tbb::concurrent_vector<double> ConcurrentDoubleVector;
|
||||
tbb::parallel_for(range, body);
|
||||
}
|
||||
#else
|
||||
namespace cv
|
||||
|
||||
template<typename Iterator, typename Body> static inline
|
||||
void parallel_do( Iterator first, Iterator last, const Body& body )
|
||||
{
|
||||
class BlockedRange
|
||||
{
|
||||
public:
|
||||
BlockedRange() : _begin(0), _end(0), _grainsize(0) {}
|
||||
BlockedRange(int b, int e, int g=1) : _begin(b), _end(e), _grainsize(g) {}
|
||||
int begin() const { return _begin; }
|
||||
int end() const { return _end; }
|
||||
int grainsize() const { return _grainsize; }
|
||||
tbb::parallel_do(first, last, body);
|
||||
}
|
||||
|
||||
protected:
|
||||
int _begin, _end, _grainsize;
|
||||
};
|
||||
typedef tbb::split Split;
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_for( const BlockedRange& range, const Body& body )
|
||||
{
|
||||
body(range);
|
||||
}
|
||||
typedef std::vector<Rect> ConcurrentRectVector;
|
||||
typedef std::vector<double> ConcurrentDoubleVector;
|
||||
template<typename Body> static inline
|
||||
void parallel_reduce( const BlockedRange& range, Body& body )
|
||||
{
|
||||
tbb::parallel_reduce(range, body);
|
||||
}
|
||||
|
||||
template<typename Iterator, typename Body> static inline
|
||||
void parallel_do( Iterator first, Iterator last, const Body& body )
|
||||
{
|
||||
for( ; first != last; ++first )
|
||||
body(*first);
|
||||
}
|
||||
typedef tbb::concurrent_vector<Rect> ConcurrentRectVector;
|
||||
typedef tbb::concurrent_vector<double> ConcurrentDoubleVector;
|
||||
#else
|
||||
class BlockedRange
|
||||
{
|
||||
public:
|
||||
BlockedRange() : _begin(0), _end(0), _grainsize(0) {}
|
||||
BlockedRange(int b, int e, int g=1) : _begin(b), _end(e), _grainsize(g) {}
|
||||
int begin() const { return _begin; }
|
||||
int end() const { return _end; }
|
||||
int grainsize() const { return _grainsize; }
|
||||
|
||||
class Split {};
|
||||
protected:
|
||||
int _begin, _end, _grainsize;
|
||||
};
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_reduce( const BlockedRange& range, Body& body )
|
||||
{
|
||||
body(range);
|
||||
}
|
||||
template<typename Body> static inline
|
||||
void parallel_for( const BlockedRange& range, const Body& body )
|
||||
{
|
||||
body(range);
|
||||
}
|
||||
typedef std::vector<Rect> ConcurrentRectVector;
|
||||
typedef std::vector<double> ConcurrentDoubleVector;
|
||||
|
||||
template<typename Iterator, typename Body> static inline
|
||||
void parallel_do( Iterator first, Iterator last, const Body& body )
|
||||
{
|
||||
for( ; first != last; ++first )
|
||||
body(*first);
|
||||
}
|
||||
|
||||
class Split {};
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_reduce( const BlockedRange& range, Body& body )
|
||||
{
|
||||
body(range);
|
||||
}
|
||||
#endif
|
||||
} //namespace cv
|
||||
|
||||
#define CV_INIT_ALGORITHM(classname, algname, memberinit) \
|
||||
#define CV_INIT_ALGORITHM(classname, algname, memberinit) \
|
||||
static Algorithm* create##classname() \
|
||||
{ \
|
||||
return new classname; \
|
||||
@ -261,7 +256,7 @@ CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
return &classname##_info(); \
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif //__cplusplus
|
||||
|
||||
/* maximal size of vector to run matrix operations on it inline (i.e. w/o ipp calls) */
|
||||
#define CV_MAX_INLINE_MAT_OP_SIZE 10
|
||||
@ -305,9 +300,9 @@ CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
#define CV_MAX_STRLEN 1024
|
||||
|
||||
#if 0 /*def CV_CHECK_FOR_NANS*/
|
||||
#define CV_CHECK_NANS( arr ) cvCheckArray((arr))
|
||||
# define CV_CHECK_NANS( arr ) cvCheckArray((arr))
|
||||
#else
|
||||
#define CV_CHECK_NANS( arr )
|
||||
# define CV_CHECK_NANS( arr )
|
||||
#endif
|
||||
|
||||
/****************************************************************************************\
|
||||
@ -316,38 +311,38 @@ CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
|
||||
/* get alloca declaration */
|
||||
#ifdef __GNUC__
|
||||
#undef alloca
|
||||
#define alloca __builtin_alloca
|
||||
#define CV_HAVE_ALLOCA 1
|
||||
# undef alloca
|
||||
# define alloca __builtin_alloca
|
||||
# define CV_HAVE_ALLOCA 1
|
||||
#elif defined WIN32 || defined _WIN32 || \
|
||||
defined WINCE || defined _MSC_VER || defined __BORLANDC__
|
||||
#include <malloc.h>
|
||||
#define CV_HAVE_ALLOCA 1
|
||||
# include <malloc.h>
|
||||
# define CV_HAVE_ALLOCA 1
|
||||
#elif defined HAVE_ALLOCA_H
|
||||
#include <alloca.h>
|
||||
#define CV_HAVE_ALLOCA 1
|
||||
# include <alloca.h>
|
||||
# define CV_HAVE_ALLOCA 1
|
||||
#elif defined HAVE_ALLOCA
|
||||
#include <stdlib.h>
|
||||
#define CV_HAVE_ALLOCA 1
|
||||
# include <stdlib.h>
|
||||
# define CV_HAVE_ALLOCA 1
|
||||
#else
|
||||
#undef CV_HAVE_ALLOCA
|
||||
# undef CV_HAVE_ALLOCA
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define CV_DECL_ALIGNED(x) __attribute__ ((aligned (x)))
|
||||
# define CV_DECL_ALIGNED(x) __attribute__ ((aligned (x)))
|
||||
#elif defined _MSC_VER
|
||||
#define CV_DECL_ALIGNED(x) __declspec(align(x))
|
||||
# define CV_DECL_ALIGNED(x) __declspec(align(x))
|
||||
#else
|
||||
#define CV_DECL_ALIGNED(x)
|
||||
# define CV_DECL_ALIGNED(x)
|
||||
#endif
|
||||
|
||||
#if CV_HAVE_ALLOCA
|
||||
/* ! DO NOT make it an inline function */
|
||||
#define cvStackAlloc(size) cvAlignPtr( alloca((size) + CV_MALLOC_ALIGN), CV_MALLOC_ALIGN )
|
||||
# define cvStackAlloc(size) cvAlignPtr( alloca((size) + CV_MALLOC_ALIGN), CV_MALLOC_ALIGN )
|
||||
#endif
|
||||
|
||||
#ifndef CV_IMPL
|
||||
#define CV_IMPL CV_EXTERN_C
|
||||
# define CV_IMPL CV_EXTERN_C
|
||||
#endif
|
||||
|
||||
#define CV_DBG_BREAK() { volatile int* crashMe = 0; *crashMe = 0; }
|
||||
@ -687,25 +682,25 @@ typedef enum CvStatus
|
||||
CV_UNSUPPORTED_DEPTH_ERR = -101,
|
||||
CV_UNSUPPORTED_FORMAT_ERR = -100,
|
||||
|
||||
CV_BADARG_ERR = -49, //ipp comp
|
||||
CV_NOTDEFINED_ERR = -48, //ipp comp
|
||||
CV_BADARG_ERR = -49, //ipp comp
|
||||
CV_NOTDEFINED_ERR = -48, //ipp comp
|
||||
|
||||
CV_BADCHANNELS_ERR = -47, //ipp comp
|
||||
CV_BADRANGE_ERR = -44, //ipp comp
|
||||
CV_BADSTEP_ERR = -29, //ipp comp
|
||||
CV_BADCHANNELS_ERR = -47, //ipp comp
|
||||
CV_BADRANGE_ERR = -44, //ipp comp
|
||||
CV_BADSTEP_ERR = -29, //ipp comp
|
||||
|
||||
CV_BADFLAG_ERR = -12,
|
||||
CV_DIV_BY_ZERO_ERR = -11, //ipp comp
|
||||
CV_BADCOEF_ERR = -10,
|
||||
CV_BADFLAG_ERR = -12,
|
||||
CV_DIV_BY_ZERO_ERR = -11, //ipp comp
|
||||
CV_BADCOEF_ERR = -10,
|
||||
|
||||
CV_BADFACTOR_ERR = -7,
|
||||
CV_BADPOINT_ERR = -6,
|
||||
CV_BADSCALE_ERR = -4,
|
||||
CV_OUTOFMEM_ERR = -3,
|
||||
CV_NULLPTR_ERR = -2,
|
||||
CV_BADSIZE_ERR = -1,
|
||||
CV_NO_ERR = 0,
|
||||
CV_OK = CV_NO_ERR
|
||||
CV_BADFACTOR_ERR = -7,
|
||||
CV_BADPOINT_ERR = -6,
|
||||
CV_BADSCALE_ERR = -4,
|
||||
CV_OUTOFMEM_ERR = -3,
|
||||
CV_NULLPTR_ERR = -2,
|
||||
CV_BADSIZE_ERR = -1,
|
||||
CV_NO_ERR = 0,
|
||||
CV_OK = CV_NO_ERR
|
||||
}
|
||||
CvStatus;
|
||||
|
||||
@ -720,8 +715,7 @@ CvFuncTable;
|
||||
typedef struct CvBigFuncTable
|
||||
{
|
||||
void* fn_2d[CV_DEPTH_MAX*4];
|
||||
}
|
||||
CvBigFuncTable;
|
||||
} CvBigFuncTable;
|
||||
|
||||
#define CV_INIT_FUNC_TAB( tab, FUNCNAME, FLAG ) \
|
||||
(tab).fn_2d[CV_8U] = (void*)FUNCNAME##_8u##FLAG; \
|
||||
@ -732,6 +726,7 @@ CvBigFuncTable;
|
||||
(tab).fn_2d[CV_32F] = (void*)FUNCNAME##_32f##FLAG; \
|
||||
(tab).fn_2d[CV_64F] = (void*)FUNCNAME##_64f##FLAG
|
||||
|
||||
#ifdef __cplusplus
|
||||
//! OpenGL extension table
|
||||
class CV_EXPORTS CvOpenGlFuncTab
|
||||
{
|
||||
@ -764,4 +759,6 @@ CV_EXPORTS bool icvCheckGlError(const char* file, const int line, const char* fu
|
||||
#define CV_CheckGlError() CV_DbgAssert( (::icvCheckGlError(__FILE__, __LINE__)) )
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif //__cplusplus
|
||||
|
||||
#endif // __OPENCV_CORE_INTERNAL_HPP__
|
||||
|
@ -43,122 +43,132 @@
|
||||
#ifndef __OPENCV_CORE_TYPES_H__
|
||||
#define __OPENCV_CORE_TYPES_H__
|
||||
|
||||
#if !defined _CRT_SECURE_NO_DEPRECATE && _MSC_VER > 1300
|
||||
#define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio 2005 warnings */
|
||||
#if !defined _CRT_SECURE_NO_DEPRECATE && defined _MSC_VER
|
||||
# if _MSC_VER > 1300
|
||||
# define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio 2005 warnings */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SKIP_INCLUDES
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <float.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <float.h>
|
||||
|
||||
#if !defined _MSC_VER && !defined __BORLANDC__
|
||||
#include <stdint.h>
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if defined __ICL
|
||||
#define CV_ICC __ICL
|
||||
#elif defined __ICC
|
||||
#define CV_ICC __ICC
|
||||
#elif defined __ECL
|
||||
#define CV_ICC __ECL
|
||||
#elif defined __ECC
|
||||
#define CV_ICC __ECC
|
||||
#elif defined __INTEL_COMPILER
|
||||
#define CV_ICC __INTEL_COMPILER
|
||||
#endif
|
||||
#if defined __ICL
|
||||
# define CV_ICC __ICL
|
||||
#elif defined __ICC
|
||||
# define CV_ICC __ICC
|
||||
#elif defined __ECL
|
||||
# define CV_ICC __ECL
|
||||
#elif defined __ECC
|
||||
# define CV_ICC __ECC
|
||||
#elif defined __INTEL_COMPILER
|
||||
# define CV_ICC __INTEL_COMPILER
|
||||
#endif
|
||||
|
||||
#if (_MSC_VER >= 1400 && defined _M_X64) || (__GNUC__ >= 4 && defined __x86_64__)
|
||||
#if defined WIN32
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
#if __SSE2__ || !defined __GNUC__
|
||||
#include <emmintrin.h>
|
||||
#endif
|
||||
#endif
|
||||
#if defined CV_ICC && !defined CV_ENABLE_UNROLLED
|
||||
# define CV_ENABLE_UNROLLED 0
|
||||
#else
|
||||
# define CV_ENABLE_UNROLLED 1
|
||||
#endif
|
||||
|
||||
#if defined __BORLANDC__
|
||||
#include <fastmath.h>
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
#if (defined _M_X64 && _MSC_VER >= 1400) || (__GNUC__ >= 4 && defined __x86_64__)
|
||||
# if defined WIN32
|
||||
# include <intrin.h>
|
||||
# endif
|
||||
# if __SSE2__ || !defined __GNUC__
|
||||
# include <emmintrin.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined __BORLANDC__
|
||||
# include <fastmath.h>
|
||||
#else
|
||||
# include <math.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IPL
|
||||
# ifndef __IPL_H__
|
||||
# if defined WIN32 || defined _WIN32
|
||||
# include <ipl.h>
|
||||
# else
|
||||
# include <ipl/ipl.h>
|
||||
# endif
|
||||
# endif
|
||||
#elif defined __IPL_H__
|
||||
# define HAVE_IPL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IPL
|
||||
#ifndef __IPL_H__
|
||||
#if defined WIN32 || defined _WIN32
|
||||
#include <ipl.h>
|
||||
#else
|
||||
#include <ipl/ipl.h>
|
||||
#endif
|
||||
#endif
|
||||
#elif defined __IPL_H__
|
||||
#define HAVE_IPL
|
||||
#endif
|
||||
#endif // SKIP_INCLUDES
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
#define CV_CDECL __cdecl
|
||||
#define CV_STDCALL __stdcall
|
||||
# define CV_CDECL __cdecl
|
||||
# define CV_STDCALL __stdcall
|
||||
#else
|
||||
#define CV_CDECL
|
||||
#define CV_STDCALL
|
||||
# define CV_CDECL
|
||||
# define CV_STDCALL
|
||||
#endif
|
||||
|
||||
#ifndef CV_EXTERN_C
|
||||
#ifdef __cplusplus
|
||||
#define CV_EXTERN_C extern "C"
|
||||
#define CV_DEFAULT(val) = val
|
||||
#else
|
||||
#define CV_EXTERN_C
|
||||
#define CV_DEFAULT(val)
|
||||
#endif
|
||||
# ifdef __cplusplus
|
||||
# define CV_EXTERN_C extern "C"
|
||||
# define CV_DEFAULT(val) = val
|
||||
# else
|
||||
# define CV_EXTERN_C
|
||||
# define CV_DEFAULT(val)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CV_EXTERN_C_FUNCPTR
|
||||
#ifdef __cplusplus
|
||||
#define CV_EXTERN_C_FUNCPTR(x) extern "C" { typedef x; }
|
||||
#else
|
||||
#define CV_EXTERN_C_FUNCPTR(x) typedef x
|
||||
#endif
|
||||
# ifdef __cplusplus
|
||||
# define CV_EXTERN_C_FUNCPTR(x) extern "C" { typedef x; }
|
||||
# else
|
||||
# define CV_EXTERN_C_FUNCPTR(x) typedef x
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CV_INLINE
|
||||
#if defined __cplusplus
|
||||
#define CV_INLINE inline
|
||||
#elif (defined WIN32 || defined _WIN32 || defined WINCE) && !defined __GNUC__
|
||||
#define CV_INLINE __inline
|
||||
#else
|
||||
#define CV_INLINE static
|
||||
#endif
|
||||
# if defined __cplusplus
|
||||
# define CV_INLINE inline
|
||||
# elif (defined WIN32 || defined _WIN32 || defined WINCE) && !defined __GNUC__
|
||||
# define CV_INLINE __inline
|
||||
# else
|
||||
# define CV_INLINE static
|
||||
# endif
|
||||
#endif /* CV_INLINE */
|
||||
|
||||
#if (defined WIN32 || defined _WIN32 || defined WINCE) && defined CVAPI_EXPORTS
|
||||
#define CV_EXPORTS __declspec(dllexport)
|
||||
# define CV_EXPORTS __declspec(dllexport)
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
# define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
#ifndef CVAPI
|
||||
#define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL
|
||||
# define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER || defined __BORLANDC__
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
#define CV_BIG_INT(n) n##I64
|
||||
#define CV_BIG_UINT(n) n##UI64
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
# define CV_BIG_INT(n) n##I64
|
||||
# define CV_BIG_UINT(n) n##UI64
|
||||
#else
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
#define CV_BIG_INT(n) n##LL
|
||||
#define CV_BIG_UINT(n) n##ULL
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
# define CV_BIG_INT(n) n##LL
|
||||
# define CV_BIG_UINT(n) n##ULL
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_IPL
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned short ushort;
|
||||
#endif
|
||||
|
||||
typedef signed char schar;
|
||||
@ -262,7 +272,7 @@ enum {
|
||||
\****************************************************************************************/
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
# include "tegra_round.hpp"
|
||||
# include "tegra_round.hpp"
|
||||
#endif
|
||||
|
||||
#define CV_PI 3.1415926535897932384626433832795
|
||||
@ -271,11 +281,11 @@ enum {
|
||||
#define CV_SWAP(a,b,t) ((t) = (a), (a) = (b), (b) = (t))
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) ((a) > (b) ? (b) : (a))
|
||||
# define MIN(a,b) ((a) > (b) ? (b) : (a))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) ((a) < (b) ? (b) : (a))
|
||||
# define MAX(a,b) ((a) < (b) ? (b) : (a))
|
||||
#endif
|
||||
|
||||
/* min & max without jumps */
|
||||
@ -285,9 +295,9 @@ enum {
|
||||
|
||||
/* absolute value without jumps */
|
||||
#ifndef __cplusplus
|
||||
#define CV_IABS(a) (((a) ^ ((a) < 0 ? -1 : 0)) - ((a) < 0 ? -1 : 0))
|
||||
# define CV_IABS(a) (((a) ^ ((a) < 0 ? -1 : 0)) - ((a) < 0 ? -1 : 0))
|
||||
#else
|
||||
#define CV_IABS(a) abs(a)
|
||||
# define CV_IABS(a) abs(a)
|
||||
#endif
|
||||
#define CV_CMP(a,b) (((a) > (b)) - ((a) < (b)))
|
||||
#define CV_SIGN(a) CV_CMP((a),0)
|
||||
@ -306,11 +316,11 @@ CV_INLINE int cvRound( double value )
|
||||
}
|
||||
return t;
|
||||
#elif defined HAVE_LRINT || defined CV_ICC || defined __GNUC__
|
||||
# ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
# ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
TEGRA_ROUND(value);
|
||||
# else
|
||||
# else
|
||||
return (int)lrint(value);
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
// while this is not IEEE754-compliant rounding, it's usually a good enough approximation
|
||||
return (int)(value + (value >= 0 ? 0.5 : -0.5));
|
||||
@ -318,7 +328,7 @@ CV_INLINE int cvRound( double value )
|
||||
}
|
||||
|
||||
#if defined __SSE2__ || (defined _M_IX86_FP && 2 == _M_IX86_FP)
|
||||
#include "emmintrin.h"
|
||||
# include "emmintrin.h"
|
||||
#endif
|
||||
|
||||
CV_INLINE int cvFloor( double value )
|
||||
@ -1886,6 +1896,6 @@ typedef struct CvModuleInfo
|
||||
}
|
||||
CvModuleInfo;
|
||||
|
||||
#endif /*_CXCORE_TYPES_H_*/
|
||||
#endif /*__OPENCV_CORE_TYPES_H__*/
|
||||
|
||||
/* End of file. */
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "opencv2/ts/ts.hpp"
|
||||
|
||||
#if GTEST_CREATE_SHARED_LIBRARY
|
||||
#ifdef GTEST_CREATE_SHARED_LIBRARY
|
||||
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
|
||||
#endif
|
||||
|
||||
|
@ -55,7 +55,9 @@ static void* OutOfMemoryError(size_t size)
|
||||
|
||||
#if CV_USE_SYSTEM_MALLOC
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
void deleteThreadAllocData() {}
|
||||
#endif
|
||||
|
||||
void* fastMalloc( size_t size )
|
||||
{
|
||||
@ -388,7 +390,7 @@ struct ThreadData
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef WINCE
|
||||
# define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
|
||||
# define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
|
||||
#endif //WINCE
|
||||
|
||||
static DWORD tlsKey;
|
||||
|
@ -974,7 +974,7 @@ void convertAndUnrollScalar( const Mat& sc, int buftype, uchar* scbuf, size_t bl
|
||||
scbuf[i] = scbuf[i - esz];
|
||||
}
|
||||
|
||||
void binary_op(InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
static void binary_op(InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
InputArray _mask, const BinaryFunc* tab, bool bitwise)
|
||||
{
|
||||
int kind1 = _src1.kind(), kind2 = _src2.kind();
|
||||
@ -1216,7 +1216,7 @@ void cv::min(const Mat& src1, double src2, Mat& dst)
|
||||
namespace cv
|
||||
{
|
||||
|
||||
void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
InputArray _mask, int dtype, BinaryFunc* tab, bool muldiv=false, void* usrdata=0)
|
||||
{
|
||||
int kind1 = _src1.kind(), kind2 = _src2.kind();
|
||||
|
@ -6,6 +6,7 @@
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
namespace {
|
||||
void helpParser()
|
||||
{
|
||||
printf("\nThe CommandLineParser class is designed for command line arguments parsing\n"
|
||||
@ -89,6 +90,8 @@ string del_space(string name)
|
||||
return name;
|
||||
}
|
||||
|
||||
}//namespace
|
||||
|
||||
CommandLineParser::CommandLineParser(int argc, const char* const argv[], const char* keys)
|
||||
{
|
||||
std::string keys_buffer;
|
||||
|
@ -1845,37 +1845,37 @@ iPow_( const T* src, T* dst, int len, int power )
|
||||
}
|
||||
|
||||
|
||||
void iPow8u(const uchar* src, uchar* dst, int len, int power)
|
||||
static void iPow8u(const uchar* src, uchar* dst, int len, int power)
|
||||
{
|
||||
iPow_<uchar, int>(src, dst, len, power);
|
||||
}
|
||||
|
||||
void iPow8s(const schar* src, schar* dst, int len, int power)
|
||||
static void iPow8s(const schar* src, schar* dst, int len, int power)
|
||||
{
|
||||
iPow_<schar, int>(src, dst, len, power);
|
||||
}
|
||||
|
||||
void iPow16u(const ushort* src, ushort* dst, int len, int power)
|
||||
static void iPow16u(const ushort* src, ushort* dst, int len, int power)
|
||||
{
|
||||
iPow_<ushort, int>(src, dst, len, power);
|
||||
}
|
||||
|
||||
void iPow16s(const short* src, short* dst, int len, int power)
|
||||
static void iPow16s(const short* src, short* dst, int len, int power)
|
||||
{
|
||||
iPow_<short, int>(src, dst, len, power);
|
||||
}
|
||||
|
||||
void iPow32s(const int* src, int* dst, int len, int power)
|
||||
static void iPow32s(const int* src, int* dst, int len, int power)
|
||||
{
|
||||
iPow_<int, int>(src, dst, len, power);
|
||||
}
|
||||
|
||||
void iPow32f(const float* src, float* dst, int len, int power)
|
||||
static void iPow32f(const float* src, float* dst, int len, int power)
|
||||
{
|
||||
iPow_<float, float>(src, dst, len, power);
|
||||
}
|
||||
|
||||
void iPow64f(const double* src, double* dst, int len, int power)
|
||||
static void iPow64f(const double* src, double* dst, int len, int power)
|
||||
{
|
||||
iPow_<double, double>(src, dst, len, power);
|
||||
}
|
||||
|
@ -493,8 +493,8 @@ Mat::Mat(const IplImage* img, bool copyData) : size(&rows)
|
||||
rows = img->roi->height; cols = img->roi->width;
|
||||
esz = CV_ELEM_SIZE(flags);
|
||||
data = datastart = (uchar*)img->imageData +
|
||||
(selectedPlane ? (img->roi->coi - 1)*step*img->height : 0) +
|
||||
img->roi->yOffset*step[0] + img->roi->xOffset*esz;
|
||||
(selectedPlane ? (img->roi->coi - 1)*step*img->height : 0) +
|
||||
img->roi->yOffset*step[0] + img->roi->xOffset*esz;
|
||||
}
|
||||
datalimit = datastart + step.p[0]*rows;
|
||||
dataend = datastart + step.p[0]*(rows-1) + esz*cols;
|
||||
@ -636,11 +636,11 @@ void Mat::push_back(const Mat& elems)
|
||||
push_back(tmp);
|
||||
return;
|
||||
}
|
||||
if( !data )
|
||||
{
|
||||
*this = elems.clone();
|
||||
return;
|
||||
}
|
||||
if( !data )
|
||||
{
|
||||
*this = elems.clone();
|
||||
return;
|
||||
}
|
||||
|
||||
size.p[0] = elems.size.p[0];
|
||||
bool eq = size == elems.size;
|
||||
@ -917,6 +917,7 @@ void scalarToRawData(const Scalar& s, void* _buf, int type, int unroll_to)
|
||||
\*************************************************************************************************/
|
||||
|
||||
_InputArray::_InputArray() : flags(0), obj(0) {}
|
||||
_InputArray::~_InputArray() {}
|
||||
_InputArray::_InputArray(const Mat& m) : flags(MAT), obj((void*)&m) {}
|
||||
_InputArray::_InputArray(const vector<Mat>& vec) : flags(STD_VECTOR_MAT), obj((void*)&vec) {}
|
||||
_InputArray::_InputArray(const double& val) : flags(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F), obj((void*)&val), sz(Size(1,1)) {}
|
||||
@ -1280,6 +1281,7 @@ bool _InputArray::empty() const
|
||||
|
||||
|
||||
_OutputArray::_OutputArray() {}
|
||||
_OutputArray::~_OutputArray() {}
|
||||
_OutputArray::_OutputArray(Mat& m) : _InputArray(m) {}
|
||||
_OutputArray::_OutputArray(vector<Mat>& vec) : _InputArray(vec) {}
|
||||
|
||||
@ -1763,7 +1765,7 @@ transpose_( const uchar* src, size_t sstep, uchar* dst, size_t dstep, Size sz )
|
||||
{
|
||||
int i=0, j, m = sz.width, n = sz.height;
|
||||
|
||||
#if CV_ENABLE_UNROLLED
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for(; i <= m - 4; i += 4 )
|
||||
{
|
||||
T* d0 = (T*)(dst + dstep*i);
|
||||
@ -1795,7 +1797,7 @@ transpose_( const uchar* src, size_t sstep, uchar* dst, size_t dstep, Size sz )
|
||||
{
|
||||
T* d0 = (T*)(dst + dstep*i);
|
||||
j = 0;
|
||||
#if CV_ENABLE_UNROLLED
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for(; j <= n - 4; j += 4 )
|
||||
{
|
||||
const T* s0 = (const T*)(src + i*sizeof(T) + sstep*j);
|
||||
@ -1985,7 +1987,7 @@ reduceR_( const Mat& srcmat, Mat& dstmat )
|
||||
{
|
||||
src += srcstep;
|
||||
i = 0;
|
||||
#if CV_ENABLE_UNROLLED
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for(; i <= size.width - 4; i += 4 )
|
||||
{
|
||||
WT s0, s1;
|
||||
@ -2044,7 +2046,7 @@ reduceC_( const Mat& srcmat, Mat& dstmat )
|
||||
dst[k] = (ST)a0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*ReduceFunc)( const Mat& src, Mat& dst );
|
||||
@ -2577,8 +2579,8 @@ double cv::kmeans( InputArray _data, int K,
|
||||
sample = data.ptr<float>(i);
|
||||
k = labels[i];
|
||||
float* center = centers.ptr<float>(k);
|
||||
j=0;
|
||||
#if CV_ENABLE_UNROLLED
|
||||
j=0;
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for(; j <= dims - 4; j += 4 )
|
||||
{
|
||||
float t0 = center[j] + sample[j];
|
||||
@ -3260,7 +3262,7 @@ convertScaleData_(const void* _from, void* _to, int cn, double alpha, double bet
|
||||
to[i] = saturate_cast<T2>(from[i]*alpha + beta);
|
||||
}
|
||||
|
||||
ConvertData getConvertData(int fromType, int toType)
|
||||
static ConvertData getConvertData(int fromType, int toType)
|
||||
{
|
||||
static ConvertData tab[][8] =
|
||||
{{ convertData_<uchar, uchar>, convertData_<uchar, schar>,
|
||||
@ -3305,7 +3307,7 @@ ConvertData getConvertData(int fromType, int toType)
|
||||
return func;
|
||||
}
|
||||
|
||||
ConvertScaleData getConvertScaleData(int fromType, int toType)
|
||||
static ConvertScaleData getConvertScaleData(int fromType, int toType)
|
||||
{
|
||||
static ConvertScaleData tab[][8] =
|
||||
{{ convertScaleData_<uchar, uchar>, convertScaleData_<uchar, schar>,
|
||||
|
@ -243,7 +243,7 @@ static CFormatter cFormatter;
|
||||
static const Formatter* g_defaultFormatter0 = &matlabFormatter;
|
||||
static const Formatter* g_defaultFormatter = &matlabFormatter;
|
||||
|
||||
bool my_streq(const char* a, const char* b)
|
||||
static bool my_streq(const char* a, const char* b)
|
||||
{
|
||||
size_t i, alen = strlen(a), blen = strlen(b);
|
||||
if( alen != blen )
|
||||
|
@ -72,7 +72,7 @@ static int sum_(const T* src0, const uchar* mask, ST* dst, int len, int cn )
|
||||
{
|
||||
ST s0 = dst[0];
|
||||
|
||||
#if CV_ENABLE_UNROLLED
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for(; i <= len - 4; i += 4, src += cn*4 )
|
||||
s0 += src[0] + src[cn] + src[cn*2] + src[cn*3];
|
||||
#endif
|
||||
@ -155,7 +155,7 @@ static int sum_(const T* src0, const uchar* mask, ST* dst, int len, int cn )
|
||||
if( mask[i] )
|
||||
{
|
||||
int k = 0;
|
||||
#if CV_ENABLE_UNROLLED
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for( ; k <= cn - 4; k += 4 )
|
||||
{
|
||||
ST s0, s1;
|
||||
@ -212,7 +212,7 @@ template<typename T>
|
||||
static int countNonZero_(const T* src, int len )
|
||||
{
|
||||
int i=0, nz = 0;
|
||||
#if CV_ENABLE_UNROLLED
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for(; i <= len - 4; i += 4 )
|
||||
nz += (src[i] != 0) + (src[i+1] != 0) + (src[i+2] != 0) + (src[i+3] != 0);
|
||||
#endif
|
||||
@ -834,7 +834,7 @@ float normL2Sqr_(const float* a, const float* b, int n)
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
{
|
||||
for( ; j <= n - 4; j += 4 )
|
||||
{
|
||||
float t0 = a[j] - b[j], t1 = a[j+1] - b[j+1], t2 = a[j+2] - b[j+2], t3 = a[j+3] - b[j+3];
|
||||
@ -962,7 +962,7 @@ static const uchar popCountTable4[] =
|
||||
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
|
||||
};
|
||||
|
||||
int normHamming(const uchar* a, int n)
|
||||
static int normHamming(const uchar* a, int n)
|
||||
{
|
||||
int i = 0, result = 0;
|
||||
#if CV_NEON
|
||||
@ -1020,7 +1020,7 @@ int normHamming(const uchar* a, const uchar* b, int n)
|
||||
return result;
|
||||
}
|
||||
|
||||
int normHamming(const uchar* a, int n, int cellSize)
|
||||
static int normHamming(const uchar* a, int n, int cellSize)
|
||||
{
|
||||
if( cellSize == 1 )
|
||||
return normHamming(a, n);
|
||||
@ -1053,7 +1053,7 @@ int normHamming(const uchar* a, const uchar* b, int n, int cellSize)
|
||||
else
|
||||
CV_Error( CV_StsBadSize, "bad cell size (not 1, 2 or 4) in normHamming" );
|
||||
int i = 0, result = 0;
|
||||
#if CV_ENABLE_UNROLLED
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for( ; i <= n - 4; i += 4 )
|
||||
result += tab[a[i] ^ b[i]] + tab[a[i+1] ^ b[i+1]] +
|
||||
tab[a[i+2] ^ b[i+2]] + tab[a[i+3] ^ b[i+3]];
|
||||
|
@ -374,7 +374,7 @@ int getThreadNum(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ANDROID
|
||||
#ifdef ANDROID
|
||||
static inline int getNumberOfCPUsImpl()
|
||||
{
|
||||
FILE* cpuPossible = fopen("/sys/devices/system/cpu/possible", "r");
|
||||
@ -421,7 +421,7 @@ int getNumberOfCPUs(void)
|
||||
GetSystemInfo( &sysinfo );
|
||||
|
||||
return (int)sysinfo.dwNumberOfProcessors;
|
||||
#elif ANDROID
|
||||
#elif defined ANDROID
|
||||
static int ncpus = getNumberOfCPUsImpl();
|
||||
printf("CPUS= %d\n", ncpus);
|
||||
return ncpus;
|
||||
@ -475,7 +475,7 @@ string tempfile( const char* suffix )
|
||||
{
|
||||
char buf[L_tmpnam];
|
||||
char* name = 0;
|
||||
#if ANDROID
|
||||
#ifdef ANDROID
|
||||
strcpy(buf, "/sdcard/__opencv_temp_XXXXXX");
|
||||
name = mktemp(buf);
|
||||
#else
|
||||
|
@ -2023,12 +2023,12 @@ void Core_GraphScanTest::run( int )
|
||||
event = "End of procedure";
|
||||
break;
|
||||
default:
|
||||
#if _MSC_VER >= 1200
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4127 )
|
||||
#endif
|
||||
CV_TS_SEQ_CHECK_CONDITION( 0, "Invalid code appeared during graph scan" );
|
||||
#if _MSC_VER >= 1200
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
|
||||
#if GTEST_CREATE_SHARED_LIBRARY
|
||||
#ifdef GTEST_CREATE_SHARED_LIBRARY
|
||||
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
|
||||
#endif
|
||||
|
||||
|
@ -61,7 +61,7 @@ inline int smoothedSum(const Mat& sum, const KeyPoint& pt, int y, int x)
|
||||
+ sum.at<int>(img_y - HALF_KERNEL, img_x - HALF_KERNEL);
|
||||
}
|
||||
|
||||
void pixelTests16(const Mat& sum, const std::vector<KeyPoint>& keypoints, Mat& descriptors)
|
||||
static void pixelTests16(const Mat& sum, const std::vector<KeyPoint>& keypoints, Mat& descriptors)
|
||||
{
|
||||
for (int i = 0; i < (int)keypoints.size(); ++i)
|
||||
{
|
||||
@ -71,7 +71,7 @@ void pixelTests16(const Mat& sum, const std::vector<KeyPoint>& keypoints, Mat& d
|
||||
}
|
||||
}
|
||||
|
||||
void pixelTests32(const Mat& sum, const std::vector<KeyPoint>& keypoints, Mat& descriptors)
|
||||
static void pixelTests32(const Mat& sum, const std::vector<KeyPoint>& keypoints, Mat& descriptors)
|
||||
{
|
||||
for (int i = 0; i < (int)keypoints.size(); ++i)
|
||||
{
|
||||
@ -82,7 +82,7 @@ void pixelTests32(const Mat& sum, const std::vector<KeyPoint>& keypoints, Mat& d
|
||||
}
|
||||
}
|
||||
|
||||
void pixelTests64(const Mat& sum, const std::vector<KeyPoint>& keypoints, Mat& descriptors)
|
||||
static void pixelTests64(const Mat& sum, const std::vector<KeyPoint>& keypoints, Mat& descriptors)
|
||||
{
|
||||
for (int i = 0; i < (int)keypoints.size(); ++i)
|
||||
{
|
||||
|
@ -117,7 +117,7 @@ OpponentColorDescriptorExtractor::OpponentColorDescriptorExtractor( const Ptr<De
|
||||
CV_Assert( !descriptorExtractor.empty() );
|
||||
}
|
||||
|
||||
void convertBGRImageToOpponentColorSpace( const Mat& bgrImage, vector<Mat>& opponentChannels )
|
||||
static void convertBGRImageToOpponentColorSpace( const Mat& bgrImage, vector<Mat>& opponentChannels )
|
||||
{
|
||||
if( bgrImage.type() != CV_8UC3 )
|
||||
CV_Error( CV_StsBadArg, "input image must be an BGR image of type CV_8UC3" );
|
||||
|
@ -150,12 +150,12 @@ void GFTTDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, co
|
||||
* DenseFeatureDetector
|
||||
*/
|
||||
DenseFeatureDetector::DenseFeatureDetector( float _initFeatureScale, int _featureScaleLevels,
|
||||
float _featureScaleMul, int _initXyStep,
|
||||
int _initImgBound, bool _varyXyStepWithScale,
|
||||
bool _varyImgBoundWithScale ) :
|
||||
initFeatureScale(_initFeatureScale), featureScaleLevels(_featureScaleLevels),
|
||||
featureScaleMul(_featureScaleMul), initXyStep(_initXyStep), initImgBound(_initImgBound),
|
||||
varyXyStepWithScale(_varyXyStepWithScale), varyImgBoundWithScale(_varyImgBoundWithScale)
|
||||
float _featureScaleMul, int _initXyStep,
|
||||
int _initImgBound, bool _varyXyStepWithScale,
|
||||
bool _varyImgBoundWithScale ) :
|
||||
initFeatureScale(_initFeatureScale), featureScaleLevels(_featureScaleLevels),
|
||||
featureScaleMul(_featureScaleMul), initXyStep(_initXyStep), initImgBound(_initImgBound),
|
||||
varyXyStepWithScale(_varyXyStepWithScale), varyImgBoundWithScale(_varyImgBoundWithScale)
|
||||
{}
|
||||
|
||||
|
||||
@ -203,7 +203,7 @@ struct ResponseComparator
|
||||
}
|
||||
};
|
||||
|
||||
void keepStrongest( int N, vector<KeyPoint>& keypoints )
|
||||
static void keepStrongest( int N, vector<KeyPoint>& keypoints )
|
||||
{
|
||||
if( (int)keypoints.size() > N )
|
||||
{
|
||||
|
@ -42,8 +42,7 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
using namespace cv;
|
||||
|
||||
/////////////////////// AlgorithmInfo for various detector & descriptors ////////////////////////////
|
||||
|
||||
@ -134,22 +133,23 @@ CV_INIT_ALGORITHM(DenseFeatureDetector, "Feature2D.Dense",
|
||||
obj.info()->addParam(obj, "varyImgBoundWithScale", obj.varyImgBoundWithScale));
|
||||
|
||||
CV_INIT_ALGORITHM(GridAdaptedFeatureDetector, "Feature2D.Grid",
|
||||
obj.info()->addParam(obj, "detector", (Ptr<Algorithm>&)obj.detector);
|
||||
//obj.info()->addParam(obj, "detector", (Ptr<Algorithm>&)obj.detector);
|
||||
obj.info()->addParam(obj, "maxTotalKeypoints", obj.maxTotalKeypoints);
|
||||
obj.info()->addParam(obj, "gridRows", obj.gridRows);
|
||||
obj.info()->addParam(obj, "gridCols", obj.gridCols));
|
||||
|
||||
bool initModule_features2d(void)
|
||||
bool cv::initModule_features2d(void)
|
||||
{
|
||||
Ptr<Algorithm> brief = createBriefDescriptorExtractor(), orb = createORB(),
|
||||
star = createStarDetector(), fastd = createFastFeatureDetector(), mser = createMSER(),
|
||||
dense = createDenseFeatureDetector(), gftt = createGFTTDetector(),
|
||||
harris = createHarrisDetector(), grid = createGridAdaptedFeatureDetector();
|
||||
bool all = true;
|
||||
all &= !BriefDescriptorExtractor_info_auto.name().empty();
|
||||
all &= !FastFeatureDetector_info_auto.name().empty();
|
||||
all &= !StarDetector_info_auto.name().empty();
|
||||
all &= !MSER_info_auto.name().empty();
|
||||
all &= !ORB_info_auto.name().empty();
|
||||
all &= !GFTTDetector_info_auto.name().empty();
|
||||
all &= !HarrisDetector_info_auto.name().empty();
|
||||
all &= !DenseFeatureDetector_info_auto.name().empty();
|
||||
all &= !GridAdaptedFeatureDetector_info_auto.name().empty();
|
||||
|
||||
return brief->info() != 0 && orb->info() != 0 && star->info() != 0 &&
|
||||
fastd->info() != 0 && mser->info() != 0 && dense->info() != 0 &&
|
||||
gftt->info() != 0 && harris->info() != 0 && grid->info() != 0;
|
||||
return all;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ int DescriptorMatcher::DescriptorCollection::size() const
|
||||
/*
|
||||
* DescriptorMatcher
|
||||
*/
|
||||
void convertMatches( const vector<vector<DMatch> >& knnMatches, vector<DMatch>& matches )
|
||||
static void convertMatches( const vector<vector<DMatch> >& knnMatches, vector<DMatch>& matches )
|
||||
{
|
||||
matches.clear();
|
||||
matches.reserve( knnMatches.size() );
|
||||
|
@ -43,7 +43,7 @@
|
||||
#ifndef __OPENCV_PRECOMP_H__
|
||||
#define __OPENCV_PRECOMP_H__
|
||||
|
||||
#if _MSC_VER >= 1200
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning( disable: 4251 4512 4710 4711 4514 4996 )
|
||||
#endif
|
||||
|
||||
|
@ -493,23 +493,6 @@ private:
|
||||
CV_DescriptorExtractorTest& operator=(const CV_DescriptorExtractorTest&) { return *this; }
|
||||
};
|
||||
|
||||
/*template<typename T, typename Distance>
|
||||
class CV_CalonderDescriptorExtractorTest : public CV_DescriptorExtractorTest<Distance>
|
||||
{
|
||||
public:
|
||||
CV_CalonderDescriptorExtractorTest( const char* testName, float _normDif, float _prevTime ) :
|
||||
CV_DescriptorExtractorTest<Distance>( testName, _normDif, Ptr<DescriptorExtractor>(), _prevTime )
|
||||
{}
|
||||
|
||||
protected:
|
||||
virtual void createDescriptorExtractor()
|
||||
{
|
||||
CV_DescriptorExtractorTest<Distance>::dextractor =
|
||||
new CalonderDescriptorExtractor<T>( string(CV_DescriptorExtractorTest<Distance>::ts->get_data_path()) +
|
||||
FEATURES2D_DIR + "/calonder_classifier.rtc");
|
||||
}
|
||||
};*/
|
||||
|
||||
/****************************************************************************************\
|
||||
* Algorithmic tests for descriptor matchers *
|
||||
\****************************************************************************************/
|
||||
@ -1059,24 +1042,6 @@ TEST( Features2d_DescriptorExtractor_BRIEF, regression )
|
||||
test.safe_run();
|
||||
}
|
||||
|
||||
#if CV_SSE2
|
||||
TEST( Features2d_DescriptorExtractor_Calonder_uchar, regression )
|
||||
{
|
||||
CV_CalonderDescriptorExtractorTest<uchar, L2<uchar> > test( "descriptor-calonder-uchar",
|
||||
std::numeric_limits<float>::epsilon() + 1,
|
||||
0.0132175f );
|
||||
test.safe_run();
|
||||
}
|
||||
|
||||
TEST( Features2d_DescriptorExtractor_Calonder_float, regression )
|
||||
{
|
||||
CV_CalonderDescriptorExtractorTest<float, L2<float> > test( "descriptor-calonder-float",
|
||||
std::numeric_limits<float>::epsilon(),
|
||||
0.0221308f );
|
||||
test.safe_run();
|
||||
}
|
||||
#endif // CV_SSE2
|
||||
|
||||
/*
|
||||
* Matchers
|
||||
*/
|
||||
|
@ -46,6 +46,7 @@ struct base_any_policy
|
||||
virtual ::size_t get_size() = 0;
|
||||
virtual const std::type_info& type() = 0;
|
||||
virtual void print(std::ostream& out, void* const* src) = 0;
|
||||
virtual ~base_any_policy() {}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
@ -35,6 +35,9 @@
|
||||
#ifndef OPENCV_FLANN_DYNAMIC_BITSET_H_
|
||||
#define OPENCV_FLANN_DYNAMIC_BITSET_H_
|
||||
|
||||
#ifndef FLANN_USE_BOOST
|
||||
# define FLANN_USE_BOOST 0
|
||||
#endif
|
||||
//#define FLANN_USE_BOOST 1
|
||||
#if FLANN_USE_BOOST
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
|
@ -40,6 +40,11 @@
|
||||
#include <iomanip>
|
||||
#include <limits.h>
|
||||
// TODO as soon as we use C++0x, use the code in USE_UNORDERED_MAP
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
# define USE_UNORDERED_MAP 1
|
||||
#else
|
||||
# define USE_UNORDERED_MAP 0
|
||||
#endif
|
||||
#if USE_UNORDERED_MAP
|
||||
#include <unordered_map>
|
||||
#else
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include "perf_utility.hpp"
|
||||
|
||||
#if GTEST_CREATE_SHARED_LIBRARY
|
||||
#ifdef GTEST_CREATE_SHARED_LIBRARY
|
||||
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
|
||||
#endif
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "perf_utility.hpp"
|
||||
|
||||
#if GTEST_CREATE_SHARED_LIBRARY
|
||||
#ifdef GTEST_CREATE_SHARED_LIBRARY
|
||||
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
|
||||
#endif
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
#ifndef __OPENCV_PRECOMP_H__
|
||||
#define __OPENCV_PRECOMP_H__
|
||||
|
||||
#if _MSC_VER >= 1200
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning( disable: 4251 4710 4711 4514 4996 )
|
||||
#endif
|
||||
|
||||
|
@ -81,6 +81,10 @@ if(HAVE_QT)
|
||||
|
||||
list(APPEND HIGHGUI_LIBRARIES ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY})
|
||||
list(APPEND highgui_srcs src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES} )
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set_source_files_properties(${_RCC_OUTFILES} PROPERTIES COMPILE_FLAGS "-Wno-missing-declarations")
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
list(APPEND highgui_srcs src/window_w32.cpp)
|
||||
elseif(HAVE_GTK)
|
||||
@ -131,6 +135,10 @@ if(HAVE_OPENNI)
|
||||
list(APPEND highgui_srcs src/cap_openni.cpp)
|
||||
ocv_include_directories(${OPENNI_INCLUDE_DIR})
|
||||
list(APPEND HIGHGUI_LIBRARIES ${OPENNI_LIBRARY})
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set_source_files_properties(src/cap_openni.cpp PROPERTIES COMPILE_FLAGS "-Wno-unknown-pragmas -Wno-uninitialized -Wno-reorder -Wno-strict-aliasing")
|
||||
endif()
|
||||
endif(HAVE_OPENNI)
|
||||
|
||||
if(HAVE_opencv_androidcamera)
|
||||
|
@ -79,7 +79,7 @@ CVAPI(void) cvDisplayStatusBar(const char* name, const char* text, int delayms C
|
||||
CVAPI(void) cvSaveWindowParameters(const char* name);
|
||||
CVAPI(void) cvLoadWindowParameters(const char* name);
|
||||
CVAPI(int) cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
|
||||
CVAPI(void) cvStopLoop();
|
||||
CVAPI(void) cvStopLoop( void );
|
||||
|
||||
typedef void (CV_CDECL *CvButtonCallback)(int state, void* userdata);
|
||||
enum {CV_PUSH_BUTTON = 0, CV_CHECKBOX = 1, CV_RADIOBOX = 2};
|
||||
@ -90,7 +90,7 @@ CVAPI(int) cvCreateButton( const char* button_name CV_DEFAULT(NULL),CvButtonCall
|
||||
/* this function is used to set some external parameters in case of X Window */
|
||||
CVAPI(int) cvInitSystem( int argc, char** argv );
|
||||
|
||||
CVAPI(int) cvStartWindowThread();
|
||||
CVAPI(int) cvStartWindowThread( void );
|
||||
|
||||
// --------- YV ---------
|
||||
enum
|
||||
@ -306,7 +306,7 @@ enum
|
||||
|
||||
CV_CAP_XIAPI =1100, // XIMEA Camera API
|
||||
|
||||
CV_CAP_AVFOUNDATION = 1200 // AVFoundation framework for iOS (OS X Lion will have the same API)
|
||||
CV_CAP_AVFOUNDATION = 1200 // AVFoundation framework for iOS (OS X Lion will have the same API)
|
||||
};
|
||||
|
||||
/* start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) */
|
||||
@ -371,11 +371,11 @@ enum
|
||||
CV_CAP_PROP_GUID =29,
|
||||
CV_CAP_PROP_ISO_SPEED =30,
|
||||
CV_CAP_PROP_MAX_DC1394 =31,
|
||||
CV_CAP_PROP_BACKLIGHT =32,
|
||||
CV_CAP_PROP_PAN =33,
|
||||
CV_CAP_PROP_TILT =34,
|
||||
CV_CAP_PROP_ROLL =35,
|
||||
CV_CAP_PROP_IRIS =36,
|
||||
CV_CAP_PROP_BACKLIGHT =32,
|
||||
CV_CAP_PROP_PAN =33,
|
||||
CV_CAP_PROP_TILT =34,
|
||||
CV_CAP_PROP_ROLL =35,
|
||||
CV_CAP_PROP_IRIS =36,
|
||||
CV_CAP_PROP_SETTINGS =37,
|
||||
|
||||
CV_CAP_PROP_AUTOGRAB =1024, // property for highgui class CvCapture_Android only
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "opencv2/ts/ts.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
|
||||
#if GTEST_CREATE_SHARED_LIBRARY
|
||||
#ifdef GTEST_CREATE_SHARED_LIBRARY
|
||||
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
|
||||
#endif
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#if _MSC_VER >= 1200
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning( disable: 4711 )
|
||||
#endif
|
||||
|
||||
@ -378,20 +378,20 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
|
||||
CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
|
||||
double fps, CvSize frameSize, int is_color )
|
||||
{
|
||||
//CV_FUNCNAME( "cvCreateVideoWriter" );
|
||||
//CV_FUNCNAME( "cvCreateVideoWriter" );
|
||||
|
||||
CvVideoWriter *result = 0;
|
||||
CvVideoWriter *result = 0;
|
||||
|
||||
if(!fourcc || !fps)
|
||||
result = cvCreateVideoWriter_Images(filename);
|
||||
if(!fourcc || !fps)
|
||||
result = cvCreateVideoWriter_Images(filename);
|
||||
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_FFMPEG_proxy (filename, fourcc, fps, frameSize, is_color);
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_FFMPEG_proxy (filename, fourcc, fps, frameSize, is_color);
|
||||
|
||||
/* #ifdef HAVE_XINE
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_XINE(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
/* #ifdef HAVE_XINE
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_XINE(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
*/
|
||||
#ifdef HAVE_AVFOUNDATION
|
||||
if (! result)
|
||||
@ -399,8 +399,8 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_QUICKTIME
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_QT(filename, fourcc, fps, frameSize, is_color);
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_QT(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GSTREAMER
|
||||
@ -408,10 +408,10 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
|
||||
result = cvCreateVideoWriter_GStreamer(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_Images(filename);
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_Images(filename);
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
CV_IMPL int cvWriteFrame( CvVideoWriter* writer, const IplImage* image )
|
||||
|
@ -140,7 +140,7 @@ extern "C" {
|
||||
#define AV_NOPTS_VALUE_ ((int64_t)AV_NOPTS_VALUE)
|
||||
#endif
|
||||
|
||||
int get_number_of_cpus(void)
|
||||
static int get_number_of_cpus(void)
|
||||
{
|
||||
#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(52, 111, 0)
|
||||
return 1;
|
||||
@ -210,7 +210,7 @@ struct CvCapture_FFMPEG
|
||||
|
||||
void seek(int64_t frame_number);
|
||||
void seek(double sec);
|
||||
bool slowSeek( int framenumber );
|
||||
bool slowSeek( int framenumber );
|
||||
|
||||
int64_t get_total_frames();
|
||||
double get_duration_sec();
|
||||
@ -293,9 +293,9 @@ void CvCapture_FFMPEG::close()
|
||||
if( ic )
|
||||
{
|
||||
#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(53, 24, 2)
|
||||
av_close_input_file(ic);
|
||||
av_close_input_file(ic);
|
||||
#else
|
||||
avformat_close_input(&ic);
|
||||
avformat_close_input(&ic);
|
||||
#endif
|
||||
|
||||
ic = NULL;
|
||||
@ -771,7 +771,7 @@ struct CvVideoWriter_FFMPEG
|
||||
|
||||
void init();
|
||||
|
||||
AVOutputFormat * fmt;
|
||||
AVOutputFormat * fmt;
|
||||
AVFormatContext * oc;
|
||||
uint8_t * outbuf;
|
||||
uint32_t outbuf_size;
|
||||
@ -1010,7 +1010,7 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
|
||||
|
||||
static const int OPENCV_NO_FRAMES_WRITTEN_CODE = 1000;
|
||||
|
||||
int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st, uint8_t * outbuf, uint32_t outbuf_size, AVFrame * picture )
|
||||
static int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st, uint8_t * outbuf, uint32_t outbuf_size, AVFrame * picture )
|
||||
{
|
||||
#if LIBAVFORMAT_BUILD > 4628
|
||||
AVCodecContext * c = video_st->codec;
|
||||
@ -1046,7 +1046,7 @@ int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st, uint8_
|
||||
|
||||
#if LIBAVFORMAT_BUILD > 4752
|
||||
if(c->coded_frame->pts != (int64_t)AV_NOPTS_VALUE)
|
||||
pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base, video_st->time_base);
|
||||
pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base, video_st->time_base);
|
||||
#else
|
||||
pkt.pts = c->coded_frame->pts;
|
||||
#endif
|
||||
|
@ -50,6 +50,20 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <queue>
|
||||
|
||||
#ifndef i386
|
||||
# define i386 0
|
||||
#endif
|
||||
#ifndef __arm__
|
||||
# define __arm__ 0
|
||||
#endif
|
||||
#ifndef _ARC
|
||||
# define _ARC 0
|
||||
#endif
|
||||
#ifndef __APPLE__
|
||||
# define __APPLE__ 0
|
||||
#endif
|
||||
|
||||
#include "XnCppWrapper.h"
|
||||
|
||||
const std::string XMLConfig =
|
||||
@ -169,6 +183,8 @@ private:
|
||||
approxSyncGrabber(approxSyncGrabber), isDepthFilled(false), isImageFilled(false)
|
||||
{}
|
||||
|
||||
virtual ~ApproximateSynchronizerBase() {}
|
||||
|
||||
virtual bool isSpinContinue() const = 0;
|
||||
virtual void pushDepthMetaData( xn::DepthMetaData& depthMetaData ) = 0;
|
||||
virtual void pushImageMetaData( xn::ImageMetaData& imageMetaData ) = 0;
|
||||
@ -508,14 +524,14 @@ bool CvCapture_OpenNI::isOpened() const
|
||||
return isContextOpened;
|
||||
}
|
||||
|
||||
XnMapOutputMode defaultMapOutputMode()
|
||||
{
|
||||
XnMapOutputMode mode;
|
||||
mode.nXRes = XN_VGA_X_RES;
|
||||
mode.nYRes = XN_VGA_Y_RES;
|
||||
mode.nFPS = 30;
|
||||
return mode;
|
||||
}
|
||||
// static XnMapOutputMode defaultMapOutputMode()
|
||||
// {
|
||||
// XnMapOutputMode mode;
|
||||
// mode.nXRes = XN_VGA_X_RES;
|
||||
// mode.nYRes = XN_VGA_Y_RES;
|
||||
// mode.nFPS = 30;
|
||||
// return mode;
|
||||
// }
|
||||
|
||||
|
||||
CvCapture_OpenNI::CvCapture_OpenNI( int index )
|
||||
@ -1201,7 +1217,7 @@ IplImage* CvCapture_OpenNI::retrievePointCloudMap()
|
||||
return outputMaps[CV_CAP_OPENNI_POINT_CLOUD_MAP].getIplImagePtr();
|
||||
}
|
||||
|
||||
void computeDisparity_32F( const xn::DepthMetaData& depthMetaData, cv::Mat& disp, XnDouble baseline, XnUInt64 F,
|
||||
static void computeDisparity_32F( const xn::DepthMetaData& depthMetaData, cv::Mat& disp, XnDouble baseline, XnUInt64 F,
|
||||
XnUInt64 noSampleValue, XnUInt64 shadowValue )
|
||||
{
|
||||
cv::Mat depth;
|
||||
|
@ -126,8 +126,7 @@ skip_input_data(j_decompress_ptr cinfo, long num_bytes)
|
||||
}
|
||||
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_buffer_src(j_decompress_ptr cinfo, JpegSource* source)
|
||||
static void jpeg_buffer_src(j_decompress_ptr cinfo, JpegSource* source)
|
||||
{
|
||||
cinfo->src = &source->pub;
|
||||
|
||||
@ -498,8 +497,7 @@ empty_output_buffer (j_compress_ptr cinfo)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_buffer_dest(j_compress_ptr cinfo, JpegDestination* destination)
|
||||
static void jpeg_buffer_dest(j_compress_ptr cinfo, JpegDestination* destination)
|
||||
{
|
||||
cinfo->dest = &destination->pub;
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace cv
|
||||
static vector<ImageDecoder> decoders;
|
||||
static vector<ImageEncoder> encoders;
|
||||
|
||||
ImageDecoder findDecoder( const string& filename )
|
||||
static ImageDecoder findDecoder( const string& filename )
|
||||
{
|
||||
size_t i, maxlen = 0;
|
||||
for( i = 0; i < decoders.size(); i++ )
|
||||
@ -83,7 +83,7 @@ ImageDecoder findDecoder( const string& filename )
|
||||
return ImageDecoder();
|
||||
}
|
||||
|
||||
ImageDecoder findDecoder( const Mat& buf )
|
||||
static ImageDecoder findDecoder( const Mat& buf )
|
||||
{
|
||||
size_t i, maxlen = 0;
|
||||
|
||||
@ -110,7 +110,7 @@ ImageDecoder findDecoder( const Mat& buf )
|
||||
return ImageDecoder();
|
||||
}
|
||||
|
||||
ImageEncoder findEncoder( const string& _ext )
|
||||
static ImageEncoder findEncoder( const string& _ext )
|
||||
{
|
||||
if( _ext.size() <= 1 )
|
||||
return ImageEncoder();
|
||||
|
@ -42,7 +42,7 @@
|
||||
#ifndef __HIGHGUI_H_
|
||||
#define __HIGHGUI_H_
|
||||
|
||||
#if _MSC_VER >= 1200
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning( disable: 4251 )
|
||||
#endif
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1372,17 +1372,17 @@ cvDestroyAllWindows( void )
|
||||
CV_UNLOCK_MUTEX();
|
||||
}
|
||||
|
||||
CvSize icvCalcOptimalWindowSize( CvWindow * window, CvSize new_image_size){
|
||||
CvSize window_size;
|
||||
GtkWidget * toplevel = gtk_widget_get_toplevel( window->frame );
|
||||
gdk_drawable_get_size( GDK_DRAWABLE(toplevel->window),
|
||||
&window_size.width, &window_size.height );
|
||||
// CvSize icvCalcOptimalWindowSize( CvWindow * window, CvSize new_image_size){
|
||||
// CvSize window_size;
|
||||
// GtkWidget * toplevel = gtk_widget_get_toplevel( window->frame );
|
||||
// gdk_drawable_get_size( GDK_DRAWABLE(toplevel->window),
|
||||
// &window_size.width, &window_size.height );
|
||||
|
||||
window_size.width = window_size.width + new_image_size.width - window->widget->allocation.width;
|
||||
window_size.height = window_size.height + new_image_size.height - window->widget->allocation.height;
|
||||
// window_size.width = window_size.width + new_image_size.width - window->widget->allocation.width;
|
||||
// window_size.height = window_size.height + new_image_size.height - window->widget->allocation.height;
|
||||
|
||||
return window_size;
|
||||
}
|
||||
// return window_size;
|
||||
// }
|
||||
|
||||
CV_IMPL void
|
||||
cvShowImage( const char* name, const CvArr* arr )
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
|
||||
#if GTEST_CREATE_SHARED_LIBRARY
|
||||
#ifdef GTEST_CREATE_SHARED_LIBRARY
|
||||
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
|
||||
#endif
|
||||
|
||||
|
@ -98,6 +98,7 @@ typedef struct _list _CVLIST;
|
||||
_LIST_INLINE CVPOS prefix##get_tail_pos_##type(_CVLIST*);\
|
||||
_LIST_INLINE type* prefix##get_next_##type(CVPOS*);\
|
||||
_LIST_INLINE type* prefix##get_prev_##type(CVPOS*);\
|
||||
_LIST_INLINE int prefix##is_pos_##type(CVPOS pos);\
|
||||
/* Modification functions*/\
|
||||
_LIST_INLINE void prefix##clear_list_##type(_CVLIST*);\
|
||||
_LIST_INLINE CVPOS prefix##add_head_##type(_CVLIST*, type*);\
|
||||
|
@ -233,7 +233,7 @@ typedef DiffC3<cv::Vec3i> Diff32sC3;
|
||||
typedef DiffC1<float> Diff32fC1;
|
||||
typedef DiffC3<cv::Vec3f> Diff32fC3;
|
||||
|
||||
cv::Vec3i& operator += (cv::Vec3i& a, const cv::Vec3b& b)
|
||||
static cv::Vec3i& operator += (cv::Vec3i& a, const cv::Vec3b& b)
|
||||
{
|
||||
a[0] += b[0];
|
||||
a[1] += b[1];
|
||||
|
@ -230,7 +230,7 @@ void GMM::calcInverseCovAndDeterm( int ci )
|
||||
Calculate beta - parameter of GrabCut algorithm.
|
||||
beta = 1/(2*avg(sqr(||color[i] - color[j]||)))
|
||||
*/
|
||||
double calcBeta( const Mat& img )
|
||||
static double calcBeta( const Mat& img )
|
||||
{
|
||||
double beta = 0;
|
||||
for( int y = 0; y < img.rows; y++ )
|
||||
@ -272,7 +272,7 @@ double calcBeta( const Mat& img )
|
||||
Calculate weights of noterminal vertices of graph.
|
||||
beta and gamma - parameters of GrabCut algorithm.
|
||||
*/
|
||||
void calcNWeights( const Mat& img, Mat& leftW, Mat& upleftW, Mat& upW, Mat& uprightW, double beta, double gamma )
|
||||
static void calcNWeights( const Mat& img, Mat& leftW, Mat& upleftW, Mat& upW, Mat& uprightW, double beta, double gamma )
|
||||
{
|
||||
const double gammaDivSqrt2 = gamma / std::sqrt(2.0f);
|
||||
leftW.create( img.rows, img.cols, CV_64FC1 );
|
||||
@ -319,7 +319,7 @@ void calcNWeights( const Mat& img, Mat& leftW, Mat& upleftW, Mat& upW, Mat& upri
|
||||
/*
|
||||
Check size, type and element values of mask matrix.
|
||||
*/
|
||||
void checkMask( const Mat& img, const Mat& mask )
|
||||
static void checkMask( const Mat& img, const Mat& mask )
|
||||
{
|
||||
if( mask.empty() )
|
||||
CV_Error( CV_StsBadArg, "mask is empty" );
|
||||
@ -342,7 +342,7 @@ void checkMask( const Mat& img, const Mat& mask )
|
||||
/*
|
||||
Initialize mask using rectangular.
|
||||
*/
|
||||
void initMaskWithRect( Mat& mask, Size imgSize, Rect rect )
|
||||
static void initMaskWithRect( Mat& mask, Size imgSize, Rect rect )
|
||||
{
|
||||
mask.create( imgSize, CV_8UC1 );
|
||||
mask.setTo( GC_BGD );
|
||||
@ -358,7 +358,7 @@ void initMaskWithRect( Mat& mask, Size imgSize, Rect rect )
|
||||
/*
|
||||
Initialize GMM background and foreground models using kmeans algorithm.
|
||||
*/
|
||||
void initGMMs( const Mat& img, const Mat& mask, GMM& bgdGMM, GMM& fgdGMM )
|
||||
static void initGMMs( const Mat& img, const Mat& mask, GMM& bgdGMM, GMM& fgdGMM )
|
||||
{
|
||||
const int kMeansItCount = 10;
|
||||
const int kMeansType = KMEANS_PP_CENTERS;
|
||||
@ -398,7 +398,7 @@ void initGMMs( const Mat& img, const Mat& mask, GMM& bgdGMM, GMM& fgdGMM )
|
||||
/*
|
||||
Assign GMMs components for each pixel.
|
||||
*/
|
||||
void assignGMMsComponents( const Mat& img, const Mat& mask, const GMM& bgdGMM, const GMM& fgdGMM, Mat& compIdxs )
|
||||
static void assignGMMsComponents( const Mat& img, const Mat& mask, const GMM& bgdGMM, const GMM& fgdGMM, Mat& compIdxs )
|
||||
{
|
||||
Point p;
|
||||
for( p.y = 0; p.y < img.rows; p.y++ )
|
||||
@ -415,7 +415,7 @@ void assignGMMsComponents( const Mat& img, const Mat& mask, const GMM& bgdGMM, c
|
||||
/*
|
||||
Learn GMMs parameters.
|
||||
*/
|
||||
void learnGMMs( const Mat& img, const Mat& mask, const Mat& compIdxs, GMM& bgdGMM, GMM& fgdGMM )
|
||||
static void learnGMMs( const Mat& img, const Mat& mask, const Mat& compIdxs, GMM& bgdGMM, GMM& fgdGMM )
|
||||
{
|
||||
bgdGMM.initLearning();
|
||||
fgdGMM.initLearning();
|
||||
@ -443,7 +443,7 @@ void learnGMMs( const Mat& img, const Mat& mask, const Mat& compIdxs, GMM& bgdGM
|
||||
/*
|
||||
Construct GCGraph
|
||||
*/
|
||||
void constructGCGraph( const Mat& img, const Mat& mask, const GMM& bgdGMM, const GMM& fgdGMM, double lambda,
|
||||
static void constructGCGraph( const Mat& img, const Mat& mask, const GMM& bgdGMM, const GMM& fgdGMM, double lambda,
|
||||
const Mat& leftW, const Mat& upleftW, const Mat& upW, const Mat& uprightW,
|
||||
GCGraph<double>& graph )
|
||||
{
|
||||
@ -506,7 +506,7 @@ void constructGCGraph( const Mat& img, const Mat& mask, const GMM& bgdGMM, const
|
||||
/*
|
||||
Estimate segmentation using MaxFlow algorithm
|
||||
*/
|
||||
void estimateSegmentation( GCGraph<double>& graph, Mat& mask )
|
||||
static void estimateSegmentation( GCGraph<double>& graph, Mat& mask )
|
||||
{
|
||||
graph.maxFlow();
|
||||
Point p;
|
||||
|
@ -842,7 +842,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
|
||||
acols = accum->cols - 2;
|
||||
adata = accum->data.i;
|
||||
astep = accum->step/sizeof(adata[0]);
|
||||
// Accumulate circle evidence for each edge pixel
|
||||
// Accumulate circle evidence for each edge pixel
|
||||
for( y = 0; y < rows; y++ )
|
||||
{
|
||||
const uchar* edges_row = edges->data.ptr + y*edges->step;
|
||||
@ -868,7 +868,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
|
||||
|
||||
x0 = cvRound((x*idp)*ONE);
|
||||
y0 = cvRound((y*idp)*ONE);
|
||||
// Step from min_radius to max_radius in both directions of the gradient
|
||||
// Step from min_radius to max_radius in both directions of the gradient
|
||||
for( k = 0; k < 2; k++ )
|
||||
{
|
||||
x1 = x0 + min_radius * sx;
|
||||
@ -894,7 +894,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
|
||||
nz_count = nz->total;
|
||||
if( !nz_count )
|
||||
return;
|
||||
//Find possible circle centers
|
||||
//Find possible circle centers
|
||||
for( y = 1; y < arows - 1; y++ )
|
||||
{
|
||||
for( x = 1; x < acols - 1; x++ )
|
||||
@ -924,19 +924,19 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
|
||||
dr = dp;
|
||||
min_dist = MAX( min_dist, dp );
|
||||
min_dist *= min_dist;
|
||||
// For each found possible center
|
||||
// Estimate radius and check support
|
||||
// For each found possible center
|
||||
// Estimate radius and check support
|
||||
for( i = 0; i < centers->total; i++ )
|
||||
{
|
||||
int ofs = *(int*)cvGetSeqElem( centers, i );
|
||||
y = ofs/(acols+2);
|
||||
x = ofs - (y)*(acols+2);
|
||||
//Calculate circle's center in pixels
|
||||
//Calculate circle's center in pixels
|
||||
float cx = (float)((x + 0.5f)*dp), cy = (float)(( y + 0.5f )*dp);
|
||||
float start_dist, dist_sum;
|
||||
float r_best = 0, c[3];
|
||||
int max_count = 0;
|
||||
// Check distance with previously detected circles
|
||||
// Check distance with previously detected circles
|
||||
for( j = 0; j < circles->total; j++ )
|
||||
{
|
||||
float* c = (float*)cvGetSeqElem( circles, j );
|
||||
@ -946,7 +946,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
|
||||
|
||||
if( j < circles->total )
|
||||
continue;
|
||||
// Estimate best radius
|
||||
// Estimate best radius
|
||||
cvStartReadSeq( nz, &reader );
|
||||
for( j = k = 0; j < nz_count; j++ )
|
||||
{
|
||||
@ -993,7 +993,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
|
||||
}
|
||||
dist_sum += d;
|
||||
}
|
||||
// Check if the circle has enough support
|
||||
// Check if the circle has enough support
|
||||
if( max_count > acc_threshold )
|
||||
{
|
||||
c[0] = cx;
|
||||
|
@ -406,7 +406,7 @@ static void fftShift(InputOutputArray _out)
|
||||
merge(planes, out);
|
||||
}
|
||||
|
||||
Point2d weightedCentroid(InputArray _src, cv::Point peakLocation, cv::Size weightBoxSize)
|
||||
static Point2d weightedCentroid(InputArray _src, cv::Point peakLocation, cv::Size weightBoxSize)
|
||||
{
|
||||
Mat src = _src.getMat();
|
||||
|
||||
|
@ -454,7 +454,7 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
|
||||
namespace cv
|
||||
{
|
||||
|
||||
#if _MSC_VER >= 1200
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning( disable: 4244 )
|
||||
#endif
|
||||
|
||||
@ -734,7 +734,7 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
|
||||
}
|
||||
|
||||
|
||||
#if _MSC_VER >= 1200
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning( default: 4244 )
|
||||
#endif
|
||||
|
||||
@ -1481,7 +1481,7 @@ bilateralFilter_32f( const Mat& src, Mat& dst, int d,
|
||||
|
||||
for( i = 0; i < size.height; i++ )
|
||||
{
|
||||
const float* sptr = (const float*)(temp.data + (i+radius)*temp.step) + radius*cn;
|
||||
const float* sptr = (const float*)(temp.data + (i+radius)*temp.step) + radius*cn;
|
||||
float* dptr = (float*)(dst.data + i*dst.step);
|
||||
|
||||
if( cn == 1 )
|
||||
@ -1493,11 +1493,11 @@ bilateralFilter_32f( const Mat& src, Mat& dst, int d,
|
||||
for( k = 0; k < maxk; k++ )
|
||||
{
|
||||
float val = sptr[j + space_ofs[k]];
|
||||
float alpha = (float)(std::abs(val - val0)*scale_index);
|
||||
float alpha = (float)(std::abs(val - val0)*scale_index);
|
||||
int idx = cvFloor(alpha);
|
||||
alpha -= idx;
|
||||
float w = space_weight[k]*(expLUT[idx] + alpha*(expLUT[idx+1] - expLUT[idx]));
|
||||
sum += val*w;
|
||||
sum += val*w;
|
||||
wsum += w;
|
||||
}
|
||||
dptr[j] = (float)(sum/wsum);
|
||||
@ -1514,7 +1514,7 @@ bilateralFilter_32f( const Mat& src, Mat& dst, int d,
|
||||
{
|
||||
const float* sptr_k = sptr + j + space_ofs[k];
|
||||
float b = sptr_k[0], g = sptr_k[1], r = sptr_k[2];
|
||||
float alpha = (float)((std::abs(b - b0) +
|
||||
float alpha = (float)((std::abs(b - b0) +
|
||||
std::abs(g - g0) + std::abs(r - r0))*scale_index);
|
||||
int idx = cvFloor(alpha);
|
||||
alpha -= idx;
|
||||
|
@ -207,8 +207,8 @@ void integral_( const T* src, size_t _srcstep, ST* sum, size_t _sumstep,
|
||||
|
||||
|
||||
#define DEF_INTEGRAL_FUNC(suffix, T, ST, QT) \
|
||||
void integral_##suffix( T* src, size_t srcstep, ST* sum, size_t sumstep, QT* sqsum, size_t sqsumstep, \
|
||||
ST* tilted, size_t tiltedstep, Size size, int cn ) \
|
||||
static void integral_##suffix( T* src, size_t srcstep, ST* sum, size_t sumstep, QT* sqsum, size_t sqsumstep, \
|
||||
ST* tilted, size_t tiltedstep, Size size, int cn ) \
|
||||
{ integral_(src, srcstep, sum, sumstep, sqsum, sqsumstep, tilted, tiltedstep, size, cn); }
|
||||
|
||||
DEF_INTEGRAL_FUNC(8u32s, uchar, int, double)
|
||||
|
@ -49,7 +49,7 @@
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#if _MSC_VER >= 1200 || defined __BORLANDC__
|
||||
#if (defined _MSC_VER && _MSC_VER >= 1200) || defined __BORLANDC__
|
||||
#define cv_stricmp stricmp
|
||||
#define cv_strnicmp strnicmp
|
||||
#if defined WINCE
|
||||
|
@ -3478,7 +3478,7 @@ typedef struct CvBGCodeBookModel
|
||||
CvBGCodeBookElem* freeList;
|
||||
} CvBGCodeBookModel;
|
||||
|
||||
CVAPI(CvBGCodeBookModel*) cvCreateBGCodeBookModel();
|
||||
CVAPI(CvBGCodeBookModel*) cvCreateBGCodeBookModel( void );
|
||||
CVAPI(void) cvReleaseBGCodeBookModel( CvBGCodeBookModel** model );
|
||||
|
||||
CVAPI(void) cvBGCodeBookUpdate( CvBGCodeBookModel* model, const CvArr* image,
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#if _MSC_VER >= 1200
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning(disable:4786) // Disable MSVC warnings in the standard library.
|
||||
#pragma warning(disable:4100)
|
||||
#pragma warning(disable:4512)
|
||||
@ -49,7 +49,7 @@
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#if _MSC_VER >= 1200
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning(default:4100)
|
||||
#pragma warning(default:4512)
|
||||
#endif
|
||||
|
@ -53,7 +53,7 @@
|
||||
#include "assert.h"
|
||||
#include "math.h"
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
#if defined _MSC_VER && _MSC_VER >= 1400
|
||||
#pragma warning(disable: 4512) // suppress "assignment operator could not be generated"
|
||||
#endif
|
||||
|
||||
@ -72,23 +72,23 @@ public:
|
||||
|
||||
private:
|
||||
struct node {
|
||||
int dim; // split dimension; >=0 for nodes, -1 for leaves
|
||||
__valuetype value; // if leaf, value of leaf
|
||||
int left, right; // node indices of left and right branches
|
||||
scalar_type boundary; // left if deref(value,dim)<=boundary, otherwise right
|
||||
int dim; // split dimension; >=0 for nodes, -1 for leaves
|
||||
__valuetype value; // if leaf, value of leaf
|
||||
int left, right; // node indices of left and right branches
|
||||
scalar_type boundary; // left if deref(value,dim)<=boundary, otherwise right
|
||||
};
|
||||
typedef std::vector < node > node_array;
|
||||
|
||||
__deref deref; // requires operator() (__valuetype lhs,int dim)
|
||||
__deref deref; // requires operator() (__valuetype lhs,int dim)
|
||||
|
||||
node_array nodes; // node storage
|
||||
int point_dim; // dimension of points (the k in kd-tree)
|
||||
int root_node; // index of root node, -1 if empty tree
|
||||
node_array nodes; // node storage
|
||||
int point_dim; // dimension of points (the k in kd-tree)
|
||||
int root_node; // index of root node, -1 if empty tree
|
||||
|
||||
// for given set of point indices, compute dimension of highest variance
|
||||
template < class __instype, class __valuector >
|
||||
int dimension_of_highest_variance(__instype * first, __instype * last,
|
||||
__valuector ctor) {
|
||||
__valuector ctor) {
|
||||
assert(last - first > 0);
|
||||
|
||||
accum_type maxvar = -std::numeric_limits < accum_type >::max();
|
||||
@ -96,20 +96,20 @@ private:
|
||||
for (int j = 0; j < point_dim; ++j) {
|
||||
accum_type mean = 0;
|
||||
for (__instype * k = first; k < last; ++k)
|
||||
mean += deref(ctor(*k), j);
|
||||
mean += deref(ctor(*k), j);
|
||||
mean /= last - first;
|
||||
accum_type var = 0;
|
||||
for (__instype * k = first; k < last; ++k) {
|
||||
accum_type diff = accum_type(deref(ctor(*k), j)) - mean;
|
||||
var += diff * diff;
|
||||
accum_type diff = accum_type(deref(ctor(*k), j)) - mean;
|
||||
var += diff * diff;
|
||||
}
|
||||
var /= last - first;
|
||||
|
||||
assert(maxj != -1 || var >= maxvar);
|
||||
|
||||
if (var >= maxvar) {
|
||||
maxvar = var;
|
||||
maxj = j;
|
||||
maxvar = var;
|
||||
maxj = j;
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ private:
|
||||
// implemented as partial quicksort; expected linear perf.
|
||||
template < class __instype, class __valuector >
|
||||
__instype * median_partition(__instype * first, __instype * last,
|
||||
int dim, __valuector ctor) {
|
||||
int dim, __valuector ctor) {
|
||||
assert(last - first > 0);
|
||||
__instype *k = first + (last - first) / 2;
|
||||
median_partition(first, last, k, dim, ctor);
|
||||
@ -144,13 +144,13 @@ private:
|
||||
|
||||
template < class __instype, class __valuector >
|
||||
void median_partition(__instype * first, __instype * last,
|
||||
__instype * k, int dim, __valuector ctor) {
|
||||
__instype * k, int dim, __valuector ctor) {
|
||||
int pivot = (int)((last - first) / 2);
|
||||
|
||||
std::swap(first[pivot], last[-1]);
|
||||
__instype *middle = std::partition(first, last - 1,
|
||||
median_pr < __instype, __valuector >
|
||||
(last[-1], dim, deref, ctor));
|
||||
median_pr < __instype, __valuector >
|
||||
(last[-1], dim, deref, ctor));
|
||||
std::swap(*middle, last[-1]);
|
||||
|
||||
if (middle < k)
|
||||
@ -171,35 +171,35 @@ private:
|
||||
|
||||
__instype *split = median;
|
||||
for (; split != last && deref(ctor(*split), dim) ==
|
||||
deref(ctor(*median), dim); ++split);
|
||||
deref(ctor(*median), dim); ++split);
|
||||
|
||||
if (split == last) { // leaf
|
||||
int nexti = -1;
|
||||
for (--split; split >= first; --split) {
|
||||
int i = (int)nodes.size();
|
||||
node & n = *nodes.insert(nodes.end(), node());
|
||||
n.dim = -1;
|
||||
n.value = ctor(*split);
|
||||
n.left = -1;
|
||||
n.right = nexti;
|
||||
nexti = i;
|
||||
}
|
||||
int nexti = -1;
|
||||
for (--split; split >= first; --split) {
|
||||
int i = (int)nodes.size();
|
||||
node & n = *nodes.insert(nodes.end(), node());
|
||||
n.dim = -1;
|
||||
n.value = ctor(*split);
|
||||
n.left = -1;
|
||||
n.right = nexti;
|
||||
nexti = i;
|
||||
}
|
||||
|
||||
return nexti;
|
||||
return nexti;
|
||||
} else { // node
|
||||
int i = (int)nodes.size();
|
||||
// note that recursive insert may invalidate this ref
|
||||
node & n = *nodes.insert(nodes.end(), node());
|
||||
int i = (int)nodes.size();
|
||||
// note that recursive insert may invalidate this ref
|
||||
node & n = *nodes.insert(nodes.end(), node());
|
||||
|
||||
n.dim = dim;
|
||||
n.boundary = deref(ctor(*median), dim);
|
||||
n.dim = dim;
|
||||
n.boundary = deref(ctor(*median), dim);
|
||||
|
||||
int left = insert(first, split, ctor);
|
||||
nodes[i].left = left;
|
||||
int right = insert(split, last, ctor);
|
||||
nodes[i].right = right;
|
||||
int left = insert(first, split, ctor);
|
||||
nodes[i].left = left;
|
||||
int right = insert(split, last, ctor);
|
||||
nodes[i].right = right;
|
||||
|
||||
return i;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -214,21 +214,21 @@ private:
|
||||
|
||||
if (n.dim >= 0) { // node
|
||||
if (deref(p, n.dim) <= n.boundary) // left
|
||||
r = remove(&n.left, p);
|
||||
r = remove(&n.left, p);
|
||||
else // right
|
||||
r = remove(&n.right, p);
|
||||
r = remove(&n.right, p);
|
||||
|
||||
// if terminal, remove this node
|
||||
if (n.left == -1 && n.right == -1)
|
||||
*i = -1;
|
||||
*i = -1;
|
||||
|
||||
return r;
|
||||
} else { // leaf
|
||||
if (n.value == p) {
|
||||
*i = n.right;
|
||||
return true;
|
||||
*i = n.right;
|
||||
return true;
|
||||
} else
|
||||
return remove(&n.right, p);
|
||||
return remove(&n.right, p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,14 +245,14 @@ public:
|
||||
}
|
||||
// given points, initialize a balanced tree
|
||||
CvKDTree(__valuetype * first, __valuetype * last, int _point_dim,
|
||||
__deref _deref = __deref())
|
||||
__deref _deref = __deref())
|
||||
: deref(_deref) {
|
||||
set_data(first, last, _point_dim, identity_ctor());
|
||||
}
|
||||
// given points, initialize a balanced tree
|
||||
template < class __instype, class __valuector >
|
||||
CvKDTree(__instype * first, __instype * last, int _point_dim,
|
||||
__valuector ctor, __deref _deref = __deref())
|
||||
__valuector ctor, __deref _deref = __deref())
|
||||
: deref(_deref) {
|
||||
set_data(first, last, _point_dim, ctor);
|
||||
}
|
||||
@ -266,7 +266,7 @@ public:
|
||||
}
|
||||
template < class __instype, class __valuector >
|
||||
void set_data(__instype * first, __instype * last, int _point_dim,
|
||||
__valuector ctor) {
|
||||
__valuector ctor) {
|
||||
point_dim = _point_dim;
|
||||
nodes.clear();
|
||||
nodes.reserve(last - first);
|
||||
@ -293,8 +293,8 @@ public:
|
||||
const node & n = nodes[i];
|
||||
if (n.dim >= 0) {
|
||||
std::cout << "node " << i << ", left " << nodes[i].left << ", right " <<
|
||||
nodes[i].right << ", dim " << nodes[i].dim << ", boundary " <<
|
||||
nodes[i].boundary << std::endl;
|
||||
nodes[i].right << ", dim " << nodes[i].dim << ", boundary " <<
|
||||
nodes[i].boundary << std::endl;
|
||||
print(n.left, indent + 3);
|
||||
print(n.right, indent + 3);
|
||||
} else
|
||||
@ -304,9 +304,9 @@ public:
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// bbf search
|
||||
public:
|
||||
struct bbf_nn { // info on found neighbors (approx k nearest)
|
||||
const __valuetype *p; // nearest neighbor
|
||||
accum_type dist; // distance from d to query point
|
||||
struct bbf_nn { // info on found neighbors (approx k nearest)
|
||||
const __valuetype *p; // nearest neighbor
|
||||
accum_type dist; // distance from d to query point
|
||||
bbf_nn(const __valuetype & _p, accum_type _dist)
|
||||
: p(&_p), dist(_dist) {
|
||||
}
|
||||
@ -316,9 +316,9 @@ public:
|
||||
};
|
||||
typedef std::vector < bbf_nn > bbf_nn_pqueue;
|
||||
private:
|
||||
struct bbf_node { // info on branches not taken
|
||||
int node; // corresponding node
|
||||
accum_type dist; // minimum distance from bounds to query point
|
||||
struct bbf_node { // info on branches not taken
|
||||
int node; // corresponding node
|
||||
accum_type dist; // minimum distance from bounds to query point
|
||||
bbf_node(int _node, accum_type _dist)
|
||||
: node(_node), dist(_dist) {
|
||||
}
|
||||
@ -346,10 +346,10 @@ private:
|
||||
int bbf_branch(int i, const __desctype * d, bbf_pqueue & pq) const {
|
||||
const node & n = nodes[i];
|
||||
// push bbf_node with bounds of alternate branch, then branch
|
||||
if (d[n.dim] <= n.boundary) { // left
|
||||
if (d[n.dim] <= n.boundary) { // left
|
||||
pq_alternate(n.right, pq, n.boundary - d[n.dim]);
|
||||
return n.left;
|
||||
} else { // right
|
||||
} else { // right
|
||||
pq_alternate(n.left, pq, d[n.dim] - n.boundary);
|
||||
return n.right;
|
||||
}
|
||||
@ -370,7 +370,7 @@ private:
|
||||
// queue len exceeds k, drops the point furthest from query point d.
|
||||
template < class __desctype >
|
||||
void bbf_new_nn(bbf_nn_pqueue & nn_pq, int k,
|
||||
const __desctype * d, const __valuetype & p) const {
|
||||
const __desctype * d, const __valuetype & p) const {
|
||||
bbf_nn nn(p, distance(d, p));
|
||||
if ((int) nn_pq.size() < k) {
|
||||
nn_pq.push_back(nn);
|
||||
@ -390,8 +390,8 @@ public:
|
||||
// (see bbf_nn structure def above).
|
||||
template < class __desctype >
|
||||
int find_nn_bbf(const __desctype * d,
|
||||
int k, int emax,
|
||||
bbf_nn_pqueue & ret_nn_pq) const {
|
||||
int k, int emax,
|
||||
bbf_nn_pqueue & ret_nn_pq) const {
|
||||
assert(k > 0);
|
||||
ret_nn_pq.clear();
|
||||
|
||||
@ -411,17 +411,17 @@ public:
|
||||
|
||||
int i;
|
||||
for (i = bbf.node;
|
||||
i != -1 && nodes[i].dim >= 0;
|
||||
i = bbf_branch(i, d, tmp_pq));
|
||||
i != -1 && nodes[i].dim >= 0;
|
||||
i = bbf_branch(i, d, tmp_pq));
|
||||
|
||||
if (i != -1) {
|
||||
|
||||
// add points in leaf/bin to ret_nn_pq
|
||||
do {
|
||||
bbf_new_nn(ret_nn_pq, k, d, nodes[i].value);
|
||||
} while (-1 != (i = nodes[i].right));
|
||||
// add points in leaf/bin to ret_nn_pq
|
||||
do {
|
||||
bbf_new_nn(ret_nn_pq, k, d, nodes[i].value);
|
||||
} while (-1 != (i = nodes[i].right));
|
||||
|
||||
--emax;
|
||||
--emax;
|
||||
}
|
||||
}
|
||||
|
||||
@ -433,27 +433,27 @@ public:
|
||||
// orthogonal range search
|
||||
private:
|
||||
void find_ortho_range(int i, scalar_type * bounds_min,
|
||||
scalar_type * bounds_max,
|
||||
std::vector < __valuetype > &inbounds) const {
|
||||
scalar_type * bounds_max,
|
||||
std::vector < __valuetype > &inbounds) const {
|
||||
if (i == -1)
|
||||
return;
|
||||
const node & n = nodes[i];
|
||||
if (n.dim >= 0) { // node
|
||||
if (bounds_min[n.dim] <= n.boundary)
|
||||
find_ortho_range(n.left, bounds_min, bounds_max, inbounds);
|
||||
find_ortho_range(n.left, bounds_min, bounds_max, inbounds);
|
||||
if (bounds_max[n.dim] > n.boundary)
|
||||
find_ortho_range(n.right, bounds_min, bounds_max, inbounds);
|
||||
find_ortho_range(n.right, bounds_min, bounds_max, inbounds);
|
||||
} else { // leaf
|
||||
do {
|
||||
inbounds.push_back(nodes[i].value);
|
||||
inbounds.push_back(nodes[i].value);
|
||||
} while (-1 != (i = nodes[i].right));
|
||||
}
|
||||
}
|
||||
public:
|
||||
// return all points that lie within the given bounds; inbounds is cleared
|
||||
int find_ortho_range(scalar_type * bounds_min,
|
||||
scalar_type * bounds_max,
|
||||
std::vector < __valuetype > &inbounds) const {
|
||||
scalar_type * bounds_max,
|
||||
std::vector < __valuetype > &inbounds) const {
|
||||
inbounds.clear();
|
||||
find_ortho_range(root_node, bounds_min, bounds_max, inbounds);
|
||||
return (int)inbounds.size();
|
||||
|
@ -237,9 +237,9 @@ public:
|
||||
virtual float* GetFVVar(){return m_FVVar;}; /* returned pointer to array of maximal values of FV, if return 0 then FVrange is not exist */
|
||||
};/* CvBlobTrackFVGenN */
|
||||
|
||||
CvBlobTrackFVGen* cvCreateFVGenP(){return (CvBlobTrackFVGen*)new CvBlobTrackFVGenN(2);}
|
||||
CvBlobTrackFVGen* cvCreateFVGenPV(){return (CvBlobTrackFVGen*)new CvBlobTrackFVGenN(4);}
|
||||
CvBlobTrackFVGen* cvCreateFVGenPVS(){return (CvBlobTrackFVGen*)new CvBlobTrackFVGenN(5);}
|
||||
inline CvBlobTrackFVGen* cvCreateFVGenP(){return (CvBlobTrackFVGen*)new CvBlobTrackFVGenN(2);}
|
||||
inline CvBlobTrackFVGen* cvCreateFVGenPV(){return (CvBlobTrackFVGen*)new CvBlobTrackFVGenN(4);}
|
||||
inline CvBlobTrackFVGen* cvCreateFVGenPVS(){return (CvBlobTrackFVGen*)new CvBlobTrackFVGenN(5);}
|
||||
#undef MAX_FV_SIZE
|
||||
|
||||
#define MAX_FV_SIZE 4
|
||||
@ -408,7 +408,7 @@ public:
|
||||
virtual float* GetFVVar(){return m_FVVar;}; /* returned pointer to array of maximal values of FV, if return 0 then FVrange is not exist */
|
||||
};/* CvBlobTrackFVGenSS */
|
||||
|
||||
CvBlobTrackFVGen* cvCreateFVGenSS(){return (CvBlobTrackFVGen*)new CvBlobTrackFVGenSS;}
|
||||
inline CvBlobTrackFVGen* cvCreateFVGenSS(){return (CvBlobTrackFVGen*)new CvBlobTrackFVGenSS;}
|
||||
|
||||
/*======================= TRAJECTORY ANALYZER MODULES =====================*/
|
||||
/* Trajectory Analyser module */
|
||||
@ -1510,7 +1510,7 @@ public:
|
||||
|
||||
}; /* CvBlobTrackAnalysisSVM. */
|
||||
|
||||
|
||||
#if 0
|
||||
CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMP()
|
||||
{return (CvBlobTrackAnalysis*) new CvBlobTrackAnalysisSVM(cvCreateFVGenP);}
|
||||
|
||||
@ -1522,3 +1522,4 @@ CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMPVS()
|
||||
|
||||
CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMSS()
|
||||
{return (CvBlobTrackAnalysis*) new CvBlobTrackAnalysisSVM(cvCreateFVGenSS);}
|
||||
#endif
|
||||
|
@ -162,12 +162,15 @@ public:
|
||||
}
|
||||
}; /* class CvBlobTrackerOneKalman */
|
||||
|
||||
#if 0
|
||||
static CvBlobTrackerOne* cvCreateModuleBlobTrackerOneKalman()
|
||||
{
|
||||
return (CvBlobTrackerOne*) new CvBlobTrackerOneKalman;
|
||||
}
|
||||
|
||||
|
||||
CvBlobTracker* cvCreateBlobTrackerKalman()
|
||||
{
|
||||
return cvCreateBlobTrackerList(cvCreateModuleBlobTrackerOneKalman);
|
||||
}
|
||||
#endif
|
||||
|
@ -716,7 +716,7 @@ void CvBlobTrackerOneMSFG::CollectHist(IplImage* pImg, IplImage* pMask, CvBlob*
|
||||
}; /* CollectHist */
|
||||
#endif
|
||||
|
||||
CvBlobTrackerOne* cvCreateBlobTrackerOneMSFG()
|
||||
static CvBlobTrackerOne* cvCreateBlobTrackerOneMSFG()
|
||||
{
|
||||
return (CvBlobTrackerOne*) new CvBlobTrackerOneMSFG;
|
||||
}
|
||||
@ -739,7 +739,7 @@ public:
|
||||
};
|
||||
};
|
||||
|
||||
CvBlobTrackerOne* cvCreateBlobTrackerOneMS()
|
||||
static CvBlobTrackerOne* cvCreateBlobTrackerOneMS()
|
||||
{
|
||||
return (CvBlobTrackerOne*) new CvBlobTrackerOneMS;
|
||||
}
|
||||
@ -1169,6 +1169,7 @@ public:
|
||||
|
||||
}; /* CvBlobTrackerOneMSPF */
|
||||
|
||||
CvBlobTrackerOne* cvCreateBlobTrackerOneMSPF();
|
||||
CvBlobTrackerOne* cvCreateBlobTrackerOneMSPF()
|
||||
{
|
||||
return (CvBlobTrackerOne*) new CvBlobTrackerOneMSPF;
|
||||
|
@ -47,7 +47,7 @@ typedef float DefHistType;
|
||||
#define DefHistTypeMat CV_32F
|
||||
#define HIST_INDEX(_pData) (((_pData)[0]>>m_ByteShift) + (((_pData)[1]>>(m_ByteShift))<<m_BinBit)+((pImgData[2]>>m_ByteShift)<<(m_BinBit*2)))
|
||||
|
||||
void calcKernelEpanechnikov(CvMat* pK)
|
||||
static void calcKernelEpanechnikov(CvMat* pK)
|
||||
{ /* Allocate kernel for histogramm creation: */
|
||||
int x,y;
|
||||
int w = pK->width;
|
||||
@ -445,7 +445,7 @@ public:
|
||||
virtual void Release(){delete this;};
|
||||
}; /*CvBlobTrackerOneMSFGS*/
|
||||
|
||||
CvBlobTrackerOne* cvCreateBlobTrackerOneMSFGS()
|
||||
static CvBlobTrackerOne* cvCreateBlobTrackerOneMSFGS()
|
||||
{
|
||||
return (CvBlobTrackerOne*) new CvBlobTrackerOneMSFGS;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ void CvBlobTrackPostProcKalman::Release()
|
||||
delete this;
|
||||
}
|
||||
|
||||
CvBlobTrackPostProcOne* cvCreateModuleBlobTrackPostProcKalmanOne()
|
||||
static CvBlobTrackPostProcOne* cvCreateModuleBlobTrackPostProcKalmanOne()
|
||||
{
|
||||
return (CvBlobTrackPostProcOne*) new CvBlobTrackPostProcKalman;
|
||||
}
|
||||
|
@ -106,12 +106,12 @@ public:
|
||||
}
|
||||
}; /* class CvBlobTrackPostProcTimeAver */
|
||||
|
||||
CvBlobTrackPostProcOne* cvCreateModuleBlobTrackPostProcTimeAverRectOne()
|
||||
static CvBlobTrackPostProcOne* cvCreateModuleBlobTrackPostProcTimeAverRectOne()
|
||||
{
|
||||
return (CvBlobTrackPostProcOne*) new CvBlobTrackPostProcTimeAver(0);
|
||||
}
|
||||
|
||||
CvBlobTrackPostProcOne* cvCreateModuleBlobTrackPostProcTimeAverExpOne()
|
||||
static CvBlobTrackPostProcOne* cvCreateModuleBlobTrackPostProcTimeAverExpOne()
|
||||
{
|
||||
return (CvBlobTrackPostProcOne*) new CvBlobTrackPostProcTimeAver(1);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
#undef quad
|
||||
|
||||
#if _MSC_VER >= 1200
|
||||
#if defined _MSC_VER && _MSC_VER >= 1200
|
||||
#pragma warning( disable: 4701 )
|
||||
#endif
|
||||
|
||||
@ -99,18 +99,18 @@ bool CvCalibFilter::SetEtalon( CvCalibEtalonType type, double* params,
|
||||
|
||||
Stop();
|
||||
|
||||
if (latestPoints != NULL)
|
||||
{
|
||||
for( i = 0; i < MAX_CAMERAS; i++ )
|
||||
cvFree( latestPoints + i );
|
||||
}
|
||||
if (latestPoints != NULL)
|
||||
{
|
||||
for( i = 0; i < MAX_CAMERAS; i++ )
|
||||
cvFree( latestPoints + i );
|
||||
}
|
||||
|
||||
if( type == CV_CALIB_ETALON_USER || type != etalonType )
|
||||
{
|
||||
if (etalonParams != NULL)
|
||||
{
|
||||
cvFree( &etalonParams );
|
||||
}
|
||||
if (etalonParams != NULL)
|
||||
{
|
||||
cvFree( &etalonParams );
|
||||
}
|
||||
}
|
||||
|
||||
etalonType = type;
|
||||
@ -154,10 +154,10 @@ bool CvCalibFilter::SetEtalon( CvCalibEtalonType type, double* params,
|
||||
|
||||
if( etalonPointCount != pointCount )
|
||||
{
|
||||
if (etalonPoints != NULL)
|
||||
{
|
||||
cvFree( &etalonPoints );
|
||||
}
|
||||
if (etalonPoints != NULL)
|
||||
{
|
||||
cvFree( &etalonPoints );
|
||||
}
|
||||
etalonPointCount = pointCount;
|
||||
etalonPoints = (CvPoint2D32f*)cvAlloc( arrSize );
|
||||
}
|
||||
@ -184,15 +184,15 @@ bool CvCalibFilter::SetEtalon( CvCalibEtalonType type, double* params,
|
||||
break;
|
||||
|
||||
case CV_CALIB_ETALON_USER:
|
||||
if (params != NULL)
|
||||
{
|
||||
memcpy( etalonParams, params, arrSize );
|
||||
}
|
||||
if (points != NULL)
|
||||
{
|
||||
memcpy( etalonPoints, points, arrSize );
|
||||
}
|
||||
break;
|
||||
if (params != NULL)
|
||||
{
|
||||
memcpy( etalonParams, params, arrSize );
|
||||
}
|
||||
if (points != NULL)
|
||||
{
|
||||
memcpy( etalonPoints, points, arrSize );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
|
@ -45,7 +45,7 @@
|
||||
//#include <limits.h>
|
||||
//#include "cv.h"
|
||||
//#include "highgui.h"
|
||||
|
||||
#if 0
|
||||
#include <stdio.h>
|
||||
|
||||
/* Valery Mosyagin */
|
||||
@ -53,7 +53,7 @@
|
||||
/* ===== Function for find corresponding between images ===== */
|
||||
|
||||
/* Create feature points on image and return number of them. Array points fills by found points */
|
||||
int icvCreateFeaturePoints(IplImage *image, CvMat *points, CvMat *status)
|
||||
static int icvCreateFeaturePoints(IplImage *image, CvMat *points, CvMat *status)
|
||||
{
|
||||
int foundFeaturePoints = 0;
|
||||
IplImage *grayImage = 0;
|
||||
@ -175,7 +175,7 @@ int icvCreateFeaturePoints(IplImage *image, CvMat *points, CvMat *status)
|
||||
|
||||
/* For given points1 (with pntStatus) on image1 finds corresponding points2 on image2 and set pntStatus2 for them */
|
||||
/* Returns number of corresponding points */
|
||||
int icvFindCorrForGivenPoints( IplImage *image1,/* Image 1 */
|
||||
static int icvFindCorrForGivenPoints( IplImage *image1,/* Image 1 */
|
||||
IplImage *image2,/* Image 2 */
|
||||
CvMat *points1,
|
||||
CvMat *pntStatus1,
|
||||
@ -435,8 +435,9 @@ int icvFindCorrForGivenPoints( IplImage *image1,/* Image 1 */
|
||||
|
||||
return resNumCorrPoints;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
int icvGrowPointsAndStatus(CvMat **oldPoints,CvMat **oldStatus,CvMat *addPoints,CvMat *addStatus,int addCreateNum)
|
||||
static int icvGrowPointsAndStatus(CvMat **oldPoints,CvMat **oldStatus,CvMat *addPoints,CvMat *addStatus,int addCreateNum)
|
||||
{
|
||||
/* Add to existing points and status arrays new points or just grow */
|
||||
CvMat *newOldPoint = 0;
|
||||
@ -546,8 +547,9 @@ int icvGrowPointsAndStatus(CvMat **oldPoints,CvMat **oldStatus,CvMat *addPoints,
|
||||
|
||||
return newTotalNumber;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
int icvRemoveDoublePoins( CvMat *oldPoints,/* Points on prev image */
|
||||
static int icvRemoveDoublePoins( CvMat *oldPoints,/* Points on prev image */
|
||||
CvMat *newPoints,/* New points */
|
||||
CvMat *oldStatus,/* Status for old points */
|
||||
CvMat *newStatus,
|
||||
@ -755,7 +757,7 @@ int icvRemoveDoublePoins( CvMat *oldPoints,/* Points on prev image */
|
||||
void icvComputeProjectMatrix(CvMat* objPoints,CvMat* projPoints,CvMat* projMatr);
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
void icvComputeProjectMatrixStatus(CvMat *objPoints4D,CvMat *points2,CvMat *status, CvMat *projMatr)
|
||||
static void icvComputeProjectMatrixStatus(CvMat *objPoints4D,CvMat *points2,CvMat *status, CvMat *projMatr)
|
||||
{
|
||||
/* Compute number of good points */
|
||||
int num = cvCountNonZero(status);
|
||||
@ -829,8 +831,7 @@ void icvComputeProjectMatrixStatus(CvMat *objPoints4D,CvMat *points2,CvMat *stat
|
||||
|
||||
|
||||
*/
|
||||
|
||||
void icvAddNewImageToPrevious____(
|
||||
static void icvAddNewImageToPrevious____(
|
||||
IplImage *newImage,//Image to add
|
||||
IplImage *oldImage,//Previous image
|
||||
CvMat *oldPoints,// previous 2D points on prev image (some points may be not visible)
|
||||
@ -947,7 +948,7 @@ void icvAddNewImageToPrevious____(
|
||||
//CreateGood
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
int icvDeleteSparsInPoints( int numImages,
|
||||
static int icvDeleteSparsInPoints( int numImages,
|
||||
CvMat **points,
|
||||
CvMat **status,
|
||||
CvMat *wasStatus)/* status of previous configuration */
|
||||
@ -1041,7 +1042,7 @@ int icvDeleteSparsInPoints( int numImages,
|
||||
return comNumber;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
void icvGrowPointsArray(CvMat **points)
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ typedef struct _CvRightImData
|
||||
#define CV_IMAX3(a,b,c) ((temp3 = (a) >= (b) ? (a) : (b)),(temp3 >= (c) ? temp3 : (c)))
|
||||
#define CV_IMIN3(a,b,c) ((temp3 = (a) <= (b) ? (a) : (b)),(temp3 <= (c) ? temp3 : (c)))
|
||||
|
||||
void icvFindStereoCorrespondenceByBirchfieldDP( uchar* src1, uchar* src2,
|
||||
static void icvFindStereoCorrespondenceByBirchfieldDP( uchar* src1, uchar* src2,
|
||||
uchar* disparities,
|
||||
CvSize size, int widthStep,
|
||||
int maxDisparity,
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
CvStatus CV_STDCALL
|
||||
static CvStatus
|
||||
icvJacobiEigens_32f(float *A, float *V, float *E, int n, float eps)
|
||||
{
|
||||
int i, j, k, ind;
|
||||
|
@ -83,7 +83,7 @@ static int CompareContour(const void* a, const void* b, void* )
|
||||
return (dx < wt && dy < ht);
|
||||
}
|
||||
|
||||
void cvFindBlobsByCCClasters(IplImage* pFG, CvBlobSeq* pBlobs, CvMemStorage* storage)
|
||||
static void cvFindBlobsByCCClasters(IplImage* pFG, CvBlobSeq* pBlobs, CvMemStorage* storage)
|
||||
{ /* Create contours: */
|
||||
IplImage* pIB = NULL;
|
||||
CvSeq* cnt = NULL;
|
||||
|
@ -160,9 +160,5 @@ public:
|
||||
};
|
||||
|
||||
/* Blob detector constructor: */
|
||||
CvBlobDetector* cvCreateBlobDetectorReal(CvTestSeq* pTestSeq){return new CvBlobDetectorReal(pTestSeq);}
|
||||
|
||||
|
||||
|
||||
|
||||
//CvBlobDetector* cvCreateBlobDetectorReal(CvTestSeq* pTestSeq){return new CvBlobDetectorReal(pTestSeq);}
|
||||
|
||||
|
@ -190,7 +190,7 @@ int icvConvertPointSystem(CvPoint3D64d M2,
|
||||
return CV_NO_ERR;
|
||||
}
|
||||
/*--------------------------------------------------------------------------------------*/
|
||||
int icvComputeCoeffForStereoV3( double quad1[4][2],
|
||||
static int icvComputeCoeffForStereoV3( double quad1[4][2],
|
||||
double quad2[4][2],
|
||||
int numScanlines,
|
||||
CvMatr64d camMatr1,
|
||||
@ -246,7 +246,7 @@ int icvComputeCoeffForStereoV3( double quad1[4][2],
|
||||
return CV_NO_ERR;
|
||||
}
|
||||
/*--------------------------------------------------------------------------------------*/
|
||||
int icvComputeCoeffForStereoNew( double quad1[4][2],
|
||||
static int icvComputeCoeffForStereoNew( double quad1[4][2],
|
||||
double quad2[4][2],
|
||||
int numScanlines,
|
||||
CvMatr32f camMatr1,
|
||||
@ -782,7 +782,7 @@ void icvGetCoefForPiece( CvPoint2D64d p_start,CvPoint2D64d p_end,
|
||||
/*---------------------------------------------------------------------------------------*/
|
||||
|
||||
/* Get common area of rectifying */
|
||||
void icvGetCommonArea( CvSize imageSize,
|
||||
static void icvGetCommonArea( CvSize imageSize,
|
||||
CvPoint3D64d epipole1,CvPoint3D64d epipole2,
|
||||
CvMatr64d fundMatr,
|
||||
CvVect64d coeff11,CvVect64d coeff12,
|
||||
@ -1660,7 +1660,7 @@ void icvGetQuadsTransform(
|
||||
|
||||
/*---------------------------------------------------------------------------------------*/
|
||||
|
||||
void icvGetQuadsTransformNew( CvSize imageSize,
|
||||
static void icvGetQuadsTransformNew( CvSize imageSize,
|
||||
CvMatr32f camMatr1,
|
||||
CvMatr32f camMatr2,
|
||||
CvMatr32f rotMatr1,
|
||||
@ -2127,7 +2127,7 @@ CV_IMPL IplImage* icvCreateIsometricImage( IplImage* src, IplImage* dst,
|
||||
return dst;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
icvCvt_32f_64d( float *src, double *dst, int size )
|
||||
{
|
||||
int t;
|
||||
@ -2147,7 +2147,7 @@ icvCvt_32f_64d( float *src, double *dst, int size )
|
||||
|
||||
/*======================================================================================*/
|
||||
/* Type conversion double -> float */
|
||||
int
|
||||
static int
|
||||
icvCvt_64d_32f( double *src, float *dst, int size )
|
||||
{
|
||||
int t;
|
||||
@ -2167,9 +2167,9 @@ icvCvt_64d_32f( double *src, float *dst, int size )
|
||||
|
||||
/*----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#if 0
|
||||
/* Find line which cross frame by line(a,b,c) */
|
||||
void FindLineForEpiline( CvSize imageSize,
|
||||
static void FindLineForEpiline( CvSize imageSize,
|
||||
float a,float b,float c,
|
||||
CvPoint2D32f *start,CvPoint2D32f *end,
|
||||
int*)
|
||||
@ -2260,8 +2260,7 @@ void FindLineForEpiline( CvSize imageSize,
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------*/
|
||||
|
||||
int GetAngleLinee( CvPoint2D32f epipole, CvSize imageSize,CvPoint2D32f point1,CvPoint2D32f point2)
|
||||
static int GetAngleLinee( CvPoint2D32f epipole, CvSize imageSize,CvPoint2D32f point1,CvPoint2D32f point2)
|
||||
{
|
||||
float width = (float)(imageSize.width);
|
||||
float height = (float)(imageSize.height);
|
||||
@ -2352,7 +2351,7 @@ int GetAngleLinee( CvPoint2D32f epipole, CvSize imageSize,CvPoint2D32f point1,Cv
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------------------*/
|
||||
void icvComputePerspectiveCoeffs(const CvPoint2D32f srcQuad[4],const CvPoint2D32f dstQuad[4],double coeffs[3][3])
|
||||
static void icvComputePerspectiveCoeffs(const CvPoint2D32f srcQuad[4],const CvPoint2D32f dstQuad[4],double coeffs[3][3])
|
||||
{/* Computes perspective coeffs for transformation from src to dst quad */
|
||||
|
||||
|
||||
@ -2435,6 +2434,7 @@ void icvComputePerspectiveCoeffs(const CvPoint2D32f srcQuad[4],const CvPoint2D32
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*--------------------------------------------------------------------------------------*/
|
||||
|
||||
@ -2690,7 +2690,7 @@ void icvComputeeInfiniteProject2( CvMatr64d rotMatr,
|
||||
|
||||
/* Select best R and t for given cameras, points, ... */
|
||||
/* For both cameras */
|
||||
int icvSelectBestRt( int numImages,
|
||||
static int icvSelectBestRt( int numImages,
|
||||
int* numPoints,
|
||||
CvPoint2D32f* imagePoints1,
|
||||
CvPoint2D32f* imagePoints2,
|
||||
@ -3233,8 +3233,9 @@ int icvStereoCalibration( int numImages,
|
||||
return CV_NO_ERR;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Find line from epipole */
|
||||
void FindLine(CvPoint2D32f epipole,CvSize imageSize,CvPoint2D32f point,CvPoint2D32f *start,CvPoint2D32f *end)
|
||||
static void FindLine(CvPoint2D32f epipole,CvSize imageSize,CvPoint2D32f point,CvPoint2D32f *start,CvPoint2D32f *end)
|
||||
{
|
||||
CvPoint2D32f frameBeg;
|
||||
CvPoint2D32f frameEnd;
|
||||
@ -3315,9 +3316,8 @@ void FindLine(CvPoint2D32f epipole,CvSize imageSize,CvPoint2D32f point,CvPoint2D
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Find line which cross frame by line(a,b,c) */
|
||||
void FindLineForEpiline(CvSize imageSize,float a,float b,float c,CvPoint2D32f *start,CvPoint2D32f *end)
|
||||
static void FindLineForEpiline(CvSize imageSize,float a,float b,float c,CvPoint2D32f *start,CvPoint2D32f *end)
|
||||
{
|
||||
CvPoint2D32f frameBeg;
|
||||
CvPoint2D32f frameEnd;
|
||||
@ -3403,7 +3403,7 @@ void FindLineForEpiline(CvSize imageSize,float a,float b,float c,CvPoint2D32f *s
|
||||
}
|
||||
|
||||
/* Cross lines */
|
||||
int GetCrossLines(CvPoint2D32f p1_start,CvPoint2D32f p1_end,CvPoint2D32f p2_start,CvPoint2D32f p2_end,CvPoint2D32f *cross)
|
||||
static int GetCrossLines(CvPoint2D32f p1_start,CvPoint2D32f p1_end,CvPoint2D32f p2_start,CvPoint2D32f p2_end,CvPoint2D32f *cross)
|
||||
{
|
||||
double ex1,ey1,ex2,ey2;
|
||||
double px1,py1,px2,py2;
|
||||
@ -3448,7 +3448,7 @@ int GetCrossLines(CvPoint2D32f p1_start,CvPoint2D32f p1_end,CvPoint2D32f p2_star
|
||||
cross->y = (float)(-delY / del);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int icvGetCrossPieceVector(CvPoint2D32f p1_start,CvPoint2D32f p1_end,CvPoint2D32f v2_start,CvPoint2D32f v2_end,CvPoint2D32f *cross)
|
||||
{
|
||||
@ -3531,7 +3531,8 @@ int icvGetCrossLineDirect(CvPoint2D32f p1,CvPoint2D32f p2,float a,float b,float
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cvComputeEpipoles( CvMatr32f camMatr1, CvMatr32f camMatr2,
|
||||
#if 0
|
||||
static int cvComputeEpipoles( CvMatr32f camMatr1, CvMatr32f camMatr2,
|
||||
CvMatr32f rotMatr1, CvMatr32f rotMatr2,
|
||||
CvVect32f transVect1,CvVect32f transVect2,
|
||||
CvVect32f epipole1,
|
||||
@ -3610,7 +3611,7 @@ int cvComputeEpipoles( CvMatr32f camMatr1, CvMatr32f camMatr2,
|
||||
|
||||
return CV_NO_ERR;
|
||||
}/* cvComputeEpipoles */
|
||||
|
||||
#endif
|
||||
|
||||
/* Compute epipoles for fundamental matrix */
|
||||
int cvComputeEpipolesFromFundMatrix(CvMatr32f fundMatr,
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include "_kdtree.hpp"
|
||||
#include "_featuretree.h"
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
#if defined _MSC_VER && _MSC_VER >= 1400
|
||||
#pragma warning(disable:4996) // suppress "function call with parameters may be unsafe" in std::copy
|
||||
#endif
|
||||
|
||||
@ -95,7 +95,7 @@ class CvKDTreeWrap : public CvFeatureTree {
|
||||
|
||||
for (int j = 0; j < d->rows; ++j) {
|
||||
const typename __treetype::scalar_type* dj =
|
||||
(const typename __treetype::scalar_type*) dptr;
|
||||
(const typename __treetype::scalar_type*) dptr;
|
||||
|
||||
int* resultsj = (int*) resultsptr;
|
||||
double* distj = (double*) distptr;
|
||||
@ -103,8 +103,8 @@ class CvKDTreeWrap : public CvFeatureTree {
|
||||
|
||||
assert((int)nn.size() <= k);
|
||||
for (unsigned int j = 0; j < nn.size(); ++j) {
|
||||
*resultsj++ = *nn[j].p;
|
||||
*distj++ = nn[j].dist;
|
||||
*resultsj++ = *nn[j].p;
|
||||
*distj++ = nn[j].dist;
|
||||
}
|
||||
std::fill(resultsj, resultsj + k - nn.size(), -1);
|
||||
std::fill(distj, distj + k - nn.size(), 0);
|
||||
@ -117,16 +117,16 @@ class CvKDTreeWrap : public CvFeatureTree {
|
||||
|
||||
template <class __treetype>
|
||||
int find_ortho_range(CvMat* bounds_min, CvMat* bounds_max,
|
||||
CvMat* results) {
|
||||
CvMat* results) {
|
||||
int rn = results->rows * results->cols;
|
||||
std::vector<int> inbounds;
|
||||
dispatch_cvtype(mat, ((__treetype*)data)->
|
||||
find_ortho_range((typename __treetype::scalar_type*)bounds_min->data.ptr,
|
||||
(typename __treetype::scalar_type*)bounds_max->data.ptr,
|
||||
inbounds));
|
||||
find_ortho_range((typename __treetype::scalar_type*)bounds_min->data.ptr,
|
||||
(typename __treetype::scalar_type*)bounds_max->data.ptr,
|
||||
inbounds));
|
||||
std::copy(inbounds.begin(),
|
||||
inbounds.begin() + std::min((int)inbounds.size(), rn),
|
||||
(int*) results->data.ptr);
|
||||
inbounds.begin() + std::min((int)inbounds.size(), rn),
|
||||
(int*) results->data.ptr);
|
||||
return (int)inbounds.size();
|
||||
}
|
||||
|
||||
@ -144,8 +144,8 @@ public:
|
||||
tmp[j] = j;
|
||||
|
||||
dispatch_cvtype(mat, data = new tree_type
|
||||
(&tmp[0], &tmp[0] + tmp.size(), mat->cols,
|
||||
tree_type::deref_type(mat)));
|
||||
(&tmp[0], &tmp[0] + tmp.size(), mat->cols,
|
||||
tree_type::deref_type(mat)));
|
||||
}
|
||||
~CvKDTreeWrap() {
|
||||
dispatch_cvtype(mat, delete (tree_type*) data);
|
||||
@ -185,15 +185,15 @@ public:
|
||||
assert(CV_MAT_TYPE(results->type) == CV_32SC1);
|
||||
|
||||
dispatch_cvtype(mat, find_nn<tree_type>
|
||||
(desc, k, emax, results, dist));
|
||||
(desc, k, emax, results, dist));
|
||||
}
|
||||
int FindOrthoRange(CvMat* bounds_min, CvMat* bounds_max,
|
||||
CvMat* results) {
|
||||
CvMat* results) {
|
||||
bool free_bounds = false;
|
||||
int count = -1;
|
||||
|
||||
if (bounds_min->cols * bounds_min->rows != dims() ||
|
||||
bounds_max->cols * bounds_max->rows != dims())
|
||||
bounds_max->cols * bounds_max->rows != dims())
|
||||
CV_Error(CV_StsUnmatchedSizes, "bounds_{min,max} must 1 x dims or dims x 1");
|
||||
if (CV_MAT_TYPE(bounds_min->type) != CV_MAT_TYPE(bounds_max->type))
|
||||
CV_Error(CV_StsUnmatchedFormats, "bounds_{min,max} must have same type");
|
||||
@ -218,7 +218,7 @@ public:
|
||||
assert(bounds_max->rows * bounds_max->cols == dims());
|
||||
|
||||
dispatch_cvtype(mat, count = find_ortho_range<tree_type>
|
||||
(bounds_min, bounds_max,results));
|
||||
(bounds_min, bounds_max,results));
|
||||
|
||||
if (free_bounds) {
|
||||
cvReleaseMat(&bounds_min);
|
||||
|
@ -1247,7 +1247,7 @@ int _cvSolveEqu1th(T c1, T c0, T* X);
|
||||
vertices_number: in, number of vertices in polygon
|
||||
Return :
|
||||
--------------------------------------------------------------------------*/
|
||||
void _cvSetSeqBlockSize(CvVoronoiDiagramInt* pVoronoiDiagramInt,int vertices_number)
|
||||
static void _cvSetSeqBlockSize(CvVoronoiDiagramInt* pVoronoiDiagramInt,int vertices_number)
|
||||
{
|
||||
int N = 2*vertices_number;
|
||||
cvSetSeqBlockSize(pVoronoiDiagramInt->SiteSeq,N*pVoronoiDiagramInt->SiteSeq->elem_size);
|
||||
|
@ -50,6 +50,7 @@
|
||||
typedef void (*pointer_LMJac)( const CvMat* src, CvMat* dst );
|
||||
typedef void (*pointer_LMFunc)( const CvMat* src, CvMat* dst );
|
||||
|
||||
#if 0
|
||||
/* Optimization using Levenberg-Marquardt */
|
||||
void cvLevenbergMarquardtOptimization(pointer_LMJac JacobianFunction,
|
||||
pointer_LMFunc function,
|
||||
@ -244,6 +245,7 @@ void cvLevenbergMarquardtOptimization(pointer_LMJac JacobianFunction,
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#if 0
|
||||
|
@ -65,9 +65,13 @@ void icvReconstructPoints4DStatus(CvMat** projPoints, CvMat **projMatrs, CvMat**
|
||||
*/
|
||||
#define TRACK_BUNDLE_FILE "d:\\test\\bundle.txt"
|
||||
|
||||
void cvOptimizeLevenbergMarquardtBundle( CvMat** projMatrs, CvMat** observProjPoints,
|
||||
CvMat** pointsPres, int numImages,
|
||||
CvMat** resultProjMatrs, CvMat* resultPoints4D,int maxIter,double epsilon );
|
||||
|
||||
|
||||
/* ============== Bundle adjustment optimization ================= */
|
||||
void icvComputeDerivateProj(CvMat *points4D,CvMat *projMatr, CvMat *status, CvMat *derivProj)
|
||||
static void icvComputeDerivateProj(CvMat *points4D,CvMat *projMatr, CvMat *status, CvMat *derivProj)
|
||||
{
|
||||
/* Compute derivate for given projection matrix points and status of points */
|
||||
|
||||
@ -201,7 +205,7 @@ void icvComputeDerivateProj(CvMat *points4D,CvMat *projMatr, CvMat *status, CvMa
|
||||
}
|
||||
/*======================================================================================*/
|
||||
|
||||
void icvComputeDerivateProjAll(CvMat *points4D, CvMat **projMatrs, CvMat **pointPres, int numImages,CvMat **projDerives)
|
||||
static void icvComputeDerivateProjAll(CvMat *points4D, CvMat **projMatrs, CvMat **pointPres, int numImages,CvMat **projDerives)
|
||||
{
|
||||
CV_FUNCNAME( "icvComputeDerivateProjAll" );
|
||||
__BEGIN__;
|
||||
@ -228,7 +232,7 @@ void icvComputeDerivateProjAll(CvMat *points4D, CvMat **projMatrs, CvMat **point
|
||||
}
|
||||
/*======================================================================================*/
|
||||
|
||||
void icvComputeDerivatePoints(CvMat *points4D,CvMat *projMatr, CvMat *presPoints, CvMat *derivPoint)
|
||||
static void icvComputeDerivatePoints(CvMat *points4D,CvMat *projMatr, CvMat *presPoints, CvMat *derivPoint)
|
||||
{
|
||||
|
||||
CV_FUNCNAME( "icvComputeDerivatePoints" );
|
||||
@ -337,8 +341,9 @@ void icvComputeDerivatePoints(CvMat *points4D,CvMat *projMatr, CvMat *presPoints
|
||||
__END__;
|
||||
return;
|
||||
}
|
||||
|
||||
/*======================================================================================*/
|
||||
void icvComputeDerivatePointsAll(CvMat *points4D, CvMat **projMatrs, CvMat **pointPres, int numImages,CvMat **pointDerives)
|
||||
static void icvComputeDerivatePointsAll(CvMat *points4D, CvMat **projMatrs, CvMat **pointPres, int numImages,CvMat **pointDerives)
|
||||
{
|
||||
CV_FUNCNAME( "icvComputeDerivatePointsAll" );
|
||||
__BEGIN__;
|
||||
@ -364,7 +369,7 @@ void icvComputeDerivatePointsAll(CvMat *points4D, CvMat **projMatrs, CvMat **poi
|
||||
return;
|
||||
}
|
||||
/*======================================================================================*/
|
||||
void icvComputeMatrixVAll(int numImages,CvMat **pointDeriv,CvMat **presPoints, CvMat **matrV)
|
||||
static void icvComputeMatrixVAll(int numImages,CvMat **pointDeriv,CvMat **presPoints, CvMat **matrV)
|
||||
{
|
||||
int *shifts = 0;
|
||||
|
||||
@ -433,7 +438,7 @@ void icvComputeMatrixVAll(int numImages,CvMat **pointDeriv,CvMat **presPoints, C
|
||||
return;
|
||||
}
|
||||
/*======================================================================================*/
|
||||
void icvComputeMatrixUAll(int numImages,CvMat **projDeriv,CvMat** matrU)
|
||||
static void icvComputeMatrixUAll(int numImages,CvMat **projDeriv,CvMat** matrU)
|
||||
{
|
||||
CV_FUNCNAME( "icvComputeMatrixVAll" );
|
||||
__BEGIN__;
|
||||
@ -460,7 +465,7 @@ void icvComputeMatrixUAll(int numImages,CvMat **projDeriv,CvMat** matrU)
|
||||
return;
|
||||
}
|
||||
/*======================================================================================*/
|
||||
void icvComputeMatrixW(int numImages, CvMat **projDeriv, CvMat **pointDeriv, CvMat **presPoints, CvMat *matrW)
|
||||
static void icvComputeMatrixW(int numImages, CvMat **projDeriv, CvMat **pointDeriv, CvMat **presPoints, CvMat *matrW)
|
||||
{
|
||||
CV_FUNCNAME( "icvComputeMatrixW" );
|
||||
__BEGIN__;
|
||||
@ -560,9 +565,10 @@ void icvComputeMatrixW(int numImages, CvMat **projDeriv, CvMat **pointDeriv, CvM
|
||||
__END__;
|
||||
return;
|
||||
}
|
||||
|
||||
/*======================================================================================*/
|
||||
/* Compute jacobian mult projection matrices error */
|
||||
void icvComputeJacErrorProj(int numImages,CvMat **projDeriv,CvMat **projErrors,CvMat *jacProjErr )
|
||||
static void icvComputeJacErrorProj(int numImages,CvMat **projDeriv,CvMat **projErrors,CvMat *jacProjErr )
|
||||
{
|
||||
CV_FUNCNAME( "icvComputeJacErrorProj" );
|
||||
__BEGIN__;
|
||||
@ -627,9 +633,10 @@ void icvComputeJacErrorProj(int numImages,CvMat **projDeriv,CvMat **projErrors,C
|
||||
__END__;
|
||||
return;
|
||||
}
|
||||
|
||||
/*======================================================================================*/
|
||||
/* Compute jacobian mult points error */
|
||||
void icvComputeJacErrorPoint(int numImages,CvMat **pointDeriv,CvMat **projErrors, CvMat **presPoints,CvMat *jacPointErr )
|
||||
static void icvComputeJacErrorPoint(int numImages,CvMat **pointDeriv,CvMat **projErrors, CvMat **presPoints,CvMat *jacPointErr )
|
||||
{
|
||||
int *shifts = 0;
|
||||
|
||||
@ -734,6 +741,7 @@ void icvComputeJacErrorPoint(int numImages,CvMat **pointDeriv,CvMat **projErrors
|
||||
}
|
||||
/*======================================================================================*/
|
||||
|
||||
|
||||
/* Reconstruct 4D points using status */
|
||||
void icvReconstructPoints4DStatus(CvMat** projPoints, CvMat **projMatrs, CvMat** presPoints,
|
||||
CvMat *points4D,int numImages,CvMat **projError)
|
||||
@ -897,7 +905,7 @@ void icvReconstructPoints4DStatus(CvMat** projPoints, CvMat **projMatrs, CvMat**
|
||||
|
||||
/*======================================================================================*/
|
||||
|
||||
void icvProjPointsStatusFunc( int numImages, CvMat *points4D, CvMat **projMatrs, CvMat **pointsPres, CvMat **projPoints)
|
||||
static void icvProjPointsStatusFunc( int numImages, CvMat *points4D, CvMat **projMatrs, CvMat **pointsPres, CvMat **projPoints)
|
||||
{
|
||||
CV_FUNCNAME( "icvProjPointsStatusFunc" );
|
||||
__BEGIN__;
|
||||
@ -998,7 +1006,7 @@ void icvProjPointsStatusFunc( int numImages, CvMat *points4D, CvMat **projMatrs,
|
||||
}
|
||||
|
||||
/*======================================================================================*/
|
||||
void icvFreeMatrixArray(CvMat ***matrArray,int numMatr)
|
||||
static void icvFreeMatrixArray(CvMat ***matrArray,int numMatr)
|
||||
{
|
||||
/* Free each matrix */
|
||||
int currMatr;
|
||||
@ -1015,7 +1023,7 @@ void icvFreeMatrixArray(CvMat ***matrArray,int numMatr)
|
||||
}
|
||||
|
||||
/*======================================================================================*/
|
||||
void *icvClearAlloc(int size)
|
||||
static void *icvClearAlloc(int size)
|
||||
{
|
||||
void *ptr = 0;
|
||||
|
||||
@ -1047,6 +1055,7 @@ int icvDeleteSparsInPoints( int numImages,
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/*======================================================================================*/
|
||||
/* !!! may be useful to return norm of error */
|
||||
/* !!! may be does not work correct with not all visible 4D points */
|
||||
|
@ -46,6 +46,8 @@
|
||||
|
||||
/* Valery Mosyagin */
|
||||
|
||||
#if 0
|
||||
|
||||
typedef void (*pointer_LMJac)( const CvMat* src, CvMat* dst );
|
||||
typedef void (*pointer_LMFunc)( const CvMat* src, CvMat* dst );
|
||||
|
||||
@ -61,7 +63,7 @@ void icvReconstructPointsFor3View( CvMat* projMatr1,CvMat* projMatr2,CvMat* proj
|
||||
|
||||
|
||||
/* Jacobian computation for trifocal case */
|
||||
void icvJacobianFunction_ProjTrifocal(const CvMat *vectX,CvMat *Jacobian)
|
||||
static void icvJacobianFunction_ProjTrifocal(const CvMat *vectX,CvMat *Jacobian)
|
||||
{
|
||||
CV_FUNCNAME( "icvJacobianFunction_ProjTrifocal" );
|
||||
__BEGIN__;
|
||||
@ -161,7 +163,7 @@ void icvJacobianFunction_ProjTrifocal(const CvMat *vectX,CvMat *Jacobian)
|
||||
return;
|
||||
}
|
||||
|
||||
void icvFunc_ProjTrifocal(const CvMat *vectX, CvMat *resFunc)
|
||||
static void icvFunc_ProjTrifocal(const CvMat *vectX, CvMat *resFunc)
|
||||
{
|
||||
/* Computes function in a given point */
|
||||
/* Computers project points using 3 projection matrices and points 3D */
|
||||
@ -264,7 +266,7 @@ void icvFunc_ProjTrifocal(const CvMat *vectX, CvMat *resFunc)
|
||||
|
||||
/*----------------------------------------------------------------------------------------*/
|
||||
|
||||
void icvOptimizeProjectionTrifocal(CvMat **projMatrs,CvMat **projPoints,
|
||||
static void icvOptimizeProjectionTrifocal(CvMat **projMatrs,CvMat **projPoints,
|
||||
CvMat **resultProjMatrs, CvMat *resultPoints4D)
|
||||
{
|
||||
|
||||
@ -441,7 +443,7 @@ void icvOptimizeProjectionTrifocal(CvMat **projMatrs,CvMat **projPoints,
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Create good points using status information */
|
||||
void icvCreateGoodPoints(CvMat *points,CvMat **goodPoints, CvMat *status)
|
||||
static void icvCreateGoodPoints(CvMat *points,CvMat **goodPoints, CvMat *status)
|
||||
{
|
||||
*goodPoints = 0;
|
||||
|
||||
@ -493,3 +495,4 @@ void icvCreateGoodPoints(CvMat *points,CvMat **goodPoints, CvMat *status)
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -96,15 +96,15 @@ double _cvStretchingWork(CvPoint2D32f* P1,
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
CvPoint2D32f Q( CvPoint2D32f q0, CvPoint2D32f q1, CvPoint2D32f q2, double t );
|
||||
double angle( CvPoint2D32f A, CvPoint2D32f B );
|
||||
|
||||
double _cvBendingWork( CvPoint2D32f* B0,
|
||||
CvPoint2D32f* F0,
|
||||
CvPoint2D32f* B1,
|
||||
CvPoint2D32f* F1/*,
|
||||
CvPoint* K*/)
|
||||
{
|
||||
CvPoint2D32f Q( CvPoint2D32f q0, CvPoint2D32f q1, CvPoint2D32f q2, double t );
|
||||
double angle( CvPoint2D32f A, CvPoint2D32f B );
|
||||
|
||||
CvPoint2D32f Q0, Q1, Q2;
|
||||
CvPoint2D32f Q1_nm = { 0, 0 }, Q2_nm = { 0, 0 };
|
||||
double d0, d1, d2, des, t_zero;
|
||||
@ -511,6 +511,7 @@ void _cvWorkSouth(int i, int j, _CvWork** W, CvPoint2D32f* edges1, CvPoint2D32f*
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//===================================================
|
||||
CvPoint2D32f Q(CvPoint2D32f q0,CvPoint2D32f q1,CvPoint2D32f q2,double t)
|
||||
{
|
||||
@ -526,7 +527,7 @@ double angle(CvPoint2D32f A, CvPoint2D32f B)
|
||||
{
|
||||
return acos( (A.x*B.x + A.y*B.y)/sqrt( (double)(A.x*A.x + A.y*A.y)*(B.x*B.x + B.y*B.y) ) );
|
||||
}
|
||||
|
||||
#if 0
|
||||
/***************************************************************************************\
|
||||
*
|
||||
* This function compute intermediate polygon between contour1 and contour2
|
||||
@ -536,7 +537,7 @@ double angle(CvPoint2D32f A, CvPoint2D32f B)
|
||||
* param = [0,1]; 0 correspondence to contour1, 1 - contour2
|
||||
*
|
||||
\***************************************************************************************/
|
||||
CvSeq* icvBlendContours(CvSeq* contour1,
|
||||
static CvSeq* icvBlendContours(CvSeq* contour1,
|
||||
CvSeq* contour2,
|
||||
CvSeq* corr,
|
||||
double param,
|
||||
@ -621,7 +622,7 @@ CvSeq* icvBlendContours(CvSeq* contour1,
|
||||
**************************************************************************************************/
|
||||
|
||||
|
||||
void icvCalcContoursCorrespondence(CvSeq* contour1,
|
||||
static void icvCalcContoursCorrespondence(CvSeq* contour1,
|
||||
CvSeq* contour2,
|
||||
CvSeq** corr,
|
||||
CvMemStorage* storage)
|
||||
@ -852,4 +853,4 @@ void icvCalcContoursCorrespondence(CvSeq* contour1,
|
||||
free(edges1);
|
||||
free(edges2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -87,12 +87,12 @@ namespace cv{
|
||||
return cvPoint(rect.x + rect.width/2, rect.y + rect.height/2);
|
||||
}
|
||||
|
||||
void homography_transform(IplImage* frontal, IplImage* result, CvMat* homography)
|
||||
{
|
||||
cvWarpPerspective(frontal, result, homography);
|
||||
}
|
||||
// static void homography_transform(IplImage* frontal, IplImage* result, CvMat* homography)
|
||||
// {
|
||||
// cvWarpPerspective(frontal, result, homography);
|
||||
// }
|
||||
|
||||
CvAffinePose perturbate_pose(CvAffinePose pose, float noise)
|
||||
static CvAffinePose perturbate_pose(CvAffinePose pose, float noise)
|
||||
{
|
||||
// perturbate the matrix
|
||||
float noise_mult_factor = 1 + (0.5f - float(rand())/RAND_MAX)*noise;
|
||||
@ -107,7 +107,7 @@ namespace cv{
|
||||
return pose_pert;
|
||||
}
|
||||
|
||||
void generate_mean_patch(IplImage* frontal, IplImage* result, CvAffinePose pose, int pose_count, float noise)
|
||||
static void generate_mean_patch(IplImage* frontal, IplImage* result, CvAffinePose pose, int pose_count, float noise)
|
||||
{
|
||||
IplImage* sum = cvCreateImage(cvSize(result->width, result->height), IPL_DEPTH_32F, 1);
|
||||
IplImage* workspace = cvCloneImage(result);
|
||||
@ -130,14 +130,14 @@ namespace cv{
|
||||
cvReleaseImage(&workspace_float);
|
||||
}
|
||||
|
||||
void generate_mean_patch_fast(IplImage* /*frontal*/, IplImage* /*result*/, CvAffinePose /*pose*/,
|
||||
CvMat* /*pca_hr_avg*/, CvMat* /*pca_hr_eigenvectors*/, const OneWayDescriptor* /*pca_descriptors*/)
|
||||
{
|
||||
/*for(int i = 0; i < pca_hr_eigenvectors->cols; i++)
|
||||
{
|
||||
// static void generate_mean_patch_fast(IplImage* /*frontal*/, IplImage* /*result*/, CvAffinePose /*pose*/,
|
||||
// CvMat* /*pca_hr_avg*/, CvMat* /*pca_hr_eigenvectors*/, const OneWayDescriptor* /*pca_descriptors*/)
|
||||
// {
|
||||
// /*for(int i = 0; i < pca_hr_eigenvectors->cols; i++)
|
||||
// {
|
||||
|
||||
}*/
|
||||
}
|
||||
// }*/
|
||||
// }
|
||||
|
||||
void readPCAFeatures(const char *filename, CvMat** avg, CvMat** eigenvectors, const char *postfix = "");
|
||||
void readPCAFeatures(const FileNode &fn, CvMat** avg, CvMat** eigenvectors, const char* postfix = "");
|
||||
@ -249,18 +249,18 @@ namespace cv{
|
||||
m_train_patch = cvCreateImage(GetInputPatchSize(), IPL_DEPTH_8U, 1);
|
||||
}
|
||||
|
||||
void cvmSet2DPoint(CvMat* matrix, int row, int col, CvPoint2D32f point)
|
||||
{
|
||||
cvmSet(matrix, row, col, point.x);
|
||||
cvmSet(matrix, row, col + 1, point.y);
|
||||
}
|
||||
// static void cvmSet2DPoint(CvMat* matrix, int row, int col, CvPoint2D32f point)
|
||||
// {
|
||||
// cvmSet(matrix, row, col, point.x);
|
||||
// cvmSet(matrix, row, col + 1, point.y);
|
||||
// }
|
||||
|
||||
void cvmSet3DPoint(CvMat* matrix, int row, int col, CvPoint3D32f point)
|
||||
{
|
||||
cvmSet(matrix, row, col, point.x);
|
||||
cvmSet(matrix, row, col + 1, point.y);
|
||||
cvmSet(matrix, row, col + 2, point.z);
|
||||
}
|
||||
// static void cvmSet3DPoint(CvMat* matrix, int row, int col, CvPoint3D32f point)
|
||||
// {
|
||||
// cvmSet(matrix, row, col, point.x);
|
||||
// cvmSet(matrix, row, col + 1, point.y);
|
||||
// cvmSet(matrix, row, col + 2, point.z);
|
||||
// }
|
||||
|
||||
CvAffinePose GenRandomAffinePose()
|
||||
{
|
||||
@ -560,33 +560,33 @@ namespace cv{
|
||||
for(int i = 0; i < m_pose_count; i++)
|
||||
{
|
||||
double dist = cvNorm(m_pca_coeffs[i], pca_coeffs);
|
||||
// float dist = 0;
|
||||
// float data1, data2;
|
||||
// //CvMat* pose_pca_coeffs = m_pca_coeffs[i];
|
||||
// for (int x=0; x < pca_coeffs->width; x++)
|
||||
// for (int y =0 ; y < pca_coeffs->height; y++)
|
||||
// {
|
||||
// data1 = ((float*)(pca_coeffs->data.ptr + pca_coeffs->step*x))[y];
|
||||
// data2 = ((float*)(m_pca_coeffs[i]->data.ptr + m_pca_coeffs[i]->step*x))[y];
|
||||
// dist+=(data1-data2)*(data1-data2);
|
||||
// }
|
||||
// float dist = 0;
|
||||
// float data1, data2;
|
||||
// //CvMat* pose_pca_coeffs = m_pca_coeffs[i];
|
||||
// for (int x=0; x < pca_coeffs->width; x++)
|
||||
// for (int y =0 ; y < pca_coeffs->height; y++)
|
||||
// {
|
||||
// data1 = ((float*)(pca_coeffs->data.ptr + pca_coeffs->step*x))[y];
|
||||
// data2 = ((float*)(m_pca_coeffs[i]->data.ptr + m_pca_coeffs[i]->step*x))[y];
|
||||
// dist+=(data1-data2)*(data1-data2);
|
||||
// }
|
||||
////#if 1
|
||||
// for (int j = 0; j < m_pca_dim_low; j++)
|
||||
// {
|
||||
// dist += (pose_pca_coeffs->data.fl[j]- pca_coeffs->data.fl[j])*(pose_pca_coeffs->data.fl[j]- pca_coeffs->data.fl[j]);
|
||||
// }
|
||||
// for (int j = 0; j < m_pca_dim_low; j++)
|
||||
// {
|
||||
// dist += (pose_pca_coeffs->data.fl[j]- pca_coeffs->data.fl[j])*(pose_pca_coeffs->data.fl[j]- pca_coeffs->data.fl[j]);
|
||||
// }
|
||||
//#else
|
||||
// for (int j = 0; j <= m_pca_dim_low - 4; j += 4)
|
||||
// {
|
||||
// dist += (pose_pca_coeffs->data.fl[j]- pca_coeffs->data.fl[j])*
|
||||
// (pose_pca_coeffs->data.fl[j]- pca_coeffs->data.fl[j]);
|
||||
// dist += (pose_pca_coeffs->data.fl[j+1]- pca_coeffs->data.fl[j+1])*
|
||||
// (pose_pca_coeffs->data.fl[j+1]- pca_coeffs->data.fl[j+1]);
|
||||
// dist += (pose_pca_coeffs->data.fl[j+2]- pca_coeffs->data.fl[j+2])*
|
||||
// (pose_pca_coeffs->data.fl[j+2]- pca_coeffs->data.fl[j+2]);
|
||||
// dist += (pose_pca_coeffs->data.fl[j+3]- pca_coeffs->data.fl[j+3])*
|
||||
// (pose_pca_coeffs->data.fl[j+3]- pca_coeffs->data.fl[j+3]);
|
||||
// }
|
||||
// for (int j = 0; j <= m_pca_dim_low - 4; j += 4)
|
||||
// {
|
||||
// dist += (pose_pca_coeffs->data.fl[j]- pca_coeffs->data.fl[j])*
|
||||
// (pose_pca_coeffs->data.fl[j]- pca_coeffs->data.fl[j]);
|
||||
// dist += (pose_pca_coeffs->data.fl[j+1]- pca_coeffs->data.fl[j+1])*
|
||||
// (pose_pca_coeffs->data.fl[j+1]- pca_coeffs->data.fl[j+1]);
|
||||
// dist += (pose_pca_coeffs->data.fl[j+2]- pca_coeffs->data.fl[j+2])*
|
||||
// (pose_pca_coeffs->data.fl[j+2]- pca_coeffs->data.fl[j+2]);
|
||||
// dist += (pose_pca_coeffs->data.fl[j+3]- pca_coeffs->data.fl[j+3])*
|
||||
// (pose_pca_coeffs->data.fl[j+3]- pca_coeffs->data.fl[j+3]);
|
||||
// }
|
||||
//#endif
|
||||
if(dist < distance)
|
||||
{
|
||||
@ -619,12 +619,12 @@ namespace cv{
|
||||
//float i1,i2;
|
||||
|
||||
//for (int y = 0; y<patch_32f->height; y++)
|
||||
// for (int x = 0; x< patch_32f->width; x++)
|
||||
// {
|
||||
// i1 = ((float*)(m_samples[i]->imageData + m_samples[i]->widthStep*y))[x];
|
||||
// i2 = ((float*)(patch_32f->imageData + patch_32f->widthStep*y))[x];
|
||||
// dist+= (i1-i2)*(i1-i2);
|
||||
// }
|
||||
// for (int x = 0; x< patch_32f->width; x++)
|
||||
// {
|
||||
// i1 = ((float*)(m_samples[i]->imageData + m_samples[i]->widthStep*y))[x];
|
||||
// i2 = ((float*)(patch_32f->imageData + patch_32f->widthStep*y))[x];
|
||||
// dist+= (i1-i2)*(i1-i2);
|
||||
// }
|
||||
|
||||
if(dist < distance)
|
||||
{
|
||||
@ -826,75 +826,75 @@ namespace cv{
|
||||
int patch_height = patch_size.height;
|
||||
//if (avg)
|
||||
//{
|
||||
CvRect _roi = cvGetImageROI((IplImage*)patch);
|
||||
IplImage* test_img = cvCreateImage(cvSize(patch_width,patch_height), IPL_DEPTH_8U, 1);
|
||||
if(_roi.width != patch_width|| _roi.height != patch_height)
|
||||
{
|
||||
CvRect _roi = cvGetImageROI((IplImage*)patch);
|
||||
IplImage* test_img = cvCreateImage(cvSize(patch_width,patch_height), IPL_DEPTH_8U, 1);
|
||||
if(_roi.width != patch_width|| _roi.height != patch_height)
|
||||
{
|
||||
|
||||
cvResize(patch, test_img);
|
||||
_roi = cvGetImageROI(test_img);
|
||||
}
|
||||
else
|
||||
{
|
||||
cvCopy(patch,test_img);
|
||||
}
|
||||
IplImage* patch_32f = cvCreateImage(cvSize(_roi.width, _roi.height), IPL_DEPTH_32F, 1);
|
||||
float sum = cvSum(test_img).val[0];
|
||||
cvConvertScale(test_img, patch_32f, 1.0f/sum);
|
||||
cvResize(patch, test_img);
|
||||
_roi = cvGetImageROI(test_img);
|
||||
}
|
||||
else
|
||||
{
|
||||
cvCopy(patch,test_img);
|
||||
}
|
||||
IplImage* patch_32f = cvCreateImage(cvSize(_roi.width, _roi.height), IPL_DEPTH_32F, 1);
|
||||
float sum = cvSum(test_img).val[0];
|
||||
cvConvertScale(test_img, patch_32f, 1.0f/sum);
|
||||
|
||||
//ProjectPCASample(patch_32f, avg, eigenvectors, pca_coeffs);
|
||||
//Projecting PCA
|
||||
CvMat* patch_mat = ConvertImageToMatrix(patch_32f);
|
||||
CvMat* temp = cvCreateMat(1, eigenvectors->cols, CV_32FC1);
|
||||
cvProjectPCA(patch_mat, avg, eigenvectors, temp);
|
||||
CvMat temp1;
|
||||
cvGetSubRect(temp, &temp1, cvRect(0, 0, pca_coeffs->cols, 1));
|
||||
cvCopy(&temp1, pca_coeffs);
|
||||
cvReleaseMat(&temp);
|
||||
cvReleaseMat(&patch_mat);
|
||||
//End of projecting
|
||||
//ProjectPCASample(patch_32f, avg, eigenvectors, pca_coeffs);
|
||||
//Projecting PCA
|
||||
CvMat* patch_mat = ConvertImageToMatrix(patch_32f);
|
||||
CvMat* temp = cvCreateMat(1, eigenvectors->cols, CV_32FC1);
|
||||
cvProjectPCA(patch_mat, avg, eigenvectors, temp);
|
||||
CvMat temp1;
|
||||
cvGetSubRect(temp, &temp1, cvRect(0, 0, pca_coeffs->cols, 1));
|
||||
cvCopy(&temp1, pca_coeffs);
|
||||
cvReleaseMat(&temp);
|
||||
cvReleaseMat(&patch_mat);
|
||||
//End of projecting
|
||||
|
||||
cvReleaseImage(&patch_32f);
|
||||
cvReleaseImage(&test_img);
|
||||
// }
|
||||
cvReleaseImage(&patch_32f);
|
||||
cvReleaseImage(&test_img);
|
||||
// }
|
||||
|
||||
//--------
|
||||
|
||||
//float* target = new float[m_pca_dim_low];
|
||||
//::cvflann::KNNResultSet res(1,pca_coeffs->data.fl,m_pca_dim_low);
|
||||
//::cvflann::SearchParams params;
|
||||
//params.checks = -1;
|
||||
//float* target = new float[m_pca_dim_low];
|
||||
//::cvflann::KNNResultSet res(1,pca_coeffs->data.fl,m_pca_dim_low);
|
||||
//::cvflann::SearchParams params;
|
||||
//params.checks = -1;
|
||||
|
||||
//int maxDepth = 1000000;
|
||||
//int neighbors_count = 1;
|
||||
//int* neighborsIdx = new int[neighbors_count];
|
||||
//float* distances = new float[neighbors_count];
|
||||
//if (m_pca_descriptors_tree->findNearest(pca_coeffs->data.fl,neighbors_count,maxDepth,neighborsIdx,0,distances) > 0)
|
||||
//{
|
||||
// desc_idx = neighborsIdx[0] / m_pose_count;
|
||||
// pose_idx = neighborsIdx[0] % m_pose_count;
|
||||
// distance = distances[0];
|
||||
//}
|
||||
//delete[] neighborsIdx;
|
||||
//delete[] distances;
|
||||
//int maxDepth = 1000000;
|
||||
//int neighbors_count = 1;
|
||||
//int* neighborsIdx = new int[neighbors_count];
|
||||
//float* distances = new float[neighbors_count];
|
||||
//if (m_pca_descriptors_tree->findNearest(pca_coeffs->data.fl,neighbors_count,maxDepth,neighborsIdx,0,distances) > 0)
|
||||
//{
|
||||
// desc_idx = neighborsIdx[0] / m_pose_count;
|
||||
// pose_idx = neighborsIdx[0] % m_pose_count;
|
||||
// distance = distances[0];
|
||||
//}
|
||||
//delete[] neighborsIdx;
|
||||
//delete[] distances;
|
||||
|
||||
cv::Mat m_object(1, m_pca_dim_low, CV_32F);
|
||||
cv::Mat m_indices(1, 1, CV_32S);
|
||||
cv::Mat m_dists(1, 1, CV_32F);
|
||||
cv::Mat m_object(1, m_pca_dim_low, CV_32F);
|
||||
cv::Mat m_indices(1, 1, CV_32S);
|
||||
cv::Mat m_dists(1, 1, CV_32F);
|
||||
|
||||
float* object_ptr = m_object.ptr<float>(0);
|
||||
for (int i=0;i<m_pca_dim_low;i++)
|
||||
{
|
||||
object_ptr[i] = pca_coeffs->data.fl[i];
|
||||
}
|
||||
float* object_ptr = m_object.ptr<float>(0);
|
||||
for (int i=0;i<m_pca_dim_low;i++)
|
||||
{
|
||||
object_ptr[i] = pca_coeffs->data.fl[i];
|
||||
}
|
||||
|
||||
m_pca_descriptors_tree->knnSearch(m_object, m_indices, m_dists, 1, cv::flann::SearchParams(-1) );
|
||||
m_pca_descriptors_tree->knnSearch(m_object, m_indices, m_dists, 1, cv::flann::SearchParams(-1) );
|
||||
|
||||
desc_idx = ((int*)(m_indices.ptr<int>(0)))[0] / m_pose_count;
|
||||
pose_idx = ((int*)(m_indices.ptr<int>(0)))[0] % m_pose_count;
|
||||
distance = ((float*)(m_dists.ptr<float>(0)))[0];
|
||||
desc_idx = ((int*)(m_indices.ptr<int>(0)))[0] / m_pose_count;
|
||||
pose_idx = ((int*)(m_indices.ptr<int>(0)))[0] % m_pose_count;
|
||||
distance = ((float*)(m_dists.ptr<float>(0)))[0];
|
||||
|
||||
// delete[] target;
|
||||
// delete[] target;
|
||||
|
||||
|
||||
// for(int i = 0; i < desc_count; i++)
|
||||
@ -905,14 +905,14 @@ namespace cv{
|
||||
//#if 0
|
||||
// descriptors[i].EstimatePose(patch, _pose_idx, _distance);
|
||||
//#else
|
||||
// if (!avg)
|
||||
// {
|
||||
// descriptors[i].EstimatePosePCA(patch, _pose_idx, _distance, avg, eigenvectors);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// descriptors[i].EstimatePosePCA(pca_coeffs, _pose_idx, _distance, avg, eigenvectors);
|
||||
// }
|
||||
// if (!avg)
|
||||
// {
|
||||
// descriptors[i].EstimatePosePCA(patch, _pose_idx, _distance, avg, eigenvectors);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// descriptors[i].EstimatePosePCA(pca_coeffs, _pose_idx, _distance, avg, eigenvectors);
|
||||
// }
|
||||
//#endif
|
||||
//
|
||||
// if(_distance < distance)
|
||||
@ -1226,7 +1226,7 @@ namespace cv{
|
||||
m_pca_descriptors_matrix = 0;
|
||||
m_pca_descriptors_tree = 0;
|
||||
#endif
|
||||
// m_pca_descriptors_matrix = 0;
|
||||
// m_pca_descriptors_matrix = 0;
|
||||
m_patch_size = patch_size;
|
||||
m_pose_count = pose_count;
|
||||
m_pyr_levels = pyr_levels;
|
||||
@ -1347,7 +1347,7 @@ namespace cv{
|
||||
scale_max = fn["maxScale"];
|
||||
scale_step = fn["stepScale"];
|
||||
|
||||
LoadPCAall (fn);
|
||||
LoadPCAall (fn);
|
||||
}
|
||||
|
||||
void OneWayDescriptorBase::LoadPCAall (const FileNode &fn)
|
||||
@ -1726,7 +1726,7 @@ namespace cv{
|
||||
cvReleaseMat(&eigenvalues);
|
||||
}
|
||||
|
||||
void extractPatches (IplImage *img, vector<IplImage*>& patches, CvSize patch_size)
|
||||
static void extractPatches (IplImage *img, vector<IplImage*>& patches, CvSize patch_size)
|
||||
{
|
||||
vector<KeyPoint> features;
|
||||
Ptr<FeatureDetector> surf_extractor = FeatureDetector::create("SURF");
|
||||
@ -1974,14 +1974,14 @@ namespace cv{
|
||||
int pca_dim_low = this->GetDescriptor(0)->GetPCADimLow();
|
||||
|
||||
//if (!m_pca_descriptors_matrix)
|
||||
// m_pca_descriptors_matrix = new ::cvflann::Matrix<float>(n*m_pose_count,pca_dim_low);
|
||||
// m_pca_descriptors_matrix = new ::cvflann::Matrix<float>(n*m_pose_count,pca_dim_low);
|
||||
//else
|
||||
//{
|
||||
// if ((m_pca_descriptors_matrix->cols != pca_dim_low)&&(m_pca_descriptors_matrix->rows != n*m_pose_count))
|
||||
// {
|
||||
// delete m_pca_descriptors_matrix;
|
||||
// m_pca_descriptors_matrix = new ::cvflann::Matrix<float>(n*m_pose_count,pca_dim_low);
|
||||
// }
|
||||
// if ((m_pca_descriptors_matrix->cols != pca_dim_low)&&(m_pca_descriptors_matrix->rows != n*m_pose_count))
|
||||
// {
|
||||
// delete m_pca_descriptors_matrix;
|
||||
// m_pca_descriptors_matrix = new ::cvflann::Matrix<float>(n*m_pose_count,pca_dim_low);
|
||||
// }
|
||||
//}
|
||||
|
||||
m_pca_descriptors_matrix = cvCreateMat(n*m_pose_count,pca_dim_low,CV_32FC1);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user