本文整理汇总了C++中FileName::getExtension方法的典型用法代码示例。如果您正苦于以下问题:C++ FileName::getExtension方法的具体用法?C++ FileName::getExtension怎么用?C++ FileName::getExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName::getExtension方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void run()
{
std::string extension=fnStack.getExtension();
if (extension=="mrc")
fnStack+=":mrcs";
else if (extension=="ali")
fnStack+=":mrcs";
std::ifstream fhAngles;
fhAngles.open(fnAngles.c_str());
if (!fhAngles)
REPORT_ERROR(ERR_IO_NOTOPEN,fnAngles);
Image<double> stack;
stack.read(fnStack, HEADER);
size_t xdim, ydim, zdim, ndim;
stack.getDimensions(xdim, ydim, zdim, ndim);
MetaData MD;
FileName fnSlice;
for (unsigned long slice = FIRST_IMAGE; slice <= ndim; slice++)
{
double angle;
fhAngles >> angle;
fnSlice.compose((int)slice,fnStack);
size_t objId=MD.addObject();
MD.setValue(MDL_IMAGE,fnSlice,objId);
MD.setValue(MDL_ANGLE_TILT,angle,objId);
MD.setValue(MDL_ENABLED,1,objId);
}
MD.write(fnOut);
}
示例2: createDefault
AnimationController* AnimationControllerFactory::createDefault()
{
AnimationController *model = 0;
const FileName fileName("data/models/cylinder/cylinder.md3xml");
MAP::iterator i = loader.find(fileName.getExtension());
if(i == loader.end() ||
(i != loader.end() &&
!(model = i->second->load(fileName, textureFactory))))
{
FAIL("Failed to load default model: " + fileName.str());
return 0;
}
return model;
}
示例3: createDefault
AnimationController* AnimationControllerFactory::createDefault() {
const FileName fileName("data/models/cylinder/cylinder.md3xml");
MAP::iterator i = loader.find(fileName.getExtension());
shared_ptr<ModelLoader> &modelLoader = i->second;
if (i == loader.end()) {
FAIL("No loader appropriate for default model: " + fileName.str());
return 0;
}
// Attempt to load the default model
AnimationController *model = modelLoader->load(fileName, textureFactory);
if (model) {
return model;
} else {
FAIL("Failed to load default model: " + fileName.str());
return 0;
}
}
示例4: checkImageFileSize
bool checkImageFileSize(const FileName &name, const ImageInfo &imgInfo, bool error)
{
FileName ext = name.getExtension();
FileName dataFname;
if ( ext.contains("hed"))
dataFname = name.removeLastExtension().addExtension("img");
else if (ext.contains("inf"))
dataFname = name.removeLastExtension();
else if (ext.contains("tif") || ext.contains("jpg") || ext.contains("hdf") || ext.contains("h5"))
return true;
else
dataFname = name;
size_t expectedSize = imgInfo.adim.nzyxdim*gettypesize(imgInfo.datatype) + imgInfo.offset;
size_t actualSize = dataFname.removeAllPrefixes().removeFileFormat().getFileSize();
bool result = (actualSize >= expectedSize);
if (error && !result)
REPORT_ERROR(ERR_IO_SIZE, formatString("Image Extension: File %s has wrong size.\n"
"Expected size (at least) %u bytes. Actual size %u bytes.", name.c_str(), expectedSize, actualSize));
return result;
}
示例5: run
void run()
{
FileName fn_out;
FileName fn_ext = fn_in.getExtension();
Image<double> I, label;
I.read(fn_in);
int object_no;
if (ZSIZE(I())==1)
object_no=labelImage2D(I(), label());
else
object_no=labelImage3D(I(), label());
for (int o = 0; o <= object_no; o++)
{
I() = label();
MultidimArray<double> &Im=MULTIDIM_ARRAY(I);
FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(Im)
{
DIRECT_MULTIDIM_ELEM(Im,n) = (DIRECT_MULTIDIM_ELEM(Im,n) == o);
if (invert)
DIRECT_MULTIDIM_ELEM(Im,n) = 1 - DIRECT_MULTIDIM_ELEM(Im,n);
}
double number_elements = I().sum();
if (number_elements > min_size)
{
fn_out.compose(fn_root, o+1, fn_ext);
I.write(fn_out);
}
if (ZSIZE(I())==1)
std::cout << "Image number " << o+1 << " contains " << number_elements
<< " pixels set to 1\n";
else
std::cout << "Volume number " << o+1 << " contains " << number_elements
<< " voxels set to 1\n";
}
}
示例6: main
int main(int argc, char *argv[])
{
if(argc > 1)
{
if(!strcmp(argv[1], "-h"))
{
cout << "Paker - Compressão de ficheiros" << endl;
cout << endl << "Para empacotar use:" << endl;
cout << endl << argv[0] << " rle|lzss|mix repetition_bits|[position_bits coincidence_bits] <filename>" << endl;
cout << endl << "ou para desempacotar:" << endl;
cout << endl << argv[0] << " -u <filename>" << endl;
cout << endl << "Para comprimir escolher um dos seguintes modos:" << endl;
cout << endl << "\trle - Utilizar a te'cnica RLE sobre o ficheiro, ";
cout << "e' necessa'rio fornecer o valore de repetition_bits (valores 4 por defeito)." << endl;
cout << endl << "\tlzss - Utilizar a te'cnica LZSS sobre o ficheiro, ";
cout << "e' necessa'rio fornecer os valores de position_bits e coincidence_bits (valores 10 e 4 por defeito)." << endl;
cout << endl << "\tmix - Utilizar a te'cnica LZSS em conjunto com RLE sobre o ficheiro, ";
cout << "e' necessa'rio fornecer os valores de repetition_bits, position_bits e coincidence_bits (valores 4, 10 e 4 por defeito)." << endl;
cout << endl << endl << "ISEL 2008 - Fa'bio Oliveira [30979] e Renato Verissi'mo [30796]" << endl;
return 0;
}
else if(!strcmp(argv[1], "-u"))
{
if (argc < 3)
{
cout << "Use " << argv[0] << " -h para obter ajuda" << endl;
return 1;
}
UnPk upk(argv[argc - 1]);
int error = upk.init();
if(error)
return error;
upk.go();
}
else
{
if (argc < 4)
{
cout << "Use " << argv[0] << " -h para obter ajuda" << endl;
return 1;
}
FileName iname = argv[argc - 1];
FileName oname = iname.getBaseName();
oname.addExtension(pk_ext);
Pk pk(iname, oname);
int error = pk.init();
if(error)
return error;
pk.go(argc - 2, argv + 1, iname.getExtension());
}
}
else
{
cout << "Use " << argv[0] << " -h para obter ajuda" << endl;
return 1;
}
}
示例7: setDevice
int main2()
{
MultidimArray<double> preImg, avgCurr, mappedImg;
MultidimArray<double> outputMovie;
Matrix1D<double> meanStdev;
ImageGeneric movieStack;
Image<double> II;
MetaData MD; // To save plot information
FileName motionInfFile, flowFileName, flowXFileName, flowYFileName;
ArrayDim aDim;
// For measuring times (both for whole process and for each level of the pyramid)
clock_t tStart, tStart2;
#ifdef GPU
// Matrix that we required in GPU part
GpuMat d_flowx, d_flowy, d_dest;
GpuMat d_avgcurr, d_preimg;
#endif
// Matrix required by Opencv
cv::Mat flow, dest, flowx, flowy;
cv::Mat flowxPre, flowyPre;
cv::Mat avgcurr, avgstep, preimg, preimg8, avgcurr8;
cv::Mat planes[]={flowxPre, flowyPre};
int imagenum, cnt=2, div=0, flowCounter;
int h, w, levelNum, levelCounter=1;
motionInfFile=foname.replaceExtension("xmd");
std::string extension=fname.getExtension();
if (extension=="mrc")
fname+=":mrcs";
movieStack.read(fname,HEADER);
movieStack.getDimensions(aDim);
imagenum = aDim.ndim;
h = aDim.ydim;
w = aDim.xdim;
if (darkImageCorr)
{
II.read(darkRefFilename);
darkImage=II();
}
if (gainImageCorr)
{
II.read(gianRefFilename);
gainImage=II();
}
meanStdev.initZeros(4);
//avgcurr=cv::Mat::zeros(h, w,CV_32FC1);
avgCurr.initZeros(h, w);
flowxPre=cv::Mat::zeros(h, w,CV_32FC1);
flowyPre=cv::Mat::zeros(h, w,CV_32FC1);
#ifdef GPU
// Object for optical flow
FarnebackOpticalFlow d_calc;
setDevice(gpuDevice);
// Initialize the parameters for optical flow structure
d_calc.numLevels=6;
d_calc.pyrScale=0.5;
d_calc.fastPyramids=true;
d_calc.winSize=winSize;
d_calc.numIters=1;
d_calc.polyN=5;
d_calc.polySigma=1.1;
d_calc.flags=0;
#endif
// Initialize the stack for the output movie
if (saveCorrMovie)
outputMovie.initZeros(imagenum, 1, h, w);
// Correct for global motion from a cross-correlation based algorithms
if (globalShiftCorr)
{
Matrix1D<double> shiftMatrix(2);
shiftVector.reserve(imagenum);
shiftMD.read(globalShiftFilename);
FOR_ALL_OBJECTS_IN_METADATA(shiftMD)
{
shiftMD.getValue(MDL_SHIFT_X, XX(shiftMatrix), __iter.objId);
shiftMD.getValue(MDL_SHIFT_Y, YY(shiftMatrix), __iter.objId);
shiftVector.push_back(shiftMatrix);
}
}
tStart2=clock();
// Compute the average of the whole stack
fstFrame++; // Just to adapt to Li algorithm
lstFrame++; // Just to adapt to Li algorithm
if (lstFrame>=imagenum || lstFrame==1)
lstFrame=imagenum;
imagenum=lstFrame-fstFrame+1;
levelNum=sqrt(double(imagenum));
computeAvg(fname, fstFrame, lstFrame, avgCurr);
// if the user want to save the PSD
if (doAverage)
{
II()=avgCurr;
II.write(foname);
//.........这里部分代码省略.........