playing card detection in matlab - inside...
TRANSCRIPT
![Page 1: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/1.jpg)
Playing Card Detection in MATLAB
Stephen Kennicutt
![Page 2: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/2.jpg)
Project Goals
● Detect playing cards in a photo● Create orthophoto for each card● Find value for each card● Find suit for each card● Output information in array
![Page 3: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/3.jpg)
Playing Card Detection
● Use bwareaopen to remove small connected areas● Use imcomplement to remove different areas
![Page 4: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/4.jpg)
Playing Card Detection
● Use ‘reigonprops’ to find each card● Draw bounding box for each card● Generate a subimage for each card● Detection is near-perfect
![Page 5: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/5.jpg)
Orthophoto Generation
● Have isolated card, now must find orthophoto● Generate edges from images● Use Canny edge detection method● Now find lines
![Page 6: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/6.jpg)
Orthophoto Generation
● Use Hough transform to find lines● Select rho and thetas from Hough peaks● Threshold: 20% of max peak
![Page 7: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/7.jpg)
Orthophoto Generation
● Check for orthogonality● Find intersections, create corners● Correlation if necessary
![Page 8: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/8.jpg)
Orthophoto Generation
● Corners found, use projective transform ● Playing cards are 5”x7”● Generate 500 x 700 pixel image
![Page 9: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/9.jpg)
Value Detection
● Generate subimage for value● Bounding box from 1st object in ‘reigonprops’
![Page 10: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/10.jpg)
Value Detection
● Clean up using disk dilation● Use MATLAB’s OCR function● Character recognition limited by RegEx
![Page 11: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/11.jpg)
Suit Detection
● Similar approach as value detection● Create subimage● Bounding box from 2nd object in ‘reigonprops’● ‘bwareaopen’ to remove unwanted areas● Disk dilation to clean up
![Page 12: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/12.jpg)
Suit Detection
● Use Fourier transforms with cross power multiplication● Compare with template images for best fit● Compute cross power spectrum● Compare x and y origin
![Page 13: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/13.jpg)
Experimentation
● Varying distances from cards ● Varying playing surfaces● Varying orientations● Varying resolutions
![Page 14: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/14.jpg)
Results
● ~80% success rate in value recognition with sufficient resolution● ~95% success rate in suit detection with sufficient resolution● 3, 5 and 10 are prone to false detections with OCR
![Page 15: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/15.jpg)
Limitations
● Shadows, poor contrast break methodology● Very high resolution images needed (3264 × 2448 or higher)● Distances can break card recognition● Only tested on Bicycle™ decks ● Computationally expensive
![Page 16: Playing Card Detection in MATLAB - Inside Minesinside.mines.edu/~whoff/courses/EENG512/projects/2016/Kennicutt.pdf · Clean up using disk dilation Use MATLAB’s OCR function Character](https://reader034.vdocuments.us/reader034/viewer/2022050617/5ab2b8687f8b9a7e1d8d9a4e/html5/thumbnails/16.jpg)
Questions?