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