#pragma once #include #include #include #include // cv::Canny() #include #include #include using namespace cv; using namespace std; #include "CBitmap.h" #include "Card.h" #include "CVGraph.h" #ifndef SQR #define SQR(x) ((x)*(x)) #endif // SQR #define SQRD(x,y) SQR((x)-(y)) // difference squared class Recognizer { public: Recognizer(); Recognizer(string file); int recognize(Mat& m); void getColors(Mat rgb, Mat rslt, const Vec3b red, const Vec3b black); int countImage(Mat im, uchar value); void getSubImages(Mat im, bool isRed, Mat& value, Mat& suit); int* profile(Mat im, bool rowSum, uchar match, int* result, int iStart, int iEnd); int maxCorr(CBitmap* stored, CBitmap v, bool fromTop, float &rmax); void writeCards(string file); void readCards(string file); void getBitmaps(Mat m, CBitmap& vb, CBitmap& sb, bool& isRed); CBitmap vBits[52], sBits[52]; // bitmap for each card, vBits = value part, sBits = suit part Vec3b red = Vec3b(47, 3, 180); // BGR color definition Vec3b black = Vec3b(27, 26, 21); // BGR #ifdef BLACK #undef BLACK #endif // BLACK const uchar BLACK=128; const uchar RED=255; const uchar NEITHER=0; const float THRESHOLD = 80.0; // color matching threshold distance; };