Added Fern Descriptor and Calonder Descriptor to the evaluation framework
This commit is contained in:
@@ -252,6 +252,10 @@ void OneWayDescriptorMatch::initialize( const Params& _params, OneWayDescriptorB
|
||||
|
||||
void OneWayDescriptorMatch::add( const Mat& image, vector<KeyPoint>& keypoints )
|
||||
{
|
||||
if( base.empty() )
|
||||
base = new OneWayDescriptorObject( params.patchSize, params.poseCount, params.pcaFilename,
|
||||
params.trainPath, params.trainImagesList, params.minScale, params.maxScale, params.stepScale);
|
||||
|
||||
size_t trainFeatureCount = keypoints.size();
|
||||
|
||||
base->Allocate( trainFeatureCount );
|
||||
@@ -269,6 +273,10 @@ void OneWayDescriptorMatch::add( const Mat& image, vector<KeyPoint>& keypoints )
|
||||
|
||||
void OneWayDescriptorMatch::add( KeyPointCollection& keypoints )
|
||||
{
|
||||
if( base.empty() )
|
||||
base = new OneWayDescriptorObject( params.patchSize, params.poseCount, params.pcaFilename,
|
||||
params.trainPath, params.trainImagesList, params.minScale, params.maxScale, params.stepScale);
|
||||
|
||||
size_t trainFeatureCount = keypoints.calcKeypointCount();
|
||||
|
||||
base->Allocate( trainFeatureCount );
|
||||
@@ -306,39 +314,15 @@ void OneWayDescriptorMatch::match( const Mat& image, vector<KeyPoint>& points, v
|
||||
|
||||
void OneWayDescriptorMatch::read( const FileNode &fn )
|
||||
{
|
||||
readParams (fn);
|
||||
|
||||
base = new OneWayDescriptorObject( params.patchSize, params.poseCount, string (), string (), string (),
|
||||
params.minScale, params.maxScale, params.stepScale );
|
||||
base->LoadPCAall (fn);
|
||||
base->Read (fn);
|
||||
}
|
||||
|
||||
void OneWayDescriptorMatch::readParams ( const FileNode &fn )
|
||||
{
|
||||
params.poseCount = fn["poseCount"];
|
||||
int patchWidth = fn["patchWidth"];
|
||||
int patchHeight = fn["patchHeight"];
|
||||
params.patchSize = Size(patchWidth, patchHeight);
|
||||
params.minScale = fn["minScale"];
|
||||
params.maxScale = fn["maxScale"];
|
||||
params.stepScale = fn["stepScale"];
|
||||
}
|
||||
|
||||
void OneWayDescriptorMatch::write( FileStorage& fs ) const
|
||||
{
|
||||
// fs << "algorithm" << getAlgorithmName ();
|
||||
writeParams (fs);
|
||||
base->SavePCAall (fs);
|
||||
}
|
||||
|
||||
void OneWayDescriptorMatch::writeParams( FileStorage& fs ) const
|
||||
{
|
||||
fs << "poseCount" << params.poseCount;
|
||||
fs << "patchWidth" << params.patchSize.width;
|
||||
fs << "patchHeight" << params.patchSize.height;
|
||||
fs << "minScale" << params.minScale;
|
||||
fs << "maxScale" << params.maxScale;
|
||||
fs << "stepScale" << params.stepScale;
|
||||
base->Write (fs);
|
||||
}
|
||||
|
||||
void OneWayDescriptorMatch::classify( const Mat& image, vector<KeyPoint>& points )
|
||||
@@ -484,6 +468,34 @@ void CalonderDescriptorMatch::classify( const Mat& image, vector<KeyPoint>& keyp
|
||||
}
|
||||
}
|
||||
|
||||
void CalonderDescriptorMatch::clear ()
|
||||
{
|
||||
GenericDescriptorMatch::clear();
|
||||
classifier.release();
|
||||
}
|
||||
|
||||
void CalonderDescriptorMatch::read( const FileNode &fn )
|
||||
{
|
||||
params.numTrees = fn["numTrees"];
|
||||
params.depth = fn["depth"];
|
||||
params.views = fn["views"];
|
||||
params.patchSize = fn["patchSize"];
|
||||
params.reducedNumDim = (int) fn["reducedNumDim"];
|
||||
params.numQuantBits = fn["numQuantBits"];
|
||||
params.printStatus = (int) fn["printStatus"];
|
||||
}
|
||||
|
||||
void CalonderDescriptorMatch::write( FileStorage& fs ) const
|
||||
{
|
||||
fs << "numTrees" << params.numTrees;
|
||||
fs << "depth" << params.depth;
|
||||
fs << "views" << params.views;
|
||||
fs << "patchSize" << params.patchSize;
|
||||
fs << "reducedNumDim" << (int) params.reducedNumDim;
|
||||
fs << "numQuantBits" << params.numQuantBits;
|
||||
fs << "printStatus" << params.printStatus;
|
||||
}
|
||||
|
||||
/****************************************************************************************\
|
||||
* FernDescriptorMatch *
|
||||
\****************************************************************************************/
|
||||
@@ -597,3 +609,35 @@ void FernDescriptorMatch::classify( const Mat& image, vector<KeyPoint>& keypoint
|
||||
keypoints[pi].class_id = collection.getKeyPoint(bestMatchIdx).class_id;
|
||||
}
|
||||
}
|
||||
|
||||
void FernDescriptorMatch::read( const FileNode &fn )
|
||||
{
|
||||
params.nclasses = fn["nclasses"];
|
||||
params.patchSize = fn["patchSize"];
|
||||
params.signatureSize = fn["signatureSize"];
|
||||
params.nstructs = fn["nstructs"];
|
||||
params.structSize = fn["structSize"];
|
||||
params.nviews = fn["nviews"];
|
||||
params.compressionMethod = fn["compressionMethod"];
|
||||
|
||||
//classifier->read(fn);
|
||||
}
|
||||
|
||||
void FernDescriptorMatch::write( FileStorage& fs ) const
|
||||
{
|
||||
fs << "nclasses" << params.nclasses;
|
||||
fs << "patchSize" << params.patchSize;
|
||||
fs << "signatureSize" << params.signatureSize;
|
||||
fs << "nstructs" << params.nstructs;
|
||||
fs << "structSize" << params.structSize;
|
||||
fs << "nviews" << params.nviews;
|
||||
fs << "compressionMethod" << params.compressionMethod;
|
||||
|
||||
// classifier->write(fs);
|
||||
}
|
||||
|
||||
void FernDescriptorMatch::clear ()
|
||||
{
|
||||
GenericDescriptorMatch::clear();
|
||||
classifier.release();
|
||||
}
|
||||
|
@@ -1332,19 +1332,26 @@ namespace cv{
|
||||
}
|
||||
}
|
||||
|
||||
void OneWayDescriptorBase::Read (const FileNode &fn)
|
||||
{
|
||||
clear ();
|
||||
|
||||
m_pose_count = fn["poseCount"];
|
||||
int patch_width = fn["patchWidth"];
|
||||
int patch_height = fn["patchHeight"];
|
||||
m_patch_size = cvSize (patch_width, patch_height);
|
||||
m_pyr_levels = fn["pyrLevels"];
|
||||
m_pca_dim_high = fn["pcaDimHigh"];
|
||||
m_pca_dim_low = fn["pcaDimLow"];
|
||||
scale_min = fn["minScale"];
|
||||
scale_max = fn["maxScale"];
|
||||
scale_step = fn["stepScale"];
|
||||
|
||||
LoadPCAall (fn);
|
||||
}
|
||||
|
||||
void OneWayDescriptorBase::LoadPCAall (const FileNode &fn)
|
||||
{
|
||||
// m_pose_count = fn["pose_count"];
|
||||
// int patch_width = fn["patch_width"];
|
||||
// int patch_height = fn["patch_height"];
|
||||
// m_patch_size = cvSize (patch_width, patch_height);
|
||||
// m_pyr_levels = fn["pyr_levels"];
|
||||
// m_pca_dim_high = fn["pca_dim_high"];
|
||||
// m_pca_dim_low = fn["pca_dim_low"];
|
||||
// scale_min = fn["scale_min"];
|
||||
// scale_max = fn["scale_max"];
|
||||
// scale_step = fn["scale_step"];
|
||||
|
||||
readPCAFeatures(fn, &m_pca_avg, &m_pca_eigenvectors, "_lr");
|
||||
readPCAFeatures(fn, &m_pca_hr_avg, &m_pca_hr_eigenvectors, "_hr");
|
||||
m_pca_descriptors = new OneWayDescriptor[m_pca_dim_high + 1];
|
||||
@@ -1855,17 +1862,23 @@ namespace cv{
|
||||
fs.release();
|
||||
}
|
||||
|
||||
void OneWayDescriptorBase::Write (FileStorage &fs) const
|
||||
{
|
||||
fs << "poseCount" << m_pose_count;
|
||||
fs << "patchWidth" << m_patch_size.width;
|
||||
fs << "patchHeight" << m_patch_size.height;
|
||||
fs << "minScale" << scale_min;
|
||||
fs << "maxScale" << scale_max;
|
||||
fs << "stepScale" << scale_step;
|
||||
fs << "pyrLevels" << m_pyr_levels;
|
||||
fs << "pcaDimHigh" << m_pca_dim_high;
|
||||
fs << "pcaDimLow" << m_pca_dim_low;
|
||||
|
||||
SavePCAall (fs);
|
||||
}
|
||||
|
||||
void OneWayDescriptorBase::SavePCAall (FileStorage &fs) const
|
||||
{
|
||||
// fs << "pose_count" << m_pose_count;
|
||||
// fs << "patch_width" << m_patch_size.width;
|
||||
// fs << "patch_height" << m_patch_size.height;
|
||||
// fs << "scale_min" << scale_min;
|
||||
// fs << "scale_max" << scale_max;
|
||||
// fs << "scale_step" << scale_step;
|
||||
// fs << "pyr_levels" << m_pyr_levels;
|
||||
// fs << "pca_dim_low" << m_pca_dim_low;
|
||||
|
||||
savePCAFeatures(fs, "hr", m_pca_hr_avg, m_pca_hr_eigenvectors);
|
||||
savePCAFeatures(fs, "lr", m_pca_avg, m_pca_eigenvectors);
|
||||
SavePCADescriptors(*fs);
|
||||
|
Reference in New Issue
Block a user