本文整理汇总了C++中cluster函数的典型用法代码示例。如果您正苦于以下问题:C++ cluster函数的具体用法?C++ cluster怎么用?C++ cluster使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cluster函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: process
/**
* @function process
*/
void process( pcl::PointCloud<pcl::PointXYZRGBA>::Ptr _cloud ) {
// Segment
TabletopSegmentor<pcl::PointXYZRGBA> tts;
tts.processCloud( _cloud );
mTableCoeffs = tts.getTableCoeffs();
int n = tts.getNumClusters();
// Set segmented variables
gClusters.resize(0);
for( int i = 0; i < n; ++i ) {
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cluster( new pcl::PointCloud<pcl::PointXYZRGBA>() );
gClusters.push_back( cluster );
}
gColors.resize(n);
for( int i = 0; i < n; ++i ) {
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cluster( new pcl::PointCloud<pcl::PointXYZRGBA>() );
*cluster = tts.getCluster(i);
gClusters[i] = cluster;
Eigen::Vector3i def;
def(0) = rand() % 255; def(1) = rand() % 255; def(2) = rand() % 255;
gColors[i]<< (double) def(0) / 255.0, (double) def(1) / 255.0, (double) def(2) / 255.0;
}
}
开发者ID:ana-GT,项目名称:golems,代码行数:34,代码来源:crichton_eye_v2.cpp
示例2: main
int main(int argc, char* argv[])
{
if (argc < 6) {
std::cout << "Usage: " << argv[0] << " in out-image out-csv threshold [sort-mode]\n";
std::cout << " sort-mode: sort-by-color, sort-by-count\n";
return 0;
}
cv::Mat Z;
std::string f = argv[1];
if (fs::is_directory(f)) {
Z = loadThumbnails(f);
} else if (fs::path(f).extension() == ".png" || fs::path(f).extension() == ".jpg") {
Z = loadImage(f);
} else {
Z = loadVideo(f);
}
std::cout << "Clustering...\n";
std::vector<Cluster> centers;
if (std::string(argv[4]).find(".") == std::string::npos) {
cluster(Z, (int)atoi(argv[4]), centers);
} else {
cluster(Z, (float)atof(argv[4]), centers);
}
std::string sort_mode = argc >= 6 ? argv[5] : "sort-by-count";
if (sort_mode == "sort-by-color") {
sortCentersByColor(centers);
} else {
sortCentersByCount(centers);
}
exportCenters(centers, argv[2], argv[3]);
}
开发者ID:proog128,项目名称:dominant_colors,代码行数:34,代码来源:main.cpp
示例3: TEST
TEST(podio, equality) {
auto cluster = ExampleCluster();
auto rel = ExampleWithOneRelation();
rel.cluster(cluster);
auto returned_cluster = rel.cluster();
EXPECT_EQ(cluster,returned_cluster);
EXPECT_EQ(returned_cluster,cluster);
}
开发者ID:roelaaij,项目名称:podio,代码行数:8,代码来源:unittest.cpp
示例4: ban_it
char * ban_it(char *nick, char *user, char *host, char *ip)
{
static char banstr[BIG_BUFFER_SIZE/4+1];
char *t = user;
char *t1 = user;
char *tmp;
*banstr = 0;
while (strlen(t1)>9)
t1++;
t1 = clear_server_flags(t1);
switch (defban)
{
case 7:
if (ip)
{
snprintf(banstr, sizeof banstr, "*!*@%s",
cluster(ip));
break;
}
case 2: /* Better */
snprintf(banstr, sizeof banstr, "*!*%[email protected]%s", t1,
cluster(host));
break;
case 3: /* Host */
snprintf(banstr, sizeof banstr, "*!*@%s", host);
break;
case 4: /* Domain */
tmp = strrchr(host, '.');
if (tmp) {
snprintf(banstr, sizeof banstr, "*!*@*%s",
tmp);
} else {
snprintf(banstr, sizeof banstr, "*!*@%s",
host);
}
break;
case 5: /* User */
snprintf(banstr, sizeof banstr, "*!%[email protected]%s", t,
cluster(host));
break;
case 6: /* Screw */
snprintf(banstr, sizeof banstr, "*!*%[email protected]%s", t1, host);
screw(banstr);
break;
case 1: /* Normal */
default:
snprintf(banstr, sizeof banstr, "%s!*%[email protected]%s", nick, t1,
host);
break;
}
return banstr;
}
开发者ID:BitchX,项目名称:BitchX1.2,代码行数:53,代码来源:banlist.c
示例5: depends
bool Package::Depend(const Package& p) const
{
bool depends(false);
std::string cluster(fs::basename(fs::path(m_Package->first).leaf()));
if(cluster.empty())
{
cluster = fs::basename(fs::absolute(m_Package->first).filename());
}
std::cout << "subgraph cluster_"
<< cluster
<< "{" << std::endl
<< "label=" << cluster
<< ';' << std::endl;
for(std::set<Object>::const_iterator it = m_Package->second.object.begin();
it != m_Package->second.object.end(); ++it)
{
std::cout << '"' << fs::basename(fs::path(it->Name()).leaf()) << "\";" << std::endl;
}
for(std::set<Package>::const_iterator it = m_Package->second.package.begin();
it != m_Package->second.package.end(); ++it)
{
it->Depend(p);
}
std::cout << "}" << std::endl;
return depends;
}
开发者ID:epronk,项目名称:nmdepend,代码行数:32,代码来源:Package.cpp
示例6: kdTree
std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> MovingObjectsIdentificator::extractClusters() {
if(verbose) std::cout << "Extracting clusters ... ";
pcl::search::KdTree<pcl::PointXYZ>::Ptr kdTree (new pcl::search::KdTree<pcl::PointXYZ>);
kdTree->setInputCloud(workingCloud);
std::vector<pcl::PointIndices> indices;
pcl::EuclideanClusterExtraction<pcl::PointXYZ> ece;
ece.setClusterTolerance(clusterTolerance);
ece.setMinClusterSize(minClusterSize);
ece.setSearchMethod(kdTree);
ece.setInputCloud(workingCloud);
ece.extract(indices);
std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr > clusters;
for(std::vector<pcl::PointIndices>::iterator it = indices.begin(); it != indices.end(); it++) {
pcl::PointCloud<pcl::PointXYZ>::Ptr cluster(new pcl::PointCloud<pcl::PointXYZ>);
pcl::ExtractIndices<pcl::PointXYZ> extract;
extract.setInputCloud(workingCloud);
pcl::PointIndices::Ptr pi(new pcl::PointIndices);
pi->indices=it->indices;
extract.setIndices(pi);
extract.setNegative(false);
extract.filter(*cluster);
clusters.push_back(cluster);
}
if(verbose) std::cout << "done!" << std::endl;
return clusters;
}
开发者ID:Xiaoliang1992,项目名称:moving-objects,代码行数:31,代码来源:moving_objects_identificator.cpp
示例7: findDoorCentroids
void findDoorCentroids(const cloud_t::Ptr &cloud, const std::vector<pcl::PointIndices> &indices, std::vector<point_t> ¢roids)
{
// X-coord width in meters
const float min_width = .8;
const float max_width = .96;
// Loop through clusters
for (std::vector<pcl::PointIndices>::const_iterator it = indices.begin(); it != indices.end(); ++it) {
// Create cluster from indices
cloud_t::Ptr cluster(new cloud_t(*cloud, (*it).indices));
// Second check: door width
point_t min;
point_t max;
pcl::getMinMax3D(*cluster, min, max);
float door_width = sqrt(pow(max.x-min.x, 2.) + pow(max.y-min.y, 2.));
//std::cout << door_width << std::endl;
if ((door_width > min_width) && (door_width < max_width)) {
// Return door centroid
Eigen::Matrix<float, 4, 1> centroid;
pcl::compute3DCentroid(*cluster, centroid);
centroids.push_back(point_t(centroid(0), centroid(1), centroid(2)));
std::cout << "Found door with centroid at: " << centroid(0) << ", " << centroid(1) << ", " << centroid(2) << std::endl;
}
}
}
开发者ID:omh1280,项目名称:door_pcl,代码行数:27,代码来源:region_growing.cpp
示例8: segment_region_growing
void segment_region_growing(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud, int index, pcl::PointCloud<pcl::PointXYZRGBA>::Ptr output_cloud) {
pcl::search::Search<pcl::PointXYZRGBA>::Ptr tree = boost::shared_ptr< pcl::search::Search<pcl::PointXYZRGBA> > (new pcl::search::KdTree<pcl::PointXYZRGBA>);
pcl::PointCloud <pcl::Normal>::Ptr normals (new pcl::PointCloud <pcl::Normal>);
pcl::NormalEstimation<pcl::PointXYZRGBA, pcl::Normal> normal_estimator;
normal_estimator.setSearchMethod (tree);
normal_estimator.setInputCloud (cloud);
normal_estimator.setKSearch (50);
normal_estimator.compute (*normals);
pcl::IndicesPtr indices (new std::vector <int>);
pcl::PassThrough<pcl::PointXYZRGBA> pass;
pass.setInputCloud (cloud);
pass.setFilterFieldName ("z"); // Filter the huge quantity of points at the origin that mean nothing
pass.setFilterLimits (-0.01, 0.01);
// pass.setFilterFieldName ("y");
// pass.setFilterLimits (-0.1, 0.1);
// pass.setFilterFieldName ("x");
// pass.setFilterLimits (-0.1, 0.1);
pass.setFilterLimitsNegative(true);
pass.filter (*indices);
pcl::PointCloud <pcl::PointXYZRGBA>::Ptr temp_visualization (new pcl::PointCloud <pcl::PointXYZRGBA>);
pcl::PointIndices filter_pts;
pcl::PointIndices::Ptr cluster_ptr(new pcl::PointIndices());
cluster_ptr->indices = *indices;
extract_indices(cloud, temp_visualization, *cluster_ptr);
pcl::RegionGrowing<pcl::PointXYZRGBA, pcl::Normal> reg;
reg.setMinClusterSize (10);
reg.setMaxClusterSize (100000);
reg.setSearchMethod (tree);
reg.setNumberOfNeighbours (30);
reg.setIndices(indices);
reg.setInputCloud (cloud);
reg.setInputNormals (normals);
// reg.setSmoothnessThreshold (3.0 / 180.0 * M_PI);
reg.setSmoothnessThreshold (15.0 / 180.0 * M_PI); // More relaxed angle constraints
reg.setCurvatureThreshold (1.0);
// std::vector <pcl::PointIndices> clusters;
// reg.extract (clusters);
/*
pcl::PointCloud <pcl::PointXYZRGB>::Ptr colored_cloud = reg.getColoredCloud();
pcl::PointCloud <pcl::PointXYZRGBA>::Ptr colored_cloud_rgba(new pcl::PointCloud <pcl::PointXYZRGBA>);
pcl::copyPointCloud(*colored_cloud, *colored_cloud_rgba);
visualize(colored_cloud_rgba, "colored segmentation");
*/
pcl::PointIndices::Ptr cluster(new pcl::PointIndices());
reg.getSegmentFromPoint(index, *cluster);
extract_indices(cloud, output_cloud, *cluster);
}
开发者ID:ehuang3,项目名称:apc_ros,代码行数:60,代码来源:segmentation.cpp
示例9: cluster
void CAttributeDlg::DoCheckSyntax()
{
m_view.SyntaxChecking();
CString ecl;
m_view.GetText(ecl);
CString cluster(GetIConfig(QUERYBUILDER_CFG)->Get(GLOBAL_CLUSTER));
CString module(m_attribute->GetModuleQualifiedLabel());
CString attribute(m_attribute->GetLabel());
if (CComPtr<IEclCC> eclcc = CreateIEclCC())
{
if (!DoSave(false))
return;
}
if (m_attribute->GetType() == CreateIAttributeECLType())
{
clib::thread run(__FUNCTION__, boost::bind(&EclCheckSyntax, this, ecl, cluster, module, attribute, _T(""), _T(""), false, false));
}
else
{
IAttributeVector attrs;
Dali::CEclExceptionVector errors;
m_attribute->PreProcess(PREPROCESS_SYNTAXCHECK, ecl, attrs, errors);
SendMessage(CWM_SUBMITDONE, Dali::WUActionCheck, (LPARAM)&errors);
}
}
开发者ID:dehilsterlexis,项目名称:eclide-1,代码行数:26,代码来源:EclDlgAttribute.cpp
示例10: discoverTopologyWithLLC
void
darts :: hwloc :: AbstractMachine :: discoverTopologyWithLLC(void)
{
unsigned nbSockets = hwloc_get_nbobjs_by_type(_topology,HWLOC_OBJ_SOCKET);
hwloc_obj_t o = hwloc_get_obj_by_type(_topology,HWLOC_OBJ_SOCKET,0);
hwloc_obj_t obj;
for (obj = o->first_child;
obj && obj->type != HWLOC_OBJ_CACHE;
obj = obj->first_child)
;
_nbClusters = nbSockets;
if (obj) {
int n = hwloc_get_nbobjs_inside_cpuset_by_type(_topology,obj->cpuset,HWLOC_OBJ_PU);
_nbClusters = _nbTotalUnits / n; // XXX assumes homogeneous distribution of PUs
}
_clusterMap = new Cluster[_nbClusters];
// TODO Refactor this code and the next function's code into a single one
for (o = obj; o; o = o->next_cousin) {
int nUnits = hwloc_get_nbobjs_inside_cpuset_by_type(_topology,o->cpuset,HWLOC_OBJ_PU);
Unit *units = new Unit[nUnits];
for (int i = 0; i < nUnits; ++i) {
hwloc_obj_t t = hwloc_get_obj_inside_cpuset_by_type(_topology,o->cpuset,HWLOC_OBJ_PU,i);
Unit hwu(o->logical_index,t->logical_index,t->os_index);
units[i] = hwu; // simple shallow copy
}
Cluster cluster(o->logical_index,o->logical_index,nUnits,units);
_clusterMap[o->logical_index] = cluster; // simple shallow copy
}
}
开发者ID:szuckerm,项目名称:DARTS,代码行数:32,代码来源:AbstractMachine.cpp
示例11: try_initialize_more
bool try_initialize_more (Ekiga::ServiceCore& core,
int* /*argc*/,
char** /*argv*/[])
{
boost::shared_ptr<Ekiga::PresenceCore> presence_core = core.get<Ekiga::PresenceCore> ("presence-core");
boost::shared_ptr<Ekiga::CallCore> call_core = core.get<Ekiga::CallCore> ("call-core");
boost::shared_ptr<Ekiga::PersonalDetails> details = core.get<Ekiga::PersonalDetails> ("personal-details");
if (presence_core && call_core && details) {
boost::shared_ptr<Avahi::PresencePublisher> publisher (new Avahi::PresencePublisher (core, *details, *call_core));
if (core.add (publisher)) {
presence_core->add_presence_publisher (publisher);
result = true;
}
boost::shared_ptr<Avahi::Cluster> cluster (new Avahi::Cluster (core));
if (core.add (cluster)) {
presence_core->add_cluster (cluster);
result = true;
}
}
return result;
}
开发者ID:extremelydangerous,项目名称:ekiga,代码行数:27,代码来源:avahi-main.cpp
示例12: build
void build(const std::string& ip_prefix, int num_nodes) {
test_utils::CassClusterPtr cluster(cass_cluster_new());
test_utils::initialize_contact_points(cluster.get(), ip_prefix, num_nodes, 0);
cass_cluster_set_load_balance_round_robin(cluster.get());
cass_cluster_set_token_aware_routing(cluster.get(), cass_false);
test_utils::CassSessionPtr session(test_utils::create_session(cluster.get()));
for (int i = 0; i < num_nodes; ++i) {
test_utils::CassStatementPtr statement(
cass_statement_new("SELECT tokens, data_center FROM system.local", 0));
test_utils::CassFuturePtr future(cass_session_execute(session.get(), statement.get()));
test_utils::wait_and_check_error(future.get());
test_utils::CassResultPtr result(cass_future_get_result(future.get()));
const CassRow* row = cass_result_first_row(result.get());
const CassValue* data_center = cass_row_get_column_by_name(row, "data_center");
const CassValue* token_set = cass_row_get_column_by_name(row, "tokens");
CassString str;
cass_value_get_string(data_center, &str.data, &str.length);
std::string dc(str.data, str.length);
std::string ip = cass::get_host_from_future(future.get());
test_utils::CassIteratorPtr iterator(cass_iterator_from_collection(token_set));
while (cass_iterator_next(iterator.get())) {
cass_value_get_string(cass_iterator_get_value(iterator.get()), &str.data, &str.length);
std::string token(str.data, str.length);
tokens[boost::lexical_cast<int64_t>(token)] = Host(ip, dc);
}
}
}
开发者ID:Shauwe,项目名称:cpp-driver,代码行数:31,代码来源:test_token_aware_policy.cpp
示例13: main
int main()
{
//CREATE GRAPH FROM A SORTED EDGE LIST FILE
createGraph();
int i=0, flg=0;
for(i=1;i<NO_OF_ENTRIES;++i)
{
if(list[i]->w>list[i+1]->w)
{
printf("\n%d) %d %d %d\n", i, list[i]->s, list[i]->d, list[i]->w);
flg++;
}
}
if(flg==0)
{
printf("\nArray is sorted. Now to apply clustering...");
getch();
}
else
return -1;
i=cluster(4);
printf("\nMaximum spacing=%d. (At edge no.=%d)", list[i]->w, i);
return 0;
}
开发者ID:somnath-saha,项目名称:Algorithms-Design-and-Analysis-Part-2,代码行数:25,代码来源:clusteringHamming.c
示例14: normal
template <typename PointT> void
pcl::people::HeadBasedSubclustering<PointT>::mergeClustersCloseInFloorCoordinates (std::vector<pcl::people::PersonCluster<PointT> >& input_clusters,
std::vector<pcl::people::PersonCluster<PointT> >& output_clusters)
{
float min_distance_between_cluster_centers = 0.4; // meters
float normalize_factor = std::pow(sqrt_ground_coeffs_, 2); // sqrt_ground_coeffs ^ 2 (precomputed for speed)
Eigen::Vector3f head_ground_coeffs = ground_coeffs_.head(3); // ground plane normal (precomputed for speed)
std::vector <std::vector<int> > connected_clusters;
connected_clusters.resize(input_clusters.size());
std::vector<bool> used_clusters; // 0 in correspondence of clusters remained to process, 1 for already used clusters
used_clusters.resize(input_clusters.size());
for(size_t i = 0; i < input_clusters.size(); i++) // for every cluster
{
Eigen::Vector3f theoretical_center = input_clusters[i].getTCenter();
float t = theoretical_center.dot(head_ground_coeffs) / normalize_factor; // height from the ground
Eigen::Vector3f current_cluster_center_projection = theoretical_center - head_ground_coeffs * t; // projection of the point on the groundplane
for(size_t j = i+1; j < input_clusters.size(); j++) // for every remaining cluster
{
theoretical_center = input_clusters[j].getTCenter();
float t = theoretical_center.dot(head_ground_coeffs) / normalize_factor; // height from the ground
Eigen::Vector3f new_cluster_center_projection = theoretical_center - head_ground_coeffs * t; // projection of the point on the groundplane
if (((new_cluster_center_projection - current_cluster_center_projection).norm()) < min_distance_between_cluster_centers)
{
connected_clusters[i].push_back(j);
}
}
}
for(size_t i = 0; i < connected_clusters.size(); i++) // for every cluster
{
if (!used_clusters[i]) // if this cluster has not been used yet
{
used_clusters[i] = true;
if (connected_clusters[i].empty()) // no other clusters to merge
{
output_clusters.push_back(input_clusters[i]);
}
else
{
// Copy cluster points into new cluster:
pcl::PointIndices point_indices;
point_indices = input_clusters[i].getIndices();
for(const int &cluster : connected_clusters[i])
{
if (!used_clusters[cluster]) // if this cluster has not been used yet
{
used_clusters[cluster] = true;
for(std::vector<int>::const_iterator points_iterator = input_clusters[cluster].getIndices().indices.begin();
points_iterator != input_clusters[cluster].getIndices().indices.end(); points_iterator++)
{
point_indices.indices.push_back(*points_iterator);
}
}
}
pcl::people::PersonCluster<PointT> cluster(cloud_, point_indices, ground_coeffs_, sqrt_ground_coeffs_, head_centroid_, vertical_);
output_clusters.push_back(cluster);
}
}
}
}
开发者ID:taketwo,项目名称:pcl,代码行数:60,代码来源:head_based_subcluster.hpp
示例15: sortByScore
vector<Detection> NonMaximumSuppression::eliminateRedundantDetections(vector<Detection> candidates) const {
if (overlapThreshold == 1.0) // with this threshold, there would be an endless loop - this check assumes distinct bounding boxes
return candidates;
sortByScore(candidates);
vector<vector<Detection>> clusters = cluster(candidates);
return getMaxima(clusters);
}
开发者ID:smajida,项目名称:FeatureDetection,代码行数:7,代码来源:NonMaximumSuppression.cpp
示例16: main
int main(int argc, char** argv)
{
try {
variable_set_type variables;
options(argc, argv, variables);
if (variables.count("temporary") && ! variables["temporary"].as<std::string>().empty())
::setenv("TMPDIR_SPEC", variables["temporary"].as<std::string>().data(), 1);
if (! variables.count("input"))
throw std::runtime_error("no input file");
if (! variables.count("output"))
throw std::runtime_error("no output file");
const std::string input_path = variables["input"].as<std::string>();
const std::string output_path = variables["output"].as<std::string>();
cicada::Cluster cluster(input_path);
::sync();
cluster.write(output_path);
}
catch (const std::exception& err) {
std::cerr << "error: " << err.what() << std::endl;
return 1;
}
return 0;
}
开发者ID:hitochan777,项目名称:cicada,代码行数:27,代码来源:cicada_index_cluster.cpp
示例17: process_ros
bool process_ros(duplo_v0::Process_PCD::Request &req,
duplo_v0::Process_PCD::Response &res)
{
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudz(new pcl::PointCloud<pcl::PointXYZRGB>); //Filtered cloud
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_inliers(new pcl::PointCloud<pcl::PointXYZRGB>); //Inliers after removing outliers
pcl::PointCloud<pcl::PointXYZRGB>::Ptr planar_cloud(new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::PointCloud<pcl::PointXYZRGB>::Ptr object_cloud(new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cluster1(new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::fromROSMsg(req.pcd_in,*cloud);
/****************** Filter out the non-table points ******************/
if (pass_through(cloud,cloudz) != 0)
{
std::cerr << "Pass-through filter error" << std::endl;
return false;
}
/* ********* Segmentation of the cloud into table and object clouds **********/
planar_seg(cloudz,planar_cloud,object_cloud,"table_try.pcd","object_try.pcd");
/********************** Cluster objects based on Euclidean distance **********/
//vector<double> volumes = cluster(object_cloud);
int num_clusters_found = cluster(object_cloud);
if (num_clusters_found == 0)
the_chosen_one.data.clear();
res.n_clusters = num_clusters_found;
processed_pointcloud = true;
return true;
}
开发者ID:meghag,项目名称:duplo_v0,代码行数:33,代码来源:process_pcd_server.cpp
示例18: cluster
/*
* Cluster all the samples again.
*/
bool OfflineKMeans::reCluster() {
bool clusterChanged = false;
for(int i = 0; i < sampleNum; ++i) {
const float* sample = samples.getSample(i);
int oldCluster = clusterIndexes[i];
int newCluster = cluster(sample, featureNum);
if(newCluster != oldCluster) {
clusterChanged = true;
#ifdef OKM_DBG
std::cout<<"i = "<<i<<", oldCluster = "<<oldCluster<<", newCluster = "
<<newCluster<<std::endl;
#endif
// move sample from the old cluster to the new cluster.
clusters[oldCluster].second.erase(const_cast<float*>(sample));
clusters[newCluster].second.insert(const_cast<float*>(sample));
/*
* set clusterIndexes[i] to newCluster to indicate now sample
* indexed by 'i' is in cluster indexed by 'newCluster'.
*/
clusterIndexes[i] = newCluster;
}
}
if(clusterChanged == true)
updateCentroids();
return clusterChanged;
}
开发者ID:JackieXie168,项目名称:machine_learning,代码行数:34,代码来源:OfflineKMeans.cpp
示例19: client
void redis_client_cluster::set_all_slot(const char* addr, int max_conns)
{
redis_client client(addr, 30, 60, false);
redis_cluster cluster(&client);
const std::vector<redis_slot*>* slots = cluster.cluster_slots();
if (slots == NULL)
return;
std::vector<redis_slot*>::const_iterator cit;
for (cit = slots->begin(); cit != slots->end(); ++cit)
{
const redis_slot* slot = *cit;
const char* ip = slot->get_ip();
if (*ip == 0)
continue;
int port = slot->get_port();
if (port <= 0)
continue;
size_t slot_min = slot->get_slot_min();
size_t slot_max = slot->get_slot_max();
if ((int) slot_max >= max_slot_ || slot_max < slot_min)
continue;
char buf[128];
safe_snprintf(buf, sizeof(buf), "%s:%d", ip, port);
redis_client_pool* conns = (redis_client_pool*) get(buf);
if (conns == NULL)
set(buf, max_conns);
for (size_t i = slot_min; i <= slot_max; i++)
set_slot((int) i, buf);
}
}
开发者ID:FlowSea,项目名称:acl,代码行数:35,代码来源:redis_client_cluster.cpp
示例20: try_initialize_more
bool try_initialize_more (Ekiga::ServiceCore& core,
int* /*argc*/,
char** /*argv*/[])
{
boost::shared_ptr<Ekiga::PresenceCore> presence = core.get<Ekiga::PresenceCore> ("presence-core");
boost::shared_ptr<Ekiga::AccountCore> account = core.get<Ekiga::AccountCore> ("account-core");
boost::shared_ptr<Ekiga::ChatCore> chat = core.get<Ekiga::ChatCore> ("chat-core");
boost::shared_ptr<Ekiga::PersonalDetails> details = core.get<Ekiga::PersonalDetails> ("personal-details");
if (presence && account && chat && details) {
LM::DialectPtr dialect(new LM::Dialect (core));
LM::ClusterPtr cluster(new LM::Cluster (dialect, details));
LM::BankPtr bank (new LM::Bank (details, dialect, cluster));
if (core.add (bank)) {
chat->add_dialect (dialect);
account->add_bank (bank);
presence->add_cluster (cluster);
result = true;
}
}
return result;
}
开发者ID:Pobegunchik,项目名称:ekiga,代码行数:25,代码来源:loudmouth-main.cpp
注:本文中的cluster函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论