Skip to content
← Back to blog

November 26, 2026 · 4 min read

Exporting my Pokémon TCG Pocket collection: the computer drives the phone over adb

ross_tcgp reads my Pokémon TCG Pocket collection over adb: it captures the screen, finds the grid, recognizes each card with a color fingerprint and reads the copies with templates. 937 cards in 5 minutes, with the exact total.

In this post
  1. Driving the phone over adb
  2. Finding the cards without fixed coordinates
  3. Recognizing each card
  4. Reading the copies without OCR
  5. Stitching the pages
  6. Exporting
  7. What I learned

I wanted to build decks for Pokémon TCG Pocket, Pokémon’s card game for phones, with AI. For that the AI needs to know which cards I own, and the game has no way to export the collection. Typing them in meant over 900 cards.

So I built ross_tcgp: the computer drives the phone. I plug it in over USB, open “My Cards” in the game, and the program scrolls, captures each screen, recognizes the cards and reads how many copies I have of each. At the end it saves everything as JSON.

The first full scan read 937 cards (393 different) in about 5 minutes, and the total matched the game’s exactly.

Driving the phone over adb

adb (Android Debug Bridge) lets you take screenshots and simulate touches from the computer. Two details made the difference:

  • Raw screenshots. screencap -p makes the phone compress a PNG before sending it: 2.2 seconds per shot. Without -p the raw pixels (about 10 MB) arrive in 1.1 seconds over USB. Half the time, across 69 pages.
  • A scroll that stops. input swipe ends with the finger still moving, and the list keeps going by inertia an unpredictable distance. In the first test it skipped rows. With input motionevent I can put the finger down, move it, hold still and only then lift: the list stops where the finger is.

Finding the cards without fixed coordinates

I didn’t want coordinates that only work on one phone. The collection’s background is light blue, and the thin lines of pure background between cards draw the grid at any resolution.

There was a trap: trainer cards have white bodies, and a “bright, colorless pixel” test mistook them for the background. What tells them apart is the blue tint: the background has a bit more blue than red, and the card’s white is neutral.

A row only counts as cards if its height matches a card’s ratio (1.394 ± 3 %), so cards cut off by the header or the bottom bar are dropped for free.

Recognizing each card

To compare I use a fingerprint: the card without its bottom 10 % (where the game puts the counter), shrunk to 16×22 color pixels and normalized. That’s 1,056 numbers.

The 4,577 reference cards form a single matrix, and one matrix product gives the similarity with all of them at once: under a millisecond.

Why not a perceptual hash, the usual way to compare images? Because it works in greyscale, and many cards share the same artwork with a different frame or rarity. Color is what tells them apart.

Almost every card scores 0.99 or higher. The lowest real scores (0.67 to 0.89) were all correct: the game’s floating button covering a corner, or the gold frames on some cards. So a card is only flagged as uncertain if its score is below 0.97 and the runner-up is within 0.05.

Reading the copies without OCR

The copy counter is a white number on a slate-blue badge. I could run it through Tesseract, but that’s one more system dependency and, on my computer, it didn’t even have the English data.

For a single typeface, templates are simpler and more accurate: I built 17 digit shapes for 0–9 from real screenshots, and each cropped digit is compared against them.

Stitching the pages

The game hides the counters while the list moves, so each page is retaken until the cards are still and the numbers show.

To join a page to the previous one I don’t compare pixels: the header shrinks while scrolling and the real distance varies. I compare cards: I look for the longest run of shared rows, by id and count. If nothing matches, I drag back half a page and retry. Two drags that add nothing mean I’ve reached the end.

--quick mode takes advantage of the game’s “Recent cards” sort: new cards rise to the top, so it stops at the first page identical to the previous scan. It takes about 15 seconds.

Exporting

With the collection in JSON, ross-tcgp export writes it as CSV for PackProphet or in TCG Pocket Collection Tracker’s format. The latter needs the ids translated (A1-096 → A1-96); I checked them against its 4,577 cards by name, and only three don’t match.

The repository contains nothing from the game: the card data comes from an open (MIT) database and the thumbnails are downloaded on your computer when you use it.

What I learned

  • Color decides: for cards with the same artwork, a color fingerprint beats a greyscale hash.
  • For a single font, templates beat OCR.
  • Keeping the screenshots (--save-pages) and rebuilding a scan without the phone let me tune the code without repeating 5-minute scans.
  • Validating against a number you already know (the game’s total) gives more confidence than any test.

Rossmel Abasto — Frontend → Fullstack Developer. LinkedIn · GitHub

Leer este artículo en español →See the case studyross_tcgp →Reads my collection from the Pokémon TCG Pocket card game by driving the phone from the computer, because the game won't export it.

Keep reading

Write to me: I read everything and reply by email.

Questions or comments about this post?

send-mail.sh