Exemplo n.º 1
0
// Constructor
ProcessingThread::ProcessingThread(ImageBuffer *imageBuffer, int inputSourceWidth, int inputSourceHeight)
    : QThread(), imageBuffer(imageBuffer), inputSourceWidth(inputSourceWidth),
      inputSourceHeight(inputSourceHeight)
{
    // Create images
    currentFrameCopy.create(Size(inputSourceWidth,inputSourceHeight),CV_8UC3);
    currentFrameCopyGrayscale.create(Size(inputSourceWidth,inputSourceHeight),CV_8UC1);
    // Initialize variables
    stopped=false;
    sampleNo=0;
    fpsSum=0;
    avgFPS=0;
    fps.clear();
    // Initialize currentROI variable
    currentROI=Rect(0,0,inputSourceWidth,inputSourceHeight);
    // Store original ROI
    originalROI=currentROI;

    //pre-process surf params.
    preLoadGlyphs(this->Glyphs ,this->keypoints);

    //game-settings init.
    initGameState(&GameState, _GameLib_NUM_DECKS);
    this->pcounter = 0;

    cleanTable(&newTable);
    SetBlackFlag = 0;

    blackVal = 300000;


} // ProcessingThread constructor
Exemplo n.º 2
0
boolean hgcentralTidy(char *config)
/* hgcentralTidy - Clean out old carts. */
{

boolean squealed = FALSE;

/* get connection info */
database = getCfgOption(config, "db"      );
host     = getCfgOption(config, "host"    );
user     = getCfgOption(config, "user"    );
password = getCfgOption(config, "password");

conn = sqlConnectRemote(host, user, password, database);

verbose(1, "Cleaning database %s.%s\n", host, database);
verbose(1, "chunkWait=%d chunkSize=%d\n", chunkWait, chunkSize);

//sessionDbTableName = "sessionDbGalt";

//userDbTableName = "userDbGalt";

if (!purgeTable || sameString(purgeTable,sessionDbTableName))
    {
    if (cleanTable(sessionDbTableName))
      squealed = TRUE;
    }

if (!purgeTable || sameString(purgeTable,userDbTableName))
    {
    if (cleanTable(userDbTableName))
      squealed = TRUE;
    }

sqlDisconnect(&conn);

return squealed;

}
Exemplo n.º 3
0
// initializer for the game-state
void initGameState(GameState *state, int numDeck){
    int i;
    if (state == NULL) return;

    state->status = NEW_GAME;

    // zero the history count
    for (i = 0; i < 13; i++){
        state->history[i] = 0;
    }
    state->deckCount = 0;
    state->numDecks = numDeck;
    cleanTable(&(state->table));

    return;
}
Exemplo n.º 4
0
/* updates the state of the game according to the new table state - assuming THERE IS a difference
 * - adds to history new cards
 * - update hands of players and adds new ones if needed
 * - updates number of cards on the table
*/
void updateGameState(gameState *state, gameTable newTable){
    uint i = 0;
    vector<hand> *hands = &(state->table.players);
    vector<hand> *newHands = &(newTable.players);
    hands->at(0).cards;

    // no new cards or ne whands on the table - nothing to do
    if ((state->table.numCards == newTable.numCards) && (hands->size() == newTable.players.size())) return;

    // the table is clean - a game was finished: clean the table
    if (state->table.numCards == 0){
        cleanTable(&(state->table));
        return;
    }

    // if we have the same number of hands - then there is a new card in a hand
    if (hands->size() == newHands->size()){
        for (i = 0; i < hands->size(); i++){

        }
    }
}
Exemplo n.º 5
0
/* this is the function where all the processing on frames is done
    and new game state is set

  */
int ProcessingThread::process(Mat *matrix){

    // we reachecd the end of a game and we see the table is empty (from cards/any other things besides the table)
    if ( (GameState.status == END_GAME) && (is_frame_empty(*matrix, blackVal))){
        GameState.status = NEW_GAME;

    }
    if (GameState.status==END_GAME) return 0; //don't process

    cleanTable(&newTable);
    getTableFromMat(&newTable, matrix);     // get info of the table from the frame
    fill_known_cards(&newTable,&GameState.table,*matrix,Glyphs, keypoints,70,20); //get the letters of the cards

    // check that te dealer didn't move too much (indicates that the dealer was hidden behind a hand in the frame)
    if (is_dealer_in_same_location(&newTable, &GameState.table, 70) == 0){
        return 0;
    }

    // get the number of cards of each value on the table
    char tempInv[13] = {0};
    getTableInventory(&newTable, tempInv);
    // get the count of the cards on the table
    int tempCount = countCards(tempInv);

    // if the game hasn't ended check if it's the dealers turn (has > 1 cards) or the players' turn
    if (GameState.status != END_GAME){
        if ((newTable.players.size() > 0) && (newTable.players.at(0).cards.size() > 1)){
            GameState.status = DEALER_TURN;
        }
        else {
            GameState.status = PLAYER_TURN;
        }
    }

    // check if the dealer has any players to play against (if they all bust - go to end game)
    char flag = 0;
    if ((newTable.players.size() > 1) && (GameState.status == PLAYER_TURN)){
        flag = 1;
        for (uint i = 1; i < newTable.players.size(); i++){
            int val = getHandVal(newTable.players.at(i));
            if ((val <= 21) || (val == BLACK_JACK) ){
                flag = 0;
                break;
            }

        }
    }


    // check on dealers turn if there is a player who didn't bust/lose to the dealer yet
    if ((newTable.players.size() > 1) &&
            (GameState.status == DEALER_TURN)){
        flag = 1;  // will stay 1 after the for iff the dealer has the highest hand
        int dval = getHandVal(newTable.players.at(0));
        for (uint i = 1; i < newTable.players.size(); i++){
            int val = getHandVal(newTable.players.at(i));

            if ((dval == BLACK_JACK) || (dval >= 17)) {
                flag = 1;
                break;
            }
            if ((val > dval) && (val <= 21) ){
                flag = 0;
                break;
            }

        }
    }

    // from the last to checks (above) the flag is 1 if the game has ended - update the Game State
    if (flag == 1){
        // a game ended update GameState (nothing new should go on the table until it is empty again
        GameState.status = END_GAME;

        //update the game state history
        for (uint i = 0; i < 13; i++){
            GameState.history[i] += tempInv[i];
        }

        //update the game state count with the temp count
        GameState.deckCount += tempCount;
    }



    // store the new processed table and update output text
    GameState.table = newTable;
    // display new text on screen
    updateGameText(tempInv);

    return 1;
}