本文整理汇总了C#中Point3.update方法的典型用法代码示例。如果您正苦于以下问题:C# Point3.update方法的具体用法?C# Point3.update怎么用?C# Point3.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point3
的用法示例。
在下文中一共展示了Point3.update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Pool
// Uses the per-pixel classes from PredictGPU to pool the location of
// gestures. Supports multiple types of pooling algorithms. Each
// algorithm is described before each section.
private static List<Pooled> Pool(PoolType type, ProcessorState state)
{
List<Pooled> gestures = new List<Pooled>();
System.Drawing.Point center;
int[] label_counts;
Tuple<int, int> max;
switch (type)
{
#region KMeans
case PoolType.KMeans:
Random rand = new Random();
Point3 p = new Point3(0, 0, 0);
int K = 7, num_changes = 10, iterations = 0;
List<Point3> centroids = new List<Point3>(K);
for (int i = 0; i < K; i++)
centroids.Insert(i, new Point3(
rand.Next(width),
rand.Next(height),
rand.Next(400, 1500)
));
List<HashSet<int>> clusters = new List<HashSet<int>>(K);
for (int i = 0; i < K; i++) clusters.Insert(i, new HashSet<int>());
Dictionary<int, int> assignments = new Dictionary<int,int>();
for (int i = 0; i < state.depth.Length; i++)
if (state.predict_labels_[i] != (int)HandGestureFormat.Background)
{
int cluster = rand.Next(K);
assignments.Add(i, cluster);
clusters[cluster].Add(i);
}
List<int> points = new List<int>(assignments.Keys);
// If there have been no changes, the centroids wont
// change either so KMeans has found a minimum. This may
// be a local minimum.
#region KMeans, can be factored out
while (num_changes > 0)
{
num_changes = 0;
iterations++;
if (iterations % 10 == 0)
Console.WriteLine("Iteration {0}", iterations);
// Update centroids
for (int i = 0; i < K; i++)
{
int x = (int)clusters[i].Average(point => Util.toXY(point, width, height, kDepthStride).X);
int y = (int)clusters[i].Average(point => Util.toXY(point, width, height, kDepthStride).Y);
int depth = (int)clusters[i].Average(point => state.depth[point]);
centroids[i].update(x, y, depth);
}
// Update classifications
foreach (int point in points)
{
System.Drawing.Point xy = Util.toXY(point, width, height, kDepthStride);
p.update(xy.X, xy.Y, state.depth[point]);
int nearest = 0;
double nearest_distance = Util.EuclideanDistance(centroids[nearest], p);
for (int i = 1; i < K; i++)
{
double distance = Util.EuclideanDistance(centroids[i], p);
if (distance < nearest_distance)
{
nearest = i;
nearest_distance = distance;
}
}
if (assignments[point] != nearest && clusters[assignments[point]].Count != 1)
{
num_changes++;
clusters[assignments[point]].Remove(point);
clusters[nearest].Add(point);
assignments[point] = nearest;
}
}
}
#endregion
// Fit a Gaussian distribution on all the cluster sizes
// and look for outliers that are at least two standard
// deviations away from the mean.
#region Gaussian outlier detection
// Print the distribution of sizes within clusters
var sizes = clusters.Select(cluster => cluster.Count).
OrderByDescending(val => val).ToArray();
// Fit normal distribution and look for outliers
//.........这里部分代码省略.........