本文整理汇总了C++中CFeatureList::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ CFeatureList::empty方法的具体用法?C++ CFeatureList::empty怎么用?C++ CFeatureList::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFeatureList
的用法示例。
在下文中一共展示了CFeatureList::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: int
inline void trackFeatures_addNewFeats<CFeatureList>(CFeatureList &featureList,const TSimpleFeatureList &new_feats, const std::vector<size_t> &sorted_indices, const size_t nNewToCheck,const size_t maxNumFeatures,const float minimum_KLT_response_to_add,const double threshold_sqr_dist_to_add_new,const size_t patchSize,const CImage &cur_gray, TFeatureID &max_feat_ID_at_input)
{
const TImageSize imgSize = cur_gray.getSize();
const int offset = (int)patchSize/2 + 1;
const int w_off = int(imgSize.x - offset);
const int h_off = int(imgSize.y - offset);
for (size_t i=0;i<nNewToCheck && featureList.size()<maxNumFeatures;i++)
{
const TSimpleFeature &feat = new_feats[ sorted_indices[i] ];
if (feat.response<minimum_KLT_response_to_add) continue;
double min_dist_sqr = square(10000);
if (!featureList.empty())
{
//m_timlog.enter("[CGenericFeatureTracker] add new features.kdtree");
min_dist_sqr = featureList.kdTreeClosestPoint2DsqrError(feat.pt.x,feat.pt.y );
//m_timlog.leave("[CGenericFeatureTracker] add new features.kdtree");
}
if (min_dist_sqr>threshold_sqr_dist_to_add_new &&
feat.pt.x > offset &&
feat.pt.y > offset &&
feat.pt.x < w_off &&
feat.pt.y < h_off )
{
// Add new feature:
CFeaturePtr ft = CFeature::Create();
ft->type = featFAST;
ft->ID = ++max_feat_ID_at_input;
ft->x = feat.pt.x;
ft->y = feat.pt.y;
ft->response = feat.response;
ft->orientation = 0;
ft->scale = 1;
ft->patchSize = patchSize; // The size of the feature patch
if( patchSize > 0 )
cur_gray.extract_patch(
ft->patch,
round( ft->x ) - offset,
round( ft->y ) - offset,
patchSize,
patchSize ); // Image patch surronding the feature
featureList.push_back( ft );
}
}
} // end of trackFeatures_addNewFeats<>
示例2: internal_computeSurfDescriptors
/************************************************************************************************
* internal_computeSurfDescriptors
************************************************************************************************/
void CFeatureExtraction::internal_computeSurfDescriptors(
const mrpt::utils::CImage &inImg,
CFeatureList &in_features) const
{
#if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x111
if (in_features.empty()) return;
const CImage img_grayscale(inImg, FAST_REF_OR_CONVERT_TO_GRAY);
const IplImage* cGrey = img_grayscale.getAs<IplImage>();
CvMemStorage *storage = cvCreateMemStorage(0);
// Fill in the desired key-points:
CvSeq *kp = cvCreateSeq( 0, sizeof(CvSeq), sizeof(CvSURFPoint), storage );
for (CFeatureList::iterator itList=in_features.begin();itList!=in_features.end();++itList)
{
CvSURFPoint point = cvSURFPoint(
cvPoint2D32f((*itList)->x,(*itList)->y),
0, // Laplacian
16 //sizes[layer]
);
cvSeqPush( kp, &point );
}
CvSeq *desc = NULL;
// Only computes the descriptors:
// Extract the SURF points:
CvSURFParams surf_params = cvSURFParams(options.SURFOptions.hessianThreshold, options.SURFOptions.rotation_invariant ? 1:0);
surf_params.nOctaves = options.SURFOptions.nOctaves;
surf_params.nOctaveLayers = options.SURFOptions.nLayersPerOctave;
cvExtractSURF( cGrey, NULL, &kp, &desc, storage, surf_params, 1 /* Use precomputed key-points */ );
// *** HAVE YOU HAD A COMPILER ERROR NEAR THIS LINE?? : You need OpenCV >=1.1.0, final release or a SVN version ***
// -----------------------------------------------------------------
// MRPT Wrapping
// -----------------------------------------------------------------
CFeatureList::iterator itList;
int i;
for (i=0, itList=in_features.begin();itList!=in_features.end();itList++,i++)
{
// Get the OpenCV SURF point
CFeaturePtr ft = *itList;
CvSURFPoint *point = (CvSURFPoint*)cvGetSeqElem( kp, i );
ft->orientation = point->dir; // Orientation
ft->scale = point->size*1.2/9; // Scale
// Get the SURF descriptor
float* d = (float*)cvGetSeqElem( desc, i );
ft->descriptors.SURF.resize( options.SURFOptions.rotation_invariant ? 128 : 64 );
std::vector<float>::iterator itDesc;
unsigned int k;
for( k = 0, itDesc = ft->descriptors.SURF.begin(); k < ft->descriptors.SURF.size(); k++, itDesc++ )
*itDesc = d[k];
} // end for
cvReleaseMemStorage(&storage); // Free memory
#else
THROW_EXCEPTION("Method not available since either MRPT has been compiled without OpenCV or OpenCV version is incorrect (Required 1.1.0)")
#endif //MRPT_HAS_OPENCV
} // end internal_computeSurfDescriptors