• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ LERROR函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中LERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ LERROR函数的具体用法?C++ LERROR怎么用?C++ LERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了LERROR函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: loadDictionaryFromFile

bool loadDictionaryFromFile(
    const std::string& filename,
    ghoul::Dictionary& dictionary,
    lua_State* state
    )
{
    const static std::string _loggerCat = "lua_loadDictionaryFromFile";

    if (state == nullptr) {
        if (_state == nullptr) {
            LDEBUG("Creating Lua state");
            _state = luaL_newstate();
            if (_state == nullptr) {
                LFATAL("Error creating new Lua state: Memory allocation error");
                return false;
            }
            LDEBUG("Open libraries");
            luaL_openlibs(_state);
        }
        state = _state;
    }

    if (filename.empty()) {
        LERROR("Filename was empty");
        return false;
    }

    if (!FileSys.fileExists(absPath(filename))) {
        LERROR("File '" << absPath(filename) << "' did not exist");
        return false;
    }

    LDEBUG("Loading dictionary script '" << filename << "'");
    int status = luaL_loadfile(state, absPath(filename).c_str());
    if (status != LUA_OK) {
        LERROR("Error loading script: '" << lua_tostring(state, -1) << "'");
        return false;
    }

    LDEBUG("Executing script");
    if (lua_pcall(state, 0, LUA_MULTRET, 0)) {
        LERROR("Error executing script: " << lua_tostring(state, -1));
        return false;
    }

    if (lua_isnil(state, -1)) {
        LERROR("Error in script: '" << filename << "'. Script did not return anything.");
        return false;
    }

    if (!lua_istable(state, -1)) {
        LERROR("Error in script: '" << filename << "'. Script did not return a table.");
        return false;
    }

    luaDictionaryFromState(state, dictionary);

    // Clean up after ourselves by cleaning the stack
    lua_settop(state, 0);

    return true;
}
开发者ID:forsythrosin,项目名称:Ghoul,代码行数:62,代码来源:lua_helper.cpp


示例2: outsym

/*
 * write information about an global declared/defined symbol
 * with storage class extern
 *
 * informations about function definitions are written in outfdef(),
 * not here
 */
void
outsym(sym_t *sym, scl_t sc, def_t def)
{

	/*
	 * Static function declarations must also be written to the output
	 * file. Compatibility of function declarations (for both static
	 * and extern functions) must be checked in lint2. Lint1 can't do
	 * this, especially not, if functions are declared at block level
	 * before their first declaration at level 0.
	 */
	if (sc != EXTERN && !(sc == STATIC && sym->s_type->t_tspec == FUNC))
		return;

	/* reset buffer */
	outclr();

	/*
	 * line number of .c source, 'd' for declaration, Id of current
	 * source (.c or .h), and line in current source.
	 */
	outint(csrc_pos.p_line);
	outchar('d');
	outint(getfnid(sym->s_dpos.p_file));
	outchar('.');
	outint(sym->s_dpos.p_line);

	/* flags */

	switch (def) {
	case DEF:
		/* defined */
		outchar('d');
		break;
	case TDEF:
		/* tentative defined */
		outchar('t');
		break;
	case DECL:
		/* declared */
		outchar('e');
		break;
	default:
		LERROR("outsym()");
	}
	if (llibflg && def != DECL) {
		/*
		 * mark it as used so we get no warnings from lint2 about
		 * unused symbols in libraries.
		 */
		outchar('u');
	}

	if (sc == STATIC)
		outchar('s');

	/* name of the symbol */
	outname(sym->s_name);

	/* renamed name of symbol, if necessary */
	if (sym->s_rename) {
		outchar('r');
		outname(sym->s_rename);
	}

	/* type of the symbol */
	outtype(sym->s_type);
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:75,代码来源:emit1.c


示例3: outtype

/*
 * Write type into the output buffer.
 * The type is written as a sequence of substrings, each of which describes a
 * node of type type_t
 * a node is coded as follows:
 *	_Bool			B
 *	_Complex float		s X
 *	_Complex double		X 
 *	_Complex long double	l X 
 *	char			C
 *	signed char		s C
 *	unsigned char		u C
 *	short			S
 *	unsigned short		u S
 *	int			I
 *	unsigned int		u I
 *	long			L
 *	unsigned long		u L
 *	long long		Q
 *	unsigned long long	u Q
 *	float			s D
 *	double			D
 *	long double		l D
 *	void			V
 *	*			P
 *	[n]			A n
 *	()			F
 *	(void)			F 0
 *	(n arguments)		F n arg1 arg2 ... argn
 *	(n arguments, ...)	F n arg1 arg2 ... argn-1 E
 *	(a, b, c, ...)		f n arg1 arg2 ...
 *	enum tag		e T tag_or_typename
 *	struct tag		s T tag_or_typename
 *	union tag		u T tag_or_typename
 *
 *	tag_or_typename		0			no tag or type name
 *				1 n tag			Tag
 *				2 n typename		only type name
 *
 * spaces are only for better readability
 * additionaly it is possible to prepend the characters 'c' (for const)
 * and 'v' (for volatile)
 */
void
outtype(type_t *tp)
{
	int	t, s, na;
	sym_t	*arg;
	tspec_t	ts;

	while (tp != NULL) {
		if ((ts = tp->t_tspec) == INT && tp->t_isenum)
			ts = ENUM;
		switch (ts) {
		case BOOL:	t = 'B';	s = '\0';	break;
		case CHAR:	t = 'C';	s = '\0';	break;
		case SCHAR:	t = 'C';	s = 's';	break;
		case UCHAR:	t = 'C';	s = 'u';	break;
		case SHORT:	t = 'S';	s = '\0';	break;
		case USHORT:	t = 'S';	s = 'u';	break;
		case INT:	t = 'I';	s = '\0';	break;
		case UINT:	t = 'I';	s = 'u';	break;
		case LONG:	t = 'L';	s = '\0';	break;
		case ULONG:	t = 'L';	s = 'u';	break;
		case QUAD:	t = 'Q';	s = '\0';	break;
		case UQUAD:	t = 'Q';	s = 'u';	break;
		case FLOAT:	t = 'D';	s = 's';	break;
		case DOUBLE:	t = 'D';	s = '\0';	break;
		case LDOUBLE:	t = 'D';	s = 'l';	break;
		case VOID:	t = 'V';	s = '\0';	break;
		case PTR:	t = 'P';	s = '\0';	break;
		case ARRAY:	t = 'A';	s = '\0';	break;
		case FUNC:	t = 'F';	s = '\0';	break;
		case ENUM:	t = 'T';	s = 'e';	break;
		case STRUCT:	t = 'T';	s = 's';	break;
		case UNION:	t = 'T';	s = 'u';	break;
		case FCOMPLEX:	t = 'X';	s = 's';	break;
		case DCOMPLEX:	t = 'X';	s = '\0';	break;
		case LCOMPLEX:	t = 'X';	s = 'l';	break;
		default:
			LERROR("outtyp()");
		}
		if (tp->t_const)
			outchar('c');
		if (tp->t_volatile)
			outchar('v');
		if (s != '\0')
			outchar(s);
		outchar(t);
		if (ts == ARRAY) {
			outint(tp->t_dim);
		} else if (ts == ENUM) {
			outtt(tp->t_enum->etag, tp->t_enum->etdef);
		} else if (ts == STRUCT || ts == UNION) {
			outtt(tp->t_str->stag, tp->t_str->stdef);
		} else if (ts == FUNC && tp->t_proto) {
			na = 0;
			for (arg = tp->t_args; arg != NULL; arg = arg->s_nxt)
					na++;
			if (tp->t_vararg)
//.........这里部分代码省略.........
开发者ID:ryo,项目名称:netbsd-src,代码行数:101,代码来源:emit1.c


示例4: LDEBUG

    void ItkReader::ReadImageDirect(DataContainer& data) {
        typedef itk::ImageIOBase::IOComponentType ScalarPixelType;

        itk::ImageIOBase::Pointer imageIO =
            itk::ImageIOFactory::CreateImageIO(p_url.getValue().c_str(), itk::ImageIOFactory::ReadMode);

        if (imageIO.IsNotNull())
        {
            WeaklyTypedPointer wtp;

            imageIO->SetFileName(p_url.getValue());
            imageIO->ReadImageInformation();

            const ScalarPixelType pixelType = imageIO->GetComponentType();
            const size_t numDimensions = imageIO->GetNumberOfDimensions();

            LDEBUG("Reading Image with Reader " << imageIO->GetNameOfClass());
            LDEBUG("Pixel Type is " << imageIO->GetComponentTypeAsString(pixelType));
            LDEBUG("numDimensions: " << numDimensions);

            if (numDimensions > 3) {
                LERROR("Error: Dimensions higher than 3 not supported!");
                return;
            }

            itk::ImageIORegion ioRegion(numDimensions);
            itk::ImageIORegion::IndexType ioStart = ioRegion.GetIndex();
            itk::ImageIORegion::SizeType ioSize = ioRegion.GetSize();

            cgt::vec3 imageOffset(0.f);
            cgt::vec3 voxelSize(1.f);
            cgt::ivec3 size_i(1);

            //we assured above that numDimensions is < 3
            for (int i = 0; i < static_cast<int>(numDimensions); i++) {
                size_i[i] = imageIO->GetDimensions(i);
                imageOffset[i] = imageIO->GetOrigin(i);
                voxelSize[i] = imageIO->GetSpacing(i);
                ioStart[i] = 0;
                ioSize[i] = size_i[i];
            }

            cgt::svec3 size(size_i);
            size_t dimensionality = (size_i[2] == 1) ? ((size_i[1] == 1) ? 1 : 2) : 3;

            LDEBUG("Image Size is " << size);
            LDEBUG("Voxel Size is " << voxelSize);
            LDEBUG("Image Offset is " << imageOffset);
            LDEBUG("component size: " << imageIO->GetComponentSize());
            LDEBUG("components: " << imageIO->GetNumberOfComponents());
            LDEBUG("pixel type (string): " << imageIO->GetPixelTypeAsString(imageIO->GetPixelType())); // 'vector'
            LDEBUG("pixel type: " << imageIO->GetPixelType()); // '5'

            switch (pixelType) {
            case itk::ImageIOBase::CHAR:
                wtp._baseType = WeaklyTypedPointer::INT8; break;
            case itk::ImageIOBase::UCHAR:
                wtp._baseType = WeaklyTypedPointer::UINT8; break;
            case itk::ImageIOBase::SHORT:
                wtp._baseType = WeaklyTypedPointer::INT16; break;
            case itk::ImageIOBase::USHORT:
                wtp._baseType = WeaklyTypedPointer::UINT16; break;
            case itk::ImageIOBase::INT:
                wtp._baseType = WeaklyTypedPointer::INT32; break;
            case itk::ImageIOBase::UINT:
                wtp._baseType = WeaklyTypedPointer::UINT32; break;
            case itk::ImageIOBase::DOUBLE:
                LWARNING("Pixel Type is DOUBLE. Conversion to float may result in loss of precision!");
            case itk::ImageIOBase::FLOAT:
                wtp._baseType = WeaklyTypedPointer::FLOAT; break;


            default:
                LERROR("Error while loading ITK image: unsupported type: " << pixelType);
                return;
            }

            wtp._numChannels = imageIO->GetNumberOfComponents();

            //Setup the image region to read
            ioRegion.SetIndex(ioStart);
            ioRegion.SetSize(ioSize);
            imageIO->SetIORegion(ioRegion);

            if (pixelType != itk::ImageIOBase::DOUBLE) {
                //Finally, allocate buffer and read the image data
                wtp._pointer = new uint8_t[imageIO->GetImageSizeInBytes()];
                imageIO->Read(wtp._pointer);
            }
            else {
                //convert float volume to double volume
                double * inputBuf = new double[imageIO->GetImageSizeInComponents()];
                wtp._pointer = new uint8_t[imageIO->GetImageSizeInComponents() * sizeof(float)];
                imageIO->Read(inputBuf);

                double * dptr = inputBuf;
                float * fptr = static_cast<float*>(wtp._pointer);
                for (int i = 0, s = imageIO->GetImageSizeInComponents(); i < s; ++i) {
                    *fptr = *dptr;
                    fptr++;
//.........这里部分代码省略.........
开发者ID:tusharuiit,项目名称:2014-2015_HiwiMedicalXTTVisualization,代码行数:101,代码来源:itkreader.cpp


示例5: init_param_options


//.........这里部分代码省略.........
      , po::value<std::string>()->default_value ( "yes" )
      , "Determinize/minimize any FSA component of the RTN (yes|no)"  )
    ( HifstConstants::kHifstReplacefstbyarcNonterminals.c_str()
      , po::value<std::string>()->default_value ( "" )
      , "Determine which cell fsts are always replaced by single arc according to its non-terminals, e.g: replacefstbyarc=X,V" )
    ( HifstConstants::kHifstReplacefstbyarcNumstates.c_str()
      , po::value<unsigned>()->default_value ( 4 )
      , "Determine the minimum number of states that triggers replacement by arc." )
    ( HifstConstants::kHifstReplacefstbyarcExceptions.c_str()
      , po::value<std::string>()->default_value ( "S" )
      , "Categories that will definitely not be replaced (takes over replacefstbyarc and replacefstbyarc.numstates)" )
    ( HifstConstants::kHifstLocalpruneEnable.c_str()
      , po::value<std::string>()->default_value ( "no" )
      , "Apply local pruning strategy based con cyk cells and number of states (yes|no)" )
    ( HifstConstants::kHifstLocalpruneLmLoad.c_str()
      , po::value<std::string>()->default_value ( "" )
      , "Load one or more language model files: (gzipped) arpa format or kenlm binary format (uses memory mapping); separated by commas" )
    ( HifstConstants::kHifstLocalpruneLmFeatureweights.c_str()
      , po::value<std::string>()->default_value ( "1.0" )
      , "Scaling factor(s) applied to the language model: arpa_weight * -log(10) * gscale. Scales separated by commas." )
    ( HifstConstants::kHifstLocalpruneLmWordpenalty.c_str()
      , po::value<std::string>()->default_value ( "0.0" )
      , "Word penalty applied along the language models (separated by commas). Assumed as 0 if not specified " )
    ( HifstConstants::kHifstLocalpruneNumstates.c_str()
      , po::value<unsigned>()->default_value ( 10000 )
      , "Maximum number of states threshold after cell pruning an FSA, If beneath the threshold, determinization/minimization is applied to pruned lattice. Also applicable in alignment mode when filtering against substring acceptor. ")
    ( HifstConstants::kHifstLocalpruneConditions.c_str()
      , po::value<std::string>()->default_value ( "" )
      , "Local pruning conditions. These are sequences of 4-tuples separated by commas: category,span,number_of_states,weight. The three first are actual thresholds that trigger local pruning, whereas the weight is the likelihood beam for pruning, IF a language model has been applied." )
    ( HifstConstants::kHifstPrune.c_str()
      , po::value<float>()->default_value ( std::numeric_limits<float>::max() )
      , "Likelihood beam to prune the translation lattice. Only applied IF a language model is available." )
    ( HifstConstants::kHifstWritertn.c_str()
      , po::value<std::string>()->default_value ( "")
      , "Write the rtn to disk -- long list of FSAs. Use %%rtn_label%% and ? to format file names appropriately, e.g. --hifst.writertn=rtn/?/%%rtn_label%%.fst" )
    ( HifstConstants::kRecaserLmLoad.c_str()
      , po::value<std::string>()->default_value ( "" )
      , "Language model for recasing" )
    ( HifstConstants::kRecaserLmFeatureweight.c_str()
      , po::value<std::string>()->default_value ( "1.0" )
      , "Scaling factor applied to the language model" )
    ( HifstConstants::kRecaserUnimapLoad.c_str()
      , po::value<std::string>()->default_value ( "" )
      , "unigram transduction model  " )
    ( HifstConstants::kRecaserUnimapWeight.c_str()
      , po::value<float>()->default_value ( 1.0f )
      , "Scaling factors applied to the unigram model " )
    ( HifstConstants::kRecaserPrune.c_str()
      , po::value<std::string>()->default_value ( "byshortestpath,1" )
      , "Choose between byshortestpath,numpaths or byweight,weight" )
    ( HifstConstants::kRecaserOutput.c_str()
      , po::value<std::string>()->default_value ("")
      , "Output true cased lattice" )
    ( HifstConstants::kPostproWordmapLoad.c_str()
      , po::value<std::string>()->default_value ( "" )
      , "Load a reverse integer mapping file so the decoder can map integers to target words" )
    ( HifstConstants::kPostproDetokenizeEnable.c_str()
      , po::value<std::string>()->default_value ( "no" )
      , "Detokenize translated 1best (yes|no) -- NOT IMPLEMENTED!" )
    ( HifstConstants::kPostproDetokenizeLanguage.c_str()
      , po::value<std::string>()->default_value ( "" ), "NOT IMPLEMENTED" )
    ( HifstConstants::kPostproCapitalizefirstwordEnable.c_str()
      , po::value<std::string>()->default_value ( "no" )
      , "Capitalize first word (yes|no). Only applies if previously mapped back to words (postpro.wordmap.load)" )
    ( HifstConstants::kStatsHifstWrite.c_str()
      , po::value<std::string>()->default_value ( "" )
      , "Dump hifst-specific stats (cyk, local pruning, etc)" )
    ( HifstConstants::kStatsHifstCykgridEnable.c_str()
      , po::value<std::string>()->default_value ( "no" )
      , "Write cyk/rtn stats to the file (yes|no)" )
    ( HifstConstants::kStatsHifstCykgridCellwidth.c_str()
      , po::value<unsigned>()->default_value ( 30 )
      , "Width of the printed cyk cell" )
    ( HifstConstants::kStatsWrite.c_str()
      , po::value<std::string>()->default_value ( "" )
      , "Dump general stats (speed and general messages)" )
    ;
    parseOptionsGeneric (desc, vm, argc, argv);
    checkCreateSSGrammarOptions (vm);
    if ( (*vm) [HifstConstants::kPatternstoinstancesMaxspan.c_str() ].as<unsigned>()
         < (*vm) [ HifstConstants::kCykparserHrmaxheight.c_str()].as<unsigned>() ) {
      LERROR ( HifstConstants::kPatternstoinstancesMaxspan <<
               " cannot be smaller than " << HifstConstants::kCykparserHrmaxheight);
      exit (EXIT_FAILURE );
    }
    if (  (*vm) [HifstConstants::kFeatureweights.c_str()].as<std::string>() != ""
          && ( (*vm) [HifstConstants::kLmFeatureweights.c_str()].as<std::string>() != ""
               || (*vm) [HifstConstants::kGrammarFeatureweights.c_str()].as<std::string>() !=
               "" ) ) {
      LWARN ("Program option featureweights OVERRIDES grammar.featureweights and lm.featureweights!!");
    }
  } catch ( std::exception& e ) {
    cerr << "error: " << e.what() << "\n";
    exit ( EXIT_FAILURE );
  } catch ( ... ) {
    cerr << "Exception of unknown type!\n";
    exit ( EXIT_FAILURE );
  }
  LINFO ( "Configuration loaded" );
};
开发者ID:Libardo1,项目名称:ucam-smt,代码行数:101,代码来源:main.hifst.init_param_options.hpp


示例6: GetImageFileNames

    void ItkReader::ReadImageSeries(DataContainer& data) {
        typedef itk::ImageIOBase::IOComponentType ScalarPixelType;

        std::vector<std::string> imageFileNames = GetImageFileNames();

        if (!imageFileNames.size())
            return;

        itk::ImageIOBase::Pointer imageIO =
            itk::ImageIOFactory::CreateImageIO(imageFileNames[0].c_str(), itk::ImageIOFactory::ReadMode);

        const int numSlices = imageFileNames.size();

        if (imageIO.IsNotNull())
        {
            WeaklyTypedPointer wtp;

            imageIO->SetFileName(imageFileNames[0]);
            imageIO->ReadImageInformation();

            const ScalarPixelType pixelType = imageIO->GetComponentType();
            const size_t numDimensions = imageIO->GetNumberOfDimensions();

            LDEBUG("Reading Image with Reader " << imageIO->GetNameOfClass());
            LDEBUG("Pixel Type is " << imageIO->GetComponentTypeAsString(pixelType));
            LDEBUG("numDimensions: " << numDimensions);

            if (numDimensions > 3) {
                LERROR("Error: Dimensions higher than 3 not supported!");
                return;
            }

            itk::ImageIORegion ioRegion(numDimensions);
            itk::ImageIORegion::IndexType ioStart = ioRegion.GetIndex();
            itk::ImageIORegion::SizeType ioSize = ioRegion.GetSize();

            cgt::vec3 imageOffset(0.f);
            cgt::vec3 voxelSize(1.f);
            cgt::ivec3 size_i(1);

            //we assured above that numDimensions is < 3
            for (int i = 0; i < static_cast<int>(numDimensions); i++) {
                size_i[i] = imageIO->GetDimensions(i);
                imageOffset[i] = imageIO->GetOrigin(i);
                voxelSize[i] = imageIO->GetSpacing(i);
                ioStart[i] = 0;
                ioSize[i] = size_i[i];
            }

            cgt::svec3 size(size_i);
            size_t dimensionality = (size_i[2] == 1) ? ((size_i[1] == 1) ? 1 : 2) : 3;
            if (dimensionality > 2) {
                LERROR("Error: Cannot load image series with more than two dimensions!");
                return;
            }

            LDEBUG("Image Size is " << size);
            LDEBUG("Voxel Size is " << voxelSize);
            LDEBUG("Image Offset is " << imageOffset);
            LDEBUG("component size: " << imageIO->GetComponentSize());
            LDEBUG("components: " << imageIO->GetNumberOfComponents());
            LDEBUG("pixel type (string): " << imageIO->GetPixelTypeAsString(imageIO->GetPixelType()));
            LDEBUG("pixel type: " << imageIO->GetPixelType());

            switch (pixelType) {
            case itk::ImageIOBase::CHAR:
                wtp._baseType = WeaklyTypedPointer::INT8; break;
            case itk::ImageIOBase::UCHAR:
                wtp._baseType = WeaklyTypedPointer::UINT8; break;
            case itk::ImageIOBase::SHORT:
                wtp._baseType = WeaklyTypedPointer::INT16; break;
            case itk::ImageIOBase::USHORT:
                wtp._baseType = WeaklyTypedPointer::UINT16; break;
            case itk::ImageIOBase::INT:
                wtp._baseType = WeaklyTypedPointer::INT32; break;
            case itk::ImageIOBase::UINT:
                wtp._baseType = WeaklyTypedPointer::UINT32; break;
            case itk::ImageIOBase::DOUBLE:
                LWARNING("Pixel Type is DOUBLE. Conversion to float may result in loss of precision!");
            case itk::ImageIOBase::FLOAT:
                wtp._baseType = WeaklyTypedPointer::FLOAT; break;


            default:
                LERROR("Error while loading ITK image: unsupported type: " << pixelType);
                return;
            }

            wtp._numChannels = imageIO->GetNumberOfComponents();

            //Setup the image region to read
            ioRegion.SetIndex(ioStart);
            ioRegion.SetSize(ioSize);
            imageIO->SetIORegion(ioRegion);

            //allocate a temporary buffer if necessary
            double* inputBuf = (pixelType == itk::ImageIOBase::DOUBLE) ? new double[imageIO->GetImageSizeInComponents()] : nullptr;
            size_t sliceSize = (pixelType == itk::ImageIOBase::DOUBLE) ? imageIO->GetImageSizeInComponents() * sizeof(float) : imageIO->GetImageSizeInBytes();
            wtp._pointer = new uint8_t[numSlices * sliceSize];
            for (int idx = 0; idx < numSlices; ++idx) {
//.........这里部分代码省略.........
开发者ID:tusharuiit,项目名称:2014-2015_HiwiMedicalXTTVisualization,代码行数:101,代码来源:itkreader.cpp


示例7: JEVOIS_TRACE

// ##############################################################################################################
void jevois::Camera::setFormat(jevois::VideoMapping const & m)
{
  JEVOIS_TRACE(2);

  JEVOIS_TIMED_LOCK(itsMtx);
  
  // Get current format:
  itsFormat.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
  XIOCTL(itsFd, VIDIOC_G_FMT, &itsFormat);
  
  // Set desired format:
  itsFormat.fmt.pix.width = m.cw;
  itsFormat.fmt.pix.height = m.ch;
  itsFormat.fmt.pix.pixelformat = m.cfmt;
  itsFormat.fmt.pix.field = V4L2_FIELD_NONE;
  itsFps = m.cfps;
  
  LDEBUG("Requesting video format " << itsFormat.fmt.pix.width << 'x' << itsFormat.fmt.pix.height << ' ' <<
         jevois::fccstr(itsFormat.fmt.pix.pixelformat));
  
  XIOCTL(itsFd, VIDIOC_S_FMT, &itsFormat);
  
  // Get the format back as the driver may have adjusted some sizes, etc:
  XIOCTL(itsFd, VIDIOC_G_FMT, &itsFormat);
  
  // The driver returns a different format code, may be the mbus code instead of the v4l2 fcc...
  itsFormat.fmt.pix.pixelformat = v4l2sunxiFix(itsFormat.fmt.pix.pixelformat);
  
  LINFO("Camera set video format to " << itsFormat.fmt.pix.width << 'x' << itsFormat.fmt.pix.height << ' ' <<
        jevois::fccstr(itsFormat.fmt.pix.pixelformat));
  
  // Because modules may rely on the exact format that they request, throw if the camera modified it:
  if (itsFormat.fmt.pix.width != m.cw || itsFormat.fmt.pix.height != m.ch || itsFormat.fmt.pix.pixelformat != m.cfmt)
    LFATAL("Camera did not accept the requested video format as specified");
  
  // Reset cropping parameters. NOTE: just open()'ing the device does not reset it, according to the unix toolchain
  // philosophy. Hence, although here we do not provide support for cropping, we still need to ensure that it is
  // properly reset. Note that some cameras do not support this so here we swallow that exception:
  try
  {
    struct v4l2_cropcap cropcap = { };
    cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    XIOCTL_QUIET(itsFd, VIDIOC_CROPCAP, &cropcap);
    
    struct v4l2_crop crop = { };
    crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; crop.c = cropcap.defrect;
    XIOCTL_QUIET(itsFd, VIDIOC_S_CROP, &crop);
    
    LDEBUG("Set cropping rectangle to " << cropcap.defrect.width << 'x' << cropcap.defrect.height << " @ ("
           << cropcap.defrect.left << ", " << cropcap.defrect.top << ')');
  }
  catch (...) { LDEBUG("Querying/setting crop rectangle not supported"); }
  
  // Set frame rate:
  try
  {
    struct v4l2_streamparm parms = { };
    parms.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    parms.parm.capture.timeperframe = jevois::VideoMapping::fpsToV4l2(m.cfps);
    parms.parm.capture.capturemode = 2; // V4L2_MODE_VIDEO not defined in our headers? its value is 2.
    XIOCTL(itsFd, VIDIOC_S_PARM, &parms);
    
    LDEBUG("Set framerate to " << m.cfps << " fps");
  }
  catch (...) { LERROR("Setting frame rate to " << m.cfps << " fps failed -- IGNORED"); }
}
开发者ID:Dennis-Wijngaarden,项目名称:jevois,代码行数:67,代码来源:Camera.C


示例8: GVX_TRACE

// ######################################################################
Image<int> IntegerSimpleChannel::getOutputInt()
{
GVX_TRACE(__PRETTY_FUNCTION__);

  if (!this->hasInput())
    // if you think this LFATAL() has been triggered incorrectly, then
    // first make sure that somebody has called setInputDims()
    CLFATAL("Oops! can't get output -- I don't even have any input yet");

  if (!this->outputAvailable())
    {
      // it's possible that we have input but don't yet have output in
      // the case of a channel that requires several input frames
      // before it can start generating output (such as a flicker or
      // motion channel); in that case we just return an empty image
      // of the appropriate size

      LERROR("No %s channel yet! -- IGNORING.", this->tagName().c_str());

      return Image<int>(this->getMapDims(), ZEROS);
    }

  if (!itsOutputCache.initialized())
    {
      itsOutputCache = Image<int>(getMapDims(), ZEROS);

      // compute max-normalized weighted sum of center-surround at all levels:
      for (uint idx = 0; idx < itsLevelSpec.getVal().maxIndex(); ++idx)
        {
          const Image<int> submap = getSubmapInt(idx); // get the unweighted map

          // add submap to our sum
          itsOutputCache += (submap / int(itsLevelSpec.getVal().maxIndex()));

          if (MYLOGVERB >= LOG_DEBUG)
            {
              uint clev = 0, slev = 0;
              itsLevelSpec.getVal().indexToCS(idx, clev, slev);
              LDEBUG("%s(%d,%d): weight %f", tagName().c_str(), clev, slev, 1.0f);
            }
        }


      // apply max-normalization on the output as needed:
      if (itsNormalizeOutput.getVal())
        {
          LDEBUG("%s: Normalizing output: %s(%d .. %d)", tagName().c_str(),
                 maxNormTypeName(itsNormType.getVal()), itsOutputRangeMin.getVal(),
                 itsOutputRangeMax.getVal());

          itsOutputCache =
            intgMaxNormalize(itsOutputCache, itsOutputRangeMin.getVal(),
                         itsOutputRangeMax.getVal(), itsNormType.getVal());
        }

      // print some debug info if in debug mode:
      if (MYLOGVERB >= LOG_DEBUG)
        {
          int mi, ma; getMinMax(itsOutputCache, mi, ma);
          LDEBUG("%s: final range [%d .. %d]", tagName().c_str(), mi, ma);
        }

      LINFO("Computed %s Conspicuity Map", descriptiveName().c_str());
    }

  return itsOutputCache;
}
开发者ID:ulyssesrr,项目名称:carmen_lcad,代码行数:68,代码来源:IntegerSimpleChannel.C


示例9: parentOffset

bool LocalErrorHistogramManager::buildFromBstChild(unsigned int bstOffset, unsigned int octreeOffset) {
    // Add errors to bst parent histogram
    int numOtNodes = _tsp->numOTNodes();
    unsigned int childIndex = bstOffset * numOtNodes + octreeOffset;
    bool isBstLeaf = _tsp->isBstLeaf(childIndex);

    if (bstOffset > 0) {
        // Not BST root
        std::vector<float> childValues;
        std::vector<float> parentValues;

        int bstParent = parentOffset(bstOffset, 2);
        unsigned int parentIndex = bstParent * numOtNodes + octreeOffset;
        unsigned int parentInnerNodeIndex = brickToInnerNodeIndex(parentIndex);

        if (isBstLeaf) {
            childValues = readValues(childIndex);
        } else {
            unsigned int childInnerNodeIndex = brickToInnerNodeIndex(childIndex);
            auto it = _voxelCache.find(childInnerNodeIndex);
            if (it != _voxelCache.end()) {
                childValues = it->second;
            } else {
                LERROR("Child " << childIndex << " visited without cache");
                return false;
            }
        }

        int bstChildIndex = bstOffset % 2;
        if (bstChildIndex == 1) {
            parentValues = readValues(parentIndex);
            _voxelCache[parentInnerNodeIndex] = parentValues;
        } else {
            auto it = _voxelCache.find(parentInnerNodeIndex);
            if (it != _voxelCache.end()) {
                parentValues = it->second;
            } else {
                LERROR("Parent " << parentIndex << " visited without cache");
                return false;
            }
        }

        // Compare values and add errors to parent histogram
        unsigned int paddedBrickDim = _tsp->paddedBrickDim();
        unsigned int brickDim = _tsp->brickDim();
        unsigned int padding = (paddedBrickDim - brickDim) / 2;

        for (int z = 0; z < brickDim; z++) {
            for (int y = 0; y < brickDim; y++) {
                for (int x = 0; x < brickDim; x++) {
                    glm::vec3 samplePoint = glm::vec3(x, y, z) + glm::vec3(padding);
                    unsigned int linearSamplePoint = linearCoords(samplePoint);
                    float childValue = childValues[linearSamplePoint];
                    float parentValue = parentValues[linearSamplePoint];

                    // Divide by number of child voxels that will be taken into account
                    float rectangleHeight = std::abs(childValue - parentValue) / 2.0;
                    _temporalHistograms[parentInnerNodeIndex].addRectangle(childValue, parentValue, rectangleHeight);
                }
            }
        }

        bool isLastBstChild = bstOffset > 0 && bstChildIndex == 0;
        if (isLastBstChild) {
            buildFromBstChild(bstParent, octreeOffset);
        }
    }

    if (!isBstLeaf) {
        unsigned int childInnerNodeIndex = brickToInnerNodeIndex(childIndex);
        _voxelCache.erase(childInnerNodeIndex);
    }

    int octreeChildIndex = (octreeOffset - 1) % 8;
    bool isLastOctreeChild = octreeOffset > 0 && octreeChildIndex == 7;
    if (isBstLeaf && isLastOctreeChild) {
        int octreeParent = parentOffset(octreeOffset, 8);
        buildFromBstChild(bstOffset, octreeParent);
    }

    return true;
}
开发者ID:OpenSpace,项目名称:OpenSpace,代码行数:82,代码来源:localerrorhistogrammanager.cpp


示例10: LINFO

bool LocalErrorHistogramManager::buildHistograms(int numBins) {
    LINFO("Build histograms with " << numBins << " bins each");
    _numBins = numBins;

    _file = &(_tsp->file());
    if (!_file->is_open()) {
        return false;
    }
    _minBin = 0.0; // Should be calculated from tsp file
    _maxBin = 1.0; // Should be calculated from tsp file as (maxValue - minValue)

    unsigned int numOtLevels = _tsp->numOTLevels();
    unsigned int numOtLeaves = pow(8, numOtLevels - 1);
    unsigned int numBstLeaves = pow(2, _tsp->numBSTLevels() - 1);

    _numInnerNodes = _tsp->numTotalNodes() - numOtLeaves * numBstLeaves;

    _spatialHistograms = std::vector<Histogram>(_numInnerNodes);
    _temporalHistograms = std::vector<Histogram>(_numInnerNodes);
    for (unsigned int i = 0; i < _numInnerNodes; i++) {
        _spatialHistograms[i] = Histogram(_minBin, _maxBin, numBins);
        _temporalHistograms[i] = Histogram(_minBin, _maxBin, numBins);
    }

    // All TSP Leaves
    int numOtNodes = _tsp->numOTNodes();
    int otOffset = (pow(8, numOtLevels - 1) - 1) / 7;

    int numBstNodes = _tsp->numBSTNodes();
    int bstOffset = numBstNodes / 2;

    int numberOfLeaves = numOtLeaves * numBstLeaves;

    LINFO("Building spatial histograms");
    ProgressBar pb1(numberOfLeaves);
    int processedLeaves = 0;
    pb1.print(processedLeaves);
    bool success = true;
    for (int bst = bstOffset; bst < numBstNodes; bst++) {
        for (int ot = otOffset; ot < numOtNodes; ot++) {
            success &= buildFromOctreeChild(bst, ot);
            if (!success) LERROR("Failed in buildFromOctreeChild");
            if (!success) return false;
            pb1.print(processedLeaves++);
        }
    }
    //pb1.stop();


    LINFO("Building temporal histograms");
    ProgressBar pb2(numberOfLeaves);
    processedLeaves = 0;
    pb2.print(processedLeaves);
    for (int ot = otOffset; ot < numOtNodes; ot++) {
        for (int bst = bstOffset; bst < numBstNodes; bst++) {
            success &= buildFromBstChild(bst, ot);
            if (!success) LERROR("Failed in buildFromBstChild");
            if (!success) return false;
            pb2.print(processedLeaves++);
        }
    }
    //pb2.stop();

    return success;
}
开发者ID:OpenSpace,项目名称:OpenSpace,代码行数:65,代码来源:localerrorhistogrammanager.cpp


示例11: clear

bool SceneGraph::loadFromFile(const std::string& sceneDescription) {
    clear(); // Move this to a later stage to retain a proper scenegraph when the loading fails ---abock

    std::string absSceneFile = absPath(sceneDescription);

    // See if scene file exists
    if (!FileSys.fileExists(absSceneFile, true)) {
        LERROR("Could not load scene file '" << absSceneFile << "'. " <<
            "File not found");
        return false;
    }
    LINFO("Loading SceneGraph from file '" << absSceneFile << "'");

    // Load dictionary
    ghoul::Dictionary sceneDictionary;
    try {
        ghoul::lua::loadDictionaryFromFile(absSceneFile, sceneDictionary);
    }
    catch (...) {
        return false;
    }

    std::string sceneDescriptionDirectory =
    ghoul::filesystem::File(absSceneFile, true).directoryName();
    std::string sceneDirectory(".");
    sceneDictionary.getValue(KeyPathScene, sceneDirectory);

    // The scene path could either be an absolute or relative path to the description
    // paths directory
    std::string relativeCandidate = sceneDescriptionDirectory +
        ghoul::filesystem::FileSystem::PathSeparator + sceneDirectory;
    std::string absoluteCandidate = absPath(sceneDirectory);

    if (FileSys.directoryExists(relativeCandidate))
        sceneDirectory = relativeCandidate;
    else if (FileSys.directoryExists(absoluteCandidate))
        sceneDirectory = absoluteCandidate;
    else {
        LERROR("The '" << KeyPathScene << "' pointed to a "
            "path '" << sceneDirectory << "' that did not exist");
        return false;
    }

    ghoul::Dictionary moduleDictionary;
    bool success = sceneDictionary.getValue(KeyModules, moduleDictionary);
    if (!success)
        // There are no modules that are loaded
        return true;

    lua_State* state = ghoul::lua::createNewLuaState();
    OsEng.scriptEngine().initializeLuaState(state);

    // Get the common directory
    bool commonFolderSpecified = sceneDictionary.hasKey(KeyCommonFolder);
    bool commonFolderCorrectType = sceneDictionary.hasKeyAndValue<std::string>(KeyCommonFolder);

    if (commonFolderSpecified) {
        if (commonFolderCorrectType) {
            std::string commonFolder = sceneDictionary.value<std::string>(KeyCommonFolder);
            std::string fullCommonFolder = FileSys.pathByAppendingComponent(
                sceneDirectory,
                commonFolder
            );
            if (!FileSys.directoryExists(fullCommonFolder))
                LERROR("Specified common folder '" << fullCommonFolder << "' did not exist");
            else {
                if (!commonFolder.empty()) {
                    FileSys.registerPathToken(_commonModuleToken, commonFolder);
                    size_t nKeys = moduleDictionary.size();
                    moduleDictionary.setValue(std::to_string(nKeys + 1), commonFolder);
                }
            }
        }
        else
            LERROR("Specification for 'common' folder has invalid type");
    }

    std::vector<std::string> keys = moduleDictionary.keys();

    std::map<std::string, std::vector<std::string>> dependencies;
    std::map<std::string, std::string> parents;

    _rootNode = new SceneGraphNode;
    _rootNode->setName(SceneGraphNode::RootNodeName);
    SceneGraphNodeInternal* internalRoot = new SceneGraphNodeInternal;
    internalRoot->node = _rootNode;
    _nodes.push_back(internalRoot);

    std::sort(keys.begin(), keys.end());
    ghoul::filesystem::Directory oldDirectory = FileSys.currentDirectory();
    for (const std::string& key : keys) {
        std::string moduleName = moduleDictionary.value<std::string>(key);
        std::string modulePath = FileSys.pathByAppendingComponent(sceneDirectory, moduleName);

        if (!FileSys.directoryExists(modulePath)) {
            LERROR("Could not load module '" << moduleName << "'. Directory did not exist");
            continue;
        }

        std::string moduleFile = FileSys.pathByAppendingComponent(
//.........这里部分代码省略.........
开发者ID:EricMyers47,项目名称:OpenSpace,代码行数:101,代码来源:scenegraph.cpp


示例12: tgtAssert


//.........这里部分代码省略.........
    else if (dynamic_cast<const VolumeRAM_3xInt32*>(volume)) {
        format = "INT";
        model = "RGB";
    }
    else if (dynamic_cast<const VolumeRAM_3xUInt64*>(volume)) {
        format = "UINT64";
        model = "RGB";
    }
    else if (dynamic_cast<const VolumeRAM_3xInt64*>(volume)) {
        format = "INT64";
        model = "RGB";
    }
    else if (dynamic_cast<const VolumeRAM_3xFloat*>(volume)) {
        format = "FLOAT";
        model = "RGB";
    }
    else if (dynamic_cast<const VolumeRAM_3xDouble*>(volume)) {
        format = "DOUBLE";
        model = "RGB";
    }
    // vec4 types
    else if (dynamic_cast<const VolumeRAM_4xUInt8*>(volume)) {
        format = "UCHAR";
        model = "RGBA";
    }
    else if (dynamic_cast<const VolumeRAM_4xInt8*>(volume)) {
        format = "CHAR";
        model = "RGBA";
    }
    else if (dynamic_cast<const VolumeRAM_4xUInt16*>(volume)) {
        format = "USHORT";
        model = "RGBA";
    }
    else if (dynamic_cast<const VolumeRAM_4xInt16*>(volume)) {
        format = "SHORT";
        model = "RGBA";
    }
    else if (dynamic_cast<const VolumeRAM_4xUInt32*>(volume)) {
        format = "UINT";
        model = "RGBA";
    }
    else if (dynamic_cast<const VolumeRAM_4xInt32*>(volume)) {
        format = "INT";
        model = "RGBA";
    }
    else if (dynamic_cast<const VolumeRAM_4xUInt64*>(volume)) {
        format = "UINT64";
        model = "RGBA";
    }
    else if (dynamic_cast<const VolumeRAM_4xInt64*>(volume)) {
        format = "INT64";
        model = "RGBA";
    }
    else if (dynamic_cast<const VolumeRAM_4xFloat*>(volume)) {
        format = "FLOAT";
        model = "RGBA";
    }
    else if (dynamic_cast<const VolumeRAM_4xDouble*>(volume)) {
        format = "DOUBLE";
        model = "RGBA";
    }
    // special types
    else if (dynamic_cast<const VolumeRAM_Mat3Float*>(volume)) {
        format = "FLOAT";
        model = "MAT3";
    }
    else if (dynamic_cast<const VolumeRAM_Tensor2Float*>(volume)) {
        format = "FLOAT";
        model = "TENSOR_UP";
    }
    else
        LERROR("Format currently not supported");

    datout << "ObjectFileName:\t" << tgt::FileSystem::fileName(rawFileName) << std::endl;

    tgt::ivec3 dimensions = volume->getDimensions();
    datout << "Resolution:\t" << dimensions.x << " " << dimensions.y << " " << dimensions.z << std::endl;

    tgt::vec3 spacing = volumeHandle->getSpacing();
    datout << "SliceThickness:\t" << spacing.x << " " << spacing.y << " " << spacing.z << std::endl;

    datout << "Format:\t\t" << format << std::endl;
    datout << "ObjectModel:\t" << model << std::endl;
    datout << "Modality:\t" << volumeHandle->getModality() << std::endl;
    datout << "Checksum:\t" << volumeHandle->getRawDataHash() << std::endl;

    // write transformation matrix unless it is the identity matrix
    tgt::mat4 transformation = volumeHandle->getPhysicalToWorldMatrix();
    if (transformation != tgt::mat4::createIdentity())
        datout << "TransformMatrix: row0\t" << transformation[0][0] << " " << transformation[0][1] << " "
               << transformation[0][2] << " " << transformation[0][3] << std::endl
               << "TransformMatrix: row1\t" << transformation[1][0] << " " << transformation[1][1] << " "
               << transformation[1][2] << " " << transformation[1][3] << std::endl
               << "TransformMatrix: row2\t" << transformation[2][0] << " " << transformation[2][1] << " "
               << transformation[2][2] << " " << transformation[2][3] << std::endl
               << "TransformMatrix: row3\t" << transformation[3][0] << " " << transformation[3][1] << " "
               << transformation[3][2] << " " << transformation[3][3] << std::endl;

    return datout.str();
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:101,代码来源:datvolumewriter.cpp


示例13: LERROR

Texture* TextureReaderDevil::loadTexture(const std::string& filename, Texture::Filter filter,
                                         bool compress, bool keepPixels, bool createOGLTex,
                                         bool textureRectangle)
{

#ifndef GL_TEXTURE_RECTANGLE_ARB
    if (textureRectangle){
        LERROR("Texture Rectangles not supported!");
        textureRectangle = false;
    }
#endif

    File* file = FileSys.open(filename);

    // check if file is open
    if (!file || !file->isOpen()) {
        delete file;
        return 0;
    }

    size_t len = file->size();

    // check if file is empty
    if (len == 0) {
        delete file;
        return 0;
    }

    // allocate memory
    char* imdata = new char[len];

    if (imdata == 0) {
        delete file;
        return 0;   // allocation failed
    }

    file->read(imdata, len);

    file->close();
    delete file;

    /*
        FIXME: I think the keepPixels option does not work properly
        -> I don't see why...afaik keepPixels has been used in some project (stefan)
    */
    ILuint ImageName;
    ilGenImages(1, &ImageName);
    ilBindImage(ImageName);
    Texture* t = new Texture();
    t->setName(filename);

    if (!ilLoadL(IL_TYPE_UNKNOWN, imdata, static_cast<ILuint>(len))) {
        LERROR("Failed to open via ilLoadL " << filename);
        delete[] imdata;
        delete t;
        return 0;
    }
    delete[] imdata;
    imdata = 0;

    t->setBpp(ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL));

    // determine image format
    ILint devilFormat;
    switch (ilGetInteger(IL_IMAGE_FORMAT)) {
        case IL_LUMINANCE:         // intensity channel only
            devilFormat = IL_LUMINANCE;
            t->setFormat(GL_LUMINANCE);
            break;
        case IL_LUMINANCE_ALPHA:   // intensity-alpha channels
            devilFormat = IL_LUMINANCE_ALPHA;
            t->setFormat(GL_LUMINANCE_ALPHA);
            break;
        case IL_RGB 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LEVEL_DEBUG函数代码示例发布时间:2022-05-30
下一篇:
C++ LERP函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap