Giter VIP home page Giter VIP logo

mtgscan's Introduction

MTGScan

License: MIT CodeFactor

mtgscan

MTGScan uses OCR recognition to list Magic cards from an image.
After OCR, cards are looked up in a dictionnary provided by MTGJSON, using fuzzy search with SymSpell.

Try the Web App (DOWN for now)

  flowchart LR;
  subgraph "Browser"
    C1[Client];
    C2[Client];
    C3[Client];
  end
  subgraph "Frontend"
    F((Flask Server));
  end
  subgraph "Backend"
    W1[Celery Worker<br>using mtgscan];
    W2[Celery Worker<br>using mtgscan];
  end
  subgraph "Cloud"
    A[Azure Read OCR];
  end
  C1 <-->|Socket.IO| F;
  C2 <-->|Socket.IO| F;
  C3 <-->|Socket.IO| F;
  F <-->|RedisMQ| W1;
  F <-->|RedisMQ| W2;
  W1 <-->|API| A;
  W2 <-->|API| A;

Repository for the web app

Prerequisites

  • Python >= 3.7
  • (Recommended) Poetry
  • Credentials for the required OCR (e.g Azure Computer Vision Read API)

Installation

... with Poetry

poetry install

... with pip

pip install mtgscan

... with docker

See https://github.com/fortierq/mtgscan-app

OCR

Currently, only Azure OCR is supported. To add an OCR, inherit mtgscan.ocr.OCR.

Azure

API subscription key and endpoint must be stored in environment variables AZURE_VISION_KEY and AZURE_VISION_ENDPOINT respectively.
Steps:

Tests

Every test case is stored in a separated folder in tests/samples/ containing:

  • image.*: image of Magic cards
  • deck.txt: decklist of the cards on the image

To run every test:

poetry run python tests/test.py

This produces the following outputs, for each sample and OCR:

  • statistics about number of cards found, number of errors...
  • test.log: informations about the run
  • errors.txt: history of the number of errors made by the OCR
  • box_texts.txt: output of the OCR

Example

This example scans the following screenshot: Screenshot

$ poetry run python example.py

Loading https://mtgjson.com/api/v5/VintageAtomic.json
Loaded all_cards.txt: 23253 cards
Loading https://mtgjson.com/api/v5/Keywords.json
Loaded Keywords.json: 282 keywords
4 Ancient Tomb
4 Mishra's Factory
4 Mishra's Workshop
1 Strip Mine
1 Tolarian Academy
4 Wasteland
1 Sacrifice
1 Mox Ruby
1 Mox Emerald
1 Mox Jet
1 Mox Pearl
1 Mox Sapphire
1 Black Lotus
1 Mana Crypt
1 Sol Ring
4 Phyrexian Revoker
4 Arcbound Ravager
1 Thorn of Amethyst
4 Sphere of Resistance
4 Foundry Inspector
3 Chief of the Foundry
1 Trinisphere
1 Lodestone Golem
1 Mystic Forge
2 Fleetwheel Cruiser
1 Traxos, Scourge of Kroog
4 Walking Ballista
3 Stonecoil Serpent
1 Chalice of the Void

3 Mindbreak Trap
4 Leyline of the Void
2 Crucible of Worlds
4 Pithing Needle
2 Wurmcoil Engine

mtgscan's People

Contributors

fortierq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

mtgscan's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.