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


C++ Labels类代码示例

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


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

示例1: criticalCellsAreSelfLabelled

Result criticalCellsAreSelfLabelled(VolumeData const& candidate)
{
    CubicalComplex const& complex = candidate.complex;
    Field const& field = candidate.field;

    for (int up = 0; up <= 1; ++up)
    {
        Labels const labels = markCells(candidate, up);
        for (Cell v = 0; v < complex.cellIdLimit(); ++v)
        {
            if (complex.isCell(v) and field.isCritical(v))
            {
                if (labels.count(v) == 0 or labels.at(v).count(v) < 1)
                {
                    std::stringstream msg;
                    msg << "Critical cell " << complex.cellPosition(v)
                        << " is not in its own " << (up ? "unstable" : "stable")
                        << " set";
                    return failure(msg.str());
                }
                else if (labels.at(v).size() > 1)
                {
                    std::stringstream msg;
                    msg << "Critical cell " << complex.cellPosition(v)
                        << " is in other " << (up ? "unstable" : "stable")
                        << " sets";
                    return failure(msg.str());
                }
            }
        }
    }

    return success();
}
开发者ID:AppliedMathematicsANU,项目名称:diamorse,代码行数:34,代码来源:testTraversal.C

示例2: descDim

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

示例3: getFieldStartingRow

void PointMatcher<T>::DataPoints::removeField(const std::string& name, Labels& labels, MatrixType& data) const
{

	const unsigned deleteId = getFieldStartingRow(name, labels);
	const unsigned span = getFieldDimension(name, labels);
	const unsigned keepAfterId = deleteId + span;
	const unsigned lastId = data.rows() - 1;
	const unsigned sizeKeep = data.rows() - keepAfterId;
	const unsigned nbPoints = data.cols();


	// check if the data to be removed at the end
	if(keepAfterId <= lastId)
	{
		data.block(deleteId, 0, sizeKeep, nbPoints) = data.block(keepAfterId, 0, sizeKeep, nbPoints);
	}

	//Remove the last rows
	data.conservativeResize(data.rows()-span, nbPoints);

	// remove label from the label list
	for(BOOST_AUTO(it, labels.begin()); it != labels.end(); ++it)
	{
		if (it->text == name)
		{
			labels.erase(it);
			break;
		}
	}

}
开发者ID:AndresStepa,项目名称:libpointmatcher,代码行数:31,代码来源:DataPoints.cpp

示例4: traversalsAreConsistent

Result traversalsAreConsistent(VolumeData const& candidate)
{
    CubicalComplex const& complex = candidate.complex;
    Field const& field = candidate.field;

    for (int up = 0; up <= 1; ++up)
    {
        Labels const labels = markCells(candidate, up);
        Field::Vectors V = up ? field.coV() : field.V();
        Facets I(complex.xdim(), complex.ydim(), complex.zdim(), up);

        for (Cell v = 0; v < complex.cellIdLimit(); ++v)
        {
            if (not complex.isCell(v))
                continue;

            if (labels.count(v) > 0)
            {
                int const n = I.count(v);
                for (int i = 0; i < n; ++i) {
                    Cell const b = I(v, i);

                    if (not V.defined(b) or V(b) == b)
                        continue;

                    Result r = labelsPropagate(labels, v, V(b), up, complex);
                    if (!r)
                        return r;
                }
            }
        }
    }
    return success();
}
开发者ID:AppliedMathematicsANU,项目名称:diamorse,代码行数:34,代码来源:testTraversal.C

示例5: getTestImage

  Image::Appc getTestImage() const
  {
    Image::Appc appc;
    appc.set_name("foo.com/bar");

    Label version;
    version.set_key("version");
    version.set_value("1.0.0");

    Label arch;
    arch.set_key("arch");
    arch.set_value("amd64");

    Label os;
    os.set_key("os");
    os.set_value("linux");

    Labels labels;
    labels.add_labels()->CopyFrom(version);
    labels.add_labels()->CopyFrom(arch);
    labels.add_labels()->CopyFrom(os);

    appc.mutable_labels()->CopyFrom(labels);

    return appc;
  }
开发者ID:EronWright,项目名称:mesos,代码行数:26,代码来源:provisioner_appc_tests.cpp

示例6: assert

//! 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

示例7: featureLabels

PointMatcher<T>::DataPoints::DataPoints(const Labels& featureLabels, const Labels& descriptorLabels, const size_t pointCount):
	featureLabels(featureLabels),
	descriptorLabels(descriptorLabels)
{
	features.resize(featureLabels.totalDim(), pointCount);
	if(descriptorLabels.totalDim())
		descriptors.resize(descriptorLabels.totalDim(), pointCount);
}
开发者ID:AndresStepa,项目名称:libpointmatcher,代码行数:8,代码来源:DataPoints.cpp

示例8:

unsigned PointMatcher<T>::DataPoints::getFieldDimension(const std::string& name, const Labels& labels) const
{
	for(BOOST_AUTO(it, labels.begin()); it != labels.end(); ++it)
	{
		if (it->text == name)
			return it->span;
	}
	return 0;
}
开发者ID:AndresStepa,项目名称:libpointmatcher,代码行数:9,代码来源:DataPoints.cpp

示例9: row

unsigned PointMatcher<T>::DataPoints::getFieldStartingRow(const std::string& name, const Labels& labels) const
{
	unsigned row(0);
	for(BOOST_AUTO(it, labels.begin()); it != labels.end(); ++it)
	{
		if (it->text == name)
			return row;
		row += it->span;
	}
	return 0;
}
开发者ID:AndresStepa,项目名称:libpointmatcher,代码行数:11,代码来源:DataPoints.cpp

示例10: masterLaunchTaskLabelDecorator

  virtual Result<Labels> masterLaunchTaskLabelDecorator(
      const TaskInfo& taskInfo,
      const FrameworkInfo& frameworkInfo,
      const SlaveInfo& slaveInfo)
  {
    LOG(INFO) << "Executing 'masterLaunchTaskLabelDecorator' hook";

    Labels labels;
    Label *label = labels.add_labels();
    label->set_key(testLabelKey);
    label->set_value(testLabelValue);

    return labels;
  }
开发者ID:abhishekamralkar,项目名称:mesos,代码行数:14,代码来源:test_hook_module.cpp

示例11: 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

示例12: labelsPropagate

Result labelsPropagate(
    Labels const& labels,
    Cell const v,
    Cell const w,
    bool const upstream,
    CubicalComplex const& complex)
{
    std::set<Cell> const& lv = labels.at(v);
    std::set<Cell> const& lw = labels.at(w);

    std::set<Cell>::const_iterator iter;
    for (iter = lv.begin(); iter != lv.end(); ++iter)
    {
        if (lw.count(*iter) == 0)
        {
            std::stringstream msg;
            msg << (upstream ? "unstable" : "stable") << " sets for cell "
                << complex.cellPosition(v)
                << " are not contained in those for "
                << complex.cellPosition(w)
                << ": {" << lv << "} vs {" << lw << "}";
            return failure(msg.str());
        }
    }
    return success();
}
开发者ID:AppliedMathematicsANU,项目名称:diamorse,代码行数:26,代码来源:testTraversal.C

示例13: RankFixture

 RankFixture(size_t fooCnt, size_t barCnt, const Labels &labels)
     : queryEnv(&indexEnv), rankSetup(factory, indexEnv),
       mdl(), match_data(), rankProgram(), fooHandles(), barHandles()
 {
     for (size_t i = 0; i < fooCnt; ++i) {
         uint32_t fieldId = indexEnv.getFieldByName("foo")->id();
         fooHandles.push_back(mdl.allocTermField(fieldId));
         SimpleTermData term;
         term.setUniqueId(i + 1);
         term.addField(fieldId).setHandle(fooHandles.back());
         queryEnv.getTerms().push_back(term);
     }
     for (size_t i = 0; i < barCnt; ++i) { 
         uint32_t fieldId = indexEnv.getFieldByName("bar")->id();
         barHandles.push_back(mdl.allocTermField(fieldId));
         SimpleTermData term;
         term.setUniqueId(fooCnt + i + 1);
         term.addField(fieldId).setHandle(barHandles.back());
         queryEnv.getTerms().push_back(term);
     }
     labels.inject(queryEnv.getProperties());
     rankSetup.setFirstPhaseRank(featureName);
     rankSetup.setIgnoreDefaultRankFeatures(true);
     ASSERT_TRUE(rankSetup.compile());
     match_data = mdl.createMatchData();
     rankProgram = rankSetup.create_first_phase_program();
     rankProgram->setup(*match_data, queryEnv);
 }
开发者ID:songhtdo,项目名称:vespa,代码行数:28,代码来源:item_raw_score_test.cpp

示例14: slaveTaskStatusLabelDecorator

    virtual Result<Labels> slaveTaskStatusLabelDecorator(
        const FrameworkID& frameworkId,
        const TaskStatus& status)
    {
        LOG(INFO) << "CalicoHook::task status label decorator";

        if (!status.has_executor_id()) {
            LOG(WARNING) << "CalicoHook:: task status has no valid executor id";
            return None();
        }

        const ExecutorID executorId = status.executor_id();
        if (!executors->contains(executorId)) {
            LOG(WARNING) << "CalicoHook:: no valid container id for: " << executorId;
            return None();
        }

        const ContainerID containerId = executors->at(executorId);
        if (infos == NULL || !infos->contains(containerId)) {
            LOG(WARNING) << "CalicoHook:: no valid infos for: " << containerId;
            return None();
        }

        const Info* info = (*infos)[containerId];
        if (info->ipAddress.isNone()) {
            LOG(WARNING) << "CalicoHook:: no valid IP address";
            return None();
        }

        Labels labels;
        if (status.has_labels()) {
            labels.CopyFrom(status.labels());
        }

        // Set IPAddress label.
        Label* label = labels.add_labels();
        label->set_key(ipAddressLabelKey);
        label->set_value(info->ipAddress.get());

        LOG(INFO) << "CalicoHook:: added label "
                  << label->key() << ":" << label->value();
        return labels;
    }
开发者ID:joestein,项目名称:net-modules,代码行数:43,代码来源:network_isolator.cpp

示例15: InvalidField

void PointMatcher<T>::DataPoints::addField(const std::string& name, const MatrixType& newField, Labels& labels, MatrixType& data) const
{
	const int newFieldDim = newField.rows();
	const int newPointCount = newField.cols();
	const int pointCount = features.cols();

	if (newField.rows() == 0)
		return;

	// Replace if the field exists
	if (fieldExists(name, 0, labels))
	{
		const int fieldDim = getFieldDimension(name, labels);
		
		if(fieldDim == newFieldDim)
		{
			// Ensure that the number of points in the point cloud and in the field are the same
			if(pointCount == newPointCount)
			{
				const int row = getFieldStartingRow(name, labels);
				data.block(row, 0, fieldDim, pointCount) = newField;
			}
			else
			{
				stringstream errorMsg;
				errorMsg << "The field " << name << " cannot be added because the number of points is not the same. Old point count: " << pointCount << "new: " << newPointCount;
				throw InvalidField(errorMsg.str());
			}
		}
		else
		{
			stringstream errorMsg;
			errorMsg << "The field " << name << " already exists but could not be added because the dimension is not the same. Old dim: " << fieldDim << " new: " << newFieldDim;
			throw InvalidField(errorMsg.str());
		}
	}
	else // Add at the end if it is a new field
	{
		if(pointCount == newPointCount || pointCount == 0)
		{
			const int oldFieldDim(data.rows());
			const int totalDim = oldFieldDim + newFieldDim;
			data.conservativeResize(totalDim, newPointCount);
			data.bottomRows(newFieldDim) = newField;
			labels.push_back(Label(name, newFieldDim));
		}
		else
		{
			stringstream errorMsg;
			errorMsg << "The field " << name << " cannot be added because the number of points is not the same. Old point count: " << pointCount << " new: " << newPointCount;
			throw InvalidField(errorMsg.str());
		}
	}
}
开发者ID:AndresStepa,项目名称:libpointmatcher,代码行数:54,代码来源:DataPoints.cpp


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