本文整理汇总了C++中Square::GetContoursCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Square::GetContoursCount方法的具体用法?C++ Square::GetContoursCount怎么用?C++ Square::GetContoursCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Square
的用法示例。
在下文中一共展示了Square::GetContoursCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessSquares
// Constructor
void BinaryMath::ProcessSquares(const Square* recognizedSquares, int size)
{
// Put NumberSquares and OperatorSquares into 2 separate vectors
// vector <Square> testSquares;
// testSquares.push_back(Square(0,cvPoint(10,20),1,1)); // 0
// testSquares.push_back(Square(1,cvPoint(20,20),1,1)); // 1
// testSquares.push_back(Square(1,cvPoint(30,20),1,1)); // 1
// testSquares.push_back(Square(2,cvPoint(40,20),1,1)); // Operator
/*
size = 3;
Square recognizedSquares[3];
recognizedSquares[0] = Square(0, cvPoint(10, 20), 1, 1);
recognizedSquares[1] = Square(1, cvPoint(20, 20), 1, 1);
recognizedSquares[2] = Square(2, cvPoint(30, 20), 1, 1);
*/
int NumberOfSquares = size;
int threshold = 6;
vector <Square> OperatorSquares;
vector <Square> NumberSquares;
for (int i=0; i < NumberOfSquares;i++)
{
Square square = recognizedSquares[i];
QString objectName = this->moduleConfig->objectForSquare(&square);
printf("Square: %d (%s)\n", square.GetContoursCount(), qPrintable(objectName));
if (this->isSquareNumber(&square))
NumberSquares.push_back(square);
else
OperatorSquares.push_back(square);
}
// Create distance list
vector <A_B_distance> DistanceList;
if (NumberSquares.size() > 0) {
for (int i = 0; i < NumberSquares.size()-1; i++) {
for (int j=i+1; j < NumberSquares.size(); j++) {
DistanceList.push_back(A_B_distance (i,j,dist(NumberSquares[i],NumberSquares[j])));
}
}
}
for (int i=0; i < (int)DistanceList.size(); i++)
cout << DistanceList[i].A << ' ' <<DistanceList[i].B << ' ' << DistanceList[i].dist << endl;
sort(DistanceList.begin(), DistanceList.end(), compare);
cout << endl;
for (int i=0;i < (int)DistanceList.size(); i++)
cout << DistanceList[i].A << ' ' <<DistanceList[i].B << ' ' << DistanceList[i].dist << endl;
//Create Clusterlist and SupportList
vector <vector <int> > ClusterList;
vector <int> SupportList;
for (int i=0;i < (int)NumberSquares.size(); i++)
{
vector <int> Cluster;
Cluster.push_back(i);
ClusterList.push_back(Cluster);
SupportList.push_back(i);
}
for (int i = 0; i < (int)DistanceList.size(); i++)
{
int Cl1 = SupportList[DistanceList[i].A];
int Cl2 = SupportList[DistanceList[i].B];
if (DistanceList[i].dist > threshold) break;
if (Cl1 == Cl2) continue;
vector <int> &Cluster1 = ClusterList[Cl1];
vector <int> &Cluster2 = ClusterList[Cl2];
for (int j = 0; j < (int)Cluster2.size(); j++)
{
Cluster1.push_back(Cluster2[j]);
SupportList[Cluster2[j]] = Cl1;
}
Cluster2.clear();
}
//Remove empty clusters
for(int i = 0; i < (int)ClusterList.size(); i++)
{
if (ClusterList[i].empty())
{
ClusterList.erase(ClusterList.begin() + i);
i--;
}
}
//Print Clusters
for(int i = 0; i < (int)ClusterList.size(); i++)
{
cout << "Cluster" << i << ":\n";
for(int j=0; j < (int)ClusterList[i].size(); j++)
{
cout << ClusterList[i][j] << endl;
//.........这里部分代码省略.........