#include #include #include #include using namespace cv; using namespace std; #pragma once class CardProcessor { const int CV_QR_NORTH = 0; const int CV_QR_EAST = 1; const int CV_QR_SOUTH = 2; const int CV_QR_WEST = 3; private: bool isInitialized; Mat gray; Mat edges; Mat traces; Mat qr, qr_raw, qr_gray, qr_thres; vector > contours; vector hierarchy; vector pointsseq; //used to save the approximated sides of each contour int mark, A, B, C, D, F, top, right, bottom, median1, median2, outlier; float AB, BC, CA, dist, slope, areat, arear, areab, large, padding; int align, orientation; private: void Initialize(Mat image); float cv_distance(Point2f P, Point2f Q); // Get Distance between two points float cv_lineEquation(Point2f L, Point2f M, Point2f J); // Perpendicular Distance of a Point J from line formed by Points L and M; Solution to equation of the line Val = ax+by+c float cv_lineSlope(Point2f L, Point2f M, int& alignement); // Slope of a line by two Points L and M on it; Slope of line, S = (x1 -x2) / (y1- y2) void cv_getVertices(vector > contours, int c_id, float slope, vector& X); void cv_updateCorner(Point2f P, Point2f ref, float& baseline, Point2f& corner); void cv_updateCornerOr(int orientation, vector IN, vector &OUT); bool getIntersectionPoint(Point2f a1, Point2f a2, Point2f b1, Point2f b2, Point2f& intersection); float cross(Point2f v1, Point2f v2); public: CardProcessor(); ~CardProcessor(); vector GetQRVertices(Mat image); vector GetQRVertices4(Mat image); vector GetArcusVertices(Mat image); Mat ApplyHomography(Mat image,vector vertices, Size destination_size); Rect CropRect(Rect rect, Size size); Point GetRectCenter(Rect rect); Scalar GetRectMeanColor(Mat image, Rect rect); Mat GetImageRect(Mat image, Rect rect); Mat Diff(Mat image, int k); void DrawImage(Mat image,Mat draw, Rect rect); void DrawHistogram(Mat image); };