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


C++ Labels::size方法代码示例

本文整理汇总了C++中Labels::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Labels::size方法的具体用法?C++ Labels::size怎么用?C++ Labels::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Labels的用法示例。


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

示例1: runtime_error

void PointMatcher<T>::DataPoints::assertConsistency(const std::string& dataName,  const int dataRows, const int dataCols, const Labels& labels) const
{
	if (dataRows == 0)
	{
		if (dataCols != 0)
			throw std::runtime_error(
				(boost::format("Point cloud has degenerate %2% dimensions of rows=0, cols=%1%") % dataCols % dataName).str()
			);
		if (labels.size() > 0)
			throw std::runtime_error(
				(boost::format("Point cloud has no %2% data but %1% descriptor labels") % labels.size() % dataName).str()
			);
	}
	else
	{
		if (dataCols != features.cols())
			throw std::runtime_error(
				(boost::format("Point cloud has %1% points in features but %2% points in %3%") % features.cols() % dataCols % dataName).str()
			);
		int descDim(0);
		for (BOOST_AUTO(it, labels.begin()); it != labels.end(); ++it)
			descDim += it->span;
		if (dataRows != descDim)
			throw std::runtime_error(
				(boost::format("Labels from %3% return %1% total dimensions but there are %2% in the %3% matrix") % descDim % dataRows % dataName).str()
			);
	}
}
开发者ID:AndresStepa,项目名称:libpointmatcher,代码行数:28,代码来源:DataPoints.cpp

示例2:

//! TR2 metric using SRM(Spatial Relations Matrix) comparison
//! returns vector holding pos[0] = match score; pos[1] = mismatch score.
vector<float> ShadeShapeMatch::tr2(ShadeShapeRelation &ssrUP, Labels &upLabels, ShadeShapeRelation &ssrDB, Labels &dbLabels, String nStr) {
	assert(upLabels.size()>0 && dbLabels.size()>0);
	assert(upLabels.size()==dbLabels.size());
	ShadeShapeRelationMatch ssrm;
	ssrm.srm_match(ssrUP,upLabels,ssrDB,dbLabels,nStr);
	float matchScore = ssrm.getMatchScore();
	float mismatchScore = ssrm.getMismatchScore();

	//store the ESG variable data to PrintStream to be printed out later
	PrintStream esgPS = ssrm.getEsgPrintStream();
	if(this->esgPS_Map.find(nStr)==this->esgPS_Map.end()) {
		this->esgPS_Map[nStr] = esgPS;
	}
	//store the entropy variable data to PrintStream to be printed out later
	PrintStream entropyPS = ssrm.getEntropyPrintStream();
	if(this->entropyPS_Map.find(nStr)==this->entropyPS_Map.end()) {
		this->entropyPS_Map[nStr] = entropyPS;
	}
	PrintStream mismatchEntropyPS = ssrm.getMismatchEntropyPrintStream();
	if(this->mismatchEntropyPS_Map.find(nStr)==this->mismatchEntropyPS_Map.end()) {
		this->mismatchEntropyPS_Map[nStr] = mismatchEntropyPS;
	}
	PrintStream noEntropyPS = ssrm.getNoEntropyPrintStream();
	if(this->noEntropyPS_Map.find(nStr)==this->noEntropyPS_Map.end()) {
		this->noEntropyPS_Map[nStr] = noEntropyPS;
	}

	vector<float> results = {matchScore,mismatchScore};

	return results;
}
开发者ID:theunknowner,项目名称:WebDerm,代码行数:33,代码来源:shadeshapematch.cpp

示例3: train

void OpenCvDetector::train(const Segments& segments, const Labels& labels)
{
    cv::Mat featureMatrix = calculateFeatureMatrix(segments);

    cv::Mat labelVector(labels.size(), 1, CV_32SC1);
    for(size_t i = 0; i < labels.size(); i++) {
        labelVector.at<signed>(i) = labels[i];
    }

    // Dump feature values into file (for analysis with Matlab etc.)
    dumpFeatureMatrix(featureMatrix, labels);

    // Implemented by the derived class.
    trainOnFeatures(featureMatrix, labelVector);   
} 
开发者ID:Aharobot,项目名称:spencer_people_tracking,代码行数:15,代码来源:opencv_detector.cpp

示例4: pow

float ShadeShapeMatch::tr1ForShade(Labels &upLabels, Labels &dbLabels) {
	assert(upLabels.size()==dbLabels.size());
	float numerSum = 0.0;
	float denomSumUP = 0.0;
	float denomSumDB = 0.0;
	map<String,pair<int,float> > upMap = upLabels.getMap();
	map<String,pair<int,float> > dbMap = dbLabels.getMap();
	for(auto itUP=upMap.begin(), itDB=dbMap.begin(); itUP!=upMap.end(), itDB!=dbMap.end(); itUP++, itDB++) {
		numerSum += (itUP->second.second * itDB->second.second);
		denomSumUP += pow(itUP->second.second,2);
		denomSumDB += pow(itDB->second.second,2);
	}
	float denomSum = sqrt(denomSumUP) * sqrt(denomSumDB);
	float results = numerSum / denomSum;
	return results;
}
开发者ID:theunknowner,项目名称:WebDerm,代码行数:16,代码来源:shadeshapematch.cpp

示例5: present

void PointMatcher<T>::DataPoints::allocateFields(const Labels& newLabels, Labels& labels, MatrixType& data) const
{
	typedef vector<bool> BoolVector;
	BoolVector present(newLabels.size(), false);
	
	// for fields that exist, take note and check dimension
	size_t additionalDim(0);
	for (size_t i = 0; i < newLabels.size(); ++i)
	{
		const string& newName(newLabels[i].text);
		const size_t newSpan(newLabels[i].span);
		for(BOOST_AUTO(it, labels.begin()); it != labels.end(); ++it)
		{
			if (it->text == newName)
			{
				if (it->span != newSpan)
					throw InvalidField(
						(boost::format("The existing field %1% has dimension %2%, different than requested dimension %3%") % newName % it->span % newSpan).str()
					);
				present[i] = true;
				break;
			}
		}
		if (!present[i])
			additionalDim += newSpan;
	}
	
	// for new fields allocate
	const int oldDim(data.rows());
	const int totalDim(oldDim + additionalDim);
	const int pointCount(features.cols());
	data.conservativeResize(totalDim, pointCount);
	for (size_t i = 0; i < newLabels.size(); ++i)
	{
		if (!present[i])
			labels.push_back(newLabels[i]);
	}
}
开发者ID:AndresStepa,项目名称:libpointmatcher,代码行数:38,代码来源:DataPoints.cpp

示例6: dotProduct

//! dot product using holder's inequality
//! TR1
//! applies shape shift penalties during calculations for the shapes shifted
float ShadeShapeMatch::dotProduct(Labels &upLabels, Labels &dbLabels) {
	ShapeMatch spm;
	ShadeMatch sdm;
	if(upLabels.size()!=dbLabels.size()) {
		cout << "ShapeMatch::dotProduct(): upLabels && dbLabels not same size!!!" << endl;
		exit(1);
	}
	float numerSum = 0.0;
	float denomSumUP = 0.0;
	float denomSumDB = 0.0;
	map<String,pair<int,float> > upMap = upLabels.getMap();
	map<String,pair<int,float> > dbMap = dbLabels.getMap();
	this->shapeTranslateCount.resize(spm.numOfShapes(),vector<int>(spm.numOfShapes(),0)); // 10 shapes
	for(auto itUP=upMap.begin(), itDB=dbMap.begin(); itUP!=upMap.end(), itDB!=dbMap.end(); itUP++, itDB++) {
		String label = itUP->first;
		float penalty = 1.0;
		int shapeNum = upLabels.getShapeNum(label);
		if(shapeNum==-1) shapeNum = dbLabels.getShapeNum(label);
		if(upLabels.isShapeShifted(label)) {
			int prevShapeNum = upLabels.getPrevShapeNum(label);
			if(prevShapeNum>=0 && shapeNum>=0) {
				penalty = spm.getShiftPenalty(prevShapeNum,shapeNum);
			} else {
				printf("ShadeShapeMatch::dotProduct() %s label does not exist!\n",itUP->first.c_str());
				printf("PrevShapeNum: %d, :CurrShapeNum: %d\n",prevShapeNum,shapeNum);
			}
		}
		int shadeLevel = upLabels.getShadeLevel(label);
		float shadeWeight = sdm.applyShadeWeights(shadeLevel);
		float shapeWeight = spm.applyShapeWeight(shapeNum);
		numerSum += (itUP->second.second * itDB->second.second) * penalty * shadeWeight * shapeWeight;
		denomSumUP += pow(itUP->second.second,2);
		denomSumDB += pow(itDB->second.second,2);
	}
	float denomSum = sqrt(denomSumUP) * sqrt(denomSumDB);
	float results = numerSum / denomSum;
	return results;
}
开发者ID:theunknowner,项目名称:WebDerm,代码行数:41,代码来源:shadeshapematch.cpp

示例7: InvalidField

void PointMatcher<T>::DataPoints::concatenateLabelledMatrix(Labels* labels, MatrixType* data, const Labels extraLabels, const MatrixType extraData)
{
	const int nbPoints1 = data->cols();
	const int nbPoints2 = extraData.cols();
	const int nbPointsTotal = nbPoints1 + nbPoints2;


	if (*labels == extraLabels)
	{
		if (labels->size() > 0)
		{
			// same descriptors, fast merge
			data->conservativeResize(Eigen::NoChange, nbPointsTotal);
			data->rightCols(nbPoints2) = extraData;
		}
	}
	else
	{
		// different descriptors, slow merge
		
		// collect labels to be kept
		Labels newLabels;
		for(BOOST_AUTO(it, labels->begin()); it != labels->end(); ++it)
		{
			for(BOOST_AUTO(jt, extraLabels.begin()); jt != extraLabels.end(); ++jt)
			{
				if (it->text == jt->text)
				{
					if (it->span != jt->span)
						throw InvalidField(
						(boost::format("The field %1% has dimension %2% in this, different than dimension %3% in that") % it->text % it->span % jt->span).str()
					);
					newLabels.push_back(*it);
					break;
				}
			}
		}
		
		// allocate new descriptors
		if (newLabels.size() > 0)
		{
			MatrixType newData;
			Labels filledLabels;
			this->allocateFields(newLabels, filledLabels, newData);
			assert(newLabels == filledLabels);
			
			// fill
			unsigned row(0);
			for(BOOST_AUTO(it, newLabels.begin()); it != newLabels.end(); ++it)
			{
				Eigen::Block<MatrixType> view(newData.block(row, 0, it->span, newData.cols()));
				view.leftCols(nbPoints1) = getViewByName(it->text, *labels, *data);
				view.rightCols(nbPoints2) = getViewByName(it->text, extraLabels, extraData);
				row += it->span;
			}
			
			// swap descriptors
			data->swap(newData);
			*labels = newLabels;
		}
		else
		{
			*data = MatrixType();
			*labels = Labels();
		}
	}
}
开发者ID:AndresStepa,项目名称:libpointmatcher,代码行数:67,代码来源:DataPoints.cpp

示例8: OTWS_Wordseg_x

int OTWS_Wordseg_x(otws_t handle, 
        const string& sent,
        vector<string>& words) {

    OTWS_Engine *engine = reinterpret_cast<OTWS_Engine *>(handle);
    words.clear();

    RawSentence *tag_sent = new TagSent();
    vector<string> chars;
    int numChars = UTF::getCharactersFromUTF8String(sent, &chars);

    // something for debug.
    cerr << "TOKEN: ";
    for (int i = 0; i < numChars; ++ i) {
        cerr << chars[i] << " | ";
        tag_sent->append(new TagItem(chars[i], "X"));
    }
    cerr << endl;

    Instance *inst = (engine)->extractor->extract(tag_sent, false);
    Items *items = inst->items();

    Labels* labels = engine->decoder->decode(inst,
            engine->model->getParameter("PARAMETER"))->best();

    Alphabet *labelsDict = engine->model->getAlphabet("LABELS");

    // something for debug.
    for (int i = 0; i < labels->size(); ++ i) {
        cerr << labelsDict->rlookup(labels->at(i)) << 
            "(" << labels->at(i) << ") ";
    }
    cerr << "| label size: " << labels->size() << endl;

    string tag;
    string word;

    for (int i = 0; i < items->size(); ) {
        tag = labelsDict->rlookup(labels->at(i));

        if ("S" == tag) {
            word = chars[i];
            words.push_back(word);
            ++ i;
        } else if ("B" == tag) {
            word = "";
            while ("E" != tag && i < items->size()){
                word = word + chars[i];
                tag = labelsDict->rlookup(labels->at(i));
                ++ i;
            }
            words.push_back(word);
        } else {
            cerr << "Exception asserted." << endl;
            words.clear();
            return -1;
        }
    }

    return words.size();
}
开发者ID:shannonyu,项目名称:online-tagger,代码行数:61,代码来源:otws_dll.cpp

示例9: UpdateGUI

//------------------------------------------------------------------------------
void ImagePlaneProbeWidget::UpdateGUI()
{
    if( mol_ == 0 )  return;

    updatingGUI_ = true;

    /// Grid data
    if( mol_->HasGridData() )
    {
        typedef MolekelMolecule::SurfaceLabels Labels;
        Labels labels = mol_->GetGridLabels();
        gridsComboBox_->setEnabled( labels.size() != 0 );
        Labels::const_iterator i = labels.begin();
        const Labels::const_iterator end = labels.end();
        for( i; i != end; ++i ) gridsComboBox_->addItem( i->c_str() );
        const double minValue = mol_->GetGridDataMin( labels.size() ? *( labels.begin() ) : "" );
        const double maxValue = mol_->GetGridDataMax( labels.size() ? *( labels.begin() ) : "" );
        gridDataRangeLabel_->setText( QString( "(%1, %2)" ).arg( minValue ).arg( maxValue ) );
    }
    else gridDataGroup_->setEnabled( false );

    /// Electron density
    if( mol_->CanComputeElectronDensity() ) eldensGroup_->setEnabled( true );
    else eldensGroup_->setEnabled( false );

    /// Spin density
    if( mol_->CanComputeSpinDensity() ) spindensGroup_->setEnabled( true );
    else spindensGroup_->setEnabled( false );

    /// MEP
    if( mol_->CanComputeMEP() ) mepGroup_->setEnabled( true );
    else mepGroup_->setEnabled( false );

    /// Orbitals
    orbitalsGroup_->setEnabled( false );
    if( mol_->GetNumberOfOrbitals() != 0 )
    {
        // update orbitals
        const int orbitals = mol_->GetNumberOfOrbitals();
        table_->setRowCount( orbitals );
        QStringList verticalHeaders;
        for( int i = 0;	 i != orbitals; ++i )
        {
            QTableWidgetItem *eigenValueItem = new QTableWidgetItem;
            eigenValueItem->setFlags(  Qt::ItemIsSelectable | Qt::ItemIsEnabled );
            eigenValueItem->setText( QString( "%1" ).arg( mol_->GetOrbitalEigenValue( i  ) ) );
            QTableWidgetItem *occupationItem = new QTableWidgetItem;
            occupationItem->setFlags(  Qt::ItemIsSelectable | Qt::ItemIsEnabled );
            occupationItem->setText( QString( "%1" ).arg( mol_->GetOrbitalOccupation( i ) ) );
            QTableWidgetItem *typeItem = new QTableWidgetItem;
            typeItem->setText( QString( "%1" ).arg( mol_->GetOrbitalType( i ) ) );
            QTableWidgetItem *selectedItem = new QTableWidgetItem;
            selectedItem->setCheckState( Qt::Unchecked );
            selectedItem->setData( Qt::UserRole, i );
            table_->setItem( i, 0, selectedItem );
            table_->setItem( i, 1, eigenValueItem );
            table_->setItem( i, 2, occupationItem );
            table_->setItem( i, 3, typeItem );

            if( mol_->IsAlphaOrbital( i ) )
            {
                verticalHeaders << QString( "%1 (%2)" ).arg( i ).arg( tr( "alpha" ) );
            }
            else if( mol_->IsBetaOrbital( i ) )
            {
                verticalHeaders << QString( "%1 (%2)" ).arg( i ).arg( tr( "beta" ) );
            }
        }
        table_->setVerticalHeaderLabels( verticalHeaders );
        table_->resizeColumnsToContents();
        /// @todo do we need the following to make sure everything is unselected ?
        /// table_->setRangeSelected( QTableWidgetSelectionRange( 0, 0, table_->rowCount() - 1, 3 ), false );
    }
    stepSizeSpinBox_->setValue( 0.25 );
    updatingGUI_ = false;
    if( mol_->GetNumberOfOrbitals() != 0 )  orbitalsGroup_->setEnabled( true );
    // signals are not emitted since slot are not active during UI update;
    // emit signals with default value to make sure all observers are
    // properly initialized
    // toggle group checkboxes to disable group content
    orbitalsGroup_->setChecked( true );
    orbitalsGroup_->setChecked( false );

    emit OrbitalSelected( -1 );
    emit StepChanged( stepSizeSpinBox_->value() );
}
开发者ID:carlfahl,项目名称:molekel,代码行数:87,代码来源:ImagePlaneProbeWidget.cpp


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