== Credit == Code mostly taken from card_scan by YenTheFirst. Chose not fork because of the amount of code change. == Overview ==
Magic the Gathering card recognition for purposes of quickly digitizing your inventory.
=== Features ===
== Screenshots ==
== Dependency ==
sudo apt-get install python-opencv sudo pip install -r requirements.txt
sudo apt-get install festival
=== MTG Set Images ===
apt-get install wine unzip GathererDownloader*.zip
== Setup ==
One variable is required to be set that denotes the location of the Magic the Gathering cards you wish to index against.
;BASE_SET_DIR/
:variable in test.py root directory of the images.
=== MTG Set Images ===
The matching algorithm is designed to find a matching card of a taken image. Thus, we need a database of cards to match against.
==== File Structure ====
;BASE_SET_DIR/
:variable in test.py root directory of the images.
;BASE_SET_DIR/
:where set_name_abbreviation is a unique identifier for the set comprised of letters and numbers.
;BASE_SET_DIR/
:where card_name is unique within a given set. Note that all the cards end in full.jpg
==== Gatherer Downloader ====
Automates downloading of full Magic the Gathering sets, both card listings and card images.
Start it
wine ./GathererDownloader.exe
Download the card database for the sets you wish to recognize/inventory. Note the "And all Sets After" option box for easily downloading multiple sets.
Now we will get the images associated with the cards but first, because we have a particular file directory structure, we need to ensure the naming convention is correct.
Click on Options -> Image Formats. Select Magic Workstation from the dropdown box and click Load Defaults. Then click Ok to save.
Click Download Card Images and select the directory you have set BASE_SET_DIR
.
== Running ==
./test.py
Note that matches cards are appended to the csv file configured via CSV_FILE
in the file test.py
=== Controls ===
Note that the background should be a solid color. I used a piece of white printer paper.
== Common Problems == test.py invalid camera.
OpenCV Error: Bad argument (Array should be CvMat or IplImage) in cvGetSize, file /build/buildd/opencv-2.3.1/modules/core/src/array.cpp, line 1238 Traceback (most recent call last): File "./test.py", line 87, incapture = scanCard.check_for_card() File "/home/meyers/Dropbox/Code/python_card_scan/scan_card.py", line 173, in check_for_card self.grab_frame() File "/home/meyers/Dropbox/Code/python_card_scan/scan_card.py", line 119, in grab_frame frame_gray = to_gray_image(frame) File "/home/meyers/Dropbox/Code/python_card_scan/cv_utils.py", line 73, in to_gray_image gray = create_dummy_image(img) File "/home/meyers/Dropbox/Code/python_card_scan/cv_utils.py", line 65, in create_dummy_image return cv.CreateImage(cv.GetSize(img), 8,1) cv2.error: Array should be CvMat or IplImage
Adding new magic sets and cards to the database to match against may require deleting the analyzed cache SET_CACHE_FILE
in test.py