本文整理汇总了C++中Scalar::index方法的典型用法代码示例。如果您正苦于以下问题:C++ Scalar::index方法的具体用法?C++ Scalar::index怎么用?C++ Scalar::index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scalar
的用法示例。
在下文中一共展示了Scalar::index方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_applyButton_clicked
void TimeAnalysisWidget::on_applyButton_clicked()
{
bool low = _ui->lowRadioButton->isChecked();
int numClusters = _ui->numClustersSpin->value();
std::vector<Point*> &points = low?_lowPoints.data():_highPoints.data();
std::vector<Point> centers;
std::vector<int> assignment;
PointClusterer::kmeans(PointClusterer::RANDOM,numClusters,
PointClusterer::EUCLIDEAN,
points, 10, centers, assignment);
std::ostringstream ss;
ss << "K-means " << numClusters << (low?" [low]":" [high]");
Scalar *scalar = addScalar(ss.str());
// create labels
scalar->labels().clear();
for (unsigned i=0; i<centers.size(); ++i) {
ss.str("");
ss << "Cluster [" << i << "]";
scalar->labels().push_back(ss.str());
}
// assigne scalar values to points
for (unsigned i=0; i<assignment.size(); ++i) {
Point *p = _lowPoints.data()[i];
p->setScalarValue(scalar, assignment[i]);
}
// refill combox
fillScalarComboBox();
_ui->colorByComboBox->setCurrentIndex(scalar->index());
}