资源简介
这是一个基于c#的扑克牌识别系统,调用了Aforge的类库,功能很强大,希望大家有用!
代码片段和文件信息
using System;
using System.Drawing;
using AForge;
using AForge.Imaging.Filters;
using Point = System.Drawing.Point;
namespace PlayingCardRecognition
{
///
/// Rank enumeration
///
public enum Rank
{
NOT_RECOGNIZED = 0
Ace = 1
Two
Three
Four
Five
Six
Seven
Eight
Nine
Ten
Jack
Queen
King
}
///
/// Suit enumeration
///
public enum Suit
{
NOT_RECOGNIZED = 0
Hearts
Diamonds
Spades
Clubs
}
///
/// Class represents recognized playing card. Contains properties of card such as ;
/// Rank of card suit of card image of card which is extracted from source image
/// corner points of card on source image
///
public class Card
{
//Variables
private Rank rank; //Rank of card
private Suit suit; //Suit of card
private Bitmap image; //Extracted(transformed) image of card
private Point[] corners ;//Corner points of card on source image
//Properties
public Point[] Corners
{
get { return this.corners; }
}
public Rank Rank
{
set { this.rank = value; }
}
public Suit Suit
{
set { this.suit = value; }
}
public Bitmap Image
{
get { return this.image; }
set
{
this.image = value;
}
}
//Constructor
public Card(Bitmap cardImg IntPoint[] cornerIntPoints)
{
this.image = cardImg;
//Convert AForge.IntPoint Array to System.Drawing.Point Array
int total = cornerIntPoints.Length;
corners = new Point[total];
for(int i = 0 ; i < total ; i++)
{
this.corners[i].X = cornerIntPoints[i].X;
this.corners[i].Y = cornerIntPoints[i].Y;
}
}
public Bitmap GetTopRightPart()
{
if (image == null)
return null;
Crop crop = new Crop(new Rectangle(image.Width - 37 10 30 60));
return crop.Apply(image);
}
///
/// Overrided ToString Function.
///
///
public override string ToString()
{
string suitStr = string.Empty;
string rankStr = string.Empty;
//Convert suit value to string
switch (suit)
{
case Suit.Clubs:
suitStr = “Clubs“;
break;
case Suit.Diamonds:
suitStr = “Diamonds“;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-10-04 14:30 PlayingCardRecognition_SampleImages\
目录 0 2011-10-04 14:30 PlayingCardRecognition_SampleImages\PlayingCardRecognition\
目录 0 2011-10-07 16:57 PlayingCardRecognition_SampleImages\PlayingCardRecognition\bin\
文件 4720 2011-10-04 01:45 PlayingCardRecognition_SampleImages\PlayingCardRecognition\Card.cs
文件 1000 2011-10-04 00:22 PlayingCardRecognition_SampleImages\PlayingCardRecognition\CardCollection.cs
文件 15067 2011-10-07 16:51 PlayingCardRecognition_SampleImages\PlayingCardRecognition\CardRecognizer.cs
文件 2541 2011-10-04 00:16 PlayingCardRecognition_SampleImages\PlayingCardRecognition\ImagePanel.cs
文件 1475 2011-10-04 00:12 PlayingCardRecognition_SampleImages\PlayingCardRecognition\ImagePanel.Designer.cs
文件 5817 2011-09-25 16:57 PlayingCardRecognition_SampleImages\PlayingCardRecognition\ImagePanel.resx
文件 4245 2011-10-04 02:50 PlayingCardRecognition_SampleImages\PlayingCardRecognition\PlayingCardRecognition.csproj
文件 377 2011-10-04 02:50 PlayingCardRecognition_SampleImages\PlayingCardRecognition\PointComparer.cs
目录 0 2011-10-04 14:30 PlayingCardRecognition_SampleImages\PlayingCardRecognition\Properties\
文件 1456 2011-10-03 16:30 PlayingCardRecognition_SampleImages\PlayingCardRecognition\Properties\AssemblyInfo.cs
文件 4597 2011-10-03 17:03 PlayingCardRecognition_SampleImages\PlayingCardRecognition\Properties\Resources.Designer.cs
文件 7623 2011-10-03 17:03 PlayingCardRecognition_SampleImages\PlayingCardRecognition\Properties\Resources.resx
目录 0 2011-10-04 14:30 PlayingCardRecognition_SampleImages\PlayingCardRecognition\Templates\
文件 1398 2011-10-02 15:59 PlayingCardRecognition_SampleImages\PlayingCardRecognition\Templates\Clubs.bmp
文件 1286 2011-10-02 15:50 PlayingCardRecognition_SampleImages\PlayingCardRecognition\Templates\Diamonds.bmp
文件 1398 2011-10-02 16:00 PlayingCardRecognition_SampleImages\PlayingCardRecognition\Templates\Hearts.bmp
文件 1330 2011-10-03 01:47 PlayingCardRecognition_SampleImages\PlayingCardRecognition\Templates\J.bmp
文件 1342 2011-10-03 01:55 PlayingCardRecognition_SampleImages\PlayingCardRecognition\Templates\K.bmp
文件 1430 2011-10-03 01:47 PlayingCardRecognition_SampleImages\PlayingCardRecognition\Templates\Q.bmp
文件 1318 2011-10-02 15:54 PlayingCardRecognition_SampleImages\PlayingCardRecognition\Templates\Spades.bmp
目录 0 2011-10-04 00:18 PlayingCardRecognition_SampleImages\PlayingCardRecognition_SampleImages\
目录 0 2011-10-03 16:29 PlayingCardRecognition_SampleImages\PlayingCardRecognition_SampleImages\bin\
目录 0 2011-10-07 16:57 PlayingCardRecognition_SampleImages\PlayingCardRecognition_SampleImages\bin\Release\
文件 16896 2011-09-16 05:32 PlayingCardRecognition_SampleImages\PlayingCardRecognition_SampleImages\bin\Release\AForge.dll
文件 249856 2011-09-16 05:32 PlayingCardRecognition_SampleImages\PlayingCardRecognition_SampleImages\bin\Release\AForge.Imaging.dll
文件 68096 2011-09-16 05:32 PlayingCardRecognition_SampleImages\PlayingCardRecognition_SampleImages\bin\Release\AForge.Math.dll
文件 26112 2011-10-07 16:54 PlayingCardRecognition_SampleImages\PlayingCardRecognition_SampleImages\bin\Release\PlayingCardRecognition.dll
文件 12288 2011-10-07 16:54 PlayingCardRecognition_SampleImages\PlayingCardRecognition_SampleImages\bin\Release\PlayingCardRecognition_SampleImages.exe
............此处省略76个文件信息
评论
共有 条评论