Пример #1
0
def readCommCards(tableReg):
    oneImg      = tableReg.flopOne.img    
    twoImg      = tableReg.flopTwo.img   
    threeImg    = tableReg.flopThree.img  
    fourImg     = tableReg.turn.img       
    fiveImg     = tableReg.river.img

    one     = (None,None)
    two     = (None,None)
    three   = (None,None)
    four    = (None,None)
    five    = (None,None)

    commImgList     = [oneImg,twoImg,threeImg,fourImg,fiveImg]
    commCardList    = [one,two,three,four,five]

    for i in range(5):
        img = commImgList[i]
    
        # check for comm card
        imgType     = 'faceCardExists'
        paramName   = 'commCardTheta.csv'
        hasCommCards = classifyImage(img,imgType,paramName)

        if hasCommCards:
            val,suit = readFaceCard(img)
            commCardList[i] = (val,suit)
    
    return commCardList
Пример #2
0
def readHoleCards(playerReg):
    imgArrOne = playerReg.holeOne.img.copy()
    imgArrTwo = playerReg.holeTwo.img.copy()

    # check for hole card
    imgType     = 'faceCardExists'
    paramName   = 'holeCardTheta.csv'
    hasHoleCards = classifyImage(imgArrOne,imgType,paramName)

    if hasHoleCards:
        valOne,suitOne = readFaceCard(imgArrOne)
        valTwo,suitTwo = readFaceCard(imgArrTwo)
    else:
        (valOne,valTwo,suitOne,suitTwo) = (None,None,None,None)
            
    return hasHoleCards,valOne,valTwo,suitOne,suitTwo
Пример #3
0
def batchSortImages():
    
    # sort community cards into card and not-card categories
    
    DIR = os.path.normpath('elementLibrary/raw/communityCard')
    imageList = [name for name in os.listdir(DIR)if os.path.isfile(os.path.join(DIR, name))]
    i = 0
    j = 0
    for imageName in imageList:
        readPath = os.path.normpath('elementLibrary/raw/communityCard/'+imageName)
        imgArr = cv.imread(readPath,1)
        imgType = 'faceCardExists'
        paramName = 'commCardTheta.csv'
        isCommCard = classifyImage(imgArr,imgType,paramName)
        # save
        if isCommCard:
            idenity = 'commCard/commCard_'+str(i)
            i += 1
        else:
            idenity = 'commCardNot/notCommCard_'+str(j)
            j += 1   
        writePath = os.path.normpath('elementLibrary/sorted/'+idenity+'.png')
        cv.imwrite(writePath,imgArr)

    # sort hole cards into card and not-card categories
   
    DIR = os.path.normpath('elementLibrary/raw/holeCard')
    imageList = [name for name in os.listdir(DIR)if os.path.isfile(os.path.join(DIR, name))]
    i = 0
    j = 0
    for imageName in imageList:
        readPath = os.path.normpath('elementLibrary/raw/holeCard/'+imageName)
        imgArr = cv.imread(readPath,1)
        imgType = 'faceCardExists'
        paramName = 'holeCardTheta.csv'
        isHoleCard = classifyImage(imgArr,imgType,paramName)
        # save
        if isHoleCard:
            idenity = 'holeCard/holeCard_'+str(i)
            i += 1
        else:
            idenity = 'holeCardNot/notholeCard_'+str(j)
            j += 1   
        writePath = os.path.normpath('elementLibrary/sorted/'+idenity+'.png')
        cv.imwrite(writePath,imgArr)
    
    # stack sort
    
    DIR = os.path.normpath('elementLibrary/raw/stack')
    imageList = [name for name in os.listdir(DIR)if os.path.isfile(os.path.join(DIR, name))]
    i = 0
    j = 0
    for imageName in imageList:
        readPath = os.path.normpath('elementLibrary/raw/stack/'+imageName)
        imgArr = cv.imread(readPath,1)
        imgType = 'stack'
        # sum up colors greater than threshold
        threshold = 150
        totalCount  = imgArr.size
        threshCount    = imgArr[imgArr>200].size
        proportion  = 100*threshCount/totalCount
        # number 1 has 27 pixels, stack size is 87*17, which makes 1 ~1.8% of the image
        if proportion > 1:
            stackExists = True
        else:
            stackExists = False
        # save
        if stackExists:
            idenity = 'stack/stack_'+str(i)
            i += 1
        else:
            idenity = 'stackNot/notStack_'+str(j)
            j += 1   
        writePath = os.path.normpath('elementLibrary/sorted/'+idenity+'.png')
        cv.imwrite(writePath,imgArr)