本文整理匯總了C++中CError函數的典型用法代碼示例。如果您正苦於以下問題:C++ CError函數的具體用法?C++ CError怎麽用?C++ CError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CError函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: weightVec
Feature
SupportVectorMachine::getWeights() const
{
if(_model == NULL) throw CError("Asking for SVM weights but there is no model. Either load one from file or train one before.");
Feature weightVec(_fVecShape);
weightVec.ClearPixels();
weightVec.origin[0] = _fVecShape.width / 2;
weightVec.origin[1] = _fVecShape.height / 2;
int nSVs = _model->l; // number of support vectors
for(int s = 0; s < nSVs; s++) {
double coeff = _model->sv_coef[0][s];
svm_node* sv = _model->SV[s];
for(int y = 0, d = 0; y < _fVecShape.height; y++) {
float* w = (float*) weightVec.PixelAddress(0,y,0);
for(int x = 0; x < _fVecShape.width * _fVecShape.nBands; x++, d++, w++, sv++) {
assert(sv->index == d);
*w += sv->value * coeff;
}
}
}
return weightVec;
}
示例2: ReadFile
void ReadFile (CImage& img, const char* filename)
{
// Determine the file extension
const char *dot = strrchr(filename, '.');
if (strcmp(dot, ".tga") == 0 || strcmp(dot, ".tga") == 0)
{
if ((&img.PixType()) == 0)
img.ReAllocate(CShape(), typeid(uchar), sizeof(uchar), true);
if (img.PixType() == typeid(uchar))
ReadFileTGA(*(CByteImage *) &img, filename);
else
throw CError("ReadFile(%s): haven't implemented conversions yet", filename);
}
else
throw CError("ReadFile(%s): file type not supported", filename);
}
示例3: SkipSpaces
bool CBaseLexer::CheckOverflowDirective()
{
SkipSpaces();
CTokenWord* tkn = (CTokenWord*)IsStringToken();
if (tkn == 0)
throw CError("expected value for 'overflow' directive",nLine);
if (strcmp(tkn->GetValue(), "extent")==0)
CIdValue::SetOverflow(OF_EXTENT);else
if (strcmp(tkn->GetValue(), "error")==0)
CIdValue::SetOverflow(OF_ERROR);else
if (strcmp(tkn->GetValue(), "skip")==0)
CIdValue::SetOverflow(OF_SKIP);else
throw CError("unknown value for 'overflow' directive",nLine);
delete tkn;
return true;
}
示例4: ReadFileJPEG
void ReadFileJPEG(CImage& img, const char* filename)
{
JPEGReader loader;
loader.header(filename);
if(loader.components() != loader.colorComponents()) {
throw CError("Loading of indexed JPEG not implemented");
}
CByteImage imgAux(loader.width(), loader.height(), loader.components());
std::vector<uchar*> rowPointers(loader.height());
CShape shape = imgAux.Shape();
for(int y = 0; y < shape.height; y++) {
rowPointers[shape.height - y - 1] = (uchar*) imgAux.PixelAddress(0,y,0);
}
loader.load(rowPointers.begin());
img.ReAllocate(shape, typeid(uchar), sizeof(uchar), true);
// Reverse color channel order
for(int y = 0; y < shape.height; y++) {
uchar* auxIt = (uchar*)imgAux.PixelAddress(0, y, 0);
uchar* imgIt = (uchar*)img.PixelAddress(0, y, 0);
for(int x = 0; x < shape.width; x++, auxIt += shape.nBands, imgIt += shape.nBands) {
for(int c = 0; c < shape.nBands; c++) {
imgIt[c] = auxIt[shape.nBands - c - 1];
}
}
}
}
示例5: main
int main(int argc, char *argv[])
{
try {
int argn = 1;
if (argc > 1 && argv[1][0]=='-' && argv[1][1]=='q') {
verbose = 0;
argn++;
}
if (argn >= argc-3 && argn <= argc-2) {
char *flowname = argv[argn++];
char *outname = argv[argn++];
float maxmotion = argn < argc ? atof(argv[argn++]) : -1;
CFloatImage im, fband;
ReadFlowFile(im, flowname);
CByteImage band, outim;
CShape sh = im.Shape();
sh.nBands = 3;
outim.ReAllocate(sh);
outim.ClearPixels();
MotionToColor(im, outim, maxmotion);
WriteImageVerb(outim, outname, verbose);
} else
throw CError(usage, argv[0]);
}
catch (CError &err) {
fprintf(stderr, err.message);
fprintf(stderr, "\n");
return -1;
}
return 0;
}
示例6: fopen
void
SupportVectorMachine::load(const char *filename)
{
FILE* f = fopen(filename, "rb");
if(f == NULL) throw CError("Failed to open file %s for reading", filename);
this->load(f);
}
示例7: LOG4CPLUS_TRACE
CError CSystemStateMachine::onCounterCADisconnected()
{
LOG4CPLUS_TRACE(sLogger, __PRETTY_FUNCTION__);
hardReset(true);
return CError(CError::NO_ERROR, "SystemStateMachine");
}
示例8: CError
double
SupportVectorMachine::getBiasTerm() const
{
if(_model == NULL)
throw CError("Asking for SVM bias term but there is no "
"model. Either load one from file or train one before.");
return _model->rho[0];
}
示例9: WriteFile
void WriteFile(CImage& img, const char* filename)
{
// Determine the file extension
char *dot = strrchr(filename, '.');
// Fixed by Loren. Was:
// if (strcmp(dot, ".tga") == 0 || strcmp(dot, ".tga") == 0)
if (dot != NULL && strcmp(dot, ".tga") == 0)
{
if (img.PixType() == typeid(uchar))
WriteFileTGA(*(CByteImage *) &img, filename);
else
throw CError("ReadFile(%s): haven't implemented conversions yet", filename);
}
else
throw CError("WriteFile(%s): file type not supported", filename);
}
示例10: MakeTank
///////////////////////////////////
// Make new Tank on BattleField
//
// Params:
// name - tank name
// x - coord on X axis
// y - coord on Y axis
// angle - facing direction
void CBattleField::MakeTank(PointName_t name, Pixel_t x, Pixel_t y, Angle_t angle)
{
//Checking for tank exist
if (GetTankByName(name)) throw CError(ERR_TANK_EXIST);
//Add Tank on BattleField!
_points.push_back(CPoint(name, x, y, angle, g_TankVelocity, STOP, false));
}
示例11: write
CError write(T const& val)
{
if (sizeof(T) > mFullSize - mUsedSize)
return CError(1, moduleName, CError::ERROR, "insufficient buffer size (from generic write)");
*reinterpret_cast<T*>(mpBuffer + mUsedSize) = val;
mUsedSize += sizeof(T);
return CError::NoError(moduleName);
}
示例12: CError
bstr::bstr( char *str )
{
ptr = NULL;
size = 0;
if ( assign( str ) == false )
throw CError( "bstr::bstr 메모리 할당 실패" );
}
示例13: m_fixedMemory
CGlobalUserList::CGlobalUserList()
: m_fixedMemory( GLOBALLIST_MAXLIST )
{
if ( !m_listUser.InitHashTable( GLOBALLIST_MAXBUCKET, IHT_ROUNDUP ) )
throw CError( "CGlobalUserList::CGlobalUserList 해쉬테이블 생성 실패" );
m_listUser.SetGetKeyFunction( __cbGetKey );
}
示例14: IPLCreateImage
IplImage* IPLCreateImage(CImage img)
{
// Compute the required parameters
CShape sh = img.Shape();
int nChannels = sh.nBands; // Number of channels in the image.
int alphaChannel = // Alpha channel number (0 if there is no alpha channel in the image).
(nChannels == 4) ? img.alphaChannel+1 : 0;
int depth = // Bit depth of pixels. Can be one of:
(img.PixType() == typeid(uchar)) ? IPL_DEPTH_8U :
(img.PixType() == typeid(char)) ? IPL_DEPTH_8S :
(img.PixType() == typeid(unsigned short)) ? IPL_DEPTH_16U :
(img.PixType() == typeid(short)) ? IPL_DEPTH_16S :
(img.PixType() == typeid(int )) ? IPL_DEPTH_32S :
(img.PixType() == typeid(float)) ? IPL_DEPTH_32F : 0;
char* colorModel = // A four-character string describing the color model.
(nChannels == 1) ? "Gray" : "RGBA";
char* channelSeq = // The sequence of color channels.
(nChannels == 1) ? "GRAY" : "BGRA";
int dataOrder = IPL_DATA_ORDER_PIXEL;
int origin = IPL_ORIGIN_TL; // The origin of the image.
int align = // Alignment of image data.
((((int) img.PixelAddress(0, 0, 0)) | ((int) img.PixelAddress(0, 1, 0))) & 7) ?
IPL_ALIGN_DWORD : IPL_ALIGN_QWORD;
int width = sh.width; // Width of the image in pixels.
int height = sh.height; // Height of the image in pixels.
IplROI* roi = 0; // Pointer to an ROI (region of interest) structure.
IplImage* maskROI = 0; // Pointer to the header of another image that specifies the mask ROI.
void* imageID = 0; // The image ID (field reserved for the application).
IplTileInfo* tileInfo = 0; // The pointer to the IplTileInfo structure
// Create the header
IplImage* ptr = iplCreateImageHeader(
nChannels,
alphaChannel, depth, colorModel,
channelSeq, dataOrder, origin, align,
width, height, roi, maskROI,
imageID, tileInfo);
if (ptr == 0)
throw CError("IPLCreateImage: could not create the header");
// Fill in the image data pointers
char* imgData = ((char *) img.PixelAddress(0, 0, 0));
int nBytes = ((char *) img.PixelAddress(0, 1, 0)) - imgData;
ptr->imageSize = nBytes * sh.height; // useful size in bytes
ptr->imageData = imgData; // pointer to aligned image
ptr->widthStep = nBytes; // size of aligned line in bytes
ptr->imageDataOrigin = imgData; // ptr to full, nonaligned image
// Set the border mode
int mode =
(img.borderMode == eBorderZero) ? IPL_BORDER_CONSTANT :
(img.borderMode == eBorderReplicate)? IPL_BORDER_REPLICATE :
(img.borderMode == eBorderReflect) ? IPL_BORDER_REFLECT :
(img.borderMode == eBorderCyclic) ? IPL_BORDER_WRAP : 0;
iplSetBorderMode(ptr, mode, IPL_SIDE_ALL, 0);
return ptr;
}
示例15: infunc
void CodeGenerator::ProcessClassTerm(int flags)
{
Class *class_ptr;
infunc(CodeGenerator::ProcessClassTerm);
if (flags & FLAGS_IN_CLASS)
throw CompileError("(Line %d) Already within a class", CUR_TOKEN.line);
if (NEXT_TOKEN.type != TOKEN_NAME)
throw CompileError("(Line %d) Expecting class name", CUR_TOKEN.line);
// Move onto the name and grab it
INC_TOKEN;
IsolateTokenString(CUR_TOKEN);
// Sneak passed it
INC_TOKEN;
if (g_Object == NULL)
{
// Allocate the memory
if ((class_ptr = new Class) == NULL)
throw CError("Couldn't allocate Class structure");
class_ptr->SetName(token_string);
}
else
{
// Class already defined, get it from the environment
class_ptr = g_Env->GetClass(token_string);
}
ProcessClassModifiers(class_ptr);
// Set the current class
g_Env->SetActiveClass(class_ptr);
cur_class = class_ptr;
ProcessBlock(flags | FLAGS_IN_CLASS);
// Go passed the close block
INC_TOKEN;
if (g_Object == NULL)
{
// Add the defined class to the environment
class_ptr->SetDefined();
g_Env->AddClassPtr(class_ptr);
}
else
{
// Write the class information to file
g_Object->WriteClassInfo(cur_class);
}
outfunc;
}