本文整理汇总了C++中CFeatureList::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ CFeatureList::resize方法的具体用法?C++ CFeatureList::resize怎么用?C++ CFeatureList::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFeatureList
的用法示例。
在下文中一共展示了CFeatureList::resize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractFeaturesSIFT
/************************************************************************************************
* extractFeaturesSIFT *
************************************************************************************************/
void CFeatureExtraction::extractFeaturesSIFT(
const CImage &img,
CFeatureList &feats,
unsigned int init_ID,
unsigned int nDesiredFeatures,
const TImageROI &ROI) const
{
bool usingROI = false;
if( ROI.xMin != 0 || ROI.xMax != 0 || ROI.yMin != 0 || ROI.yMax != 0 )
usingROI = true; // A ROI has been defined
// ROI can not be managed properly (yet) with these method, so we extract a subimage
// use a smart pointer so we just copy the pointer if the image is grayscale, or we'll create a new one if it was RGB:
CImage img_grayscale(img, FAST_REF_OR_CONVERT_TO_GRAY); // Was: auxImgPtr;
if( usingROI )
{
ASSERT_( ROI.xMin >= 0 && ROI.xMin < ROI.xMax && ROI.xMax < img.getWidth() && ROI.yMin >= 0 && ROI.yMax < img.getHeight() && ROI.yMin < ROI.yMax );
CImage auximg;
img_grayscale.extract_patch( auximg, ROI.xMin, ROI.yMin, ROI.xMax-ROI.xMin+1, ROI.yMax-ROI.yMin+1 ); // Subimage in "auxImg"
img_grayscale.swap(auximg);
}
switch( options.SIFTOptions.implementation )
{
// --------------------------------------------------------------------------------------
// Binary in C# -> OPTIONAL: Feature position already computed
// --------------------------------------------------------------------------------------
case CSBinary:
{
#ifdef MRPT_OS_WINDOWS
char filImg[2000],filOut[2000],filFeat[2000];
char paramImg[2000];
GetTempPathA(1000,filOut); os::strcat(filOut,1000,"temp_out.txt"); // OUTPUT FILE
GetTempPathA(1000,filImg); os::strcat(filImg,1000,"temp_img.bmp"); // INPUT IMAGE (BMP) FOR BINARY IN (C#)
bool onlyDesc = feats.size() > 0 ? true : false;
if( onlyDesc )
{
GetTempPathA(1000,filFeat); os::strcat(filFeat,1000,"temp_feats.txt"); // KEYPOINTS INPUT FILE
CMatrix listPoints(feats.size(),2);
for (size_t i= 0;i<feats.size();i++)
{
listPoints(i,0) = feats[i]->x;
listPoints(i,1) = feats[i]->y;
}
listPoints.saveToTextFile( filFeat, MATRIX_FORMAT_FIXED /*Float format*/ );
} // end if
// -------------------------------------------
// CALL TO "extractSIFT.exe"
// -------------------------------------------
img_grayscale.saveToFile( filImg );
// ------------------------------------
// Version with "CreateProcess":
// ------------------------------------
os::strcpy(paramImg,1000,"extractSIFT.exe -i"); os::strcat(paramImg,1000,filImg);
os::strcat(paramImg,1000," -f"); os::strcat(paramImg,1000,filOut);
os::strcat(paramImg,1000," -l"); os::strcat(paramImg,1000,filFeat);
// ------------------------------------
// Launch process
// ------------------------------------
bool ret = mrpt::system::launchProcess( paramImg );
if( !ret )
THROW_EXCEPTION( "[extractFeaturesSIFT] Could not launch external process... (extractSIFT.exe)" )
// Process Results
CFeatureList::iterator itFeat = feats.begin();
size_t nFeats;
CMatrix aux;
aux.loadFromTextFile( filOut );
std::cout << "[computeSiftFeatures] " << aux.getRowCount() << " features." << std::endl;
if( onlyDesc )
nFeats = feats.size();
else
{
nFeats = aux.getRowCount();
feats.resize( nFeats );
}
for( size_t i = 0;
itFeat != feats.end();
i++, itFeat++)
{
(*itFeat)->type = featSIFT;
(*itFeat)->x = usingROI ? aux(i,0) + ROI.xMin : aux(i,0);
(*itFeat)->y = usingROI ? aux(i,1) + ROI.yMin : aux(i,1);
(*itFeat)->orientation = aux(i,2);
(*itFeat)->scale = aux(i,3);
//.........这里部分代码省略.........