我正在使用来自Basler的Pylon库,它是GenICam的扩展。
在那里,他们将保存图像的函数定义为:
virtual void Save (EImageFileFormat imageFileFormat, const String_t &filename, CImagePersistenceOptions *pOptions=NULL) const 其中String_t是GenICam::gcstring的扩展
有关gcstring的信息如下:
Portable string implementation. More...
#include <new>
#include <string>
#include <iostream>
#include <Base/GCTypes.h>
Classes
class GenICam::gcstring
A string class which is a clone of std::string. More...
Namespaces
GenICam
Contains definitions of GenICam types and exceptions.
Macros
#define GCSTRING_NPOS size_t(-1)
Indicates either 'not found' or 'all remaining characters'.
Functions
std::istream & GenICam::getline (std::istream &is, GenICam::gcstring &str)
std::istream & GenICam::getline (std::istream &is, GenICam::gcstring &str, char delim)
std::ostream & operator<< (std::ostream &ostr, const GenICam::gcstring &str)
std::istream & operator>> (std::istream &istr, GenICam::gcstring &str)我需要保存一个由长int生成的文件名的映像,我尝试了很多方法,但是失败了,谁能帮上忙呢?
发布于 2017-12-22 18:59:15
对于任何仍在寻找答案的人,String_t接受一个const数组作为输入。因此,您可以简单地将long转换为std::string,然后将string.c_str()传递给String_t构造函数。
因此,要将long转换为std::string,请执行以下操作:
#include <string>
long myNumber = getNumber();
std::string s = std::to_string(myNumber);然后,您可以像这样保存图像:
CImagePersistence::Save(ImageFileFormat_Tiff, String_t(s.c_str()), *image);注:我用的是塔架5号。
发布于 2020-01-09 10:44:30
请使用以下方法。
char char_arr [100];
long int num = 10;
sprintf(char_arr, "%d", num);
String_t stringValue(char_arr);https://stackoverflow.com/questions/38161650
复制相似问题