Exemple #1
0
def readFaceCard(imgArr):
    imgType = 'faceCard'
    (valBin,suitBin) = processImage(imgArr,imgType,returnBin=True)

    # ===== classify value ===== #
    imgType = 'cardVal'
    parameterName = 'cardValTheta.csv'
    val = classifyMultiImage(valBin,imgType,parameterName)

    # ===== classify suit ===== #
    imgType = 'suit'
    parameterName = 'suitTheta.csv'
    #print suitBin,suitBin.shape
    suit = classifyMultiImage(suitBin,imgType,parameterName)
    
    return val,suit
Exemple #2
0
def readBet(playerReg,p):
	chipSideList = ['left','left','left','right','right','right']
	chipSide = chipSideList[p]
	betImg = playerReg.bet.img
	(digitBin,numDigits) = processImage(betImg,'bet'+chipSide)
	if numDigits == 0:
	    return 0
	else:
	    bet = 0
        for i in range(numDigits):
	    if numDigits == 1:
		thisDigit   = classifyMultiImage(digitBin[:,:],'betDigit','betDigitTheta.csv')
	    else:
		thisDigit   = classifyMultiImage(digitBin[:,:,i],'betDigit','betDigitTheta.csv')
            bet = bet + int(thisDigit)*10**(numDigits-i-1)
	return bet
Exemple #3
0
def readStack(playerReg):
            # ===== read stack ===== #
            imgArr = playerReg.stack.img.copy()
            isSittingOut = False
            isAllIn = False
            isNoPlayer = False
            # check for no stack present - 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 image size is 87*17, which makes digit 1 ~1.8% of the image
            stackExists = proportion > 1
            if stackExists:
                # grab 1st digit and classify (numbers 1-9, A or S - 0 not an option for 1st digit)
                digitOne = processImage(imgArr,'stackCheck',returnBin=True)
                imageCat = classifyMultiImage(digitOne,'digit','digitTheta.csv')
                if imageCat == 'S':
                    isSittingOut = True
                    stack = 0
                elif imageCat == 'A':
                    isAllIn = True
                    stack = 0
                elif int(imageCat) > 0 and int(imageCat) <=9:
                    # classify each digit, add digits sequentially to get stack value
                    (digitBin,numDigits) = processImage(imgArr,'stack',returnBin=True)
                    digitArr = np.zeros(numDigits)
                    stack = 0
                    for i in range(numDigits):
			if numDigits == 1:
			    thisDigit   = classifyMultiImage(digitBin[:,:],'digit','digitTheta.csv')
			else:
			    thisDigit   = classifyMultiImage(digitBin[:,:,i],'digit','digitTheta.csv')
                        if thisDigit == 'A' or thisDigit == 'S':
                            raise ValueError('digit misread as A or S when reading stack')
                        stack = stack + int(thisDigit)*10**(numDigits-i-1)
                else:
                    raise ValueError('no valid integer read as first digit of stack')
            else:
                stack = 0
                isNoPlayer = True

            return stack,isSittingOut,isAllIn,isNoPlayer
Exemple #4
0
def readPot(tableReg):
    imgArr = tableReg.pot.img.copy()
    # check for pot
    threshold = 150
    totalCount  = imgArr.size
    threshCount = imgArr[imgArr>threshold].size
    proportion  = 100*threshCount/totalCount
    potExists = proportion > 1
    if potExists:
        # classify each digit, add digits sequentially to get stack value
        (digitBin,numDigits) = processImage(imgArr,'pot',returnBin=True)
        pot = 0
        for i in range(numDigits):
	    if numDigits == 1:
		thisDigit   = classifyMultiImage(digitBin[:,:],'digit','digitTheta.csv')
	    else:
		thisDigit   = classifyMultiImage(digitBin[:,:,i],'digit','digitTheta.csv')
            if thisDigit == 'A' or thisDigit == 'S':
                raise ValueError('digit misread as A or S when reading pot')
            pot = pot + int(thisDigit)*10**(numDigits-i-1)
    else:
        pot = 0
    return pot