本文整理汇总了C#中Glyph.getPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Glyph.getPosition方法的具体用法?C# Glyph.getPosition怎么用?C# Glyph.getPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Glyph
的用法示例。
在下文中一共展示了Glyph.getPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: detectionGlyph
public double[] detectionGlyph(bool CalculTailleTerrain)
{
bool Trouve = false;
double[] ratio = new double[2] { 0, 0 };
SimpleShapeChecker shapeChecker = new SimpleShapeChecker();
BlobCounter blobCounter = new BlobCounter();
blobCounter.MinHeight = 23;
blobCounter.MinWidth = 23;
blobCounter.FilterBlobs = true;
blobCounter.ObjectsOrder = ObjectsOrder.Size;
// 4 - find all stand alone blobs
blobCounter.ProcessImage(imgContour);
Blob[] blobs = blobCounter.GetObjectsInformation();
// 5 - check each blob
for (int i = 0, n = blobs.Length; i < n; i++)
{
List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blobs[i]);
List<IntPoint> corners = null;
// Test de la forme selectionnée
if (shapeChecker.IsQuadrilateral(edgePoints, out corners))
{
// Détection des points de coutour
List<IntPoint> leftEdgePoints, rightEdgePoints, topEdgePoints, bottomEdgePoints;
Line Horizontale = Line.FromPoints(new IntPoint(0,0),new IntPoint(10,0));
blobCounter.GetBlobsLeftAndRightEdges(blobs[i], out leftEdgePoints, out rightEdgePoints);
blobCounter.GetBlobsTopAndBottomEdges(blobs[i], out topEdgePoints, out bottomEdgePoints);
// calculate average difference between pixel values from outside of the
// shape and from inside
float diff = CalculateAverageEdgesBrightnessDifference(leftEdgePoints, rightEdgePoints, imgNB);
// check average difference, which tells how much outside is lighter than
// inside on the average
if (diff > 20)
{
// Transformation de l'image reçu en un carré pour la reconnaissance
QuadrilateralTransformation quadrilateralTransformation = new QuadrilateralTransformation(corners, 60, 60);
UnmanagedImage glyphImage = quadrilateralTransformation.Apply(imgNB);
// Filtre de contraste
OtsuThreshold otsuThresholdFilter = new OtsuThreshold();
otsuThresholdFilter.ApplyInPlace(glyphImage);
imgContour = glyphImage;
// Reconnaissance du Glyph
Glyph Gl = new Glyph(glyphImage, GlyphSize);
Gl.ReconnaissanceGlyph(corners, imgNB);
// Si le Glyph est valide
if (Gl.getIdentifiant() > 0)
{
if (AutAffichage[0])
{
// Coloration des contours des zones détectées
UnImgReel.SetPixels(leftEdgePoints, Color.Red);
UnImgReel.SetPixels(rightEdgePoints, Color.Red);
UnImgReel.SetPixels(topEdgePoints, Color.Red);
UnImgReel.SetPixels(bottomEdgePoints, Color.Red);
}
// Détection du milieu
Line line = Line.FromPoints(corners[0], corners[2]);
Line line2 = Line.FromPoints(corners[1], corners[3]);
IntPoint intersection = (IntPoint)line.GetIntersectionWith(line2);
if (AutAffichage[1])
{
dessinePoint(intersection, UnImgReel, 4, Color.Yellow);
}
// Calcul de la rotation
Line ComparasionAngle = Line.FromPoints(corners[0], corners[1]);
Double rotation = (int) ComparasionAngle.GetAngleBetweenLines(Horizontale);
rotation += 90 * Gl.getNbRotation();
Gl.rotation = 360 - rotation;
rotation *= (Math.PI / 180.0);
// Calcul d'un point en bout de pince
float Taille = corners[0].DistanceTo(corners[1]);
float taille = (Taille / BibliotequeGlyph.Biblioteque[Gl.getPosition()].taille) * BibliotequeGlyph.Biblioteque[Gl.getPosition()].DistancePince;
int x = -(int)(System.Math.Sin(rotation) * taille);
int y = -(int)(System.Math.Cos(rotation) * taille);
x += (int)intersection.X;
y += (int)intersection.Y;
Gl.Position = new int[2]{x,y};
if (AutAffichage[2])
{
dessinePoint(new IntPoint(x, y), UnImgReel, 4, Color.Cyan);
}
imgContour = Gl.getImage();
addGlyph(Gl);
if (CalculTailleTerrain == true && Trouve == false)
{
Trouve = true;
int tailleglyph = BibliotequeGlyph.Biblioteque[Gl.getPosition()].taille;
//.........这里部分代码省略.........