31
Card recognition Justin Pinkul

Card recognition - Today at Minesinside.mines.edu/~whoff/courses/EENG510/projects/2012... · 2012-12-06 · The algorithm Grayscale template-matching invariant to rotation scale,

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Card recognitionJustin Pinkul

Blackjack

Needed information

● Position

● Value

● Orientation

● Scale

Assumptions

● Same deck of cards

● Fixed viewing angle

● Comparable lighting

The algorithm

Grayscale template-matching invariant to rotation scale, translation, brightness and contrast

Three step filtering process

The algorithm

Step 1: circular sampling

Circular sampling

Circular sampling

Circular sampling

The algorithm

Step 2: radial sampling

Radial sampling

Radial sampling

Radial sampling

Radial sampling

Radial sampling

The algorithm

Step 3: normal template matching

● Probable scale known from circle sampling

● Probable rotation known from radius sampling

Pseudo Code - circularTest

mainI = imageG = templatescales = 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85radius = 0, 8, 16, 24, 32, 45

pass1, probScales = circularTest(I, G, scales, radius)pass2, probAngles = radialTest(I, G, scales, radius,

pass1, probScales)templateMatch(I, G, pass2, probScales, probAngles)

Pseudo Code

circularTest(I, G, scales, radius)

for scale = all scales resizedQ = resize Q to the scale for len = all radius

(xcen, ycen) = center of resizedQ qScore[scale, length] = getCircleAverage(resizedQ

xcen, ycen ,len) end end for all (x,y) in I for len = all radius iScore[x, y, length] = getCircleAverage(I, x, y, len) end end

Pseudo Code - circularTest cont.

for all (x,y) in I for scale = all scales

iRadiusAvgs = iScore(x,y, ...)qRadiusAvgs = qScores(scale, ...)cor = correlate(iRadiusAvgs, qRadiusAvgs)add cor to correlations

end pass1(x,y) = max(correlations) > threshold1 probableScale(x,y) = scales(index of max(correlations)) end end

Pseudo Code - radiusTest

radiusTest(I, G, scales, radius, pass1, probScales) r = largest radius for theta = all test angels (cenx, ceny) = the center of Q qScores[theta] = getRadiusAverage(Q, theta, cenx, ceny, r) end

for all (x,y) in I if pass1(x,y) iR = r * probScales(x,y) iScores[x,y,theta] = getRadiusAverage(Q, theta, x, y, iR) end end

Pseudo Code - radiusTest cont.

for all (x,y) in I if pass1(x,y) for theta = all angels iAngAvgs = iScores(x,y,...) for all orientations

shifted = shift qScores to the new orientationcor = correlate(iAngAvgs, shifted)add cor to correlations

end pass2(x,y) = max(correlations) > threshold2 probRadius = radius(index of max(correlations))

end end end end

Results

Limitations

● Template size

● Speed

Future work

● Partially visible cards

● Automated process for choosing scale and radius samples

● Variable viewing angles

● Real time analysis with a video camera

Questions?

ReferencesDe Araújo, Sidnei. "Grayscale Template-Matching Invariant to Rotation, Scale, Translation, Brightness and Contrast." Advances in Image and Video Technology. By Hae Kim. Heidelberg: Springer Berlin, 2007. 100-13. Print.