当前位置: 首页>>代码示例>>C++>>正文


C++ CError函数代码示例

本文整理汇总了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;
}
开发者ID:hicannon,项目名称:ObjectDetection,代码行数:28,代码来源:SupportVectorMachine.cpp

示例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);
}
开发者ID:David-Wong,项目名称:cse455,代码行数:16,代码来源:FileIO.cpp

示例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;
}
开发者ID:8441918,项目名称:evg-parser,代码行数:16,代码来源:lexer.cpp

示例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];
            }
        }
    }
}
开发者ID:actionfarsi,项目名称:cv-pj4,代码行数:32,代码来源:FileIO.cpp

示例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;
}
开发者ID:angusforbes,项目名称:optiflow,代码行数:32,代码来源:color_flow.cpp

示例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);
}
开发者ID:hicannon,项目名称:ObjectDetection,代码行数:7,代码来源:SupportVectorMachine.cpp

示例7: LOG4CPLUS_TRACE

CError CSystemStateMachine::onCounterCADisconnected()
{
   LOG4CPLUS_TRACE(sLogger, __PRETTY_FUNCTION__);

   hardReset(true);
   
   return CError(CError::NO_ERROR, "SystemStateMachine");
}
开发者ID:Vanuan,项目名称:iviLink,代码行数:8,代码来源:CSystemStateMachine.cpp

示例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];
}
开发者ID:Sachin003,项目名称:PedestrianDetection,代码行数:8,代码来源:SupportVectorMachine.cpp

示例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);
}
开发者ID:adevore3,项目名称:Computer_Vision,代码行数:17,代码来源:FileIO.cpp

示例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));
}
开发者ID:footnoise,项目名称:robocode,代码行数:16,代码来源:types.cpp

示例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);
 }
开发者ID:babenkoav78,项目名称:iviLink,代码行数:8,代码来源:buffer_helpers.hpp

示例12: CError

bstr::bstr( char *str )
{
	ptr		= NULL;
	size	= 0;

	if ( assign( str ) == false )
		throw CError( "bstr::bstr 메모리 할당 실패" );
}
开发者ID:KaSt,项目名称:LegendOfMir3_Src,代码行数:8,代码来源:stringex.cpp

示例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 );
}
开发者ID:KaSt,项目名称:mir2ei,代码行数:8,代码来源:GlobalUserList.cpp

示例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;
}
开发者ID:yingthu,项目名称:Autostitch,代码行数:58,代码来源:IPLInterface.cpp

示例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;
}
开发者ID:dwilliamson,项目名称:TahitiGameLanguage,代码行数:57,代码来源:CodeGenerator.cpp


注:本文中的CError函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。