Blackjack Decision Maker
Card.h
Go to the documentation of this file.
1 /*
2 Copyright 2023 Georgios Titas
3 Copyright 2023 Alexander Douglas
4 Copyright 2023 Jijo Varghese
5 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 */
9 
10 #ifndef CARDS_H
11 #define CARDS_H
12 
13 #include <opencv2/videoio.hpp>
14 #include <opencv2/highgui.hpp>
15 #include <opencv2/imgproc.hpp>
16 #include <vector>
17 #include <iostream>
18 
19 /* Defined based on specific Hardware setup
20 such as camera height from table/cards */
21 #define CARD_MAX_AREA 120000
22 #define CARD_MIN_AREA 10000
23 /* Width and height of card corner, where rank and suit are */
24 #define FLATTENED_WIDTH 230
25 #define FLATTENED_HEIGHT 300
26 /* Dimensions of rank train images */
27 #define RANK_WIDTH 70
28 #define RANK_HEIGHT 125
29 
35 enum decisions {
36  HIT,
42  STOP
43 };
44 
52 {
53  int err = 0;
54  int num_of_cards = 0;
55  cv::Mat currentFrame;
56  std::vector<int> contour_is_card_idx;
57  /* Holds all contours of single frame */
58  std::vector<std::vector<cv::Point>> contours;
59  /* Card corner points */
60  std::vector<std::vector<cv::Point>> card_approxs;
61  /* Card centre points */
62  std::vector<cv::Point_<int>> centre_pts;
63  /* Card dimensions */
64  std::vector<cv::Size> card_size;
65  /* Card rotated bounding box */
66  std::vector<cv::RotatedRect> rotatedbox;
67  std::vector<std::vector<cv::Point2f>> rotatedbox_pts;
68  /* Vector of images to hold all detected Ranks */
69  std::vector<cv::Mat> rank_rois;
70  /* Hold detect card names */
71  std::vector<cv::String> card_names;
72 };
73 
81  cv::Mat nextFrame;
84  int dealercard;
85  std::vector<int> playercards;
86 };
87 
92 struct qCard
93 {
94  /* Card dimensions */
95  cv::Size card_size;
96  /* Card centre points */
97  cv::Point_<int> centre_pts;
98  /* Card corner points */
99  std::vector<cv::Point> corner_pts;
100  /* Card rotated bounding box */
101  cv::RotatedRect rotatedbox;
102 };
103 
104 #endif /* CARDS_H */
decisions
A Blackjack enum decisions to determine the next Optimal Play.
Definition: Card.h:35
@ DOUBLE
Definition: Card.h:39
@ STOP
Definition: Card.h:42
@ UNKNOWN
Definition: Card.h:40
@ SPLIT
Definition: Card.h:38
@ LOSE
Definition: Card.h:41
@ HIT
Definition: Card.h:36
@ STAND
Definition: Card.h:37
Utility structure used by the AcePlays repo for passing necessary information down the processing pip...
Definition: Card.h:80
int dealercard
Definition: Card.h:84
decisions blackjackDecision
Definition: Card.h:83
std::vector< int > playercards
Definition: Card.h:85
Card_params cardParams
Definition: Card.h:82
cv::Mat nextFrame
Definition: Card.h:81
Structure holding the parameters of all detected card shapes in a frame, such as their position in th...
Definition: Card.h:52
std::vector< cv::String > card_names
Definition: Card.h:71
std::vector< cv::RotatedRect > rotatedbox
Definition: Card.h:66
std::vector< cv::Size > card_size
Definition: Card.h:64
int num_of_cards
Definition: Card.h:54
std::vector< cv::Point_< int > > centre_pts
Definition: Card.h:62
int err
Definition: Card.h:53
std::vector< cv::Mat > rank_rois
Definition: Card.h:69
std::vector< std::vector< cv::Point > > card_approxs
Definition: Card.h:60
std::vector< std::vector< cv::Point > > contours
Definition: Card.h:58
std::vector< std::vector< cv::Point2f > > rotatedbox_pts
Definition: Card.h:67
std::vector< int > contour_is_card_idx
Definition: Card.h:56
cv::Mat currentFrame
Definition: Card.h:55
Structure to store information about single card in the camera image.
Definition: Card.h:93
cv::Point_< int > centre_pts
Definition: Card.h:97
cv::RotatedRect rotatedbox
Definition: Card.h:101
cv::Size card_size
Definition: Card.h:95
std::vector< cv::Point > corner_pts
Definition: Card.h:99